From 4bf806825f1da08c25274ed2be5122bc4f39393b Mon Sep 17 00:00:00 2001 From: David Turner Date: Wed, 19 Jun 2024 14:56:40 +0100 Subject: [PATCH] Fix `TasksIT#testTasksCancellation` The tasks are removed from the task manager _after_ sending the response, so we cannot reliably assert they're done. With this commit we wait for them to complete properly first. Closes #109686 --- .../action/admin/cluster/node/tasks/TasksIT.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/node/tasks/TasksIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/node/tasks/TasksIT.java index 30be4c86eaeef..4ad2a56d2e979 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/node/tasks/TasksIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/node/tasks/TasksIT.java @@ -488,7 +488,6 @@ public void onTaskRegistered(Task task) { } } - @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/109686") public void testTasksCancellation() throws Exception { // Start blocking test task // Get real client (the plugin is not registered on transport nodes) @@ -511,6 +510,9 @@ public void testTasksCancellation() throws Exception { expectThrows(TaskCancelledException.class, future); + logger.info("--> waiting for all ongoing tasks to complete within a reasonable time"); + safeGet(clusterAdmin().prepareListTasks().setActions(TEST_TASK_ACTION.name() + "*").setWaitForCompletion(true).execute()); + logger.info("--> checking that test tasks are not running"); assertEquals(0, clusterAdmin().prepareListTasks().setActions(TEST_TASK_ACTION.name() + "*").get().getTasks().size()); }