From ae9c3281fcf8c79831e12831cfc99318fdec6828 Mon Sep 17 00:00:00 2001 From: Yannick Welsch Date: Mon, 8 Jan 2018 10:02:56 +0100 Subject: [PATCH] [TEST] Wait for replicas to be allocated before shrinking The full-cluster-restart tests are run with two nodes. This can lead to situations where the shrink tests fail because the replicas are not allocated yet and the shrink operation needs the source shards to be available on the same node. --- .../java/org/elasticsearch/upgrades/FullClusterRestartIT.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qa/full-cluster-restart/src/test/java/org/elasticsearch/upgrades/FullClusterRestartIT.java b/qa/full-cluster-restart/src/test/java/org/elasticsearch/upgrades/FullClusterRestartIT.java index ec755cda6b8..06b8406b078 100644 --- a/qa/full-cluster-restart/src/test/java/org/elasticsearch/upgrades/FullClusterRestartIT.java +++ b/qa/full-cluster-restart/src/test/java/org/elasticsearch/upgrades/FullClusterRestartIT.java @@ -388,6 +388,8 @@ public class FullClusterRestartIT extends ESRestTestCase { .endObject(); }); + ensureGreen(index); // wait for source index to be available on both nodes before starting shrink + String updateSettingsRequestBody = "{\"settings\": {\"index.blocks.write\": true}}"; Response rsp = client().performRequest("PUT", "/" + index + "/_settings", Collections.emptyMap(), new StringEntity(updateSettingsRequestBody, ContentType.APPLICATION_JSON)); @@ -453,6 +455,8 @@ public class FullClusterRestartIT extends ESRestTestCase { .endObject(); }); } else { + ensureGreen(index); // wait for source index to be available on both nodes before starting shrink + String updateSettingsRequestBody = "{\"settings\": {\"index.blocks.write\": true}}"; Response rsp = client().performRequest("PUT", "/" + index + "/_settings", Collections.emptyMap(), new StringEntity(updateSettingsRequestBody, ContentType.APPLICATION_JSON));