jpountz commented on a change in pull request #916: LUCENE-8213: Asynchronous Caching in LRUQueryCache URL: https://github.com/apache/lucene-solr/pull/916#discussion_r332859481
########## File path: lucene/core/src/test/org/apache/lucene/search/TestLRUQueryCache.java ########## @@ -1229,17 +1476,49 @@ public void testMinSegmentSizePredicate() throws IOException { LRUQueryCache cache = new LRUQueryCache(2, 10000, new LRUQueryCache.MinSegmentSizePredicate(2, 0f)); searcher.setQueryCache(cache); searcher.count(new DummyQuery()); + assertEquals(0, cache.getCacheCount()); - cache = new LRUQueryCache(2, 10000, new LRUQueryCache.MinSegmentSizePredicate(1, 0f)); + final CountDownLatch[] latch = { new CountDownLatch(1)}; + cache = new LRUQueryCache(2, 10000, + new LRUQueryCache.MinSegmentSizePredicate(1, 0f)) { + @Override + protected void onDocIdSetCache(Object readerCoreKey, long ramBytesUsed) { + super.onDocIdSetCache(readerCoreKey, ramBytesUsed); + latch[0].countDown(); + } + }; + searcher.setQueryCache(cache); + searcher.count(new DummyQuery()); - assertEquals(1, cache.getCacheCount()); - cache = new LRUQueryCache(2, 10000, new LRUQueryCache.MinSegmentSizePredicate(0, .6f)); + if (cache.getCacheCount() != 1) { + try { + latch[0].await(200, TimeUnit.MILLISECONDS); + } catch (InterruptedException e) { + throw new RuntimeException(e.getMessage()); + } + assertEquals(1, cache.getCacheCount()); + } + + latch[0] = new CountDownLatch(1); + cache = new LRUQueryCache(2, 10000, + new LRUQueryCache.MinSegmentSizePredicate(0, .6f)) { + @Override + protected void onDocIdSetCache(Object readerCoreKey, long ramBytesUsed) { + super.onDocIdSetCache(readerCoreKey, ramBytesUsed); + latch[0].countDown(); + } + }; + searcher.setQueryCache(cache); + searcher.count(new DummyQuery()); - assertEquals(1, cache.getCacheCount()); + if (cache.getCacheCount() != 1) { Review comment: same question here ---------------------------------------------------------------- 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