mirror of https://github.com/apache/lucene.git
yet more verbosity for this test that only fails rarely on OS X
This commit is contained in:
parent
fc879d1a5d
commit
2018122bcf
|
@ -20,6 +20,8 @@ package org.apache.lucene;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
import java.io.StringWriter;
|
||||||
|
|
||||||
import org.apache.lucene.analysis.MockAnalyzer;
|
import org.apache.lucene.analysis.MockAnalyzer;
|
||||||
import org.apache.lucene.document.Document;
|
import org.apache.lucene.document.Document;
|
||||||
|
@ -36,6 +38,7 @@ 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.IOUtils;
|
||||||
|
import org.apache.lucene.util.InfoStream;
|
||||||
import org.apache.lucene.util.LuceneTestCase;
|
import org.apache.lucene.util.LuceneTestCase;
|
||||||
import org.apache.lucene.util.PrintStreamInfoStream;
|
import org.apache.lucene.util.PrintStreamInfoStream;
|
||||||
|
|
||||||
|
@ -48,6 +51,7 @@ public class TestMergeSchedulerExternal extends LuceneTestCase {
|
||||||
volatile boolean mergeCalled;
|
volatile boolean mergeCalled;
|
||||||
volatile boolean mergeThreadCreated;
|
volatile boolean mergeThreadCreated;
|
||||||
volatile boolean excCalled;
|
volatile boolean excCalled;
|
||||||
|
volatile static InfoStream infoStream;
|
||||||
|
|
||||||
private class MyMergeScheduler extends ConcurrentMergeScheduler {
|
private class MyMergeScheduler extends ConcurrentMergeScheduler {
|
||||||
|
|
||||||
|
@ -84,7 +88,14 @@ public class TestMergeSchedulerExternal extends LuceneTestCase {
|
||||||
StackTraceElement[] trace = new Exception().getStackTrace();
|
StackTraceElement[] trace = new Exception().getStackTrace();
|
||||||
for (int i = 0; i < trace.length; i++) {
|
for (int i = 0; i < trace.length; i++) {
|
||||||
if ("doMerge".equals(trace[i].getMethodName())) {
|
if ("doMerge".equals(trace[i].getMethodName())) {
|
||||||
throw new IOException("now failing during merge");
|
IOException ioe = new IOException("now failing during merge");
|
||||||
|
StringWriter sw = new StringWriter();
|
||||||
|
PrintWriter pw = new PrintWriter(sw);
|
||||||
|
ioe.printStackTrace(pw);
|
||||||
|
if (infoStream.isEnabled("IW")) {
|
||||||
|
infoStream.message("IW", "TEST: now throw exc:\n" + sw.toString());
|
||||||
|
}
|
||||||
|
throw ioe;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,7 +115,8 @@ public class TestMergeSchedulerExternal extends LuceneTestCase {
|
||||||
.setMergePolicy(newLogMergePolicy());
|
.setMergePolicy(newLogMergePolicy());
|
||||||
|
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
iwc.setInfoStream(new PrintStreamInfoStream(new PrintStream(baos, true, IOUtils.UTF_8)));
|
infoStream = new PrintStreamInfoStream(new PrintStream(baos, true, IOUtils.UTF_8));
|
||||||
|
iwc.setInfoStream(infoStream);
|
||||||
|
|
||||||
IndexWriter writer = new IndexWriter(dir, iwc);
|
IndexWriter writer = new IndexWriter(dir, iwc);
|
||||||
LogMergePolicy logMP = (LogMergePolicy) writer.getConfig().getMergePolicy();
|
LogMergePolicy logMP = (LogMergePolicy) writer.getConfig().getMergePolicy();
|
||||||
|
|
Loading…
Reference in New Issue