Skip to content

Commit 180c0c3

Browse files
committed
watcher: Fix Smoketests to ensure correct start/stop of Watcher
Ensure that Watcher is correctly started and stopped between tests for SmokeTestWatcherWithSecurityIT and SmokeTestWatcherWithSecurityClientYamlTestSuiteIT. 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 elastic#33291 closes elastic#29877
1 parent 216c761 commit 180c0c3

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

x-pack/qa/smoke-test-watcher-with-security/src/test/java/org/elasticsearch/smoketest/SmokeTestWatcherWithSecurityClientYamlTestSuiteIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public void startWatcher() throws Exception {
6262
getAdminExecutionContext().callApi("xpack.watcher.start", emptyMap(), emptyList(), emptyMap());
6363
boolean isAcknowledged = (boolean) startResponse.evaluate("acknowledged");
6464
assertThat(isAcknowledged, is(true));
65-
break;
65+
throw new AssertionError("waiting until stopped state reached started state");
6666
case "stopping":
6767
throw new AssertionError("waiting until stopping state reached stopped state to start again");
6868
case "starting":
@@ -104,7 +104,7 @@ public void stopWatcher() throws Exception {
104104
getAdminExecutionContext().callApi("xpack.watcher.stop", emptyMap(), emptyList(), emptyMap());
105105
boolean isAcknowledged = (boolean) stopResponse.evaluate("acknowledged");
106106
assertThat(isAcknowledged, is(true));
107-
break;
107+
throw new AssertionError("waiting until started state reached stopped state");
108108
default:
109109
throw new AssertionError("unknown state[" + state + "]");
110110
}

x-pack/qa/smoke-test-watcher-with-security/src/test/java/org/elasticsearch/smoketest/SmokeTestWatcherWithSecurityIT.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public void startWatcher() throws Exception {
6363
Response startResponse = adminClient().performRequest(new Request("POST", "/_xpack/watcher/_start"));
6464
Map<String, Object> responseMap = entityAsMap(startResponse);
6565
assertThat(responseMap, hasEntry("acknowledged", true));
66-
break;
66+
throw new AssertionError("waiting until stopped state reached started state");
6767
case "stopping":
6868
throw new AssertionError("waiting until stopping state reached stopped state to start again");
6969
case "starting":
@@ -108,7 +108,7 @@ public void stopWatcher() throws Exception {
108108
Response stopResponse = adminClient().performRequest(new Request("POST", "/_xpack/watcher/_stop"));
109109
String body = EntityUtils.toString(stopResponse.getEntity());
110110
assertThat(body, containsString("\"acknowledged\":true"));
111-
break;
111+
throw new AssertionError("waiting until started state reached stopped state");
112112
default:
113113
throw new AssertionError("unknown state[" + state + "]");
114114
}

0 commit comments

Comments
 (0)