mirror of https://github.com/apache/lucene.git
LUCENE-10473: Make tests a bit faster when running nightly. (#754)
This commit is contained in:
parent
fcacd22a80
commit
1b890ab5f9
|
@ -151,9 +151,6 @@ public final class CompetitiveImpactAccumulator {
|
|||
|
||||
// Only called by assertions
|
||||
private boolean assertConsistent() {
|
||||
for (int freq : maxFreqs) {
|
||||
assert freq >= 0;
|
||||
}
|
||||
int previousFreq = 0;
|
||||
long previousNorm = 0;
|
||||
for (Impact impact : otherFreqNormPairs) {
|
||||
|
|
|
@ -37,6 +37,7 @@ import org.apache.lucene.codecs.lucene90.Lucene90PointsWriter;
|
|||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.NumericDocValuesField;
|
||||
import org.apache.lucene.document.StringField;
|
||||
import org.apache.lucene.geo.Polygon;
|
||||
import org.apache.lucene.geo.Rectangle;
|
||||
import org.apache.lucene.index.DirectoryReader;
|
||||
|
@ -610,8 +611,9 @@ public class TestGeo3DPoint extends LuceneTestCase {
|
|||
|
||||
boolean haveRealDoc = false;
|
||||
|
||||
Random random = random();
|
||||
for (int docID = 0; docID < numPoints; docID++) {
|
||||
int x = random().nextInt(20);
|
||||
int x = random.nextInt(20);
|
||||
if (x == 17) {
|
||||
// Some docs don't have a point:
|
||||
lats[docID] = Double.NaN;
|
||||
|
@ -624,7 +626,7 @@ public class TestGeo3DPoint extends LuceneTestCase {
|
|||
if (docID > 0 && x < 3 && haveRealDoc) {
|
||||
int oldDocID;
|
||||
while (true) {
|
||||
oldDocID = random().nextInt(docID);
|
||||
oldDocID = random.nextInt(docID);
|
||||
if (Double.isNaN(lats[oldDocID]) == false) {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -909,6 +909,8 @@ public abstract class BaseGeoPointTestCase extends LuceneTestCase {
|
|||
}
|
||||
Directory dir;
|
||||
if (lats.length > 100000) {
|
||||
// Avoid slow codecs like SimpleText
|
||||
iwc.setCodec(TestUtil.getDefaultCodec());
|
||||
dir = newFSDirectory(createTempDir(getClass().getSimpleName()));
|
||||
} else {
|
||||
dir = newDirectory();
|
||||
|
@ -992,6 +994,8 @@ public abstract class BaseGeoPointTestCase extends LuceneTestCase {
|
|||
}
|
||||
Directory dir;
|
||||
if (lats.length > 100000) {
|
||||
// Avoid slow codecs like SimpleText
|
||||
iwc.setCodec(TestUtil.getDefaultCodec());
|
||||
dir = newFSDirectory(createTempDir(getClass().getSimpleName()));
|
||||
} else {
|
||||
dir = newDirectory();
|
||||
|
@ -1095,6 +1099,8 @@ public abstract class BaseGeoPointTestCase extends LuceneTestCase {
|
|||
}
|
||||
Directory dir;
|
||||
if (lats.length > 100000) {
|
||||
// Avoid slow codecs like SimpleText
|
||||
iwc.setCodec(TestUtil.getDefaultCodec());
|
||||
dir = newFSDirectory(createTempDir(getClass().getSimpleName()));
|
||||
} else {
|
||||
dir = newDirectory();
|
||||
|
@ -1179,6 +1185,8 @@ public abstract class BaseGeoPointTestCase extends LuceneTestCase {
|
|||
}
|
||||
Directory dir;
|
||||
if (lats.length > 100000) {
|
||||
// Avoid slow codecs like SimpleText
|
||||
iwc.setCodec(TestUtil.getDefaultCodec());
|
||||
dir = newFSDirectory(createTempDir(getClass().getSimpleName()));
|
||||
} else {
|
||||
dir = newDirectory();
|
||||
|
|
|
@ -805,6 +805,8 @@ public abstract class BaseXYPointTestCase extends LuceneTestCase {
|
|||
}
|
||||
Directory dir;
|
||||
if (xs.length > 100000) {
|
||||
// Avoid slow codecs like SimpleText
|
||||
iwc.setCodec(TestUtil.getDefaultCodec());
|
||||
dir = newFSDirectory(createTempDir(getClass().getSimpleName()));
|
||||
} else {
|
||||
dir = newDirectory();
|
||||
|
@ -887,6 +889,8 @@ public abstract class BaseXYPointTestCase extends LuceneTestCase {
|
|||
}
|
||||
Directory dir;
|
||||
if (xs.length > 100000) {
|
||||
// Avoid slow codecs like SimpleText
|
||||
iwc.setCodec(TestUtil.getDefaultCodec());
|
||||
dir = newFSDirectory(createTempDir(getClass().getSimpleName()));
|
||||
} else {
|
||||
dir = newDirectory();
|
||||
|
@ -986,6 +990,8 @@ public abstract class BaseXYPointTestCase extends LuceneTestCase {
|
|||
}
|
||||
Directory dir;
|
||||
if (xs.length > 100000) {
|
||||
// Avoid slow codecs like SimpleText
|
||||
iwc.setCodec(TestUtil.getDefaultCodec());
|
||||
dir = newFSDirectory(createTempDir(getClass().getSimpleName()));
|
||||
} else {
|
||||
dir = newDirectory();
|
||||
|
@ -1069,6 +1075,8 @@ public abstract class BaseXYPointTestCase extends LuceneTestCase {
|
|||
}
|
||||
Directory dir;
|
||||
if (xs.length > 100000) {
|
||||
// Avoid slow codecs like SimpleText
|
||||
iwc.setCodec(TestUtil.getDefaultCodec());
|
||||
dir = newFSDirectory(createTempDir(getClass().getSimpleName()));
|
||||
} else {
|
||||
dir = newDirectory();
|
||||
|
|
|
@ -23,6 +23,7 @@ import java.util.Set;
|
|||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.document.NumericDocValuesField;
|
||||
import org.apache.lucene.document.StringField;
|
||||
import org.apache.lucene.index.DirectoryReader;
|
||||
import org.apache.lucene.index.IndexReader;
|
||||
import org.apache.lucene.index.IndexWriter;
|
||||
|
@ -230,6 +231,8 @@ public abstract class BaseRangeFieldQueryTestCase extends LuceneTestCase {
|
|||
}
|
||||
Directory dir;
|
||||
if (ranges.length > 50000) {
|
||||
// Avoid slow codecs like SimpleText
|
||||
iwc.setCodec(TestUtil.getDefaultCodec());
|
||||
dir = newFSDirectory(createTempDir(getClass().getSimpleName()));
|
||||
} else {
|
||||
dir = newDirectory();
|
||||
|
|
|
@ -402,12 +402,6 @@ public abstract class LuceneTestCase extends Assert {
|
|||
/** Enables or disables dumping of {@link InfoStream} messages. */
|
||||
public static final boolean INFOSTREAM = systemPropertyAsBoolean("tests.infostream", VERBOSE);
|
||||
|
||||
/**
|
||||
* A random multiplier which you should use when writing random tests: multiply it by the number
|
||||
* of iterations to scale your tests (for nightly builds).
|
||||
*/
|
||||
public static final int RANDOM_MULTIPLIER = systemPropertyAsInt("tests.multiplier", 1);
|
||||
|
||||
public static final boolean TEST_ASSERTS_ENABLED = systemPropertyAsBoolean("tests.asserts", true);
|
||||
|
||||
/**
|
||||
|
@ -474,6 +468,13 @@ public abstract class LuceneTestCase extends Assert {
|
|||
public static final Throttling TEST_THROTTLING =
|
||||
TEST_NIGHTLY ? Throttling.SOMETIMES : Throttling.NEVER;
|
||||
|
||||
/**
|
||||
* A random multiplier which you should use when writing random tests: multiply it by the number
|
||||
* of iterations to scale your tests (for nightly builds).
|
||||
*/
|
||||
public static final int RANDOM_MULTIPLIER =
|
||||
systemPropertyAsInt("tests.multiplier", TEST_NIGHTLY ? 2 : 1);
|
||||
|
||||
/** Leave temporary files on disk, even on successful runs. */
|
||||
public static final boolean LEAVE_TEMPORARY;
|
||||
|
||||
|
@ -873,7 +874,7 @@ public abstract class LuceneTestCase extends Assert {
|
|||
* {@link #RANDOM_MULTIPLIER}, but also with some random fudge.
|
||||
*/
|
||||
public static int atLeast(Random random, int i) {
|
||||
int min = (TEST_NIGHTLY ? 2 * i : i) * RANDOM_MULTIPLIER;
|
||||
int min = i * RANDOM_MULTIPLIER;
|
||||
int max = min + (min / 2);
|
||||
return TestUtil.nextInt(random, min, max);
|
||||
}
|
||||
|
@ -889,9 +890,9 @@ public abstract class LuceneTestCase extends Assert {
|
|||
* {@link #RANDOM_MULTIPLIER}.
|
||||
*/
|
||||
public static boolean rarely(Random random) {
|
||||
int p = TEST_NIGHTLY ? 10 : 1;
|
||||
int p = TEST_NIGHTLY ? 5 : 1;
|
||||
p += (p * Math.log(RANDOM_MULTIPLIER));
|
||||
int min = 100 - Math.min(p, 50); // never more than 50
|
||||
int min = 100 - Math.min(p, 20); // never more than 20
|
||||
return random.nextInt(100) >= min;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue