Skip to content

Commit 0f2d26b

Browse files
committed
Unmute 'Test url escaping with url mustache function' webhook watcher test (#50439)
Some changes had to be made in order to make the test pass due to the removal or types. Added some more assertions. The failure description in this comment [0] indicates that the rest handler couldn't be found. The test passes now. I plan to merge this into master and see how CI reacts, if it handles this change well then I will also unmute this test in 7 dot x branch. Also check watch count after stopping watcher in test teardown and disabled slm in smoke test watcher qa test. Relates to #41172 0: #41172 (comment)
1 parent 2362c43 commit 0f2d26b

File tree

3 files changed

+18
-16
lines changed

3 files changed

+18
-16
lines changed

x-pack/qa/smoke-test-watcher/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ dependencies {
88

99
testClusters.integTest {
1010
testDistribution = 'DEFAULT'
11+
setting 'xpack.slm.enabled', 'false'
1112
setting 'xpack.ilm.enabled', 'false'
1213
setting 'xpack.security.enabled', 'false'
1314
setting 'xpack.monitoring.enabled', 'false'

x-pack/qa/smoke-test-watcher/src/test/java/org/elasticsearch/smoketest/WatcherRestIT.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import com.carrotsearch.randomizedtesting.annotations.Name;
99
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
10+
import org.elasticsearch.client.Request;
1011
import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
1112
import org.elasticsearch.test.rest.yaml.ClientYamlTestResponse;
1213
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
@@ -19,6 +20,7 @@
1920
import static java.util.Collections.emptyList;
2021
import static java.util.Collections.emptyMap;
2122
import static java.util.Collections.singletonMap;
23+
import static org.hamcrest.Matchers.equalTo;
2224
import static org.hamcrest.Matchers.is;
2325

2426
/** Runs rest tests against external cluster */
@@ -70,13 +72,19 @@ public void startWatcher() throws Exception {
7072

7173
@After
7274
public void stopWatcher() throws Exception {
75+
Request deleteWatchesIndexRequest = new Request("DELETE", "/.watches");
76+
deleteWatchesIndexRequest.addParameter("ignore_unavailable", "true");
77+
adminClient().performRequest(deleteWatchesIndexRequest);
78+
7379
assertBusy(() -> {
7480
ClientYamlTestResponse response =
7581
getAdminExecutionContext().callApi("watcher.stats", emptyMap(), emptyList(), emptyMap());
7682
String state = (String) response.evaluate("stats.0.watcher_state");
7783

7884
switch (state) {
7985
case "stopped":
86+
int watcherCount = (int) response.evaluate("stats.0.watch_count");
87+
assertThat(watcherCount, equalTo(0));
8088
// all good here, we are done
8189
break;
8290
case "stopping":

x-pack/qa/smoke-test-watcher/src/test/resources/rest-api-spec/test/mustache/50_webhook_url_escaping.yml

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,12 @@
11
---
22
"Test url escaping with url mustache function":
3-
- skip:
4-
version: "all"
5-
reason: "AwaitsFix https://github.com/elastic/elasticsearch/issues/41172"
6-
- do:
7-
cluster.health:
8-
wait_for_status: yellow
9-
103
- do:
114
index:
125
index: <date-index-{now/d}>
13-
type: log
146
id: 1
157
refresh: true
168
body: { foo: bar }
179

18-
- do: {watcher.stats:{}}
19-
- match: { "stats.0.watcher_state": "started" }
20-
- match: { "stats.0.watch_count": 0 }
21-
2210
# extract http host and port from master node
2311
- do:
2412
cluster.state: {}
@@ -36,10 +24,15 @@
3624
pipeline:
3725
description: _description
3826
processors: [ grok: { field: host, patterns : ["%{IPORHOST:hostname}:%{NUMBER:port:int}"] } ]
39-
docs: [ { _index: index, _type: type, _id: id, _source: { host: $host } } ]
27+
docs: [ { _index: index, _id: id, _source: { host: $host } } ]
4028
- set: { docs.0.doc._source.hostname: hostname }
4129
- set: { docs.0.doc._source.port: port }
4230

31+
- do:
32+
count:
33+
index: <date-index-{now/d}>
34+
- match: {count: 1}
35+
4336
- do:
4437
watcher.put_watch:
4538
id: "test_watch"
@@ -67,7 +60,7 @@
6760
method: PUT
6861
host: $hostname
6962
port: $port
70-
path: "/{{#url}}{{ctx.metadata.index}}{{/url}}/log/2"
63+
path: "/{{#url}}{{ctx.metadata.index}}{{/url}}/_doc/2"
7164
params:
7265
refresh: "true"
7366
body: "{ \"foo\": \"bar\" }"
@@ -78,11 +71,11 @@
7871
- do:
7972
watcher.execute_watch:
8073
id: "test_watch"
74+
- match: {watch_record.result.condition.met: true}
75+
- match: {watch_record.result.actions.0.status: 'success'}
8176

8277
- do:
8378
count:
8479
index: <date-index-{now/d}>
85-
type: log
8680

8781
- match: {count : 2}
88-

0 commit comments

Comments
 (0)