speedups for the slowest tests

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1674704 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2015-04-19 22:47:00 +00:00
parent ea83cc6678
commit 39da139934
4 changed files with 27 additions and 7 deletions

View File

@ -28,6 +28,7 @@ import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.IOUtils; import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.LineFileDocs; import org.apache.lucene.util.LineFileDocs;
import org.apache.lucene.util.LuceneTestCase; import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.lucene.util.TestUtil; import org.apache.lucene.util.TestUtil;
import java.io.IOException; import java.io.IOException;
@ -36,6 +37,7 @@ import java.util.Random;
/** /**
* Compares one codec against another * Compares one codec against another
*/ */
@Slow
public class TestDuelingCodecs extends LuceneTestCase { public class TestDuelingCodecs extends LuceneTestCase {
Directory leftDir; Directory leftDir;
IndexReader leftReader; IndexReader leftReader;

View File

@ -879,14 +879,25 @@ public class TestLRUQueryCache extends LuceneTestCase {
doc.add(f); doc.add(f);
w.addDocument(doc); w.addDocument(doc);
IndexReader reader = w.getReader(); IndexReader reader = w.getReader();
final int maxSize;
final long maxRamBytesUsed;
final int iters;
if (TEST_NIGHTLY) {
maxSize = TestUtil.nextInt(random(), 1, 10000);
maxRamBytesUsed = TestUtil.nextLong(random(), 1, 5000000);
iters = atLeast(20000);
} else {
maxSize = TestUtil.nextInt(random(), 1, 1000);
maxRamBytesUsed = TestUtil.nextLong(random(), 1, 500000);
iters = atLeast(2000);
}
final int maxSize = TestUtil.nextInt(random(), 1, 10000);
final long maxRamBytesUsed = TestUtil.nextLong(random(), 1, 5000000);
final LRUQueryCache queryCache = new LRUQueryCache(maxSize, maxRamBytesUsed); final LRUQueryCache queryCache = new LRUQueryCache(maxSize, maxRamBytesUsed);
IndexSearcher uncachedSearcher = null; IndexSearcher uncachedSearcher = null;
IndexSearcher cachedSearcher = null; IndexSearcher cachedSearcher = null;
final int iters = atLeast(20000);
for (int i = 0; i < iters; ++i) { for (int i = 0; i < iters; ++i) {
if (i == 0 || random().nextInt(100) == 1) { if (i == 0 || random().nextInt(100) == 1) {
reader.close(); reader.close();

View File

@ -37,6 +37,7 @@ import org.apache.lucene.store.Directory;
import org.apache.lucene.util.BitDocIdSet; import org.apache.lucene.util.BitDocIdSet;
import org.apache.lucene.util.Bits; import org.apache.lucene.util.Bits;
import org.apache.lucene.util.LuceneTestCase; import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.LuceneTestCase.SuppressCodecs;
import org.apache.lucene.util.TestUtil; import org.apache.lucene.util.TestUtil;
import org.apache.lucene.util.automaton.Automata; import org.apache.lucene.util.automaton.Automata;
import org.apache.lucene.util.automaton.CharacterRunAutomaton; import org.apache.lucene.util.automaton.CharacterRunAutomaton;
@ -50,6 +51,7 @@ import org.junit.BeforeClass;
* {@link #assertSameSet(Query, Query)} and * {@link #assertSameSet(Query, Query)} and
* {@link #assertSubsetOf(Query, Query)} * {@link #assertSubsetOf(Query, Query)}
*/ */
@SuppressCodecs("SimpleText")
public abstract class SearchEquivalenceTestBase extends LuceneTestCase { public abstract class SearchEquivalenceTestBase extends LuceneTestCase {
protected static IndexSearcher s1, s2; protected static IndexSearcher s1, s2;
protected static Directory directory; protected static Directory directory;
@ -72,7 +74,7 @@ public abstract class SearchEquivalenceTestBase extends LuceneTestCase {
doc.add(field); doc.add(field);
// index some docs // index some docs
int numDocs = atLeast(1000); int numDocs = TEST_NIGHTLY ? atLeast(1000) : atLeast(100);
for (int i = 0; i < numDocs; i++) { for (int i = 0; i < numDocs; i++) {
id.setStringValue(Integer.toString(i)); id.setStringValue(Integer.toString(i));
field.setStringValue(randomFieldContents()); field.setStringValue(randomFieldContents());
@ -244,7 +246,7 @@ public abstract class SearchEquivalenceTestBase extends LuceneTestCase {
assertSubsetOf(q1, q2, null); assertSubsetOf(q1, q2, null);
// test with some filters (this will sometimes cause advance'ing enough to test it) // test with some filters (this will sometimes cause advance'ing enough to test it)
int numFilters = atLeast(10); int numFilters = TEST_NIGHTLY ? atLeast(10) : atLeast(3);
for (int i = 0; i < numFilters; i++) { for (int i = 0; i < numFilters; i++) {
Filter filter = randomFilter(); Filter filter = randomFilter();
// incorporate the filter in different ways. // incorporate the filter in different ways.
@ -298,7 +300,7 @@ public abstract class SearchEquivalenceTestBase extends LuceneTestCase {
assertSameScores(q1, q2, null); assertSameScores(q1, q2, null);
// also test with some filters to test advancing // also test with some filters to test advancing
int numFilters = atLeast(10); int numFilters = TEST_NIGHTLY ? atLeast(10) : atLeast(3);
for (int i = 0; i < numFilters; i++) { for (int i = 0; i < numFilters; i++) {
Filter filter = randomFilter(); Filter filter = randomFilter();
// incorporate the filter in different ways. // incorporate the filter in different ways.

View File

@ -1057,7 +1057,12 @@ public abstract class BaseDirectoryTestCase extends LuceneTestCase {
public void testSliceOfSlice() throws Exception { public void testSliceOfSlice() throws Exception {
Directory dir = getDirectory(createTempDir("sliceOfSlice")); Directory dir = getDirectory(createTempDir("sliceOfSlice"));
IndexOutput output = dir.createOutput("bytes", newIOContext(random())); IndexOutput output = dir.createOutput("bytes", newIOContext(random()));
int num = TestUtil.nextInt(random(), 50, 2500); final int num;
if (TEST_NIGHTLY) {
num = TestUtil.nextInt(random(), 250, 2500);
} else {
num = TestUtil.nextInt(random(), 50, 250);
}
byte bytes[] = new byte[num]; byte bytes[] = new byte[num];
random().nextBytes(bytes); random().nextBytes(bytes);
for (int i = 0; i < bytes.length; i++) { for (int i = 0; i < bytes.length; i++) {