Skip to content

Commit

Permalink
watcher: Fix integration tests to ensure correct start/stop of Watcher (
Browse files Browse the repository at this point in the history
#35271)

Ensure that Watcher is correctly started and stopped between tests for
SmokeTestWatcherWithSecurityIT,
SmokeTestWatcherWithSecurityClientYamlTestSuiteIT,
SmokeTestWatcherTestSuiteIT, WatcherRestIT,
XDocsClientYamlTestSuiteIT, and XPackRestIT

The change here is to throw an `AssertionError` instead of `break;` to
allow the `assertBusy()` to continue to busy wait until the desired
state is reached.

closes #33291, closes #29877, closes #34462, closes #30705, closes #34448
  • Loading branch information
jakelandis authored Nov 7, 2018
1 parent b1655c4 commit d7a4cef
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void reenableWatcher() throws Exception {
getAdminExecutionContext().callApi("xpack.watcher.start", emptyMap(), emptyList(), emptyMap());
boolean isAcknowledged = (boolean) startResponse.evaluate("acknowledged");
assertThat(isAcknowledged, is(true));
break;
throw new AssertionError("waiting until stopped state reached started state");
case "stopping":
throw new AssertionError("waiting until stopping state reached stopped state to start again");
case "starting":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ private void waitForWatcher() throws Exception {
getAdminExecutionContext().callApi("xpack.watcher.start", emptyMap(), emptyList(), emptyMap());
boolean isAcknowledged = (boolean) startResponse.evaluate("acknowledged");
assertThat(isAcknowledged, is(true));
break;
throw new AssertionError("waiting until stopped state reached started state");
case "stopping":
throw new AssertionError("waiting until stopping state reached stopped state to start again");
case "starting":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void startWatcher() throws Exception {
getAdminExecutionContext().callApi("xpack.watcher.start", emptyMap(), emptyList(), emptyMap());
boolean isAcknowledged = (boolean) startResponse.evaluate("acknowledged");
assertThat(isAcknowledged, is(true));
break;
throw new AssertionError("waiting until stopped state reached started state");
case "stopping":
throw new AssertionError("waiting until stopping state reached stopped state to start again");
case "starting":
Expand Down Expand Up @@ -104,7 +104,7 @@ public void stopWatcher() throws Exception {
getAdminExecutionContext().callApi("xpack.watcher.stop", emptyMap(), emptyList(), emptyMap());
boolean isAcknowledged = (boolean) stopResponse.evaluate("acknowledged");
assertThat(isAcknowledged, is(true));
break;
throw new AssertionError("waiting until started state reached stopped state");
default:
throw new AssertionError("unknown state[" + state + "]");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void startWatcher() throws Exception {
Response startResponse = adminClient().performRequest(new Request("POST", "/_xpack/watcher/_start"));
Map<String, Object> responseMap = entityAsMap(startResponse);
assertThat(responseMap, hasEntry("acknowledged", true));
break;
throw new AssertionError("waiting until stopped state reached started state");
case "stopping":
throw new AssertionError("waiting until stopping state reached stopped state to start again");
case "starting":
Expand Down Expand Up @@ -108,7 +108,7 @@ public void stopWatcher() throws Exception {
Response stopResponse = adminClient().performRequest(new Request("POST", "/_xpack/watcher/_stop"));
String body = EntityUtils.toString(stopResponse.getEntity());
assertThat(body, containsString("\"acknowledged\":true"));
break;
throw new AssertionError("waiting until started state reached stopped state");
default:
throw new AssertionError("unknown state[" + state + "]");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void startWatcher() throws Exception {
Response startResponse = adminClient().performRequest(new Request("POST", "/_xpack/watcher/_start"));
boolean isAcknowledged = ObjectPath.createFromResponse(startResponse).evaluate("acknowledged");
assertThat(isAcknowledged, is(true));
break;
throw new AssertionError("waiting until stopped state reached started state");
case "stopping":
throw new AssertionError("waiting until stopping state reached stopped state to start again");
case "starting":
Expand Down Expand Up @@ -87,7 +87,7 @@ public void stopWatcher() throws Exception {
Response stopResponse = adminClient().performRequest(new Request("POST", "/_xpack/watcher/_stop"));
boolean isAcknowledged = ObjectPath.createFromResponse(stopResponse).evaluate("acknowledged");
assertThat(isAcknowledged, is(true));
break;
throw new AssertionError("waiting until started state reached stopped state");
default:
throw new AssertionError("unknown state[" + state + "]");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void startWatcher() throws Exception {
getAdminExecutionContext().callApi("xpack.watcher.start", emptyMap(), emptyList(), emptyMap());
boolean isAcknowledged = (boolean) startResponse.evaluate("acknowledged");
assertThat(isAcknowledged, is(true));
break;
throw new AssertionError("waiting until stopped state reached started state");
case "stopping":
throw new AssertionError("waiting until stopping state reached stopped state to start again");
case "starting":
Expand Down Expand Up @@ -86,7 +86,7 @@ public void stopWatcher() throws Exception {
getAdminExecutionContext().callApi("xpack.watcher.stop", emptyMap(), emptyList(), emptyMap());
boolean isAcknowledged = (boolean) stopResponse.evaluate("acknowledged");
assertThat(isAcknowledged, is(true));
break;
throw new AssertionError("waiting until started state reached stopped state");
default:
throw new AssertionError("unknown state[" + state + "]");
}
Expand Down

0 comments on commit d7a4cef

Please sign in to comment.