TESTS: Fix Concurent Remote Connection Updates (#33707)

* Same fix idea as in #10666a4 to prevent background
threads trying to reconnect after the tests are done from
throwing `ExecutionCancelledException` and breaking the test
* Closes #30714
This commit is contained in:
Armin Braun 2018-09-17 16:38:44 +02:00 committed by GitHub
parent 2d81fc3873
commit a654f21599
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 4 deletions

View File

@ -389,10 +389,27 @@ public class RemoteClusterConnectionTests extends ESTestCase {
throws Exception {
CountDownLatch latch = new CountDownLatch(1);
AtomicReference<Exception> exceptionAtomicReference = new AtomicReference<>();
ActionListener<Void> listener = ActionListener.wrap(x -> latch.countDown(), x -> {
ActionListener<Void> listener = ActionListener.wrap(
x -> latch.countDown(),
x -> {
/*
* This can occur on a thread submitted to the thread pool while we are closing the
* remote cluster connection at the end of the test.
*/
if (x instanceof CancellableThreads.ExecutionCancelledException) {
try {
// we should already be shutting down
assertEquals(0L, latch.getCount());
} finally {
// ensure we count down the latch on failure as well to not prevent failing tests from ending
latch.countDown();
}
return;
}
exceptionAtomicReference.set(x);
latch.countDown();
});
}
);
connection.updateSeedNodes(proxyAddress, seedNodes, listener);
latch.await();
if (exceptionAtomicReference.get() != null) {