mirror of https://github.com/apache/lucene.git
LUCENE-5649: if this test gets MockRandomMP, it must disable reader-wrapping because it fails on any non-bulk merges
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1592843 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
090b804efc
commit
b234e9748f
|
@ -32,12 +32,21 @@ import org.apache.lucene.util.TestUtil;
|
|||
*/
|
||||
public class MockRandomMergePolicy extends MergePolicy {
|
||||
private final Random random;
|
||||
boolean doNonBulkMerges = true;
|
||||
|
||||
public MockRandomMergePolicy(Random random) {
|
||||
// fork a private random, since we are called
|
||||
// unpredictably from threads:
|
||||
this.random = new Random(random.nextLong());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set to true if sometimes readers to be merged should be wrapped in a FilterReader
|
||||
* to mixup bulk merging.
|
||||
*/
|
||||
public void setDoNonBulkMerges(boolean v) {
|
||||
doNonBulkMerges = v;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MergeSpecification findMerges(MergeTrigger mergeTrigger, SegmentInfos segmentInfos) {
|
||||
|
@ -64,7 +73,11 @@ public class MockRandomMergePolicy extends MergePolicy {
|
|||
// TODO: sometimes make more than 1 merge?
|
||||
mergeSpec = new MergeSpecification();
|
||||
final int segsToMerge = TestUtil.nextInt(random, 1, numSegments);
|
||||
mergeSpec.add(new MockRandomOneMerge(segments.subList(0, segsToMerge),random.nextLong()));
|
||||
if (doNonBulkMerges) {
|
||||
mergeSpec.add(new MockRandomOneMerge(segments.subList(0, segsToMerge),random.nextLong()));
|
||||
} else {
|
||||
mergeSpec.add(new OneMerge(segments.subList(0, segsToMerge)));
|
||||
}
|
||||
}
|
||||
|
||||
return mergeSpec;
|
||||
|
@ -93,7 +106,11 @@ public class MockRandomMergePolicy extends MergePolicy {
|
|||
while(upto < eligibleSegments.size()) {
|
||||
int max = Math.min(10, eligibleSegments.size()-upto);
|
||||
int inc = max <= 2 ? max : TestUtil.nextInt(random, 2, max);
|
||||
mergeSpec.add(new MockRandomOneMerge(eligibleSegments.subList(upto, upto+inc), random.nextLong()));
|
||||
if (doNonBulkMerges) {
|
||||
mergeSpec.add(new MockRandomOneMerge(eligibleSegments.subList(upto, upto+inc), random.nextLong()));
|
||||
} else {
|
||||
mergeSpec.add(new OneMerge(eligibleSegments.subList(upto, upto+inc)));
|
||||
}
|
||||
upto += inc;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -442,8 +442,11 @@ public abstract class ThreadedIndexingAndSearchingTestCase extends LuceneTestCas
|
|||
}
|
||||
MockAnalyzer analyzer = new MockAnalyzer(random());
|
||||
analyzer.setMaxTokenLength(TestUtil.nextInt(random(), 1, IndexWriter.MAX_TERM_LENGTH));
|
||||
final IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT,
|
||||
analyzer).setInfoStream(new FailOnNonBulkMergesInfoStream());
|
||||
final IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
|
||||
conf.setInfoStream(new FailOnNonBulkMergesInfoStream());
|
||||
if (conf.getMergePolicy() instanceof MockRandomMergePolicy) {
|
||||
((MockRandomMergePolicy)conf.getMergePolicy()).setDoNonBulkMerges(false);
|
||||
}
|
||||
|
||||
if (LuceneTestCase.TEST_NIGHTLY) {
|
||||
// newIWConfig makes smallish max seg size, which
|
||||
|
|
Loading…
Reference in New Issue