Improve stability of SimpleDataNodesTests

Make sure that we are waiting for the new state to be propagated to the node where we are executing the followup query that depends on this state.
This commit is contained in:
Igor Motov 2013-05-02 15:36:40 -04:00
parent c9c10273a6
commit ed289dc6c7
2 changed files with 7 additions and 2 deletions

View File

@ -88,6 +88,11 @@ public class ClusterHealthRequestBuilder extends MasterNodeOperationRequestBuild
return this;
}
public ClusterHealthRequestBuilder setLocal(boolean local) {
request.local(local);
return this;
}
@Override
protected void doExecute(ActionListener<ClusterHealthResponse> listener) {
((ClusterAdminClient) client).health(request, listener);

View File

@ -55,7 +55,7 @@ public class SimpleDataNodesTests extends AbstractNodesTests {
}
startNode("nonData2", settingsBuilder().put("node.data", false).build());
assertThat(client("nonData1").admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForNodes("2").execute().actionGet().isTimedOut(), equalTo(false));
assertThat(client("nonData2").admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForNodes("2").setLocal(true).execute().actionGet().isTimedOut(), equalTo(false));
// still no shard should be allocated
try {
@ -67,7 +67,7 @@ public class SimpleDataNodesTests extends AbstractNodesTests {
// now, start a node data, and see that it gets with shards
startNode("data1", settingsBuilder().put("node.data", true).build());
assertThat(client("nonData1").admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForNodes("3").execute().actionGet().isTimedOut(), equalTo(false));
assertThat(client("nonData2").admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setWaitForNodes("3").setLocal(true).execute().actionGet().isTimedOut(), equalTo(false));
IndexResponse indexResponse = client("nonData2").index(Requests.indexRequest("test").type("type1").id("1").source(source("1", "test"))).actionGet();
assertThat(indexResponse.getId(), equalTo("1"));