test-only fixes: MockRandomCodec sometimes never picked an index term; TestNRTThreads creates way too many segments

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1125711 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Michael McCandless 2011-05-21 14:21:31 +00:00
parent 91c74bb6e7
commit dbf5ab4af2
2 changed files with 16 additions and 1 deletions

View File

@ -196,7 +196,7 @@ public class MockRandomCodec extends Codec {
@Override
public boolean isIndexTerm(BytesRef term, TermStats stats) {
return rand.nextInt(gap) == 17;
return rand.nextInt(gap) == gap/2;
}
@Override

View File

@ -71,6 +71,21 @@ public class TestNRTThreads extends LuceneTestCase {
final File tempDir = _TestUtil.getTempDir("nrtopenfiles");
final MockDirectoryWrapper dir = new MockDirectoryWrapper(random, FSDirectory.open(tempDir));
final IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random));
if (LuceneTestCase.TEST_NIGHTLY) {
// newIWConfig makes smallish max seg size, which
// results in tons and tons of segments for this test
// when run nightly:
MergePolicy mp = conf.getMergePolicy();
if (mp instanceof TieredMergePolicy) {
((TieredMergePolicy) mp).setMaxMergedSegmentMB(5000.);
} else if (mp instanceof LogByteSizeMergePolicy) {
((LogByteSizeMergePolicy) mp).setMaxMergeMB(1000.);
} else if (mp instanceof LogMergePolicy) {
((LogMergePolicy) mp).setMaxMergeDocs(100000);
}
}
conf.setMergedSegmentWarmer(new IndexWriter.IndexReaderWarmer() {
@Override
public void warm(IndexReader reader) throws IOException {