Skip to content

Commit

Permalink
[TEST] wait for http channels to be closed in ESIntegTestCase (#45977)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
javanna committed Aug 27, 2019
1 parent 1ebee5b commit 2671839
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ private TestCluster buildAndPutCluster(Scope currentClusterScope, long seed) thr
return testCluster;
}

private static void clearClusters() throws IOException {
private static void clearClusters() throws Exception {
if (!clusters.isEmpty()) {
IOUtils.close(clusters.values());
clusters.clear();
Expand All @@ -537,9 +537,9 @@ private static void clearClusters() throws IOException {
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 {
Expand Down

0 comments on commit 2671839

Please sign in to comment.