Skip to content

Commit d42d6f0

Browse files
committed
[TEST] Fix RemoteClusterConnectionTests
With PR #31574 we now ensure that connections are established under the proper thread context. There is a test in RemoteClusterConnectionTests, however, that shuts down the service while connecting. With the above change, a new kind of exception can occur that the test is unaware of.
1 parent adc4c91 commit d42d6f0

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

server/src/test/java/org/elasticsearch/transport/RemoteClusterConnectionTests.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484

8585
import static java.util.Collections.emptyMap;
8686
import static java.util.Collections.emptySet;
87+
import static org.hamcrest.Matchers.containsString;
8788
import static org.hamcrest.Matchers.equalTo;
8889
import static org.hamcrest.Matchers.instanceOf;
8990
import static org.hamcrest.Matchers.iterableWithSize;
@@ -861,7 +862,13 @@ public void run() {
861862
throw new AssertionError(x);
862863
}
863864
});
864-
connection.updateSeedNodes(seedNodes, listener);
865+
try {
866+
connection.updateSeedNodes(seedNodes, listener);
867+
} catch (Exception e) {
868+
// it's ok if we're shutting down
869+
assertThat(e.getMessage(), containsString("threadcontext is already closed"));
870+
latch.countDown();
871+
}
865872
}
866873
latch.await();
867874
} catch (Exception ex) {

0 commit comments

Comments
 (0)