diff options
Diffstat (limited to 'core/src/test/java/org/elasticsearch/cluster/routing/allocation/PreferPrimaryAllocationTests.java')
-rw-r--r-- | core/src/test/java/org/elasticsearch/cluster/routing/allocation/PreferPrimaryAllocationTests.java | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/PreferPrimaryAllocationTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/PreferPrimaryAllocationTests.java index 7badada5d5..1c209157b1 100644 --- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/PreferPrimaryAllocationTests.java +++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/PreferPrimaryAllocationTests.java @@ -22,6 +22,7 @@ package org.elasticsearch.cluster.routing.allocation; import org.apache.logging.log4j.Logger; import org.elasticsearch.Version; import org.elasticsearch.cluster.ClusterState; +import org.elasticsearch.cluster.ESAllocationTestCase; import org.elasticsearch.cluster.metadata.IndexMetaData; import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.node.DiscoveryNodes; @@ -29,7 +30,6 @@ import org.elasticsearch.cluster.routing.RoutingTable; import org.elasticsearch.cluster.routing.allocation.decider.ThrottlingAllocationDecider; import org.elasticsearch.common.logging.Loggers; import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.cluster.ESAllocationTestCase; import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING; import static org.hamcrest.Matchers.equalTo; @@ -63,12 +63,10 @@ public class PreferPrimaryAllocationTests extends ESAllocationTestCase { logger.info("adding two nodes and performing rerouting till all are allocated"); clusterState = ClusterState.builder(clusterState).nodes(DiscoveryNodes.builder().add(newNode("node1")).add(newNode("node2"))).build(); - RoutingAllocation.Result routingResult = strategy.reroute(clusterState, "reroute"); - clusterState = ClusterState.builder(clusterState).routingResult(routingResult).build(); + clusterState = strategy.reroute(clusterState, "reroute"); while (!clusterState.getRoutingNodes().shardsWithState(INITIALIZING).isEmpty()) { - routingResult = strategy.applyStartedShards(clusterState, clusterState.getRoutingNodes().shardsWithState(INITIALIZING)); - clusterState = ClusterState.builder(clusterState).routingResult(routingResult).build(); + clusterState = strategy.applyStartedShards(clusterState, clusterState.getRoutingNodes().shardsWithState(INITIALIZING)); } logger.info("increasing the number of replicas to 1, and perform a reroute (to get the replicas allocation going)"); @@ -76,8 +74,7 @@ public class PreferPrimaryAllocationTests extends ESAllocationTestCase { metaData = MetaData.builder(clusterState.metaData()).updateNumberOfReplicas(1).build(); clusterState = ClusterState.builder(clusterState).routingTable(updatedRoutingTable).metaData(metaData).build(); - routingResult = strategy.reroute(clusterState, "reroute"); - clusterState = ClusterState.builder(clusterState).routingResult(routingResult).build(); + clusterState = strategy.reroute(clusterState, "reroute"); logger.info("2 replicas should be initializing now for the existing indices (we throttle to 1)"); assertThat(clusterState.getRoutingNodes().shardsWithState(INITIALIZING).size(), equalTo(2)); @@ -94,8 +91,7 @@ public class PreferPrimaryAllocationTests extends ESAllocationTestCase { clusterState = ClusterState.builder(clusterState).metaData(metaData).routingTable(updatedRoutingTable).build(); logger.info("reroute, verify that primaries for the new index primary shards are allocated"); - routingResult = strategy.reroute(clusterState, "reroute"); - clusterState = ClusterState.builder(clusterState).routingResult(routingResult).build(); + clusterState = strategy.reroute(clusterState, "reroute"); assertThat(clusterState.routingTable().index("new_index").shardsWithState(INITIALIZING).size(), equalTo(2)); } |