Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ public void initClient() throws IOException {
@After
public final void cleanUpCluster() throws Exception {
wipeCluster();
waitForClusterStateUpdatesToFinish();
logIfThereAreRunningTasks();
}

Expand Down Expand Up @@ -253,6 +254,22 @@ private void logIfThereAreRunningTasks() throws InterruptedException, IOExceptio
*/
}

/**
* Waits for the cluster state updates to have been processed, so that no cluster
* state updates are still in-progress when the next test starts.
*/
private void waitForClusterStateUpdatesToFinish() throws Exception {
assertBusy(() -> {
try {
Response response = adminClient().performRequest("GET", "_cluster/pending_tasks");
List<Object> tasks = (List<Object>) entityAsMap(response).get("tasks");
assertTrue(tasks.isEmpty());
} catch (IOException e) {
fail("cannot get cluster's pending tasks: " + e.getMessage());
}
});
}

/**
* Used to obtain settings for the REST client that is used to send REST requests.
*/
Expand Down