1
0
Эх сурвалжийг харах

[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.
Simon Willnauer 11 жил өмнө
parent
commit
c9266e8b6b

+ 4 - 1
src/test/java/org/elasticsearch/gateway/local/SimpleRecoveryLocalGatewayTests.java

@@ -61,7 +61,7 @@ public class SimpleRecoveryLocalGatewayTests extends ElasticsearchIntegrationTes
 
     @Test
     @Slow
-    public void testX() throws Exception {
+    public void testOneNodeRecoverFromGateway() throws Exception {
 
         internalCluster().startNode(settingsBuilder().build());
 
@@ -70,6 +70,7 @@ public class SimpleRecoveryLocalGatewayTests extends ElasticsearchIntegrationTes
                 .endObject().endObject().string();
         assertAcked(prepareCreate("test").addMapping("type1", mapping));
 
+
         client().prepareIndex("test", "type1", "10990239").setSource(jsonBuilder().startObject()
                 .field("_id", "10990239")
                 .startArray("appAccountIds").value(14).value(179).endArray().endObject()).execute().actionGet();
@@ -88,6 +89,8 @@ public class SimpleRecoveryLocalGatewayTests extends ElasticsearchIntegrationTes
 
         refresh();
         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();
 
         logger.info("Running Cluster Health (wait for the shards to startup)");