From 6d2ca116b9610cc181da321b5100a17af2f91f3d Mon Sep 17 00:00:00 2001 From: Shay Banon Date: Thu, 18 Jun 2015 20:30:25 +0200 Subject: [PATCH] [TEST] assertBusy on hasUnassigned on fast machines, node leave might not move shards to unassigned right away, wait for it --- .../routing/DelayedAllocationTests.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/DelayedAllocationTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/DelayedAllocationTests.java index 846c3e5d2bb..61dabe02a4b 100644 --- a/core/src/test/java/org/elasticsearch/cluster/routing/DelayedAllocationTests.java +++ b/core/src/test/java/org/elasticsearch/cluster/routing/DelayedAllocationTests.java @@ -73,7 +73,12 @@ public class DelayedAllocationTests extends ElasticsearchIntegrationTest { ensureGreen("test"); indexRandomData(); internalCluster().stopRandomNode(InternalTestCluster.nameFilter(findNodeWithShard())); - assertThat(client().admin().cluster().prepareState().all().get().getState().routingNodes().hasUnassigned(), equalTo(true)); + assertBusy(new Runnable() { + @Override + public void run() { + assertThat(client().admin().cluster().prepareState().all().get().getState().routingNodes().hasUnassigned(), equalTo(true)); + } + }); assertThat(client().admin().cluster().prepareHealth().get().getDelayedUnassignedShards(), equalTo(1)); internalCluster().startNode(); // this will use the same data location as the stopped node ensureGreen("test"); @@ -116,7 +121,12 @@ public class DelayedAllocationTests extends ElasticsearchIntegrationTest { ensureGreen("test"); indexRandomData(); internalCluster().stopRandomNode(InternalTestCluster.nameFilter(findNodeWithShard())); - assertThat(client().admin().cluster().prepareState().all().get().getState().routingNodes().hasUnassigned(), equalTo(true)); + assertBusy(new Runnable() { + @Override + public void run() { + assertThat(client().admin().cluster().prepareState().all().get().getState().routingNodes().hasUnassigned(), equalTo(true)); + } + }); assertThat(client().admin().cluster().prepareHealth().get().getDelayedUnassignedShards(), equalTo(1)); assertAcked(client().admin().indices().prepareUpdateSettings("test").setSettings(Settings.builder().put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING, TimeValue.timeValueMillis(100))).get()); ensureGreen("test"); @@ -138,7 +148,12 @@ public class DelayedAllocationTests extends ElasticsearchIntegrationTest { ensureGreen("test"); indexRandomData(); internalCluster().stopRandomNode(InternalTestCluster.nameFilter(findNodeWithShard())); - assertThat(client().admin().cluster().prepareState().all().get().getState().routingNodes().hasUnassigned(), equalTo(true)); + assertBusy(new Runnable() { + @Override + public void run() { + assertThat(client().admin().cluster().prepareState().all().get().getState().routingNodes().hasUnassigned(), equalTo(true)); + } + }); assertThat(client().admin().cluster().prepareHealth().get().getDelayedUnassignedShards(), equalTo(1)); assertAcked(client().admin().indices().prepareUpdateSettings("test").setSettings(Settings.builder().put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING, TimeValue.timeValueMillis(0))).get()); ensureGreen("test");