[TEST] Use better REST endpoints for testing watch actions

This is the x-pack side of https://github.com/elastic/elasticsearch/pull/24437

It changes two things, for the disable tests, it uses a valid endpoint instead
of a previously invalid endpoint that happened to return a 400 because the
endpoint was bad, regardless of if watcher was disabled.

The other change is to create the watches index by putting a watch using the
correct API, rather than manually creating the index. This is because
`RestHijackOperationAction` hijacks operations like this and stops accessing the
endpoint in a regular manner.

Original commit: elastic/x-pack-elasticsearch@3be78d9aea
This commit is contained in:
Lee Hinman 2017-06-23 10:17:59 -06:00
parent c035adb568
commit b66560fa85
2 changed files with 32 additions and 6 deletions

View File

@ -70,7 +70,7 @@ public class WatcherPluginDisableTests extends ESIntegTestCase {
public void testRestEndpoints() throws Exception {
try {
getRestClient().performRequest("GET", "/_xpack/watcher");
getRestClient().performRequest("GET", "/_xpack/watcher/watch/my-watch");
fail("request should have failed");
} catch(ResponseException e) {
assertThat(e.getResponse().getStatusLine().getStatusCode(), is(HttpStatus.SC_BAD_REQUEST));

View File

@ -4,12 +4,38 @@
cluster.health:
wait_for_status: yellow
# ensure index exists, but ignore if it does already
# this test should ensure the watch is missing, while the index is there
# ensure index exists by creating a different watch
- do:
indices.create:
index: .watches
ignore: 400
xpack.watcher.put_watch:
id: "other"
body: >
{
"trigger": {
"schedule": {
"hourly": {
"minute": [ 0, 5 ]
}
}
},
"input": {
"simple": {
"payload": {
"send": "yes"
}
}
},
"condition": {
"always": {}
},
"actions": {
"test_index": {
"index": {
"index": "test",
"doc_type": "test2"
}
}
}
}
- do:
catch: missing