From 198e856d776277325afc68ca7656a8c88b31acf1 Mon Sep 17 00:00:00 2001 From: Pat Whelan Date: Mon, 9 Mar 2026 09:00:40 -0400 Subject: [PATCH] [ML] Wait for cluster state in test (#143767) 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 842ed7a4a2a2e..21eed7e265fb4 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(10, 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 {