From 85a05b546bee9ff7484372c44854d4fd66d63b36 Mon Sep 17 00:00:00 2001 From: Adrien Grand Date: Thu, 19 Jan 2017 09:54:23 +0100 Subject: [PATCH] LUCENE-7640: Fix test. --- .../codecs/lucene60/TestLucene60PointsFormat.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lucene/core/src/test/org/apache/lucene/codecs/lucene60/TestLucene60PointsFormat.java b/lucene/core/src/test/org/apache/lucene/codecs/lucene60/TestLucene60PointsFormat.java index 4287273e2c0..08dc6c60827 100644 --- a/lucene/core/src/test/org/apache/lucene/codecs/lucene60/TestLucene60PointsFormat.java +++ b/lucene/core/src/test/org/apache/lucene/codecs/lucene60/TestLucene60PointsFormat.java @@ -31,7 +31,9 @@ import org.apache.lucene.index.BasePointsFormatTestCase; import org.apache.lucene.index.DirectoryReader; import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexWriter; +import org.apache.lucene.index.IndexWriterConfig; import org.apache.lucene.index.LeafReader; +import org.apache.lucene.index.MockRandomMergePolicy; import org.apache.lucene.index.PointValues; import org.apache.lucene.index.SegmentReadState; import org.apache.lucene.index.SegmentWriteState; @@ -97,7 +99,13 @@ public class TestLucene60PointsFormat extends BasePointsFormatTestCase { public void testEstimatePointCount() throws IOException { Directory dir = newDirectory(); - IndexWriter w = new IndexWriter(dir, newIndexWriterConfig()); + IndexWriterConfig iwc = newIndexWriterConfig(); + // Avoid mockRandomMP since it may cause non-optimal merges that make the + // number of points per leaf hard to predict + while (iwc.getMergePolicy() instanceof MockRandomMergePolicy) { + iwc.setMergePolicy(newMergePolicy()); + } + IndexWriter w = new IndexWriter(dir, iwc); byte[] pointValue = new byte[3]; byte[] uniquePointValue = new byte[3]; random().nextBytes(uniquePointValue);