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: https://github.com/elastic/elasticsearch/issues/41172#issuecomment-496993976
This commit is contained in:
Martijn van Groningen 2019-12-23 10:48:58 +01:00
parent 2362c430cd
commit 0f2d26bdca
No known key found for this signature in database
GPG Key ID: AB236F4FCF2AF12A
3 changed files with 18 additions and 16 deletions

View File

@ -8,6 +8,7 @@ dependencies {
testClusters.integTest { testClusters.integTest {
testDistribution = 'DEFAULT' testDistribution = 'DEFAULT'
setting 'xpack.slm.enabled', 'false'
setting 'xpack.ilm.enabled', 'false' setting 'xpack.ilm.enabled', 'false'
setting 'xpack.security.enabled', 'false' setting 'xpack.security.enabled', 'false'
setting 'xpack.monitoring.enabled', 'false' setting 'xpack.monitoring.enabled', 'false'

View File

@ -7,6 +7,7 @@ package org.elasticsearch.smoketest;
import com.carrotsearch.randomizedtesting.annotations.Name; import com.carrotsearch.randomizedtesting.annotations.Name;
import com.carrotsearch.randomizedtesting.annotations.ParametersFactory; import com.carrotsearch.randomizedtesting.annotations.ParametersFactory;
import org.elasticsearch.client.Request;
import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate; import org.elasticsearch.test.rest.yaml.ClientYamlTestCandidate;
import org.elasticsearch.test.rest.yaml.ClientYamlTestResponse; import org.elasticsearch.test.rest.yaml.ClientYamlTestResponse;
import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase; import org.elasticsearch.test.rest.yaml.ESClientYamlSuiteTestCase;
@ -19,6 +20,7 @@ import java.util.concurrent.TimeUnit;
import static java.util.Collections.emptyList; import static java.util.Collections.emptyList;
import static java.util.Collections.emptyMap; import static java.util.Collections.emptyMap;
import static java.util.Collections.singletonMap; import static java.util.Collections.singletonMap;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is;
/** Runs rest tests against external cluster */ /** Runs rest tests against external cluster */
@ -70,6 +72,10 @@ public class WatcherRestIT extends ESClientYamlSuiteTestCase {
@After @After
public void stopWatcher() throws Exception { public void stopWatcher() throws Exception {
Request deleteWatchesIndexRequest = new Request("DELETE", "/.watches");
deleteWatchesIndexRequest.addParameter("ignore_unavailable", "true");
adminClient().performRequest(deleteWatchesIndexRequest);
assertBusy(() -> { assertBusy(() -> {
ClientYamlTestResponse response = ClientYamlTestResponse response =
getAdminExecutionContext().callApi("watcher.stats", emptyMap(), emptyList(), emptyMap()); getAdminExecutionContext().callApi("watcher.stats", emptyMap(), emptyList(), emptyMap());
@ -77,6 +83,8 @@ public class WatcherRestIT extends ESClientYamlSuiteTestCase {
switch (state) { switch (state) {
case "stopped": case "stopped":
int watcherCount = (int) response.evaluate("stats.0.watch_count");
assertThat(watcherCount, equalTo(0));
// all good here, we are done // all good here, we are done
break; break;
case "stopping": case "stopping":

View File

@ -1,24 +1,12 @@
--- ---
"Test url escaping with url mustache function": "Test url escaping with url mustache function":
- skip:
version: "all"
reason: "AwaitsFix https://github.com/elastic/elasticsearch/issues/41172"
- do:
cluster.health:
wait_for_status: yellow
- do: - do:
index: index:
index: <date-index-{now/d}> index: <date-index-{now/d}>
type: log
id: 1 id: 1
refresh: true refresh: true
body: { foo: bar } body: { foo: bar }
- do: {watcher.stats:{}}
- match: { "stats.0.watcher_state": "started" }
- match: { "stats.0.watch_count": 0 }
# extract http host and port from master node # extract http host and port from master node
- do: - do:
cluster.state: {} cluster.state: {}
@ -36,10 +24,15 @@
pipeline: pipeline:
description: _description description: _description
processors: [ grok: { field: host, patterns : ["%{IPORHOST:hostname}:%{NUMBER:port:int}"] } ] processors: [ grok: { field: host, patterns : ["%{IPORHOST:hostname}:%{NUMBER:port:int}"] } ]
docs: [ { _index: index, _type: type, _id: id, _source: { host: $host } } ] docs: [ { _index: index, _id: id, _source: { host: $host } } ]
- set: { docs.0.doc._source.hostname: hostname } - set: { docs.0.doc._source.hostname: hostname }
- set: { docs.0.doc._source.port: port } - set: { docs.0.doc._source.port: port }
- do:
count:
index: <date-index-{now/d}>
- match: {count: 1}
- do: - do:
watcher.put_watch: watcher.put_watch:
id: "test_watch" id: "test_watch"
@ -67,7 +60,7 @@
method: PUT method: PUT
host: $hostname host: $hostname
port: $port port: $port
path: "/{{#url}}{{ctx.metadata.index}}{{/url}}/log/2" path: "/{{#url}}{{ctx.metadata.index}}{{/url}}/_doc/2"
params: params:
refresh: "true" refresh: "true"
body: "{ \"foo\": \"bar\" }" body: "{ \"foo\": \"bar\" }"
@ -78,11 +71,11 @@
- do: - do:
watcher.execute_watch: watcher.execute_watch:
id: "test_watch" id: "test_watch"
- match: {watch_record.result.condition.met: true}
- match: {watch_record.result.actions.0.status: 'success'}
- do: - do:
count: count:
index: <date-index-{now/d}> index: <date-index-{now/d}>
type: log
- match: {count : 2} - match: {count : 2}