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 @@ -154,7 +154,6 @@ public void testGetProfilingDataUnfiltered() throws Exception {
assertNotNull("libc.so.6", response.getExecutables().get("QCCDqjSg3bMK1C4YRK6Tiw"));
}

@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/92039")
public void testAutomaticCancellation() throws Exception {
Request restRequest = new Request("POST", "/_profiling/stacktraces");
restRequest.setEntity(new StringEntity("""
Expand Down Expand Up @@ -223,7 +222,13 @@ private static Collection<TaskId> collectProfilingRelatedTasks(String transportA
}
}
assertNotNull(profilingTask.get());
return taskToParent.get(profilingTask.get().taskId());
Set<TaskId> childTaskIds = taskToParent.get(profilingTask.get().taskId());
Set<TaskId> profilingTaskIds = new HashSet<>();
profilingTaskIds.add(profilingTask.get().taskId());
if (childTaskIds != null) {
profilingTaskIds.addAll(childTaskIds);
}
return profilingTaskIds;
}

private static void ensureTasksAreCancelled(Collection<TaskId> taskIds, Function<String, String> nodeIdToName) throws Exception {
Expand All @@ -232,8 +237,12 @@ private static void ensureTasksAreCancelled(Collection<TaskId> taskIds, Function
String nodeName = nodeIdToName.apply(taskId.getNodeId());
TaskManager taskManager = internalCluster().getInstance(TransportService.class, nodeName).getTaskManager();
Task task = taskManager.getTask(taskId.getId());
assertThat(task, instanceOf(CancellableTask.class));
assertTrue(((CancellableTask) task).isCancelled());
// as we capture the task hierarchy at the beginning but cancel in the middle of execution, some tasks have been
// unregistered already by the time we verify cancellation.
if (task != null) {
assertThat(task, instanceOf(CancellableTask.class));
assertTrue(((CancellableTask) task).isCancelled());
}
}
});
}
Expand Down