From f29224ce62a184a6536b96c13583a5943542070c Mon Sep 17 00:00:00 2001 From: Pat Whelan Date: Fri, 6 Mar 2026 14:13:54 -0500 Subject: [PATCH] [ML] Wait for cluster state in test Before the test ends, wait until all of our cluster state changes have propagated to all nodes. This fixes an inconsistent test failure where one node has the latest changes and returns the datafeed stats while another node is still updating with the latest state of the datafeed and cannot clean it up after the test. Resolve #82591 --- .../xpack/ml/integration/BasicDistributedJobsIT.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/BasicDistributedJobsIT.java b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/BasicDistributedJobsIT.java index a3d2aff4ceb02..3f2ad8b7ee6cc 100644 --- a/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/BasicDistributedJobsIT.java +++ b/x-pack/plugin/ml/src/internalClusterTest/java/org/elasticsearch/xpack/ml/integration/BasicDistributedJobsIT.java @@ -95,7 +95,6 @@ public void testFailOverBasics() throws Exception { assertRecentLastTaskStateChangeTime(MlTasks.jobTaskId(job.getId()), Duration.of(30, ChronoUnit.SECONDS), null); } - @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/82591") public void testFailOverBasics_withDataFeeder() throws Exception { internalCluster().ensureAtLeastNumDataNodes(4); ensureStableCluster(4); @@ -168,6 +167,12 @@ public void testFailOverBasics_withDataFeeder() throws Exception { assertEquals(1, statsResponse.getResponse().results().size()); assertEquals(DatafeedState.STARTED, statsResponse.getResponse().results().get(0).getDatafeedState()); }); + + // Ensure all nodes have a consistent view of the cluster state before cleanup + // runs, otherwise the stop-datafeed request during cleanup may be routed to a + // node that hasn't yet received the state update showing the datafeed as started. + // See https://github.com/elastic/elasticsearch/issues/82591 + waitNoPendingTasksOnAll(); } public void testJobAutoClose() throws Exception {