Skip to content

Commit 12b4fcf

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 90e663b commit 12b4fcf

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

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

Lines changed: 5 additions & 1 deletion
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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ public void testReindexConflict() throws IOException {
189189
assertTrue(response.getTook().getMillis() > 0);
190190
}
191191

192-
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/60811#issuecomment-830040692")
193192
public void testDeleteByQuery() throws Exception {
194193
final String sourceIndex = "source1";
195194
{
@@ -264,6 +263,8 @@ public void onFailure(Exception e) {
264263
float requestsPerSecond = 1000f;
265264
ListTasksResponse response = execute(new RethrottleRequest(taskIdToRethrottle, requestsPerSecond),
266265
highLevelClient()::deleteByQueryRethrottle, highLevelClient()::deleteByQueryRethrottleAsync);
266+
assertThat(response.getTaskFailures(), empty());
267+
assertThat(response.getNodeFailures(), empty());
267268
assertThat(response.getTasks(), hasSize(1));
268269
assertEquals(taskIdToRethrottle, response.getTasks().get(0).getTaskId());
269270
assertThat(response.getTasks().get(0).getStatus(), instanceOf(RawTaskStatus.class));

0 commit comments

Comments
 (0)