From 5fc6fb34ed2c62eae242c992bb5e09066655e727 Mon Sep 17 00:00:00 2001 From: Michael McCandless Date: Tue, 24 Aug 2010 21:55:32 +0000 Subject: [PATCH] sync CMS to address intermittent failure git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@988736 13f79535-47bb-0310-9956-ffa450edef68 --- .../search/TestCachingWrapperFilter.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/lucene/src/test/org/apache/lucene/search/TestCachingWrapperFilter.java b/lucene/src/test/org/apache/lucene/search/TestCachingWrapperFilter.java index f3d2d6dc223..95bf1380d2c 100644 --- a/lucene/src/test/org/apache/lucene/search/TestCachingWrapperFilter.java +++ b/lucene/src/test/org/apache/lucene/search/TestCachingWrapperFilter.java @@ -24,6 +24,8 @@ import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.Term; import org.apache.lucene.document.Document; import org.apache.lucene.document.Field; +import org.apache.lucene.index.MergeScheduler; +import org.apache.lucene.index.ConcurrentMergeScheduler; import org.apache.lucene.index.RandomIndexWriter; import org.apache.lucene.index.SlowMultiReaderWrapper; import org.apache.lucene.store.Directory; @@ -160,6 +162,14 @@ public class TestCachingWrapperFilter extends LuceneTestCase { Directory dir = newDirectory(rand); RandomIndexWriter writer = new RandomIndexWriter(rand, dir); + MergeScheduler ms = writer.w.getMergeScheduler(); + ConcurrentMergeScheduler cms; + if (ms instanceof ConcurrentMergeScheduler) { + cms = (ConcurrentMergeScheduler) ms; + } else { + cms = null; + } + // NOTE: cannot use writer.getReader because RIW (on // flipping a coin) may give us a newly opened reader, // but we use .reopen on this reader below and expect to @@ -172,6 +182,9 @@ public class TestCachingWrapperFilter extends LuceneTestCase { doc.add(new Field("id", "1", Field.Store.YES, Field.Index.NOT_ANALYZED)); writer.addDocument(doc); + if (cms != null) { + cms.sync(); + } reader = refreshReader(reader); searcher = new IndexSearcher(reader); @@ -192,6 +205,9 @@ public class TestCachingWrapperFilter extends LuceneTestCase { // now delete the doc, refresh the reader, and see that it's not there writer.deleteDocuments(new Term("id", "1")); + if (cms != null) { + cms.sync(); + } reader = refreshReader(reader); searcher = new IndexSearcher(reader); @@ -206,6 +222,10 @@ public class TestCachingWrapperFilter extends LuceneTestCase { filter = new CachingWrapperFilter(startFilter, CachingWrapperFilter.DeletesMode.RECACHE); writer.addDocument(doc); + + if (cms != null) { + cms.sync(); + } reader = refreshReader(reader); searcher = new IndexSearcher(reader); @@ -218,6 +238,9 @@ public class TestCachingWrapperFilter extends LuceneTestCase { // make sure we get a cache hit when we reopen reader // that had no change to deletions + if (cms != null) { + cms.sync(); + } IndexReader newReader = refreshReader(reader); assertTrue(reader != newReader); reader = newReader; @@ -230,6 +253,9 @@ public class TestCachingWrapperFilter extends LuceneTestCase { // now delete the doc, refresh the reader, and see that it's not there writer.deleteDocuments(new Term("id", "1")); + if (cms != null) { + cms.sync(); + } reader = refreshReader(reader); searcher = new IndexSearcher(reader); @@ -245,6 +271,9 @@ public class TestCachingWrapperFilter extends LuceneTestCase { filter = new CachingWrapperFilter(startFilter, CachingWrapperFilter.DeletesMode.DYNAMIC); writer.addDocument(doc); + if (cms != null) { + cms.sync(); + } reader = refreshReader(reader); searcher = new IndexSearcher(reader); @@ -257,6 +286,9 @@ public class TestCachingWrapperFilter extends LuceneTestCase { // now delete the doc, refresh the reader, and see that it's not there writer.deleteDocuments(new Term("id", "1")); + if (cms != null) { + cms.sync(); + } reader = refreshReader(reader); searcher = new IndexSearcher(reader);