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() {
|
||||
// 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
|
||||
// it will throw off the docIds
|
||||
IndexReader[] readers = new IndexReader[] {
|
||||
edge < 0 ? r : IndexReader.open(makeEmptyIndex(random, 0), true),
|
||||
IndexReader.open(makeEmptyIndex(random, 0), true),
|
||||
new MultiReader(IndexReader.open(makeEmptyIndex(random, edge < 0 ? 4 : 0), true),
|
||||
IndexReader.open(makeEmptyIndex(random, 0), true),
|
||||
0 == edge ? r : IndexReader.open(makeEmptyIndex(random, 0), true)),
|
||||
IndexReader.open(makeEmptyIndex(random, 0 < edge ? 0 : 7), true),
|
||||
IndexReader.open(makeEmptyIndex(random, 0), true),
|
||||
new MultiReader(IndexReader.open(makeEmptyIndex(random, 0 < edge ? 0 : 5), true),
|
||||
IndexReader.open(makeEmptyIndex(random, 0), true),
|
||||
0 < edge ? r : IndexReader.open(makeEmptyIndex(random, 0), true))
|
||||
edge < 0 ? r : emptyReaders[0],
|
||||
emptyReaders[0],
|
||||
new MultiReader(edge < 0 ? emptyReaders[4] : emptyReaders[0],
|
||||
emptyReaders[0],
|
||||
0 == edge ? r : emptyReaders[0]),
|
||||
0 < edge ? emptyReaders[0] : emptyReaders[7],
|
||||
emptyReaders[0],
|
||||
new MultiReader(0 < edge ? emptyReaders[0] : emptyReaders[5],
|
||||
emptyReaders[0],
|
||||
0 < edge ? r : emptyReaders[0])
|
||||
};
|
||||
IndexSearcher out = LuceneTestCase.newSearcher(new MultiReader(readers));
|
||||
out.setSimilarityProvider(s.getSimilarityProvider());
|
||||
return out;
|
||||
}
|
||||
|
||||
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 Directory makeEmptyIndex(Random random, final int numDeletedDocs)
|
||||
private static IndexReader makeEmptyIndex(Random random, final int numDeletedDocs)
|
||||
throws IOException {
|
||||
Directory d = new MockDirectoryWrapper(random, new RAMDirectory());
|
||||
IndexWriter w = new IndexWriter(d, new IndexWriterConfig(
|
||||
|
@ -188,8 +200,7 @@ public class QueryUtils {
|
|||
IndexReader r = IndexReader.open(d, true);
|
||||
Assert.assertEquals("reader has wrong number of deleted docs",
|
||||
numDeletedDocs, r.numDeletedDocs());
|
||||
r.close();
|
||||
return d;
|
||||
return r;
|
||||
}
|
||||
|
||||
/** alternate scorer skipTo(),skipTo(),next(),next(),skipTo(),skipTo(), etc
|
||||
|
|
|
@ -64,7 +64,7 @@ public class TestIndexWriterOnJRECrash extends TestNRTThreads {
|
|||
}
|
||||
} else {
|
||||
// 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() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -93,6 +93,8 @@ public class TestIndexWriterOnJRECrash extends TestNRTThreads {
|
|||
+ "java");
|
||||
cmd.add("-Xmx512m");
|
||||
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("-Dtests.seed=" + random.nextLong() + ":" + random.nextLong());
|
||||
cmd.add("-ea");
|
||||
|
|
Loading…
Reference in New Issue