[TEST] Wait for primary allocations before restart

This commit ensures that all primaries are allocated before we
restart the node. If one primary is in post recovery when we
restart it will not be allocated otherwise.
This commit is contained in:
Simon Willnauer 2014-07-10 11:51:41 +02:00
parent 4ddec99703
commit c9266e8b6b
1 changed files with 4 additions and 1 deletions

View File

@ -61,7 +61,7 @@ public class SimpleRecoveryLocalGatewayTests extends ElasticsearchIntegrationTes
@Test @Test
@Slow @Slow
public void testX() throws Exception { public void testOneNodeRecoverFromGateway() throws Exception {
internalCluster().startNode(settingsBuilder().build()); internalCluster().startNode(settingsBuilder().build());
@ -70,6 +70,7 @@ public class SimpleRecoveryLocalGatewayTests extends ElasticsearchIntegrationTes
.endObject().endObject().string(); .endObject().endObject().string();
assertAcked(prepareCreate("test").addMapping("type1", mapping)); assertAcked(prepareCreate("test").addMapping("type1", mapping));
client().prepareIndex("test", "type1", "10990239").setSource(jsonBuilder().startObject() client().prepareIndex("test", "type1", "10990239").setSource(jsonBuilder().startObject()
.field("_id", "10990239") .field("_id", "10990239")
.startArray("appAccountIds").value(14).value(179).endArray().endObject()).execute().actionGet(); .startArray("appAccountIds").value(14).value(179).endArray().endObject()).execute().actionGet();
@ -88,6 +89,8 @@ public class SimpleRecoveryLocalGatewayTests extends ElasticsearchIntegrationTes
refresh(); refresh();
assertHitCount(client().prepareCount().setQuery(termQuery("appAccountIds", 179)).execute().actionGet(), 2); assertHitCount(client().prepareCount().setQuery(termQuery("appAccountIds", 179)).execute().actionGet(), 2);
ensureYellow("test"); // wait for primary allocations here otherwise if we have a lot of shards we might have a
// shard that is still in post recovery when we restart and the ensureYellow() below will timeout
internalCluster().fullRestart(); internalCluster().fullRestart();
logger.info("Running Cluster Health (wait for the shards to startup)"); logger.info("Running Cluster Health (wait for the shards to startup)");