This commit is contained in:
Shay Banon 2012-02-21 13:44:31 +02:00
parent 0bf61ab6c8
commit 9d724b8a14
1 changed files with 12 additions and 12 deletions

View File

@ -37,11 +37,10 @@ import static org.elasticsearch.cluster.routing.RoutingBuilders.indexRoutingTabl
import static org.elasticsearch.cluster.routing.RoutingBuilders.routingTable;
import static org.elasticsearch.cluster.routing.ShardRoutingState.INITIALIZING;
import static org.elasticsearch.cluster.routing.ShardRoutingState.STARTED;
import static org.elasticsearch.test.unit.cluster.routing.allocation.RoutingAllocationTests.newNode;
import static org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder;
import static org.elasticsearch.test.unit.cluster.routing.allocation.RoutingAllocationTests.newNode;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.notNullValue;
/**
*
@ -104,8 +103,8 @@ public class ElectReplicaAsPrimaryDuringRelocationTests {
indexShardRoutingTable = routingTable.index("test").shard(1);
}
assertThat("failed to find relocating replica", indexShardRoutingTable, notNullValue());
// we might have primary relocating, and the test is only for replicas, so only test in the case of replica allocation
if (indexShardRoutingTable != null) {
logger.info("kill the node [{}] of the primary shard for the relocating replica", indexShardRoutingTable.primaryShard().currentNodeId());
clusterState = newClusterStateBuilder().state(clusterState).nodes(newNodesBuilder().putAll(clusterState.nodes()).remove(indexShardRoutingTable.primaryShard().currentNodeId())).build();
prevRoutingTable = routingTable;
@ -116,4 +115,5 @@ public class ElectReplicaAsPrimaryDuringRelocationTests {
assertThat(routingTable.index("test").shard(0).primaryShard().active(), equalTo(true));
assertThat(routingTable.index("test").shard(1).primaryShard().active(), equalTo(true));
}
}
}