From ed289dc6c73c6e71fb5886c75bee560701874a8c Mon Sep 17 00:00:00 2001 From: Igor Motov Date: Thu, 2 May 2013 15:36:40 -0400 Subject: [PATCH] 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. --- .../admin/cluster/health/ClusterHealthRequestBuilder.java | 5 +++++ .../test/integration/cluster/SimpleDataNodesTests.java | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthRequestBuilder.java b/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthRequestBuilder.java index bc0ae8fb99f..f5212513f9f 100644 --- a/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthRequestBuilder.java +++ b/src/main/java/org/elasticsearch/action/admin/cluster/health/ClusterHealthRequestBuilder.java @@ -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 listener) { ((ClusterAdminClient) client).health(request, listener); diff --git a/src/test/java/org/elasticsearch/test/integration/cluster/SimpleDataNodesTests.java b/src/test/java/org/elasticsearch/test/integration/cluster/SimpleDataNodesTests.java index d143f910555..2fc9830bdea 100644 --- a/src/test/java/org/elasticsearch/test/integration/cluster/SimpleDataNodesTests.java +++ b/src/test/java/org/elasticsearch/test/integration/cluster/SimpleDataNodesTests.java @@ -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"));