summaryrefslogtreecommitdiff
path: root/core/src/test/java/org/elasticsearch/cluster/ack/AckIT.java
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/test/java/org/elasticsearch/cluster/ack/AckIT.java')
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/ack/AckIT.java25
1 files changed, 16 insertions, 9 deletions
diff --git a/core/src/test/java/org/elasticsearch/cluster/ack/AckIT.java b/core/src/test/java/org/elasticsearch/cluster/ack/AckIT.java
index 9f646d0df5..2ec3b11a16 100644
--- a/core/src/test/java/org/elasticsearch/cluster/ack/AckIT.java
+++ b/core/src/test/java/org/elasticsearch/cluster/ack/AckIT.java
@@ -38,6 +38,8 @@ import org.elasticsearch.cluster.routing.ShardRoutingState;
import org.elasticsearch.cluster.routing.allocation.command.MoveAllocationCommand;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.discovery.DiscoverySettings;
+import org.elasticsearch.index.Index;
+import org.elasticsearch.index.shard.ShardId;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
@@ -60,7 +62,7 @@ public class AckIT extends ESIntegTestCase {
//otherwise the operation is most likely acknowledged even if it doesn't support ack
return Settings.builder().put(super.nodeSettings(nodeOrdinal))
.put(DiscoverySettings.PUBLISH_TIMEOUT_SETTING.getKey(), 0).build();
-}
+ }
public void testUpdateSettingsAcknowledgement() {
createIndex("test");
@@ -83,13 +85,15 @@ public class AckIT extends ESIntegTestCase {
public void testClusterRerouteAcknowledgement() throws InterruptedException {
assertAcked(prepareCreate("test").setSettings(Settings.builder()
- .put(indexSettings())
- .put(SETTING_NUMBER_OF_SHARDS, between(cluster().numDataNodes(), DEFAULT_MAX_NUM_SHARDS))
- .put(SETTING_NUMBER_OF_REPLICAS, 0)
+ .put(indexSettings())
+ .put(SETTING_NUMBER_OF_SHARDS, between(cluster().numDataNodes(), DEFAULT_MAX_NUM_SHARDS))
+ .put(SETTING_NUMBER_OF_REPLICAS, 0)
));
ensureGreen();
MoveAllocationCommand moveAllocationCommand = getAllocationCommand();
+ final Index index = client().admin().cluster().prepareState().get().getState().metaData().index("test").getIndex();
+ final ShardId commandShard = new ShardId(index, moveAllocationCommand.shardId());
assertAcked(client().admin().cluster().prepareReroute().add(moveAllocationCommand));
@@ -97,7 +101,7 @@ public class AckIT extends ESIntegTestCase {
ClusterState clusterState = getLocalClusterState(client);
for (ShardRouting shardRouting : clusterState.getRoutingNodes().routingNodeIter(moveAllocationCommand.fromNode())) {
//if the shard that we wanted to move is still on the same node, it must be relocating
- if (shardRouting.shardId().equals(moveAllocationCommand.shardId())) {
+ if (shardRouting.shardId().equals(commandShard)) {
assertThat(shardRouting.relocating(), equalTo(true));
}
@@ -105,7 +109,7 @@ public class AckIT extends ESIntegTestCase {
boolean found = false;
for (ShardRouting shardRouting : clusterState.getRoutingNodes().routingNodeIter(moveAllocationCommand.toNode())) {
- if (shardRouting.shardId().equals(moveAllocationCommand.shardId())) {
+ if (shardRouting.shardId().equals(commandShard)) {
assertThat(shardRouting.state(), anyOf(equalTo(ShardRoutingState.INITIALIZING), equalTo(ShardRoutingState.STARTED)));
found = true;
break;
@@ -137,6 +141,9 @@ public class AckIT extends ESIntegTestCase {
MoveAllocationCommand moveAllocationCommand = getAllocationCommand();
+ final Index index = client().admin().cluster().prepareState().get().getState().metaData().index("test").getIndex();
+ final ShardId commandShard = new ShardId(index, moveAllocationCommand.shardId());
+
assertAcked(client().admin().cluster().prepareReroute().setDryRun(true).add(moveAllocationCommand));
//testing only on master with the latest cluster state as we didn't make any change thus we cannot guarantee that
@@ -145,7 +152,7 @@ public class AckIT extends ESIntegTestCase {
boolean found = false;
for (ShardRouting shardRouting : clusterStateResponse.getState().getRoutingNodes().routingNodeIter(moveAllocationCommand.fromNode())) {
//the shard that we wanted to move is still on the same node, as we had dryRun flag
- if (shardRouting.shardId().equals(moveAllocationCommand.shardId())) {
+ if (shardRouting.shardId().equals(commandShard)) {
assertThat(shardRouting.started(), equalTo(true));
found = true;
break;
@@ -154,7 +161,7 @@ public class AckIT extends ESIntegTestCase {
assertThat(found, equalTo(true));
for (ShardRouting shardRouting : clusterStateResponse.getState().getRoutingNodes().routingNodeIter(moveAllocationCommand.toNode())) {
- if (shardRouting.shardId().equals(moveAllocationCommand.shardId())) {
+ if (shardRouting.shardId().equals(commandShard)) {
fail("shard [" + shardRouting + "] shouldn't be on node [" + moveAllocationCommand.toString() + "]");
}
}
@@ -199,7 +206,7 @@ public class AckIT extends ESIntegTestCase {
assertNotNull(shardToBeMoved);
logger.info("==> going to move shard [{}] from [{}] to [{}]", shardToBeMoved, fromNodeId, toNodeId);
- return new MoveAllocationCommand(shardToBeMoved.shardId(), fromNodeId, toNodeId);
+ return new MoveAllocationCommand(shardToBeMoved.getIndexName(), shardToBeMoved.id(), fromNodeId, toNodeId);
}
public void testIndicesAliasesAcknowledgement() {