mirror of https://github.com/apache/lucene.git
LUCENE-6750: add verbosity when this test fails
This commit is contained in:
parent
f8bd22e58c
commit
1d4d9c588c
|
@ -17,6 +17,10 @@
|
||||||
package org.apache.lucene;
|
package org.apache.lucene;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.PrintStream;
|
||||||
|
|
||||||
import org.apache.lucene.analysis.MockAnalyzer;
|
import org.apache.lucene.analysis.MockAnalyzer;
|
||||||
import org.apache.lucene.document.Document;
|
import org.apache.lucene.document.Document;
|
||||||
import org.apache.lucene.document.Field;
|
import org.apache.lucene.document.Field;
|
||||||
|
@ -24,16 +28,16 @@ import org.apache.lucene.index.ConcurrentMergeScheduler;
|
||||||
import org.apache.lucene.index.IndexWriter;
|
import org.apache.lucene.index.IndexWriter;
|
||||||
import org.apache.lucene.index.IndexWriterConfig;
|
import org.apache.lucene.index.IndexWriterConfig;
|
||||||
import org.apache.lucene.index.LogMergePolicy;
|
import org.apache.lucene.index.LogMergePolicy;
|
||||||
import org.apache.lucene.index.MergePolicy;
|
|
||||||
import org.apache.lucene.index.MergePolicy.OneMerge;
|
import org.apache.lucene.index.MergePolicy.OneMerge;
|
||||||
|
import org.apache.lucene.index.MergePolicy;
|
||||||
import org.apache.lucene.index.MergeScheduler;
|
import org.apache.lucene.index.MergeScheduler;
|
||||||
import org.apache.lucene.index.MergeTrigger;
|
import org.apache.lucene.index.MergeTrigger;
|
||||||
import org.apache.lucene.store.Directory;
|
import org.apache.lucene.store.Directory;
|
||||||
import org.apache.lucene.store.MockDirectoryWrapper;
|
import org.apache.lucene.store.MockDirectoryWrapper;
|
||||||
import org.apache.lucene.store.RAMDirectory;
|
import org.apache.lucene.store.RAMDirectory;
|
||||||
|
import org.apache.lucene.util.IOUtils;
|
||||||
import org.apache.lucene.util.LuceneTestCase;
|
import org.apache.lucene.util.LuceneTestCase;
|
||||||
|
import org.apache.lucene.util.PrintStreamInfoStream;
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds tests cases to verify external APIs are accessible
|
* Holds tests cases to verify external APIs are accessible
|
||||||
|
@ -93,11 +97,16 @@ public class TestMergeSchedulerExternal extends LuceneTestCase {
|
||||||
Document doc = new Document();
|
Document doc = new Document();
|
||||||
Field idField = newStringField("id", "", Field.Store.YES);
|
Field idField = newStringField("id", "", Field.Store.YES);
|
||||||
doc.add(idField);
|
doc.add(idField);
|
||||||
|
|
||||||
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(new MockAnalyzer(random()))
|
IndexWriterConfig iwc = newIndexWriterConfig(new MockAnalyzer(random()))
|
||||||
.setMergeScheduler(new MyMergeScheduler())
|
.setMergeScheduler(new MyMergeScheduler())
|
||||||
.setMaxBufferedDocs(2).setRAMBufferSizeMB(IndexWriterConfig.DISABLE_AUTO_FLUSH)
|
.setMaxBufferedDocs(2).setRAMBufferSizeMB(IndexWriterConfig.DISABLE_AUTO_FLUSH)
|
||||||
.setMergePolicy(newLogMergePolicy()));
|
.setMergePolicy(newLogMergePolicy());
|
||||||
|
|
||||||
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
iwc.setInfoStream(new PrintStreamInfoStream(new PrintStream(baos, true, IOUtils.UTF_8)));
|
||||||
|
|
||||||
|
IndexWriter writer = new IndexWriter(dir, iwc);
|
||||||
LogMergePolicy logMP = (LogMergePolicy) writer.getConfig().getMergePolicy();
|
LogMergePolicy logMP = (LogMergePolicy) writer.getConfig().getMergePolicy();
|
||||||
logMP.setMergeFactor(10);
|
logMP.setMergeFactor(10);
|
||||||
for(int i=0;i<20;i++) {
|
for(int i=0;i<20;i++) {
|
||||||
|
@ -110,10 +119,16 @@ public class TestMergeSchedulerExternal extends LuceneTestCase {
|
||||||
// OK
|
// OK
|
||||||
}
|
}
|
||||||
writer.rollback();
|
writer.rollback();
|
||||||
|
|
||||||
assertTrue(mergeThreadCreated);
|
try {
|
||||||
assertTrue(mergeCalled);
|
assertTrue(mergeThreadCreated);
|
||||||
assertTrue(excCalled);
|
assertTrue(mergeCalled);
|
||||||
|
assertTrue(excCalled);
|
||||||
|
} catch (AssertionError ae) {
|
||||||
|
System.out.println("TEST FAILED; IW infoStream output:");
|
||||||
|
System.out.println(baos.toString(IOUtils.UTF_8));
|
||||||
|
throw ae;
|
||||||
|
}
|
||||||
dir.close();
|
dir.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue