diff --git a/core/src/test/java/org/elasticsearch/action/admin/cluster/allocation/ClusterAllocationExplainIT.java b/core/src/test/java/org/elasticsearch/action/admin/cluster/allocation/ClusterAllocationExplainIT.java index 97c1a20c33f..23fdf3499b2 100644 --- a/core/src/test/java/org/elasticsearch/action/admin/cluster/allocation/ClusterAllocationExplainIT.java +++ b/core/src/test/java/org/elasticsearch/action/admin/cluster/allocation/ClusterAllocationExplainIT.java @@ -19,7 +19,6 @@ package org.elasticsearch.action.admin.cluster.allocation; -import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse; import org.elasticsearch.action.admin.indices.shards.IndicesShardStoresResponse; import org.elasticsearch.action.support.ActiveShardCount; import org.elasticsearch.client.Requests; @@ -31,7 +30,6 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.test.ESIntegTestCase; import org.elasticsearch.test.junit.annotations.TestLogging; -import java.util.List; import java.util.Map; import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked; @@ -47,14 +45,11 @@ public final class ClusterAllocationExplainIT extends ESIntegTestCase { @TestLogging("_root:DEBUG") public void testDelayShards() throws Exception { logger.info("--> starting 3 nodes"); - List nodes = internalCluster().startNodesAsync(3).get(); + internalCluster().startNodesAsync(3).get(); // Wait for all 3 nodes to be up logger.info("--> waiting for 3 nodes to be up"); - assertBusy(() -> { - NodesStatsResponse resp = client().admin().cluster().prepareNodesStats().get(); - assertThat(resp.getNodes().size(), equalTo(3)); - }); + ensureStableCluster(3); logger.info("--> creating 'test' index"); assertAcked(prepareCreate("test").setSettings(Settings.builder() @@ -66,7 +61,8 @@ public final class ClusterAllocationExplainIT extends ESIntegTestCase { logger.info("--> stopping a random node"); assertTrue(internalCluster().stopRandomDataNode()); - ensureYellow("test"); + logger.info("--> waiting for the master to remove the stopped node from the cluster state"); + ensureStableCluster(2); ClusterAllocationExplainResponse resp = client().admin().cluster().prepareAllocationExplain().useAnyUnassignedShard().get(); ClusterAllocationExplanation cae = resp.getExplanation();