diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/FailedShardsRoutingTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/FailedShardsRoutingTests.java index 569018c431d..a53206494d6 100644 --- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/FailedShardsRoutingTests.java +++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/FailedShardsRoutingTests.java @@ -19,6 +19,7 @@ package org.elasticsearch.cluster.routing.allocation; +import com.carrotsearch.randomizedtesting.annotations.Repeat; import com.google.common.collect.ImmutableList; import org.elasticsearch.Version; import org.elasticsearch.cluster.ClusterState; @@ -371,11 +372,14 @@ public class FailedShardsRoutingTests extends ElasticsearchAllocationTestCase { logger.info("fail the first shard, will start INITIALIZING on the second node"); prevRoutingTable = routingTable; - final ShardRouting firstShard = clusterState.routingNodes().node("node1").get(0); + final ShardRouting firstShard = clusterState.routingNodes().node(nodeHoldingPrimary).get(0); routingTable = strategy.applyFailedShard(clusterState, firstShard).routingTable(); clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build(); - assertThat(prevRoutingTable != routingTable, equalTo(true)); + + final String nodeHoldingPrimary2 = routingTable.index("test").shard(0).primaryShard().currentNodeId(); + assertThat(nodeHoldingPrimary2, not(equalTo(nodeHoldingPrimary))); + assertThat(routingTable.index("test").shards().size(), equalTo(1)); for (int i = 0; i < routingTable.index("test").shards().size(); i++) { assertThat(routingTable.index("test").shard(i).size(), equalTo(2));