You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2015/08/26 00:16:14 UTC
svn commit: r1697777 - in /lucene/dev/branches/branch_5x: ./ lucene/
lucene/test-framework/
lucene/test-framework/src/java/org/apache/lucene/store/BaseLockFactoryTestCase.java
Author: mikemccand
Date: Tue Aug 25 22:16:14 2015
New Revision: 1697777
URL: http://svn.apache.org/r1697777
Log:
print IW infoStream on failure in this test
Modified:
lucene/dev/branches/branch_5x/ (props changed)
lucene/dev/branches/branch_5x/lucene/ (props changed)
lucene/dev/branches/branch_5x/lucene/test-framework/ (props changed)
lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/store/BaseLockFactoryTestCase.java
Modified: lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/store/BaseLockFactoryTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/store/BaseLockFactoryTestCase.java?rev=1697777&r1=1697776&r2=1697777&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/store/BaseLockFactoryTestCase.java (original)
+++ lucene/dev/branches/branch_5x/lucene/test-framework/src/java/org/apache/lucene/store/BaseLockFactoryTestCase.java Tue Aug 25 22:16:14 2015
@@ -17,7 +17,10 @@ package org.apache.lucene.store;
* limitations under the License.
*/
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.io.PrintStream;
+import java.io.UnsupportedEncodingException;
import java.nio.file.Path;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -30,13 +33,14 @@ import org.apache.lucene.document.Field;
import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.IndexWriter;
+import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.index.IndexWriterConfig;
import org.apache.lucene.index.Term;
-import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.PrintStreamInfoStream;
/** Base class for per-LockFactory tests. */
public abstract class BaseLockFactoryTestCase extends LuceneTestCase {
@@ -186,6 +190,16 @@ public abstract class BaseLockFactoryTes
this.numIteration = numIteration;
this.dir = dir;
}
+
+ private String toString(ByteArrayOutputStream baos) {
+ try {
+ return baos.toString("UTF8");
+ } catch (UnsupportedEncodingException uee) {
+ // shouldn't happen
+ throw new RuntimeException(uee);
+ }
+ }
+
@Override
public void run() {
IndexWriter writer = null;
@@ -193,8 +207,20 @@ public abstract class BaseLockFactoryTes
if (VERBOSE) {
System.out.println("TEST: WriterThread iter=" + i);
}
+
+ IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
+
+ // We only print the IW infoStream output on exc, below:
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try {
+ iwc.setInfoStream(new PrintStreamInfoStream(new PrintStream(baos, true, "UTF8")));
+ } catch (UnsupportedEncodingException uee) {
+ // shouldn't happen
+ throw new RuntimeException(uee);
+ }
+ iwc.setOpenMode(OpenMode.APPEND);
try {
- writer = new IndexWriter(dir, new IndexWriterConfig(new MockAnalyzer(random())).setOpenMode(OpenMode.APPEND));
+ writer = new IndexWriter(dir, iwc);
} catch (LockObtainFailedException e) {
// lock obtain timed out
// NOTE: we should at some point
@@ -206,6 +232,7 @@ public abstract class BaseLockFactoryTes
hitException = true;
System.out.println("Stress Test Index Writer: creation hit unexpected exception: " + e.toString());
e.printStackTrace(System.out);
+ System.out.println(toString(baos));
break;
}
if (writer != null) {
@@ -215,6 +242,7 @@ public abstract class BaseLockFactoryTes
hitException = true;
System.out.println("Stress Test Index Writer: addDoc hit unexpected exception: " + e.toString());
e.printStackTrace(System.out);
+ System.out.println(toString(baos));
break;
}
try {
@@ -223,6 +251,7 @@ public abstract class BaseLockFactoryTes
hitException = true;
System.out.println("Stress Test Index Writer: close hit unexpected exception: " + e.toString());
e.printStackTrace(System.out);
+ System.out.println(toString(baos));
break;
}
writer = null;
@@ -230,7 +259,7 @@ public abstract class BaseLockFactoryTes
}
}
}
-
+
private class SearcherThread extends Thread {
private Directory dir;
private int numIteration;