You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ro...@apache.org on 2019/06/20 16:33:39 UTC
[lucene-solr] 01/02: LUCENE-8766: Fix timing problem in test
This is an automated email from the ASF dual-hosted git repository.
romseygeek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
commit 371f50acc2630109e30a3cc8536691e954874852
Author: Alan Woodward <ro...@apache.org>
AuthorDate: Mon Jun 17 14:18:28 2019 +0100
LUCENE-8766: Fix timing problem in test
---
.../test/org/apache/lucene/monitor/TestCachePurging.java | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/lucene/monitor/src/test/org/apache/lucene/monitor/TestCachePurging.java b/lucene/monitor/src/test/org/apache/lucene/monitor/TestCachePurging.java
index 8291e48..3e87071 100644
--- a/lucene/monitor/src/test/org/apache/lucene/monitor/TestCachePurging.java
+++ b/lucene/monitor/src/test/org/apache/lucene/monitor/TestCachePurging.java
@@ -132,7 +132,7 @@ public class TestCachePurging extends MonitorTestBase {
public void testBackgroundPurges() throws IOException, InterruptedException {
- MonitorConfiguration config = new MonitorConfiguration().setPurgeFrequency(1, TimeUnit.SECONDS);
+ MonitorConfiguration config = new MonitorConfiguration().setPurgeFrequency(50, TimeUnit.MILLISECONDS);
try (Monitor monitor = new Monitor(ANALYZER, Presearcher.NO_FILTERING, config)) {
assertEquals(-1, monitor.getQueryCacheStats().lastPurged);
@@ -140,11 +140,20 @@ public class TestCachePurging extends MonitorTestBase {
for (int i = 0; i < 100; i++) {
monitor.register(newMonitorQuery(i));
}
+ assertEquals(100, monitor.getQueryCacheStats().cachedQueries);
+
monitor.deleteById("5");
assertEquals(99, monitor.getQueryCacheStats().queries);
- assertEquals(100, monitor.getQueryCacheStats().cachedQueries);
- TimeUnit.SECONDS.sleep(2);
+ CountDownLatch latch = new CountDownLatch(1);
+ monitor.addQueryIndexUpdateListener(new MonitorUpdateListener() {
+ @Override
+ public void onPurge() {
+ latch.countDown();
+ }
+ });
+
+ assertTrue(latch.await(5, TimeUnit.SECONDS));
assertEquals(99, monitor.getQueryCacheStats().queries);
assertEquals(99, monitor.getQueryCacheStats().cachedQueries);
assertTrue(monitor.getQueryCacheStats().lastPurged > 0);