|
@@ -13,6 +13,7 @@ import org.elasticsearch.action.admin.cluster.state.ClusterStateResponse;
|
|
|
import org.elasticsearch.cluster.routing.ShardRoutingState;
|
|
|
import org.elasticsearch.cluster.routing.allocation.command.MoveAllocationCommand;
|
|
|
import org.elasticsearch.cluster.routing.allocation.decider.EnableAllocationDecider;
|
|
|
+import org.elasticsearch.cluster.routing.allocation.decider.MaxRetryAllocationDecider;
|
|
|
import org.elasticsearch.common.Strings;
|
|
|
import org.elasticsearch.common.settings.Settings;
|
|
|
import org.elasticsearch.core.CheckedRunnable;
|
|
@@ -127,7 +128,7 @@ public class IndicesLifecycleListenerIT extends ESIntegTestCase {
|
|
|
assertThat(state.nodes().get(shard.currentNodeId()).getName(), equalTo(node1));
|
|
|
}
|
|
|
|
|
|
- public void testRelocationFailureNotRetriedForever() {
|
|
|
+ public void testRelocationFailureNotRetriedForever() throws Exception {
|
|
|
String node1 = internalCluster().startNode();
|
|
|
createIndex("index1", 1, 0);
|
|
|
ensureGreen("index1");
|
|
@@ -143,6 +144,16 @@ public class IndicesLifecycleListenerIT extends ESIntegTestCase {
|
|
|
updateIndexSettings(Settings.builder().put(INDEX_ROUTING_EXCLUDE_GROUP_PREFIX + "._name", node1), "index1");
|
|
|
ensureGreen("index1");
|
|
|
|
|
|
+ var maxAttempts = MaxRetryAllocationDecider.SETTING_ALLOCATION_MAX_RETRY.get(Settings.EMPTY);
|
|
|
+
|
|
|
+ // await all relocation attempts are exhausted
|
|
|
+ assertBusy(() -> {
|
|
|
+ var state = clusterAdmin().prepareState().get().getState();
|
|
|
+ var shard = state.routingTable().index("index1").shard(0).primaryShard();
|
|
|
+ assertThat(shard, notNullValue());
|
|
|
+ assertThat(shard.relocationFailureInfo().failedRelocations(), equalTo(maxAttempts));
|
|
|
+ });
|
|
|
+ // ensure the shard remain started
|
|
|
var state = clusterAdmin().prepareState().get().getState();
|
|
|
logger.info("Final routing is {}", state.getRoutingNodes().toString());
|
|
|
var shard = state.routingTable().index("index1").shard(0).primaryShard();
|