watcher: Fix integration tests to ensure correct start/stop of Watcher (#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
This commit is contained in:
Jake Landis 2018-11-07 15:08:03 -06:00 committed by GitHub
parent b1655c468a
commit d7a4cef483
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 10 additions and 10 deletions

View File

@ -88,7 +88,7 @@ public class XDocsClientYamlTestSuiteIT extends XPackRestIT {
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":

View File

@ -111,7 +111,7 @@ public class XPackRestIT extends ESClientYamlSuiteTestCase {
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":

View File

@ -62,7 +62,7 @@ public class SmokeTestWatcherWithSecurityClientYamlTestSuiteIT extends ESClientY
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":
@ -104,7 +104,7 @@ public class SmokeTestWatcherWithSecurityClientYamlTestSuiteIT extends ESClientY
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 + "]");
}

View File

@ -63,7 +63,7 @@ public class SmokeTestWatcherWithSecurityIT extends ESRestTestCase {
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":
@ -108,7 +108,7 @@ public class SmokeTestWatcherWithSecurityIT extends ESRestTestCase {
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 + "]");
}

View File

@ -48,7 +48,7 @@ public class SmokeTestWatcherTestSuiteIT extends ESRestTestCase {
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":
@ -87,7 +87,7 @@ public class SmokeTestWatcherTestSuiteIT extends ESRestTestCase {
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 + "]");
}

View File

@ -44,7 +44,7 @@ public class WatcherRestIT extends ESClientYamlSuiteTestCase {
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":
@ -86,7 +86,7 @@ public class WatcherRestIT extends ESClientYamlSuiteTestCase {
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 + "]");
}