Rethrottle tests wait for task to start (#77822)

Improved how we wait for tasks to really start, to ensure that
rethrottle does not fail the test.

Closes #75327
This commit is contained in:
Henning Andersen 2021-10-27 17:53:49 +02:00 committed by Henning Andersen
parent 286cd3516c
commit 3cad9c1c39

View file

@ -336,7 +336,8 @@ public abstract class ESRestHighLevelClientTestCase extends ESRestTestCase {
TaskGroup taskGroup = taskGroups.get(0);
assertThat(taskGroup.getChildTasks(), empty());
// check that the task initialized enough that it can rethrottle too.
if (((RawTaskStatus) taskGroup.getTaskInfo().getStatus()).toMap().containsKey("batches")) {
Map<String, Object> statusMap = ((RawTaskStatus) taskGroup.getTaskInfo().getStatus()).toMap();
if (statusMap.get("batches").equals(1)) {
return taskGroup.getTaskInfo().getTaskId();
}
} while (System.nanoTime() - start < TimeUnit.SECONDS.toNanos(10));