From 73f71a22171c378e4029974712b36776be974096 Mon Sep 17 00:00:00 2001 From: David Turner Date: Thu, 18 Jul 2019 08:06:15 +0100 Subject: [PATCH] Wait for pending tasks in TransportSearchFailuresIT The change in #44433 introduces a state in which the cluster has no relocating shards but still has a pending reroute task which might start a shard relocation. `TransportSearchFailuresIT` failed on a PR build seemingly because it did not wait for this pending task to complete too, reporting more active shards than expected: 2> java.lang.AssertionError: Expected: <9> but: was <10> at __randomizedtesting.SeedInfo.seed([4057CA4301FE95FA:207EC88573747235]:0) at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:18) at org.junit.Assert.assertThat(Assert.java:956) at org.junit.Assert.assertThat(Assert.java:923) at org.elasticsearch.search.basic.TransportSearchFailuresIT.testFailedSearchWithWrongQuery(TransportSearchFailuresIT.java:97) This commit addresses this failure by waiting until there are neither pending tasks nor shard relocations in progress. --- .../elasticsearch/search/basic/TransportSearchFailuresIT.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/test/java/org/elasticsearch/search/basic/TransportSearchFailuresIT.java b/server/src/test/java/org/elasticsearch/search/basic/TransportSearchFailuresIT.java index 152a57a6c1387..03e856ba8b68b 100644 --- a/server/src/test/java/org/elasticsearch/search/basic/TransportSearchFailuresIT.java +++ b/server/src/test/java/org/elasticsearch/search/basic/TransportSearchFailuresIT.java @@ -86,7 +86,7 @@ public void testFailedSearchWithWrongQuery() throws Exception { ClusterHealthResponse clusterHealth = client() .admin() .cluster() - .health(clusterHealthRequest("test").waitForYellowStatus().waitForNoRelocatingShards(true) + .health(clusterHealthRequest("test").waitForYellowStatus().waitForNoRelocatingShards(true).waitForEvents(Priority.LANGUID) .waitForActiveShards(test.totalNumShards)).actionGet(); logger.info("Done Cluster Health, status {}", clusterHealth.getStatus()); assertThat(clusterHealth.isTimedOut(), equalTo(false));