mirror of https://github.com/apache/lucene.git
speed up tests to run faster locally
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1467436 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
dfd50b7438
commit
5032ea0010
|
@ -319,7 +319,7 @@ public class TestGraphTokenizers extends BaseTokenStreamTestCase {
|
|||
};
|
||||
|
||||
Random random = random();
|
||||
checkRandomData(random, a, 5, atLeast(1000));
|
||||
checkRandomData(random, a, 5, atLeast(100));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -344,7 +344,7 @@ public class TestGraphTokenizers extends BaseTokenStreamTestCase {
|
|||
};
|
||||
|
||||
Random random = random();
|
||||
checkRandomData(random, a, 5, atLeast(1000));
|
||||
checkRandomData(random, a, 5, atLeast(100));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -368,7 +368,7 @@ public class TestGraphTokenizers extends BaseTokenStreamTestCase {
|
|||
};
|
||||
|
||||
Random random = random();
|
||||
checkRandomData(random, a, 5, atLeast(1000));
|
||||
checkRandomData(random, a, 5, atLeast(100));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -392,7 +392,7 @@ public class TestGraphTokenizers extends BaseTokenStreamTestCase {
|
|||
};
|
||||
|
||||
Random random = random();
|
||||
checkRandomData(random, a, 5, atLeast(1000));
|
||||
checkRandomData(random, a, 5, atLeast(100));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,26 +44,27 @@ import org.apache.lucene.util.BytesRef;
|
|||
import org.apache.lucene.util.LuceneTestCase;
|
||||
import org.apache.lucene.util._TestUtil;
|
||||
import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
/** tests BooleanScorer2's minShouldMatch */
|
||||
@SuppressCodecs({"Lucene40", "Lucene41"})
|
||||
public class TestMinShouldMatch2 extends LuceneTestCase {
|
||||
Directory dir;
|
||||
DirectoryReader r;
|
||||
AtomicReader reader;
|
||||
IndexSearcher searcher;
|
||||
static Directory dir;
|
||||
static DirectoryReader r;
|
||||
static AtomicReader reader;
|
||||
static IndexSearcher searcher;
|
||||
|
||||
static final String alwaysTerms[] = { "a" };
|
||||
static final String commonTerms[] = { "b", "c", "d" };
|
||||
static final String mediumTerms[] = { "e", "f", "g" };
|
||||
static final String rareTerms[] = { "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" };
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
dir = newDirectory();
|
||||
RandomIndexWriter iw = new RandomIndexWriter(random(), dir);
|
||||
final int numDocs = 1000;
|
||||
final int numDocs = atLeast(300);
|
||||
for (int i = 0; i < numDocs; i++) {
|
||||
Document doc = new Document();
|
||||
|
||||
|
@ -93,14 +94,17 @@ public class TestMinShouldMatch2 extends LuceneTestCase {
|
|||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tearDown() throws Exception {
|
||||
@AfterClass
|
||||
public static void afterClass() throws Exception {
|
||||
reader.close();
|
||||
dir.close();
|
||||
super.tearDown();
|
||||
searcher = null;
|
||||
reader = null;
|
||||
r = null;
|
||||
dir = null;
|
||||
}
|
||||
|
||||
private void addSome(Document doc, String values[]) {
|
||||
private static void addSome(Document doc, String values[]) {
|
||||
List<String> list = Arrays.asList(values);
|
||||
Collections.shuffle(list, random());
|
||||
int howMany = _TestUtil.nextInt(random(), 1, list.size());
|
||||
|
|
|
@ -1136,7 +1136,7 @@ public abstract class BaseDocValuesFormatTestCase extends LuceneTestCase {
|
|||
doc.add(dvField);
|
||||
|
||||
// index some docs
|
||||
int numDocs = atLeast(1000);
|
||||
int numDocs = atLeast(300);
|
||||
for (int i = 0; i < numDocs; i++) {
|
||||
idField.setStringValue(Integer.toString(i));
|
||||
long value = _TestUtil.nextLong(random(), minValue, maxValue);
|
||||
|
@ -1218,7 +1218,7 @@ public abstract class BaseDocValuesFormatTestCase extends LuceneTestCase {
|
|||
doc.add(dvField);
|
||||
|
||||
// index some docs
|
||||
int numDocs = atLeast(1000);
|
||||
int numDocs = atLeast(300);
|
||||
for (int i = 0; i < numDocs; i++) {
|
||||
idField.setStringValue(Integer.toString(i));
|
||||
final int length;
|
||||
|
@ -1289,7 +1289,7 @@ public abstract class BaseDocValuesFormatTestCase extends LuceneTestCase {
|
|||
doc.add(dvField);
|
||||
|
||||
// index some docs
|
||||
int numDocs = atLeast(1000);
|
||||
int numDocs = atLeast(300);
|
||||
for (int i = 0; i < numDocs; i++) {
|
||||
idField.setStringValue(Integer.toString(i));
|
||||
final int length;
|
||||
|
@ -1801,7 +1801,7 @@ public abstract class BaseDocValuesFormatTestCase extends LuceneTestCase {
|
|||
RandomIndexWriter writer = new RandomIndexWriter(random(), dir, conf);
|
||||
|
||||
// index some docs
|
||||
int numDocs = atLeast(1000);
|
||||
int numDocs = atLeast(300);
|
||||
for (int i = 0; i < numDocs; i++) {
|
||||
Document doc = new Document();
|
||||
Field idField = new StringField("id", Integer.toString(i), Field.Store.NO);
|
||||
|
@ -1922,7 +1922,7 @@ public abstract class BaseDocValuesFormatTestCase extends LuceneTestCase {
|
|||
RandomIndexWriter writer = new RandomIndexWriter(random(), dir, conf);
|
||||
|
||||
// index some docs
|
||||
int numDocs = atLeast(1000);
|
||||
int numDocs = atLeast(300);
|
||||
for (int i = 0; i < numDocs; i++) {
|
||||
Document doc = new Document();
|
||||
Field idField = new StringField("id", Integer.toString(i), Field.Store.NO);
|
||||
|
|
|
@ -520,7 +520,7 @@ public abstract class BaseTermVectorsFormatTestCase extends LuceneTestCase {
|
|||
public void testRareVectors() throws IOException {
|
||||
final RandomDocumentFactory docFactory = new RandomDocumentFactory(10, 20);
|
||||
for (Options options : validOptions()) {
|
||||
final int numDocs = _TestUtil.nextInt(random(), 10, 10000);
|
||||
final int numDocs = atLeast(200);
|
||||
final int docWithVectors = random().nextInt(numDocs);
|
||||
final Document emptyDoc = new Document();
|
||||
final Directory dir = newDirectory();
|
||||
|
@ -560,7 +560,7 @@ public abstract class BaseTermVectorsFormatTestCase extends LuceneTestCase {
|
|||
}
|
||||
final Directory dir = newDirectory();
|
||||
final RandomIndexWriter writer = new RandomIndexWriter(random(), dir);
|
||||
final RandomDocument doc = docFactory.newDocument(_TestUtil.nextInt(random(), 1, 2), _TestUtil.nextInt(random(), 50000, 100000), options);
|
||||
final RandomDocument doc = docFactory.newDocument(_TestUtil.nextInt(random(), 1, 2), atLeast(20000), options);
|
||||
writer.addDocument(doc.toDocument());
|
||||
final IndexReader reader = writer.getReader();
|
||||
assertEquals(doc, reader.getTermVectors(0));
|
||||
|
@ -575,7 +575,7 @@ public abstract class BaseTermVectorsFormatTestCase extends LuceneTestCase {
|
|||
for (Options options : validOptions()) {
|
||||
final Directory dir = newDirectory();
|
||||
final RandomIndexWriter writer = new RandomIndexWriter(random(), dir);
|
||||
final RandomDocument doc = docFactory.newDocument(_TestUtil.nextInt(random(), 500, 1000), 5, options);
|
||||
final RandomDocument doc = docFactory.newDocument(atLeast(100), 5, options);
|
||||
writer.addDocument(doc.toDocument());
|
||||
final IndexReader reader = writer.getReader();
|
||||
assertEquals(doc, reader.getTermVectors(0));
|
||||
|
@ -614,7 +614,7 @@ public abstract class BaseTermVectorsFormatTestCase extends LuceneTestCase {
|
|||
|
||||
public void testRandom() throws IOException {
|
||||
final RandomDocumentFactory docFactory = new RandomDocumentFactory(5, 20);
|
||||
final int numDocs = _TestUtil.nextInt(random(), 100, 1000);
|
||||
final int numDocs = atLeast(100);
|
||||
final RandomDocument[] docs = new RandomDocument[numDocs];
|
||||
for (int i = 0; i < numDocs; ++i) {
|
||||
docs[i] = docFactory.newDocument(_TestUtil.nextInt(random(), 1, 3), _TestUtil.nextInt(random(), 10, 50), randomOptions());
|
||||
|
@ -636,7 +636,7 @@ public abstract class BaseTermVectorsFormatTestCase extends LuceneTestCase {
|
|||
|
||||
public void testMerge() throws IOException {
|
||||
final RandomDocumentFactory docFactory = new RandomDocumentFactory(5, 20);
|
||||
final int numDocs = _TestUtil.nextInt(random(), 100, 500);
|
||||
final int numDocs = atLeast(100);
|
||||
final int numDeletes = random().nextInt(numDocs);
|
||||
final Set<Integer> deletes = new HashSet<Integer>();
|
||||
while (deletes.size() < numDeletes) {
|
||||
|
@ -645,7 +645,7 @@ public abstract class BaseTermVectorsFormatTestCase extends LuceneTestCase {
|
|||
for (Options options : validOptions()) {
|
||||
final RandomDocument[] docs = new RandomDocument[numDocs];
|
||||
for (int i = 0; i < numDocs; ++i) {
|
||||
docs[i] = docFactory.newDocument(_TestUtil.nextInt(random(), 1, 3), _TestUtil.nextInt(random(), 10, 50), options);
|
||||
docs[i] = docFactory.newDocument(_TestUtil.nextInt(random(), 1, 3), atLeast(10), options);
|
||||
}
|
||||
final Directory dir = newDirectory();
|
||||
final RandomIndexWriter writer = new RandomIndexWriter(random(), dir);
|
||||
|
@ -677,11 +677,11 @@ public abstract class BaseTermVectorsFormatTestCase extends LuceneTestCase {
|
|||
// don't share mutable data
|
||||
public void testClone() throws IOException, InterruptedException {
|
||||
final RandomDocumentFactory docFactory = new RandomDocumentFactory(5, 20);
|
||||
final int numDocs = _TestUtil.nextInt(random(), 100, 1000);
|
||||
final int numDocs = atLeast(100);
|
||||
for (Options options : validOptions()) {
|
||||
final RandomDocument[] docs = new RandomDocument[numDocs];
|
||||
for (int i = 0; i < numDocs; ++i) {
|
||||
docs[i] = docFactory.newDocument(_TestUtil.nextInt(random(), 1, 3), _TestUtil.nextInt(random(), 10, 50), options);
|
||||
docs[i] = docFactory.newDocument(_TestUtil.nextInt(random(), 1, 3), atLeast(10), options);
|
||||
}
|
||||
final Directory dir = newDirectory();
|
||||
final RandomIndexWriter writer = new RandomIndexWriter(random(), dir);
|
||||
|
|
|
@ -625,7 +625,7 @@ public abstract class LuceneTestCase extends Assert {
|
|||
* is active and {@link #RANDOM_MULTIPLIER}.
|
||||
*/
|
||||
public static boolean rarely(Random random) {
|
||||
int p = TEST_NIGHTLY ? 10 : 5;
|
||||
int p = TEST_NIGHTLY ? 10 : 1;
|
||||
p += (p * Math.log(RANDOM_MULTIPLIER));
|
||||
int min = 100 - Math.min(p, 50); // never more than 50
|
||||
return random.nextInt(100) >= min;
|
||||
|
|
|
@ -189,7 +189,7 @@ final class TestRuleSetupAndRestoreClassEnv extends AbstractBeforeAfterRule {
|
|||
return super.toString() + ": " + format.toString() + ", " + dvFormat.toString();
|
||||
}
|
||||
};
|
||||
} else if ("SimpleText".equals(TEST_CODEC) || ("random".equals(TEST_CODEC) && randomVal == 9 && !shouldAvoidCodec("SimpleText"))) {
|
||||
} else if ("SimpleText".equals(TEST_CODEC) || ("random".equals(TEST_CODEC) && randomVal == 9 && LuceneTestCase.rarely(random) && !shouldAvoidCodec("SimpleText"))) {
|
||||
codec = new SimpleTextCodec();
|
||||
} else if ("CheapBastard".equals(TEST_CODEC) || ("random".equals(TEST_CODEC) && randomVal == 8 && !shouldAvoidCodec("CheapBastard") && !shouldAvoidCodec("Lucene41"))) {
|
||||
// we also avoid this codec if Lucene41 is avoided, since thats the postings format it uses.
|
||||
|
|
Loading…
Reference in New Issue