From b66560fa85e7e2a0fd4774207be9668c912ebf4c Mon Sep 17 00:00:00 2001 From: Lee Hinman Date: Fri, 23 Jun 2017 10:17:59 -0600 Subject: [PATCH] [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@3be78d9aea02080f5cd00d9b0bace78eec05616e --- .../watcher/WatcherPluginDisableTests.java | 2 +- .../test/watcher/get_watch/20_missing.yml | 36 ++++++++++++++++--- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/plugin/src/test/java/org/elasticsearch/xpack/watcher/WatcherPluginDisableTests.java b/plugin/src/test/java/org/elasticsearch/xpack/watcher/WatcherPluginDisableTests.java index 4215bf1aaae..904cb51c1dd 100644 --- a/plugin/src/test/java/org/elasticsearch/xpack/watcher/WatcherPluginDisableTests.java +++ b/plugin/src/test/java/org/elasticsearch/xpack/watcher/WatcherPluginDisableTests.java @@ -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)); diff --git a/plugin/src/test/resources/rest-api-spec/test/watcher/get_watch/20_missing.yml b/plugin/src/test/resources/rest-api-spec/test/watcher/get_watch/20_missing.yml index 3083b8bbb92..ee4fd2e7e43 100644 --- a/plugin/src/test/resources/rest-api-spec/test/watcher/get_watch/20_missing.yml +++ b/plugin/src/test/resources/rest-api-spec/test/watcher/get_watch/20_missing.yml @@ -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