Skip to content

Commit 2671839

Browse files
committed
[TEST] wait for http channels to be closed in ESIntegTestCase (#45977)
We recently added a check to `ESIntegTestCase` in order to verify that no http channels are being tracked when we close clusters and the REST client. Close listeners though are invoked asynchronously, hence this check may fail if we assert before the close listener that removes the channel from the map is invoked. With this commit we add an `assertBusy` so we try and wait for the map to be empty. Closes #45914 Closes #45955
1 parent 1ebee5b commit 2671839

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ private TestCluster buildAndPutCluster(Scope currentClusterScope, long seed) thr
528528
return testCluster;
529529
}
530530

531-
private static void clearClusters() throws IOException {
531+
private static void clearClusters() throws Exception {
532532
if (!clusters.isEmpty()) {
533533
IOUtils.close(clusters.values());
534534
clusters.clear();
@@ -537,9 +537,9 @@ private static void clearClusters() throws IOException {
537537
restClient.close();
538538
restClient = null;
539539
}
540-
assertEquals(HttpChannelTaskHandler.INSTANCE.getNumChannels() + " channels still being tracked in " +
541-
HttpChannelTaskHandler.class.getSimpleName() + " while there should be none", 0,
542-
HttpChannelTaskHandler.INSTANCE.getNumChannels());
540+
assertBusy(() -> assertEquals(HttpChannelTaskHandler.INSTANCE.getNumChannels() + " channels still being tracked in " +
541+
HttpChannelTaskHandler.class.getSimpleName() + " while there should be none", 0,
542+
HttpChannelTaskHandler.INSTANCE.getNumChannels()));
543543
}
544544

545545
private void afterInternal(boolean afterClass) throws Exception {

0 commit comments

Comments
 (0)