[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
This commit is contained in:
Luca Cavanna 2019-08-27 09:07:59 +02:00
parent 1ebee5bf9b
commit 267183998e
1 changed files with 4 additions and 4 deletions

View File

@ -528,7 +528,7 @@ public abstract class ESIntegTestCase extends ESTestCase {
return testCluster;
}
private static void clearClusters() throws IOException {
private static void clearClusters() throws Exception {
if (!clusters.isEmpty()) {
IOUtils.close(clusters.values());
clusters.clear();
@ -537,9 +537,9 @@ public abstract class ESIntegTestCase extends ESTestCase {
restClient.close();
restClient = null;
}
assertEquals(HttpChannelTaskHandler.INSTANCE.getNumChannels() + " channels still being tracked in " +
HttpChannelTaskHandler.class.getSimpleName() + " while there should be none", 0,
HttpChannelTaskHandler.INSTANCE.getNumChannels());
assertBusy(() -> assertEquals(HttpChannelTaskHandler.INSTANCE.getNumChannels() + " channels still being tracked in " +
HttpChannelTaskHandler.class.getSimpleName() + " while there should be none", 0,
HttpChannelTaskHandler.INSTANCE.getNumChannels()));
}
private void afterInternal(boolean afterClass) throws Exception {