You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2014/05/01 18:50:16 UTC

svn commit: r1591708 - /lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions2.java

Author: rmuir
Date: Thu May  1 16:50:15 2014
New Revision: 1591708

URL: http://svn.apache.org/r1591708
Log:
LUCENE-5635: add some deletes and open reader from writer

Modified:
    lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions2.java

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions2.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions2.java?rev=1591708&r1=1591707&r2=1591708&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions2.java (original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions2.java Thu May  1 16:50:15 2014
@@ -31,6 +31,7 @@ import org.apache.lucene.document.Docume
 import org.apache.lucene.document.Field;
 import org.apache.lucene.document.NumericDocValuesField;
 import org.apache.lucene.store.Directory;
+import org.apache.lucene.util.IOUtils;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.util.TestUtil;
 import org.apache.lucene.util.Rethrow;
@@ -88,6 +89,10 @@ public class TestIndexWriterExceptions2 
         // TODO: sometimes update dv
         try {
           iw.addDocument(doc);
+          // we made it, sometimes delete our doc
+          if (random().nextInt(4) == 0) {
+            iw.deleteDocuments(new Term("id", Integer.toString(i)));
+          }
         } catch (Exception e) {
           if (e.getMessage() != null && e.getMessage().startsWith("Fake IOException")) {
             exceptionStream.println("\nTEST: got expected fake exc:" + e.getMessage());
@@ -97,9 +102,19 @@ public class TestIndexWriterExceptions2 
           }
         }
         if (random().nextInt(10) == 0) {
-          // trigger flush: TODO: sometimes reopen
+          // trigger flush:
           try {
-            iw.commit();
+            if (random().nextBoolean()) {
+              DirectoryReader ir = null;
+              try {
+                ir = DirectoryReader.open(iw, random().nextBoolean());
+                TestUtil.checkReader(ir);
+              } finally {
+                IOUtils.closeWhileHandlingException(ir);
+              }
+            } else {
+              iw.commit();
+            }
             if (DirectoryReader.indexExists(dir)) {
               TestUtil.checkIndex(dir);
             }
@@ -118,7 +133,7 @@ public class TestIndexWriterExceptions2 
         iw.shutdown();
       } catch (Exception e) {
         if (e.getMessage() != null && e.getMessage().startsWith("Fake IOException")) {
-          System.out.println("\nTEST: got expected fake exc:" + e.getMessage());
+          exceptionStream.println("\nTEST: got expected fake exc:" + e.getMessage());
           e.printStackTrace(exceptionStream);
           try {
             iw.rollback();