[TEST] Fix testDelayShards to wait for master to remove stopped node
This test failed when the node that was shutting down was not yet removed from the cluster state on the master. The cluster allocation explain API will not see any unassigned shards until the node shutting down is removed from the cluster state.
This commit is contained in:
parent
118913b553
commit
952097b1c0
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
package org.elasticsearch.action.admin.cluster.allocation;
|
package org.elasticsearch.action.admin.cluster.allocation;
|
||||||
|
|
||||||
import org.elasticsearch.action.admin.cluster.node.stats.NodesStatsResponse;
|
|
||||||
import org.elasticsearch.action.admin.indices.shards.IndicesShardStoresResponse;
|
import org.elasticsearch.action.admin.indices.shards.IndicesShardStoresResponse;
|
||||||
import org.elasticsearch.action.support.ActiveShardCount;
|
import org.elasticsearch.action.support.ActiveShardCount;
|
||||||
import org.elasticsearch.client.Requests;
|
import org.elasticsearch.client.Requests;
|
||||||
|
@ -31,7 +30,6 @@ import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.test.ESIntegTestCase;
|
import org.elasticsearch.test.ESIntegTestCase;
|
||||||
import org.elasticsearch.test.junit.annotations.TestLogging;
|
import org.elasticsearch.test.junit.annotations.TestLogging;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
||||||
|
@ -47,14 +45,11 @@ public final class ClusterAllocationExplainIT extends ESIntegTestCase {
|
||||||
@TestLogging("_root:DEBUG")
|
@TestLogging("_root:DEBUG")
|
||||||
public void testDelayShards() throws Exception {
|
public void testDelayShards() throws Exception {
|
||||||
logger.info("--> starting 3 nodes");
|
logger.info("--> starting 3 nodes");
|
||||||
List<String> nodes = internalCluster().startNodesAsync(3).get();
|
internalCluster().startNodesAsync(3).get();
|
||||||
|
|
||||||
// Wait for all 3 nodes to be up
|
// Wait for all 3 nodes to be up
|
||||||
logger.info("--> waiting for 3 nodes to be up");
|
logger.info("--> waiting for 3 nodes to be up");
|
||||||
assertBusy(() -> {
|
ensureStableCluster(3);
|
||||||
NodesStatsResponse resp = client().admin().cluster().prepareNodesStats().get();
|
|
||||||
assertThat(resp.getNodes().size(), equalTo(3));
|
|
||||||
});
|
|
||||||
|
|
||||||
logger.info("--> creating 'test' index");
|
logger.info("--> creating 'test' index");
|
||||||
assertAcked(prepareCreate("test").setSettings(Settings.builder()
|
assertAcked(prepareCreate("test").setSettings(Settings.builder()
|
||||||
|
@ -66,7 +61,8 @@ public final class ClusterAllocationExplainIT extends ESIntegTestCase {
|
||||||
logger.info("--> stopping a random node");
|
logger.info("--> stopping a random node");
|
||||||
assertTrue(internalCluster().stopRandomDataNode());
|
assertTrue(internalCluster().stopRandomDataNode());
|
||||||
|
|
||||||
ensureYellow("test");
|
logger.info("--> waiting for the master to remove the stopped node from the cluster state");
|
||||||
|
ensureStableCluster(2);
|
||||||
|
|
||||||
ClusterAllocationExplainResponse resp = client().admin().cluster().prepareAllocationExplain().useAnyUnassignedShard().get();
|
ClusterAllocationExplainResponse resp = client().admin().cluster().prepareAllocationExplain().useAnyUnassignedShard().get();
|
||||||
ClusterAllocationExplanation cae = resp.getExplanation();
|
ClusterAllocationExplanation cae = resp.getExplanation();
|
||||||
|
|
Loading…
Reference in New Issue