Skip to content

Commit decae8a

Browse files
ReindexIT wait for task to really start (#73018)
Reindex and friends have tasks that start but are not ready to rethrottle before they figured out if they are leader or worker tasks. Now wait for the task to fully start before rethrottling. Also added additional assertions to help see if the inability to rethrottle is caused by some failure. Closes #60811
1 parent e31d5f8 commit decae8a

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

client/rest-high-level/src/test/java/org/elasticsearch/client/ESRestHighLevelClientTestCase.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.elasticsearch.ingest.Pipeline;
3636
import org.elasticsearch.search.SearchHit;
3737
import org.elasticsearch.search.SearchModule;
38+
import org.elasticsearch.tasks.RawTaskStatus;
3839
import org.elasticsearch.tasks.TaskId;
3940
import org.elasticsearch.test.rest.ESRestTestCase;
4041
import org.junit.AfterClass;
@@ -324,7 +325,10 @@ protected static TaskId findTaskToRethrottle(String actionName, String descripti
324325
}
325326
TaskGroup taskGroup = taskGroups.get(0);
326327
assertThat(taskGroup.getChildTasks(), empty());
327-
return taskGroup.getTaskInfo().getTaskId();
328+
// check that the task initialized enough that it can rethrottle too.
329+
if (((RawTaskStatus) taskGroup.getTaskInfo().getStatus()).toMap().containsKey("batches")) {
330+
return taskGroup.getTaskInfo().getTaskId();
331+
}
328332
} while (System.nanoTime() - start < TimeUnit.SECONDS.toNanos(10));
329333
throw new AssertionError("Couldn't find tasks to rethrottle. Here are the running tasks " +
330334
highLevelClient().tasks().list(request, RequestOptions.DEFAULT));

client/rest-high-level/src/test/java/org/elasticsearch/client/ReindexIT.java

+2
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,8 @@ public void onFailure(Exception e) {
263263
float requestsPerSecond = 1000f;
264264
ListTasksResponse response = execute(new RethrottleRequest(taskIdToRethrottle, requestsPerSecond),
265265
highLevelClient()::deleteByQueryRethrottle, highLevelClient()::deleteByQueryRethrottleAsync);
266+
assertThat(response.getTaskFailures(), empty());
267+
assertThat(response.getNodeFailures(), empty());
266268
assertThat(response.getTasks(), hasSize(1));
267269
assertEquals(taskIdToRethrottle, response.getTasks().get(0).getTaskId());
268270
assertThat(response.getTasks().get(0).getStatus(), instanceOf(RawTaskStatus.class));

0 commit comments

Comments
 (0)