From 0b102f63721472d7de89c21c78c9210aed90e7de Mon Sep 17 00:00:00 2001 From: Yannick Welsch Date: Thu, 7 Dec 2017 10:23:36 +0100 Subject: [PATCH] [TEST] Fix testOpenWaitingForActiveShardsFailed This test periodically fails if the nodes that apply the cluster state fail to ack the change within 100ms. This commit changes the checks on the test so that it still checks that the open command has taken effect, but that the wait for active shards has actually failed. --- .../org/elasticsearch/indices/state/OpenCloseIndexIT.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/src/test/java/org/elasticsearch/indices/state/OpenCloseIndexIT.java b/core/src/test/java/org/elasticsearch/indices/state/OpenCloseIndexIT.java index f0808f35741..02191bc22fa 100644 --- a/core/src/test/java/org/elasticsearch/indices/state/OpenCloseIndexIT.java +++ b/core/src/test/java/org/elasticsearch/indices/state/OpenCloseIndexIT.java @@ -298,7 +298,7 @@ public class OpenCloseIndexIT extends ESIntegTestCase { assertIndexIsOpened("test1", "test2"); } - public void testOpenWaitingForActiveShardsFailed() { + public void testOpenWaitingForActiveShardsFailed() throws Exception { Client client = client(); Settings settings = Settings.builder() .put(IndexMetaData.INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), 1) @@ -308,8 +308,10 @@ public class OpenCloseIndexIT extends ESIntegTestCase { assertAcked(client.admin().indices().prepareClose("test").get()); OpenIndexResponse response = client.admin().indices().prepareOpen("test").setTimeout("100ms").setWaitForActiveShards(2).get(); - assertAcked(response); assertThat(response.isShardsAcknowledged(), equalTo(false)); + assertBusy(() -> assertThat(client.admin().cluster().prepareState().get().getState().metaData().index("test").getState(), + equalTo(IndexMetaData.State.OPEN))); + ensureGreen("test"); } private void assertIndexIsOpened(String... indices) {