[TEST] assertBusy on hasUnassigned

on fast machines, node leave might not move shards to unassigned right away, wait for it
This commit is contained in:
Shay Banon 2015-06-18 20:30:25 +02:00
parent 256f3d21ce
commit 6d2ca116b9
1 changed files with 18 additions and 3 deletions

View File

@ -73,7 +73,12 @@ public class DelayedAllocationTests extends ElasticsearchIntegrationTest {
ensureGreen("test"); ensureGreen("test");
indexRandomData(); indexRandomData();
internalCluster().stopRandomNode(InternalTestCluster.nameFilter(findNodeWithShard())); 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)); assertThat(client().admin().cluster().prepareHealth().get().getDelayedUnassignedShards(), equalTo(1));
internalCluster().startNode(); // this will use the same data location as the stopped node internalCluster().startNode(); // this will use the same data location as the stopped node
ensureGreen("test"); ensureGreen("test");
@ -116,7 +121,12 @@ public class DelayedAllocationTests extends ElasticsearchIntegrationTest {
ensureGreen("test"); ensureGreen("test");
indexRandomData(); indexRandomData();
internalCluster().stopRandomNode(InternalTestCluster.nameFilter(findNodeWithShard())); 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)); 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()); assertAcked(client().admin().indices().prepareUpdateSettings("test").setSettings(Settings.builder().put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING, TimeValue.timeValueMillis(100))).get());
ensureGreen("test"); ensureGreen("test");
@ -138,7 +148,12 @@ public class DelayedAllocationTests extends ElasticsearchIntegrationTest {
ensureGreen("test"); ensureGreen("test");
indexRandomData(); indexRandomData();
internalCluster().stopRandomNode(InternalTestCluster.nameFilter(findNodeWithShard())); 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)); 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()); assertAcked(client().admin().indices().prepareUpdateSettings("test").setSettings(Settings.builder().put(UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING, TimeValue.timeValueMillis(0))).get());
ensureGreen("test"); ensureGreen("test");