lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject lucene-solr git commit: LUCENE-6750: add verbosity when this test fails
Date Sun, 07 Feb 2016 18:35:13 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/master f8bd22e58 -> 1d4d9c588


LUCENE-6750: add verbosity when this test fails


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/1d4d9c58
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/1d4d9c58
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/1d4d9c58

Branch: refs/heads/master
Commit: 1d4d9c588ca433262feb79297262dca73e327f2e
Parents: f8bd22e
Author: Mike McCandless <mikemccand@apache.org>
Authored: Sun Feb 7 13:35:00 2016 -0500
Committer: Mike McCandless <mikemccand@apache.org>
Committed: Sun Feb 7 13:35:24 2016 -0500

----------------------------------------------------------------------
 .../lucene/TestMergeSchedulerExternal.java      | 39 ++++++++++++++------
 1 file changed, 27 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/1d4d9c58/lucene/core/src/test/org/apache/lucene/TestMergeSchedulerExternal.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/test/org/apache/lucene/TestMergeSchedulerExternal.java b/lucene/core/src/test/org/apache/lucene/TestMergeSchedulerExternal.java
index 241e966..d4aaeb1 100644
--- a/lucene/core/src/test/org/apache/lucene/TestMergeSchedulerExternal.java
+++ b/lucene/core/src/test/org/apache/lucene/TestMergeSchedulerExternal.java
@@ -17,6 +17,10 @@
 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.document.Document;
 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.IndexWriterConfig;
 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;
 import org.apache.lucene.index.MergeScheduler;
 import org.apache.lucene.index.MergeTrigger;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.MockDirectoryWrapper;
 import org.apache.lucene.store.RAMDirectory;
+import org.apache.lucene.util.IOUtils;
 import org.apache.lucene.util.LuceneTestCase;
-
-import java.io.IOException;
+import org.apache.lucene.util.PrintStreamInfoStream;
 
 /**
  * Holds tests cases to verify external APIs are accessible
@@ -93,11 +97,16 @@ public class TestMergeSchedulerExternal extends LuceneTestCase {
     Document doc = new Document();
     Field idField = newStringField("id", "", Field.Store.YES);
     doc.add(idField);
-    
-    IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(new MockAnalyzer(random()))
-        .setMergeScheduler(new MyMergeScheduler())
-        .setMaxBufferedDocs(2).setRAMBufferSizeMB(IndexWriterConfig.DISABLE_AUTO_FLUSH)
-        .setMergePolicy(newLogMergePolicy()));
+
+    IndexWriterConfig iwc = newIndexWriterConfig(new MockAnalyzer(random()))
+      .setMergeScheduler(new MyMergeScheduler())
+      .setMaxBufferedDocs(2).setRAMBufferSizeMB(IndexWriterConfig.DISABLE_AUTO_FLUSH)
+      .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();
     logMP.setMergeFactor(10);
     for(int i=0;i<20;i++) {
@@ -110,10 +119,16 @@ public class TestMergeSchedulerExternal extends LuceneTestCase {
       // OK
     }
     writer.rollback();
-    
-    assertTrue(mergeThreadCreated);
-    assertTrue(mergeCalled);
-    assertTrue(excCalled);
+
+    try {
+      assertTrue(mergeThreadCreated);
+      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();
   }
   


Mime
View raw message