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/11/27 02:23:32 UTC

svn commit: r1641983 - in /lucene/dev/branches/branch_5x: ./ lucene/ lucene/core/ lucene/core/src/test/org/apache/lucene/codecs/lucene50/ lucene/core/src/test/org/apache/lucene/index/

Author: rmuir
Date: Thu Nov 27 01:23:32 2014
New Revision: 1641983

URL: http://svn.apache.org/r1641983
Log:
more test speedups

Modified:
    lucene/dev/branches/branch_5x/   (props changed)
    lucene/dev/branches/branch_5x/lucene/   (props changed)
    lucene/dev/branches/branch_5x/lucene/core/   (props changed)
    lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/codecs/lucene50/TestBlockPostingsFormat3.java
    lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java
    lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java

Modified: lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/codecs/lucene50/TestBlockPostingsFormat3.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/codecs/lucene50/TestBlockPostingsFormat3.java?rev=1641983&r1=1641982&r2=1641983&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/codecs/lucene50/TestBlockPostingsFormat3.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/codecs/lucene50/TestBlockPostingsFormat3.java Thu Nov 27 01:23:32 2014
@@ -61,7 +61,8 @@ import org.apache.lucene.util.automaton.
  * Tests partial enumeration (only pulling a subset of the indexed data) 
  */
 public class TestBlockPostingsFormat3 extends LuceneTestCase {
-  static final int MAXDOC = Lucene50PostingsFormat.BLOCK_SIZE * 20;
+  private final int MAXDOC = TEST_NIGHTLY ? Lucene50PostingsFormat.BLOCK_SIZE * 20 
+                                          : Lucene50PostingsFormat.BLOCK_SIZE * 3;
   
   // creates 8 fields with different options and does "duels" of fields against each other
   public void test() throws Exception {

Modified: lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java?rev=1641983&r1=1641982&r2=1641983&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java Thu Nov 27 01:23:32 2014
@@ -1121,8 +1121,8 @@ public class TestIndexWriter extends Luc
     // init this class (in servicing a first interrupt):
     assertTrue(new ThreadInterruptedException(new InterruptedException()).getCause() instanceof InterruptedException);
 
-    // issue 300 interrupts to child thread
-    final int numInterrupts = atLeast(300);
+    // issue 100 interrupts to child thread
+    final int numInterrupts = atLeast(100);
     int i = 0;
     while(i < numInterrupts) {
       // TODO: would be nice to also sometimes interrupt the
@@ -1142,52 +1142,6 @@ public class TestIndexWriter extends Luc
       fail(new String(t.bytesLog.toString("UTF-8")));
     }
   }
-  
-  /** testThreadInterruptDeadlock but with 2 indexer threads */
-  public void testTwoThreadsInterruptDeadlock() throws Exception {
-    IndexerThreadInterrupt t1 = new IndexerThreadInterrupt(1);
-    t1.setDaemon(true);
-    t1.start();
-    
-    IndexerThreadInterrupt t2 = new IndexerThreadInterrupt(2);
-    t2.setDaemon(true);
-    t2.start();
-
-    // Force class loader to load ThreadInterruptedException
-    // up front... else we can see a false failure if 2nd
-    // interrupt arrives while class loader is trying to
-    // init this class (in servicing a first interrupt):
-    assertTrue(new ThreadInterruptedException(new InterruptedException()).getCause() instanceof InterruptedException);
-
-    // issue 300 interrupts to child thread
-    final int numInterrupts = atLeast(300);
-    int i = 0;
-    while(i < numInterrupts) {
-      // TODO: would be nice to also sometimes interrupt the
-      // CMS merge threads too ...
-      Thread.sleep(10);
-      IndexerThreadInterrupt t = random().nextBoolean() ? t1 : t2;
-      if (t.allowInterrupt) {
-        i++;
-        t.interrupt();
-      }
-      if (!t1.isAlive() && !t2.isAlive()) {
-        break;
-      }
-    }
-    t1.finish = true;
-    t2.finish = true;
-    t1.join();
-    t2.join();
-    if (t1.failed) {
-      System.out.println("Thread1 failed:\n" + new String(t1.bytesLog.toString("UTF-8")));
-    }
-    if (t2.failed) {
-      System.out.println("Thread2 failed:\n" + new String(t2.bytesLog.toString("UTF-8")));
-    }
-    assertFalse(t1.failed || t2.failed);
-  }
-
 
   public void testIndexStoreCombos() throws Exception {
     Directory dir = newDirectory();

Modified: lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java?rev=1641983&r1=1641982&r2=1641983&view=diff
==============================================================================
--- lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java (original)
+++ lucene/dev/branches/branch_5x/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java Thu Nov 27 01:23:32 2014
@@ -1902,11 +1902,19 @@ public class TestIndexWriterExceptions e
       
       @Override
       public void eval(MockDirectoryWrapper dir) throws IOException {
-        StackTraceElement[] trace = new Exception().getStackTrace();
         if (shouldFail.get() == false) {
+          // Only sometimes throw the exc, so we get
+          // it sometimes on creating the file, on
+          // flushing buffer, on closing the file:
           return;
         }
         
+        if (random().nextInt(3) != 2) {
+          return;
+        }
+
+        StackTraceElement[] trace = Thread.currentThread().getStackTrace();
+
         boolean sawSeal = false;
         boolean sawWrite = false;
         for (int i = 0; i < trace.length; i++) {
@@ -1921,10 +1929,7 @@ public class TestIndexWriterExceptions e
         
         // Don't throw exc if we are "flushing", else
         // the segment is aborted and docs are lost:
-        if (sawWrite && sawSeal == false && random().nextInt(3) == 2) {
-          // Only sometimes throw the exc, so we get
-          // it sometimes on creating the file, on
-          // flushing buffer, on closing the file:
+        if (sawWrite && sawSeal == false) {
           if (VERBOSE) {
             System.out.println("TEST: now fail; thread=" + Thread.currentThread().getName() + " exc:");
             new Throwable().printStackTrace(System.out);
@@ -2240,8 +2245,11 @@ public class TestIndexWriterExceptions e
         
         @Override
         public void eval(MockDirectoryWrapper dir) throws IOException {
+          if (random().nextInt(10) != 0) {
+            return;
+          }
           boolean maybeFail = false;
-          StackTraceElement[] trace = new Exception().getStackTrace();
+          StackTraceElement[] trace = Thread.currentThread().getStackTrace();
           
           for (int i = 0; i < trace.length; i++) {
             if ("rollbackInternal".equals(trace[i].getMethodName())) {
@@ -2250,7 +2258,7 @@ public class TestIndexWriterExceptions e
             }
           }
           
-          if (maybeFail && random().nextInt(10) == 0) {
+          if (maybeFail) {
             if (VERBOSE) {
               System.out.println("TEST: now fail; thread=" + Thread.currentThread().getName() + " exc:");
               new Throwable().printStackTrace(System.out);