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:
parent
2d81fc3873
commit
a654f21599
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue