mirror of https://github.com/apache/lucene.git
speed up some tests
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1137529 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4d68c56a04
commit
3d7ebb0627
|
@ -114,7 +114,7 @@ public class RandomIndexWriter implements Closeable {
|
||||||
|
|
||||||
private void switchDoDocValues() {
|
private void switchDoDocValues() {
|
||||||
// randomly enable / disable docValues
|
// randomly enable / disable docValues
|
||||||
doDocValues = r.nextInt(10) != 0;
|
doDocValues = LuceneTestCase.rarely(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -148,23 +148,35 @@ public class QueryUtils {
|
||||||
// we can't put deleted docs before the nested reader, because
|
// we can't put deleted docs before the nested reader, because
|
||||||
// it will throw off the docIds
|
// it will throw off the docIds
|
||||||
IndexReader[] readers = new IndexReader[] {
|
IndexReader[] readers = new IndexReader[] {
|
||||||
edge < 0 ? r : IndexReader.open(makeEmptyIndex(random, 0), true),
|
edge < 0 ? r : emptyReaders[0],
|
||||||
IndexReader.open(makeEmptyIndex(random, 0), true),
|
emptyReaders[0],
|
||||||
new MultiReader(IndexReader.open(makeEmptyIndex(random, edge < 0 ? 4 : 0), true),
|
new MultiReader(edge < 0 ? emptyReaders[4] : emptyReaders[0],
|
||||||
IndexReader.open(makeEmptyIndex(random, 0), true),
|
emptyReaders[0],
|
||||||
0 == edge ? r : IndexReader.open(makeEmptyIndex(random, 0), true)),
|
0 == edge ? r : emptyReaders[0]),
|
||||||
IndexReader.open(makeEmptyIndex(random, 0 < edge ? 0 : 7), true),
|
0 < edge ? emptyReaders[0] : emptyReaders[7],
|
||||||
IndexReader.open(makeEmptyIndex(random, 0), true),
|
emptyReaders[0],
|
||||||
new MultiReader(IndexReader.open(makeEmptyIndex(random, 0 < edge ? 0 : 5), true),
|
new MultiReader(0 < edge ? emptyReaders[0] : emptyReaders[5],
|
||||||
IndexReader.open(makeEmptyIndex(random, 0), true),
|
emptyReaders[0],
|
||||||
0 < edge ? r : IndexReader.open(makeEmptyIndex(random, 0), true))
|
0 < edge ? r : emptyReaders[0])
|
||||||
};
|
};
|
||||||
IndexSearcher out = LuceneTestCase.newSearcher(new MultiReader(readers));
|
IndexSearcher out = LuceneTestCase.newSearcher(new MultiReader(readers));
|
||||||
out.setSimilarityProvider(s.getSimilarityProvider());
|
out.setSimilarityProvider(s.getSimilarityProvider());
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Directory makeEmptyIndex(Random random, final int numDeletedDocs)
|
static final IndexReader[] emptyReaders = new IndexReader[8];
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
emptyReaders[0] = makeEmptyIndex(new Random(0), 0);
|
||||||
|
emptyReaders[4] = makeEmptyIndex(new Random(0), 4);
|
||||||
|
emptyReaders[5] = makeEmptyIndex(new Random(0), 5);
|
||||||
|
emptyReaders[7] = makeEmptyIndex(new Random(0), 7);
|
||||||
|
} catch (IOException ex) {
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IndexReader makeEmptyIndex(Random random, final int numDeletedDocs)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
Directory d = new MockDirectoryWrapper(random, new RAMDirectory());
|
Directory d = new MockDirectoryWrapper(random, new RAMDirectory());
|
||||||
IndexWriter w = new IndexWriter(d, new IndexWriterConfig(
|
IndexWriter w = new IndexWriter(d, new IndexWriterConfig(
|
||||||
|
@ -188,8 +200,7 @@ public class QueryUtils {
|
||||||
IndexReader r = IndexReader.open(d, true);
|
IndexReader r = IndexReader.open(d, true);
|
||||||
Assert.assertEquals("reader has wrong number of deleted docs",
|
Assert.assertEquals("reader has wrong number of deleted docs",
|
||||||
numDeletedDocs, r.numDeletedDocs());
|
numDeletedDocs, r.numDeletedDocs());
|
||||||
r.close();
|
return r;
|
||||||
return d;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** alternate scorer skipTo(),skipTo(),next(),next(),skipTo(),skipTo(), etc
|
/** alternate scorer skipTo(),skipTo(),next(),next(),skipTo(),skipTo(), etc
|
||||||
|
|
|
@ -64,7 +64,7 @@ public class TestIndexWriterOnJRECrash extends TestNRTThreads {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// we are the fork, setup a crashing thread
|
// we are the fork, setup a crashing thread
|
||||||
final int crashTime = TEST_NIGHTLY ? _TestUtil.nextInt(random, 500, 4000) : _TestUtil.nextInt(random, 300, 1000);
|
final int crashTime = _TestUtil.nextInt(random, 3000, 4000);
|
||||||
Thread t = new Thread() {
|
Thread t = new Thread() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -93,6 +93,8 @@ public class TestIndexWriterOnJRECrash extends TestNRTThreads {
|
||||||
+ "java");
|
+ "java");
|
||||||
cmd.add("-Xmx512m");
|
cmd.add("-Xmx512m");
|
||||||
cmd.add("-Dtests.crashmode=true");
|
cmd.add("-Dtests.crashmode=true");
|
||||||
|
// passing NIGHTLY to this test makes it run for much longer, easier to catch it in the act...
|
||||||
|
cmd.add("-Dtests.nightly=true");
|
||||||
cmd.add("-DtempDir=" + tempDir.getPath());
|
cmd.add("-DtempDir=" + tempDir.getPath());
|
||||||
cmd.add("-Dtests.seed=" + random.nextLong() + ":" + random.nextLong());
|
cmd.add("-Dtests.seed=" + random.nextLong() + ":" + random.nextLong());
|
||||||
cmd.add("-ea");
|
cmd.add("-ea");
|
||||||
|
|
Loading…
Reference in New Issue