diff --git a/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/WatchBackwardsCompatibilityIT.java b/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/WatchBackwardsCompatibilityIT.java index 564242f1b5b..521f107f45c 100644 --- a/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/WatchBackwardsCompatibilityIT.java +++ b/qa/rolling-upgrade/src/test/java/org/elasticsearch/upgrades/WatchBackwardsCompatibilityIT.java @@ -187,15 +187,7 @@ public class WatchBackwardsCompatibilityIT extends ESRestTestCase { ensureWatcherStopped(); executeAgainstRandomNode(client -> assertOK(client.performRequest("POST", "/_xpack/watcher/_start"))); - executeAgainstMasterNode(client -> assertBusy(() -> { - Response response = client.performRequest("GET", "_xpack/watcher/stats"); - String responseBody = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8); - // TODO once the serialization fix is in here, we can check for concrete fields if the run against a 5.x or a 6.x node - // using a checkedbiconsumer, that provides info against which node the request runs - assertThat(responseBody, not(containsString("\"watcher_state\":\"starting\""))); - assertThat(responseBody, not(containsString("\"watcher_state\":\"stopping\""))); - assertThat(responseBody, not(containsString("\"watcher_state\":\"stopped\""))); - })); + ensureWatcherStarted(); } public void testWatchCrudApis() throws Exception { @@ -260,6 +252,7 @@ public class WatchBackwardsCompatibilityIT extends ESRestTestCase { ensureWatcherStopped(); assertOK(client.performRequest("POST", "/_xpack/watcher/_start")); logger.info("started watcher manually after running upgrade"); + ensureWatcherStarted(); } } } @@ -311,6 +304,16 @@ public class WatchBackwardsCompatibilityIT extends ESRestTestCase { })); } + private void ensureWatcherStarted() throws Exception { + executeAgainstMasterNode(client -> assertBusy(() -> { + Response response = client.performRequest("GET", "_xpack/watcher/stats"); + String responseBody = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8); + assertThat(responseBody, not(containsString("\"watcher_state\":\"starting\""))); + assertThat(responseBody, not(containsString("\"watcher_state\":\"stopping\""))); + assertThat(responseBody, not(containsString("\"watcher_state\":\"stopped\""))); + })); + } + private void assertOK(Response response) throws IOException { assertThat(response.getStatusLine().getStatusCode(), anyOf(equalTo(200), equalTo(201))); // consume that entity, otherwise the input stream will not be closed