Keep track of the exceptions instead of just flagging that an exception has occured.
This commit is contained in:
parent
c841aa296a
commit
d05b4ef769
|
@ -83,7 +83,7 @@ public class ConcurrentPercolatorTests extends ElasticsearchIntegrationTest {
|
||||||
final CountDownLatch start = new CountDownLatch(1);
|
final CountDownLatch start = new CountDownLatch(1);
|
||||||
final AtomicBoolean stop = new AtomicBoolean(false);
|
final AtomicBoolean stop = new AtomicBoolean(false);
|
||||||
final AtomicInteger counts = new AtomicInteger(0);
|
final AtomicInteger counts = new AtomicInteger(0);
|
||||||
final AtomicBoolean assertionFailure = new AtomicBoolean(false);
|
final AtomicReference<Throwable> exceptionHolder = new AtomicReference<Throwable>();
|
||||||
Thread[] threads = new Thread[5];
|
Thread[] threads = new Thread[5];
|
||||||
|
|
||||||
for (int i = 0; i < threads.length; i++) {
|
for (int i = 0; i < threads.length; i++) {
|
||||||
|
@ -118,11 +118,10 @@ public class ConcurrentPercolatorTests extends ElasticsearchIntegrationTest {
|
||||||
assertThat(convertFromTextArray(percolate.getMatches(), "index"), arrayContaining("test2"));
|
assertThat(convertFromTextArray(percolate.getMatches(), "index"), arrayContaining("test2"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
} catch (AssertionError e) {
|
} catch (Throwable e) {
|
||||||
assertionFailure.set(true);
|
exceptionHolder.set(e);
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,7 +135,11 @@ public class ConcurrentPercolatorTests extends ElasticsearchIntegrationTest {
|
||||||
thread.join();
|
thread.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
assertThat(assertionFailure.get(), equalTo(false));
|
Throwable assertionError = exceptionHolder.get();
|
||||||
|
if (assertionError != null) {
|
||||||
|
assertionError.printStackTrace();
|
||||||
|
}
|
||||||
|
assertThat(assertionError + " should be null", assertionError, nullValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -147,7 +150,7 @@ public class ConcurrentPercolatorTests extends ElasticsearchIntegrationTest {
|
||||||
final int numPercolateThreads = 6;
|
final int numPercolateThreads = 6;
|
||||||
final int numPercolatorOperationsPerThread = 1000;
|
final int numPercolatorOperationsPerThread = 1000;
|
||||||
|
|
||||||
final AtomicBoolean assertionFailure = new AtomicBoolean(false);
|
final Set<Throwable> exceptionsHolder = ConcurrentCollections.newConcurrentSet();
|
||||||
final CountDownLatch start = new CountDownLatch(1);
|
final CountDownLatch start = new CountDownLatch(1);
|
||||||
final AtomicInteger runningPercolateThreads = new AtomicInteger(numPercolateThreads);
|
final AtomicInteger runningPercolateThreads = new AtomicInteger(numPercolateThreads);
|
||||||
final AtomicInteger type1 = new AtomicInteger();
|
final AtomicInteger type1 = new AtomicInteger();
|
||||||
|
@ -202,7 +205,7 @@ public class ConcurrentPercolatorTests extends ElasticsearchIntegrationTest {
|
||||||
assertThat(response.getVersion(), equalTo(1l));
|
assertThat(response.getVersion(), equalTo(1l));
|
||||||
}
|
}
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
assertionFailure.set(true);
|
exceptionsHolder.add(t);
|
||||||
logger.error("Error in indexing thread...", t);
|
logger.error("Error in indexing thread...", t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -261,7 +264,7 @@ public class ConcurrentPercolatorTests extends ElasticsearchIntegrationTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
assertionFailure.set(true);
|
exceptionsHolder.add(t);
|
||||||
logger.error("Error in percolate thread...", t);
|
logger.error("Error in percolate thread...", t);
|
||||||
} finally {
|
} finally {
|
||||||
runningPercolateThreads.decrementAndGet();
|
runningPercolateThreads.decrementAndGet();
|
||||||
|
@ -280,7 +283,10 @@ public class ConcurrentPercolatorTests extends ElasticsearchIntegrationTest {
|
||||||
thread.join();
|
thread.join();
|
||||||
}
|
}
|
||||||
|
|
||||||
assertThat(assertionFailure.get(), equalTo(false));
|
for (Throwable t : exceptionsHolder) {
|
||||||
|
logger.error("Unexpected exception {}", t.getMessage(), t);
|
||||||
|
}
|
||||||
|
assertThat(exceptionsHolder.isEmpty(), equalTo(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue