jpountz commented on a change in pull request #1294: LUCENE-9074: Slice Allocation Control Plane For Concurrent Searches URL: https://github.com/apache/lucene-solr/pull/1294#discussion_r400490515
########## File path: lucene/core/src/test/org/apache/lucene/search/TestIndexSearcher.java ########## @@ -347,4 +370,82 @@ public void execute(final Runnable runnable) { throw new RejectedExecutionException(); } } + + public void testQueueSizeBasedCP() throws Exception { + ThreadPoolExecutor service = new ThreadPoolExecutor(4, 4, 0L, TimeUnit.MILLISECONDS, + new LinkedBlockingQueue<Runnable>(), + new NamedThreadFactory("TestIndexSearcher")); + + runCPTest(service, false); + + TestUtil.shutdownExecutorService(service); + } + + public void testRandomBlockingCP() throws Exception { + ThreadPoolExecutor service = new ThreadPoolExecutor(4, 4, 0L, TimeUnit.MILLISECONDS, + new LinkedBlockingQueue<Runnable>(), + new NamedThreadFactory("TestIndexSearcher")); + + runCPTest(service, true); + + TestUtil.shutdownExecutorService(service); + } + + private void runCPTest(ThreadPoolExecutor service, boolean useRandomCP) throws Exception { + SliceExecutor sliceExecutor = useRandomCP == true ? new RandomBlockingSliceExecutor(service) : + new QueueSizeBasedExecutor(service); + + IndexSearcher searcher = new IndexSearcher(reader2.getContext(), service, sliceExecutor); + + Query queries[] = new Query[] { + new MatchAllDocsQuery(), + new TermQuery(new Term("field", "1")) + }; + Sort sorts[] = new Sort[] { + null, + new Sort(new SortField("field2", SortField.Type.STRING)) + }; + ScoreDoc afters[] = new ScoreDoc[] { + null, + new FieldDoc(0, 0f, new Object[] { new BytesRef("boo!") }) + }; + + for (ScoreDoc after : afters) { + for (Query query : queries) { + for (Sort sort : sorts) { + searcher.search(query, Integer.MAX_VALUE); + searcher.searchAfter(after, query, Integer.MAX_VALUE); + if (sort != null) { + searcher.search(query, Integer.MAX_VALUE, sort); + searcher.search(query, Integer.MAX_VALUE, sort, true); + searcher.search(query, Integer.MAX_VALUE, sort, false); + searcher.searchAfter(after, query, Integer.MAX_VALUE, sort); + searcher.searchAfter(after, query, Integer.MAX_VALUE, sort, true); + searcher.searchAfter(after, query, Integer.MAX_VALUE, sort, false); Review comment: should we assert on the results? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org