From 889651d1eb22eeed43f3b4dc5af8720c5d9b48a3 Mon Sep 17 00:00:00 2001 From: Henning Andersen <33268011+henningandersen@users.noreply.github.com> Date: Wed, 27 Oct 2021 17:53:49 +0200 Subject: [PATCH] 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 --- .../elasticsearch/client/ESRestHighLevelClientTestCase.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/ESRestHighLevelClientTestCase.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/ESRestHighLevelClientTestCase.java index 83d7f19cd811f..d9ead045bcf97 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/ESRestHighLevelClientTestCase.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/ESRestHighLevelClientTestCase.java @@ -351,7 +351,8 @@ protected static TaskId findTaskToRethrottle(String actionName, String descripti 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 statusMap = ((RawTaskStatus) taskGroup.getTaskInfo().getStatus()).toMap(); + if (statusMap.get("batches").equals(1)) { return taskGroup.getTaskInfo().getTaskId(); } } while (System.nanoTime() - start < TimeUnit.SECONDS.toNanos(10));