more test speedups

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1641982 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Muir 2014-11-27 01:22:53 +00:00
parent 7ae4a36a77
commit 608a726516
3 changed files with 19 additions and 56 deletions

View File

@ -61,7 +61,8 @@ import org.apache.lucene.util.automaton.RegExp;
* Tests partial enumeration (only pulling a subset of the indexed data) * Tests partial enumeration (only pulling a subset of the indexed data)
*/ */
public class TestBlockPostingsFormat3 extends LuceneTestCase { 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 // creates 8 fields with different options and does "duels" of fields against each other
public void test() throws Exception { public void test() throws Exception {

View File

@ -1122,8 +1122,8 @@ public class TestIndexWriter extends LuceneTestCase {
// init this class (in servicing a first interrupt): // init this class (in servicing a first interrupt):
assertTrue(new ThreadInterruptedException(new InterruptedException()).getCause() instanceof InterruptedException); assertTrue(new ThreadInterruptedException(new InterruptedException()).getCause() instanceof InterruptedException);
// issue 300 interrupts to child thread // issue 100 interrupts to child thread
final int numInterrupts = atLeast(300); final int numInterrupts = atLeast(100);
int i = 0; int i = 0;
while(i < numInterrupts) { while(i < numInterrupts) {
// TODO: would be nice to also sometimes interrupt the // 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"))); 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 { public void testIndexStoreCombos() throws Exception {
Directory dir = newDirectory(); Directory dir = newDirectory();

View File

@ -1897,11 +1897,19 @@ public class TestIndexWriterExceptions extends LuceneTestCase {
@Override @Override
public void eval(MockDirectoryWrapper dir) throws IOException { public void eval(MockDirectoryWrapper dir) throws IOException {
StackTraceElement[] trace = new Exception().getStackTrace();
if (shouldFail.get() == false) { 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; return;
} }
if (random().nextInt(3) != 2) {
return;
}
StackTraceElement[] trace = Thread.currentThread().getStackTrace();
boolean sawSeal = false; boolean sawSeal = false;
boolean sawWrite = false; boolean sawWrite = false;
for (int i = 0; i < trace.length; i++) { 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 // Don't throw exc if we are "flushing", else
// the segment is aborted and docs are lost: // the segment is aborted and docs are lost:
if (sawWrite && sawSeal == false && random().nextInt(3) == 2) { if (sawWrite && sawSeal == false) {
// Only sometimes throw the exc, so we get
// it sometimes on creating the file, on
// flushing buffer, on closing the file:
if (VERBOSE) { if (VERBOSE) {
System.out.println("TEST: now fail; thread=" + Thread.currentThread().getName() + " exc:"); System.out.println("TEST: now fail; thread=" + Thread.currentThread().getName() + " exc:");
new Throwable().printStackTrace(System.out); new Throwable().printStackTrace(System.out);
@ -2235,8 +2240,11 @@ public class TestIndexWriterExceptions extends LuceneTestCase {
@Override @Override
public void eval(MockDirectoryWrapper dir) throws IOException { public void eval(MockDirectoryWrapper dir) throws IOException {
if (random().nextInt(10) != 0) {
return;
}
boolean maybeFail = false; boolean maybeFail = false;
StackTraceElement[] trace = new Exception().getStackTrace(); StackTraceElement[] trace = Thread.currentThread().getStackTrace();
for (int i = 0; i < trace.length; i++) { for (int i = 0; i < trace.length; i++) {
if ("rollbackInternal".equals(trace[i].getMethodName())) { 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) { if (VERBOSE) {
System.out.println("TEST: now fail; thread=" + Thread.currentThread().getName() + " exc:"); System.out.println("TEST: now fail; thread=" + Thread.currentThread().getName() + " exc:");
new Throwable().printStackTrace(System.out); new Throwable().printStackTrace(System.out);