Apache Solr open-source search software
LUCENE-6697: fix test bugs
Michael McCandless4f543493a4d7
diff --git a/lucene/sandbox/src/test/org/apache/lucene/bkdtree/TestBKDTree.java b/lucene/sandbox/src/test/org/apache/lucene/bkdtree/TestBKDTree.javaindex b791b3f5992..7d3fe4f0524 100644--- a/lucene/sandbox/src/test/org/apache/lucene/bkdtree/TestBKDTree.java+++ b/lucene/sandbox/src/test/org/apache/lucene/bkdtree/TestBKDTree.java@@ -169,9 +169,7 @@ public class TestBKDTree extends LuceneTestCase {IndexWriterConfig iwc = newIndexWriterConfig();// We rely on docID order:iwc.setMergePolicy(newLogMergePolicy());- int maxPointsInLeaf = TestUtil.nextInt(random(), 16, 2048);- int maxPointsSortInHeap = TestUtil.nextInt(random(), maxPointsInLeaf, 1024*1024);- Codec codec = TestUtil.alwaysDocValuesFormat(new BKDTreeDocValuesFormat(maxPointsInLeaf, maxPointsSortInHeap));+ Codec codec = TestUtil.alwaysDocValuesFormat(getDocValuesFormat());iwc.setCodec(codec);RandomIndexWriter w = new RandomIndexWriter(random(), dir, iwc);@@ -360,15 +358,13 @@ public class TestBKDTree extends LuceneTestCase {private static final double TOLERANCE = 1e-7;private static void verify(double[] lats, double[] lons) throws Exception {- int maxPointsInLeaf = TestUtil.nextInt(random(), 16, 2048);- int maxPointsSortInHeap = TestUtil.nextInt(random(), maxPointsInLeaf, 1024*1024);IndexWriterConfig iwc = newIndexWriterConfig();// Else we can get O(N^2) merging:int mbd = iwc.getMaxBufferedDocs();if (mbd != -1 && mbd < lats.length/100) {iwc.setMaxBufferedDocs(lats.length/100);}- final DocValuesFormat dvFormat = new BKDTreeDocValuesFormat(maxPointsInLeaf, maxPointsSortInHeap);+ final DocValuesFormat dvFormat = getDocValuesFormat();Codec codec = new Lucene53Codec() {@Overridepublic DocValuesFormat getDocValuesFormatForField(String field) {@@ -616,7 +612,7 @@ public class TestBKDTree extends LuceneTestCase {public void testAccountableHasDelegate() throws Exception {Directory dir = newDirectory();IndexWriterConfig iwc = newIndexWriterConfig();- Codec codec = TestUtil.alwaysDocValuesFormat(new BKDTreeDocValuesFormat());+ Codec codec = TestUtil.alwaysDocValuesFormat(getDocValuesFormat());iwc.setCodec(codec);RandomIndexWriter w = new RandomIndexWriter(random(), dir, iwc);Document doc = new Document();@@ -632,4 +628,10 @@ public class TestBKDTree extends LuceneTestCase {assertTrue(Accountables.toString((Accountable) r.leaves().get(0).reader()).contains("delegate"));IOUtils.close(r, w, dir);}++ private static DocValuesFormat getDocValuesFormat() {+ int maxPointsInLeaf = TestUtil.nextInt(random(), 16, 2048);+ int maxPointsSortInHeap = TestUtil.nextInt(random(), maxPointsInLeaf, 1024*1024);+ return new BKDTreeDocValuesFormat(maxPointsInLeaf, maxPointsSortInHeap);+ }}diff --git a/lucene/sandbox/src/test/org/apache/lucene/rangetree/TestRangeTree.java b/lucene/sandbox/src/test/org/apache/lucene/rangetree/TestRangeTree.javaindex a632bc9f211..0332748336f 100644--- a/lucene/sandbox/src/test/org/apache/lucene/rangetree/TestRangeTree.java+++ b/lucene/sandbox/src/test/org/apache/lucene/rangetree/TestRangeTree.java@@ -123,9 +123,7 @@ public class TestRangeTree extends LuceneTestCase {// We rely on docID order:iwc.setMergePolicy(newLogMergePolicy());- int maxPointsInLeaf = TestUtil.nextInt(random(), 16, 2048);- int maxPointsSortInHeap = TestUtil.nextInt(random(), maxPointsInLeaf, 1024*1024);- Codec codec = TestUtil.alwaysDocValuesFormat(new RangeTreeDocValuesFormat(maxPointsInLeaf, maxPointsSortInHeap));+ Codec codec = TestUtil.alwaysDocValuesFormat(getDocValuesFormat());iwc.setCodec(codec);RandomIndexWriter w = new RandomIndexWriter(random(), dir, iwc);@@ -210,9 +208,7 @@ public class TestRangeTree extends LuceneTestCase {// We rely on docID order:iwc.setMergePolicy(newLogMergePolicy());- int maxPointsInLeaf = TestUtil.nextInt(random(), 16, 2048);- int maxPointsSortInHeap = TestUtil.nextInt(random(), 1024, 1024*1024);- Codec codec = TestUtil.alwaysDocValuesFormat(new RangeTreeDocValuesFormat(maxPointsInLeaf, maxPointsSortInHeap));+ Codec codec = TestUtil.alwaysDocValuesFormat(getDocValuesFormat());iwc.setCodec(codec);RandomIndexWriter w = new RandomIndexWriter(random(), dir, iwc);@@ -353,8 +349,6 @@ public class TestRangeTree extends LuceneTestCase {}private static void verify(Bits missing, long[] values) throws Exception {- int maxPointsInLeaf = TestUtil.nextInt(random(), 16, 2048);- int maxPointsSortInHeap = TestUtil.nextInt(random(), maxPointsInLeaf, 1024*1024);IndexWriterConfig iwc = newIndexWriterConfig();// Else we can get O(N^2) merging:@@ -362,7 +356,7 @@ public class TestRangeTree extends LuceneTestCase {if (mbd != -1 && mbd < values.length/100) {iwc.setMaxBufferedDocs(values.length/100);}- final DocValuesFormat dvFormat = new RangeTreeDocValuesFormat(maxPointsInLeaf, maxPointsSortInHeap);+ final DocValuesFormat dvFormat = getDocValuesFormat();Codec codec = new Lucene53Codec() {@Overridepublic DocValuesFormat getDocValuesFormatForField(String field) {@@ -768,4 +762,10 @@ public class TestRangeTree extends LuceneTestCase {return v ^ 0x8000000000000000L;}*/++ private static DocValuesFormat getDocValuesFormat() {+ int maxPointsInLeaf = TestUtil.nextInt(random(), 16, 2048);+ int maxPointsSortInHeap = TestUtil.nextInt(random(), maxPointsInLeaf, 1024*1024);+ return new RangeTreeDocValuesFormat(maxPointsInLeaf, maxPointsSortInHeap);+ }}