Apache Lucene open-source search software
LUCENE-7415: tone down some of the longest core tests
Robert Muirba09fa7a4a8e
diff --git a/lucene/core/src/test/org/apache/lucene/codecs/compressing/TestGrowableByteArrayDataOutput.java b/lucene/core/src/test/org/apache/lucene/codecs/compressing/TestGrowableByteArrayDataOutput.javaindex fb90d925eb9..3820733ecca 100644--- a/lucene/core/src/test/org/apache/lucene/codecs/compressing/TestGrowableByteArrayDataOutput.java+++ b/lucene/core/src/test/org/apache/lucene/codecs/compressing/TestGrowableByteArrayDataOutput.java@@ -58,7 +58,7 @@ public class TestGrowableByteArrayDataOutput extends LuceneTestCase {public void testWriteLargeStrings() throws Exception {int minSizeForDoublePass = GrowableByteArrayDataOutput.MIN_UTF8_SIZE_TO_ENABLE_DOUBLE_PASS_ENCODING;- int num = atLeast(1000);+ int num = atLeast(100);for (int i = 0; i < num; i++) {String unicode = TestUtil.randomRealisticUnicodeString(random(), minSizeForDoublePass, 10 * minSizeForDoublePass);byte[] utf8 = new byte[unicode.length() * UnicodeUtil.MAX_UTF8_BYTES_PER_CHAR];diff --git a/lucene/core/src/test/org/apache/lucene/geo/TestGeoUtils.java b/lucene/core/src/test/org/apache/lucene/geo/TestGeoUtils.javaindex e75ae85b8a6..2cfb2f84002 100644--- a/lucene/core/src/test/org/apache/lucene/geo/TestGeoUtils.java+++ b/lucene/core/src/test/org/apache/lucene/geo/TestGeoUtils.java@@ -30,7 +30,7 @@ public class TestGeoUtils extends LuceneTestCase {// We rely heavily on GeoUtils.circleToBBox so we test it here:public void testRandomCircleToBBox() throws Exception {- int iters = atLeast(1000);+ int iters = atLeast(100);for(int iter=0;iter<iters;iter++) {double centerLat = GeoTestUtil.nextLatitude();@@ -89,7 +89,8 @@ public class TestGeoUtils extends LuceneTestCase {// similar to testRandomCircleToBBox, but different, less evil, maybe simplerpublic void testBoundingBoxOpto() {- for (int i = 0; i < 1000; i++) {+ int iters = atLeast(100);+ for (int i = 0; i < iters; i++) {double lat = GeoTestUtil.nextLatitude();double lon = GeoTestUtil.nextLongitude();double radius = 50000000 * random().nextDouble();@@ -119,7 +120,8 @@ public class TestGeoUtils extends LuceneTestCase {// test we can use haversinSortKey() for distance queries.public void testHaversinOpto() {- for (int i = 0; i < 1000; i++) {+ int iters = atLeast(100);+ for (int i = 0; i < iters; i++) {double lat = GeoTestUtil.nextLatitude();double lon = GeoTestUtil.nextLongitude();double radius = 50000000 * random().nextDouble();@@ -193,7 +195,8 @@ public class TestGeoUtils extends LuceneTestCase {// TODO: does not really belong here, but we test it like this for now// we can make a fake IndexReader to send boxes directly to Point visitors instead?public void testCircleOpto() throws Exception {- for (int i = 0; i < 50; i++) {+ int iters = atLeast(20);+ for (int i = 0; i < iters; i++) {// circlefinal double centerLat = -90 + 180.0 * random().nextDouble();final double centerLon = -180 + 360.0 * random().nextDouble();diff --git a/lucene/core/src/test/org/apache/lucene/geo/TestPolygon2D.java b/lucene/core/src/test/org/apache/lucene/geo/TestPolygon2D.javaindex 70281cac1d4..31a42c01ba5 100644--- a/lucene/core/src/test/org/apache/lucene/geo/TestPolygon2D.java+++ b/lucene/core/src/test/org/apache/lucene/geo/TestPolygon2D.java@@ -103,7 +103,8 @@ public class TestPolygon2D extends LuceneTestCase {/** If polygon.contains(box) returns true, then any point in that box should return true as well */public void testContainsRandom() throws Exception {- for (int i = 0; i < 1000; i++) {+ int iters = atLeast(50);+ for (int i = 0; i < iters; i++) {Polygon polygon = nextPolygon();Polygon2D impl = Polygon2D.create(polygon);@@ -175,7 +176,8 @@ public class TestPolygon2D extends LuceneTestCase {/** If polygon.intersects(box) returns false, then any point in that box should return false as well */public void testIntersectRandom() {- for (int i = 0; i < 100; i++) {+ int iters = atLeast(10);+ for (int i = 0; i < iters; i++) {Polygon polygon = nextPolygon();Polygon2D impl = Polygon2D.create(polygon);@@ -268,7 +270,8 @@ public class TestPolygon2D extends LuceneTestCase {/** Tests current impl against original algorithm */public void testContainsAgainstOriginal() {- for (int i = 0; i < 1000; i++) {+ int iters = atLeast(100);+ for (int i = 0; i < iters; i++) {Polygon polygon = nextPolygon();// currently we don't generate these, but this test does not want holes.while (polygon.getHoles().length > 0) {diff --git a/lucene/core/src/test/org/apache/lucene/index/TestIndexSorting.java b/lucene/core/src/test/org/apache/lucene/index/TestIndexSorting.javaindex 363ccb2ce59..5045396e43e 100644--- a/lucene/core/src/test/org/apache/lucene/index/TestIndexSorting.java+++ b/lucene/core/src/test/org/apache/lucene/index/TestIndexSorting.java@@ -1217,7 +1217,7 @@ public class TestIndexSorting extends LuceneTestCase {if (TEST_NIGHTLY) {numDocs = atLeast(100000);} else {- numDocs = atLeast(10000);+ numDocs = atLeast(1000);}List<RandomDoc> docs = new ArrayList<>();diff --git a/lucene/core/src/test/org/apache/lucene/index/TestIndexingSequenceNumbers.java b/lucene/core/src/test/org/apache/lucene/index/TestIndexingSequenceNumbers.javaindex 8d4c5c7903f..55aa6e036d8 100644--- a/lucene/core/src/test/org/apache/lucene/index/TestIndexingSequenceNumbers.java+++ b/lucene/core/src/test/org/apache/lucene/index/TestIndexingSequenceNumbers.java@@ -72,6 +72,7 @@ public class TestIndexingSequenceNumbers extends LuceneTestCase {dir.close();}+ @Slowpublic void testStressUpdateSameID() throws Exception {int iters = atLeast(100);for(int iter=0;iter<iters;iter++) {@@ -144,6 +145,7 @@ public class TestIndexingSequenceNumbers extends LuceneTestCase {long seqNo;}+ @Slowpublic void testStressConcurrentCommit() throws Exception {final int opCount = atLeast(10000);final int idCount = TestUtil.nextInt(random(), 10, 1000);@@ -303,6 +305,7 @@ public class TestIndexingSequenceNumbers extends LuceneTestCase {dir.close();}+ @Slowpublic void testStressConcurrentDocValuesUpdatesCommit() throws Exception {final int opCount = atLeast(10000);final int idCount = TestUtil.nextInt(random(), 10, 1000);@@ -459,6 +462,7 @@ public class TestIndexingSequenceNumbers extends LuceneTestCase {dir.close();}+ @Slowpublic void testStressConcurrentAddAndDeleteAndCommit() throws Exception {final int opCount = atLeast(10000);final int idCount = TestUtil.nextInt(random(), 10, 1000);diff --git a/lucene/core/src/test/org/apache/lucene/search/TestBoolean2.java b/lucene/core/src/test/org/apache/lucene/search/TestBoolean2.javaindex ae46e343a73..49aeddf0f00 100644--- a/lucene/core/src/test/org/apache/lucene/search/TestBoolean2.java+++ b/lucene/core/src/test/org/apache/lucene/search/TestBoolean2.java@@ -25,6 +25,8 @@ import java.util.Random;import org.apache.lucene.analysis.MockAnalyzer;import org.apache.lucene.document.Document;import org.apache.lucene.document.Field;+import org.apache.lucene.document.FieldType;+import org.apache.lucene.document.TextField;import org.apache.lucene.index.DirectoryReader;import org.apache.lucene.index.IndexReader;import org.apache.lucene.index.IndexWriter;@@ -66,7 +68,7 @@ public class TestBoolean2 extends LuceneTestCase {@BeforeClasspublic static void beforeClass() throws Exception {- // in some runs, test immediate adjacency of matches - in others, force a full bucket gap betwen docs+ // in some runs, test immediate adjacency of matches - in others, force a full bucket gap between docsNUM_FILLER_DOCS = random().nextBoolean() ? 0 : BooleanScorer.SIZE;PRE_FILLER_DOCS = TestUtil.nextInt(random(), 0, (NUM_FILLER_DOCS / 2));@@ -77,13 +79,16 @@ public class TestBoolean2 extends LuceneTestCase {}RandomIndexWriter writer= new RandomIndexWriter(random(), directory, newIndexWriterConfig(new MockAnalyzer(random())).setMergePolicy(newLogMergePolicy()));+ // we'll make a ton of docs, disable store/norms/vectors+ FieldType ft = new FieldType(TextField.TYPE_NOT_STORED);+ ft.setOmitNorms(true);Document doc = new Document();for (int filler = 0; filler < PRE_FILLER_DOCS; filler++) {writer.addDocument(doc);}for (int i = 0; i < docFields.length; i++) {- doc.add(newTextField(field, docFields[i], Field.Store.NO));+ doc.add(new Field(field, docFields[i], ft));writer.addDocument(doc);doc = new Document();@@ -148,12 +153,12 @@ public class TestBoolean2 extends LuceneTestCase {newIndexWriterConfig(new MockAnalyzer(random())).setMaxBufferedDocs(TestUtil.nextInt(random(), 50, 1000)));doc = new Document();- doc.add(newTextField("field2", "xxx", Field.Store.NO));+ doc.add(new Field("field2", "xxx", ft));for(int i=0;i<NUM_EXTRA_DOCS/2;i++) {w.addDocument(doc);}doc = new Document();- doc.add(newTextField("field2", "big bad bug", Field.Store.NO));+ doc.add(new Field("field2", "big bad bug", ft));for(int i=0;i<NUM_EXTRA_DOCS/2;i++) {w.addDocument(doc);}diff --git a/lucene/core/src/test/org/apache/lucene/search/TestSimpleExplanationsWithFillerDocs.java b/lucene/core/src/test/org/apache/lucene/search/TestSimpleExplanationsWithFillerDocs.javaindex 0a79ae0f495..9f506688c52 100644--- a/lucene/core/src/test/org/apache/lucene/search/TestSimpleExplanationsWithFillerDocs.java+++ b/lucene/core/src/test/org/apache/lucene/search/TestSimpleExplanationsWithFillerDocs.java@@ -23,6 +23,7 @@ import org.apache.lucene.document.Field;import org.apache.lucene.index.Term;import org.apache.lucene.index.RandomIndexWriter;import org.apache.lucene.util.TestUtil;+import org.apache.lucene.util.LuceneTestCase.Slow;import org.junit.BeforeClass;import org.junit.Assume;@@ -34,6 +35,7 @@ import org.junit.Assume;* all use terms from same set of source data as our regular docs (to emphasis the DocFreq factor in scoring),* in which case the queries will be wrapped so they can be excluded.*/+@Slow // can this be sped up to be non-slow? filler docs make it quite a bit slower and many test methods...public class TestSimpleExplanationsWithFillerDocs extends TestSimpleExplanations {/** num of empty docs injected between every doc in the index */