From 14305d9e3c4e5ccb923581f22aa86157ca919138 Mon Sep 17 00:00:00 2001 From: Michael McCandless Date: Tue, 30 Nov 2010 09:22:02 +0000 Subject: [PATCH] fix false random test failure (take 2) git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1040447 13f79535-47bb-0310-9956-ffa450edef68 --- .../lucene/search/BaseTestRangeFilter.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lucene/src/test/org/apache/lucene/search/BaseTestRangeFilter.java b/lucene/src/test/org/apache/lucene/search/BaseTestRangeFilter.java index 75833c2683e..0ac5192350b 100644 --- a/lucene/src/test/org/apache/lucene/search/BaseTestRangeFilter.java +++ b/lucene/src/test/org/apache/lucene/search/BaseTestRangeFilter.java @@ -115,10 +115,6 @@ public class BaseTestRangeFilter extends LuceneTestCase { private static IndexReader build(Random random, TestIndex index) throws IOException { /* build an index */ - RandomIndexWriter writer = new RandomIndexWriter(random, index.index, - newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()) - .setOpenMode(OpenMode.CREATE).setMaxBufferedDocs(_TestUtil.nextInt(random, 50, 1000))); - _TestUtil.reduceOpenFiles(writer.w); Document doc = new Document(); Field idField = newField(random, "id", "", Field.Store.YES, Field.Index.NOT_ANALYZED); @@ -128,11 +124,16 @@ public class BaseTestRangeFilter extends LuceneTestCase { doc.add(randField); doc.add(bodyField); - int minCount = 0; - int maxCount = 0; - + RandomIndexWriter writer = new RandomIndexWriter(random, index.index, + newIndexWriterConfig(random, TEST_VERSION_CURRENT, new MockAnalyzer()) + .setOpenMode(OpenMode.CREATE).setMaxBufferedDocs(_TestUtil.nextInt(random, 50, 1000))); while(true) { + int minCount = 0; + int maxCount = 0; + + _TestUtil.reduceOpenFiles(writer.w); + for (int d = minId; d <= maxId; d++) { idField.setValue(pad(d)); int r = index.allowNegativeRandomInts ? random.nextInt() : random @@ -160,15 +161,14 @@ public class BaseTestRangeFilter extends LuceneTestCase { // max, so, we loop until we satisfy that. it should be // exceedingly rare (Yonik calculates 1 in ~429,000) // times) that this loop requires more than one try: - break; + IndexReader ir = writer.getReader(); + writer.close(); + return ir; } // try again + writer.deleteAll(); } - - IndexReader ir = writer.getReader(); - writer.close(); - return ir; } @Test