Fix more test to not fail when rarely() selects a maximum segment size

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1377397 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Uwe Schindler 2012-08-26 09:31:40 +00:00
parent 50f38aa1ab
commit ccd6a2ca54
7 changed files with 23 additions and 11 deletions

View File

@ -1106,10 +1106,11 @@ public class TestAddIndexes extends LuceneTestCase {
IndexReader[] readers = new IndexReader[] { DirectoryReader.open(dirs[0]), DirectoryReader.open(dirs[1]) };
Directory dir = new MockDirectoryWrapper(random(), new RAMDirectory());
IndexWriterConfig conf = new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).setMergePolicy(newLogMergePolicy());
IndexWriterConfig conf = new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).setMergePolicy(newLogMergePolicy(true));
LogMergePolicy lmp = (LogMergePolicy) conf.getMergePolicy();
lmp.setUseCompoundFile(true);
lmp.setNoCFSRatio(1.0); // Force creation of CFS
// Force creation of CFS:
lmp.setNoCFSRatio(1.0);
lmp.setMaxCFSSegmentSizeMB(Double.POSITIVE_INFINITY);
IndexWriter w3 = new IndexWriter(dir, conf);
w3.addIndexes(readers);
w3.close();

View File

@ -510,6 +510,7 @@ public class TestBackwardsCompatibility extends LuceneTestCase {
LogByteSizeMergePolicy mp = new LogByteSizeMergePolicy();
mp.setUseCompoundFile(doCFS);
mp.setNoCFSRatio(1.0);
mp.setMaxCFSSegmentSizeMB(Double.POSITIVE_INFINITY);
// TODO: remove randomness
IndexWriterConfig conf = new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()))
.setMaxBufferedDocs(10).setMergePolicy(mp);

View File

@ -45,7 +45,10 @@ public class TestIndexFileDeleter extends LuceneTestCase {
}
LogMergePolicy mergePolicy = newLogMergePolicy(true, 10);
mergePolicy.setNoCFSRatio(1); // This test expects all of its segments to be in CFS
// This test expects all of its segments to be in CFS
mergePolicy.setNoCFSRatio(1.0);
mergePolicy.setMaxCFSSegmentSizeMB(Double.POSITIVE_INFINITY);
IndexWriter writer = new IndexWriter(
dir,

View File

@ -1275,7 +1275,10 @@ public class TestIndexWriter extends LuceneTestCase {
Directory dir = newMockDirectory(); // relies on windows semantics
LogMergePolicy mergePolicy = newLogMergePolicy(true);
mergePolicy.setNoCFSRatio(1); // This test expects all of its segments to be in CFS
// This test expects all of its segments to be in CFS
mergePolicy.setNoCFSRatio(1.0);
mergePolicy.setMaxCFSSegmentSizeMB(Double.POSITIVE_INFINITY);
IndexWriter w = new IndexWriter(
dir,

View File

@ -331,15 +331,15 @@ public class TestIndexWriterConfig extends LuceneTestCase {
public void testLiveChangeToCFS() throws Exception {
Directory dir = newDirectory();
IndexWriterConfig iwc = new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
iwc.setMergePolicy(newLogMergePolicy());
iwc.setMergePolicy(newLogMergePolicy(true));
// Start false:
((LogMergePolicy) iwc.getMergePolicy()).setUseCompoundFile(false);
IndexWriter w = new IndexWriter(dir, iwc);
// Change to true:
((LogMergePolicy) w.getConfig().getMergePolicy()).setNoCFSRatio(1.0);
((LogMergePolicy) w.getConfig().getMergePolicy()).setUseCompoundFile(true);
LogMergePolicy lmp = ((LogMergePolicy) w.getConfig().getMergePolicy());
lmp.setNoCFSRatio(1.0);
lmp.setMaxCFSSegmentSizeMB(Double.POSITIVE_INFINITY);
Document doc = new Document();
doc.add(newStringField("field", "foo", Store.NO));

View File

@ -1134,7 +1134,10 @@ public class TestIndexWriterExceptions extends LuceneTestCase {
newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).
setMergePolicy(newLogMergePolicy(true))
);
((LogMergePolicy) writer.getConfig().getMergePolicy()).setNoCFSRatio(1.0);
LogMergePolicy lmp = (LogMergePolicy) writer.getConfig().getMergePolicy();
// Force creation of CFS:
lmp.setNoCFSRatio(1.0);
lmp.setMaxCFSSegmentSizeMB(Double.POSITIVE_INFINITY);
// add 100 documents
for (int i = 0; i < 100; i++) {

View File

@ -36,7 +36,8 @@ public class TestIndexSplitter extends LuceneTestCase {
Directory fsDir = newFSDirectory(dir);
LogMergePolicy mergePolicy = new LogByteSizeMergePolicy();
mergePolicy.setNoCFSRatio(1);
mergePolicy.setNoCFSRatio(1.0);
mergePolicy.setMaxCFSSegmentSizeMB(Double.POSITIVE_INFINITY);
IndexWriter iw = new IndexWriter(
fsDir,
new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).