Skip to content

Apache Lucene open-source search software

more test speedups

Robert Muir608a726516d3
diff --git a/lucene/core/src/test/org/apache/lucene/codecs/lucene50/TestBlockPostingsFormat3.java b/lucene/core/src/test/org/apache/lucene/codecs/lucene50/TestBlockPostingsFormat3.java
index fb058036c28..fbb405563af 100644
--- a/lucene/core/src/test/org/apache/lucene/codecs/lucene50/TestBlockPostingsFormat3.java
+++ b/lucene/core/src/test/org/apache/lucene/codecs/lucene50/TestBlockPostingsFormat3.java
@@ -61,7 +61,8 @@ import org.apache.lucene.util.automaton.RegExp;
* 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 {
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java
index fee4280b1f5..21ceeaaa90e 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java
@@ -1122,8 +1122,8 @@ public class TestIndexWriter extends LuceneTestCase {
// 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
@@ -1143,52 +1143,6 @@ public class TestIndexWriter extends LuceneTestCase {
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();
diff --git a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java
index 49ef73beb30..950fabb10ac 100644
--- a/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java
+++ b/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterExceptions.java
@@ -1897,11 +1897,19 @@ public class TestIndexWriterExceptions extends LuceneTestCase {
@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++) {
@@ -1916,10 +1924,7 @@ public class TestIndexWriterExceptions extends LuceneTestCase {
// 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);
@@ -2235,8 +2240,11 @@ public class TestIndexWriterExceptions extends LuceneTestCase {
@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())) {
@@ -2245,7 +2253,7 @@ public class TestIndexWriterExceptions extends LuceneTestCase {
}
}
- 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);