[TEST] Verify expected number of nodes in cluster before issuing shardStores request
This commit is contained in:
parent
c286cd11cf
commit
01ea89acbf
|
@ -45,6 +45,7 @@ import java.util.*;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertAcked;
|
||||||
|
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertNoTimeout;
|
||||||
import static org.hamcrest.Matchers.*;
|
import static org.hamcrest.Matchers.*;
|
||||||
|
|
||||||
@ElasticsearchIntegrationTest.ClusterScope(scope = ElasticsearchIntegrationTest.Scope.TEST)
|
@ElasticsearchIntegrationTest.ClusterScope(scope = ElasticsearchIntegrationTest.Scope.TEST)
|
||||||
|
@ -91,8 +92,9 @@ public class IndicesShardStoreRequestTests extends ElasticsearchIntegrationTest
|
||||||
logger.info("--> disable allocation");
|
logger.info("--> disable allocation");
|
||||||
disableAllocation(index);
|
disableAllocation(index);
|
||||||
logger.info("--> stop random node");
|
logger.info("--> stop random node");
|
||||||
|
int num = client().admin().cluster().prepareState().get().getState().nodes().getSize();
|
||||||
internalCluster().stopRandomNode(new IndexNodePredicate(index));
|
internalCluster().stopRandomNode(new IndexNodePredicate(index));
|
||||||
ensureYellow(index);
|
assertNoTimeout(client().admin().cluster().prepareHealth().setWaitForNodes("" + (num - 1)));
|
||||||
ClusterState clusterState = client().admin().cluster().prepareState().get().getState();
|
ClusterState clusterState = client().admin().cluster().prepareState().get().getState();
|
||||||
List<ShardRouting> unassignedShards = clusterState.routingTable().index(index).shardsWithState(ShardRoutingState.UNASSIGNED);
|
List<ShardRouting> unassignedShards = clusterState.routingTable().index(index).shardsWithState(ShardRoutingState.UNASSIGNED);
|
||||||
response = client().admin().indices().shardStores(Requests.indicesShardStoresRequest(index)).get();
|
response = client().admin().indices().shardStores(Requests.indicesShardStoresRequest(index)).get();
|
||||||
|
|
Loading…
Reference in New Issue