diff --git a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/node/tasks/CancellableTasksIT.java b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/node/tasks/CancellableTasksIT.java index 7aff274009588..132d3202270b1 100644 --- a/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/node/tasks/CancellableTasksIT.java +++ b/server/src/internalClusterTest/java/org/elasticsearch/action/admin/cluster/node/tasks/CancellableTasksIT.java @@ -45,7 +45,6 @@ import org.elasticsearch.tasks.TaskManager; import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.threadpool.ThreadPool; -import org.elasticsearch.threadpool.ThreadPoolStats; import org.elasticsearch.transport.ReceiveTimeoutTransportException; import org.elasticsearch.transport.SendRequestTransportException; import org.elasticsearch.transport.Transport; @@ -383,16 +382,12 @@ public void testChildrenTasksCancelledOnTimeout() throws Exception { ActionFuture rootTaskFuture = client().execute(TransportTestAction.ACTION, rootRequest); allowEntireRequest(rootRequest); waitForRootTask(rootTaskFuture, true); - assertBusy(() -> { - for (DiscoveryNode node : nodes) { - TransportService transportService = internalCluster().getInstance(TransportService.class, node.getName()); - for (ThreadPoolStats.Stats stat : transportService.getThreadPool().stats()) { - assertEquals(0, stat.getActive()); - assertEquals(0, stat.getQueue()); - } - } - }, 60L, TimeUnit.SECONDS); ensureBansAndCancellationsConsistency(); + + // Make sure all descendent requests have completed + for (TestRequest subRequest : rootRequest.descendants()) { + assertTrue(completedLatches.get(subRequest).await(60, TimeUnit.SECONDS)); + } } static TaskId getRootTaskId(TestRequest request) throws Exception {