From 427563132e6ff272202e6ffe18034f095aba10ca Mon Sep 17 00:00:00 2001 From: Karel Minarik Date: Fri, 1 Jul 2016 20:13:21 +0200 Subject: [PATCH] Watcher: Added `teardown` sections to the REST tests The tests have been failing because they haven't cleaned up the environment after their run, leaving documents with watches behind. This patch adds `teardown` sections which delete the documents created by tests. Related: elastic/elasticsearch#2648 Closes elastic/elasticsearch#2690 Original commit: elastic/x-pack-elasticsearch@e34e40d879d72e7575cf2f571bc8567b4751665e --- .../test/xpack/watcher/get_watch/10_basic.yaml | 11 ++++++++++- .../getting_started/10_monitor_cluster_health.yaml | 12 ++++++++++-- .../20_put_watch_with_throttle_period.yaml | 13 +++++++++++-- .../30_put_watch_with_action_throttle_period.yaml | 13 +++++++++++-- .../watcher/put_watch/40_put_watch_as_inactive.yaml | 13 +++++++++++-- 5 files changed, 53 insertions(+), 9 deletions(-) diff --git a/elasticsearch/x-pack/watcher/src/test/resources/rest-api-spec/test/xpack/watcher/get_watch/10_basic.yaml b/elasticsearch/x-pack/watcher/src/test/resources/rest-api-spec/test/xpack/watcher/get_watch/10_basic.yaml index 6fe44ebf0b3..355a52a71aa 100644 --- a/elasticsearch/x-pack/watcher/src/test/resources/rest-api-spec/test/xpack/watcher/get_watch/10_basic.yaml +++ b/elasticsearch/x-pack/watcher/src/test/resources/rest-api-spec/test/xpack/watcher/get_watch/10_basic.yaml @@ -1,9 +1,18 @@ --- -"Test get watch api": +setup: - do: cluster.health: wait_for_status: yellow +--- +teardown: + - do: + xpack.watcher.delete_watch: + id: "my_watch" + ignore: 404 + +--- +"Test get watch api": - do: xpack.watcher.put_watch: id: "my_watch" diff --git a/elasticsearch/x-pack/watcher/src/test/resources/rest-api-spec/test/xpack/watcher/getting_started/10_monitor_cluster_health.yaml b/elasticsearch/x-pack/watcher/src/test/resources/rest-api-spec/test/xpack/watcher/getting_started/10_monitor_cluster_health.yaml index dbd737057ed..e3353c4cf6c 100644 --- a/elasticsearch/x-pack/watcher/src/test/resources/rest-api-spec/test/xpack/watcher/getting_started/10_monitor_cluster_health.yaml +++ b/elasticsearch/x-pack/watcher/src/test/resources/rest-api-spec/test/xpack/watcher/getting_started/10_monitor_cluster_health.yaml @@ -1,10 +1,18 @@ --- -"Getting started - Monitor cluster health": +setup: - do: cluster.health: - wait_for_status: yellow + wait_for_status: yellow +--- +teardown: + - do: + xpack.watcher.delete_watch: + id: "cluster_health_watch" + ignore: 404 +--- +"Getting started - Monitor cluster health": - do: xpack.watcher.stats: {} - match: { "watcher_state": "started" } diff --git a/elasticsearch/x-pack/watcher/src/test/resources/rest-api-spec/test/xpack/watcher/put_watch/20_put_watch_with_throttle_period.yaml b/elasticsearch/x-pack/watcher/src/test/resources/rest-api-spec/test/xpack/watcher/put_watch/20_put_watch_with_throttle_period.yaml index d9ba99221cd..4d36f92e92d 100644 --- a/elasticsearch/x-pack/watcher/src/test/resources/rest-api-spec/test/xpack/watcher/put_watch/20_put_watch_with_throttle_period.yaml +++ b/elasticsearch/x-pack/watcher/src/test/resources/rest-api-spec/test/xpack/watcher/put_watch/20_put_watch_with_throttle_period.yaml @@ -1,9 +1,18 @@ --- -"Test put watch api with watch level throttle": +setup: - do: cluster.health: - wait_for_status: yellow + wait_for_status: yellow +--- +teardown: + - do: + xpack.watcher.delete_watch: + id: "my_watch1" + ignore: 404 + +--- +"Test put watch api with watch level throttle": - do: xpack.watcher.put_watch: id: "my_watch1" diff --git a/elasticsearch/x-pack/watcher/src/test/resources/rest-api-spec/test/xpack/watcher/put_watch/30_put_watch_with_action_throttle_period.yaml b/elasticsearch/x-pack/watcher/src/test/resources/rest-api-spec/test/xpack/watcher/put_watch/30_put_watch_with_action_throttle_period.yaml index c53847a0064..30348737d2e 100644 --- a/elasticsearch/x-pack/watcher/src/test/resources/rest-api-spec/test/xpack/watcher/put_watch/30_put_watch_with_action_throttle_period.yaml +++ b/elasticsearch/x-pack/watcher/src/test/resources/rest-api-spec/test/xpack/watcher/put_watch/30_put_watch_with_action_throttle_period.yaml @@ -1,9 +1,18 @@ --- -"Test put watch api with action level throttle period": +setup: - do: cluster.health: - wait_for_status: yellow + wait_for_status: yellow +--- +teardown: + - do: + xpack.watcher.delete_watch: + id: "my_watch1" + ignore: 404 + +--- +"Test put watch api with action level throttle period": - do: xpack.watcher.put_watch: id: "my_watch1" diff --git a/elasticsearch/x-pack/watcher/src/test/resources/rest-api-spec/test/xpack/watcher/put_watch/40_put_watch_as_inactive.yaml b/elasticsearch/x-pack/watcher/src/test/resources/rest-api-spec/test/xpack/watcher/put_watch/40_put_watch_as_inactive.yaml index 3aabc40a967..ee25ab5acc1 100644 --- a/elasticsearch/x-pack/watcher/src/test/resources/rest-api-spec/test/xpack/watcher/put_watch/40_put_watch_as_inactive.yaml +++ b/elasticsearch/x-pack/watcher/src/test/resources/rest-api-spec/test/xpack/watcher/put_watch/40_put_watch_as_inactive.yaml @@ -1,15 +1,24 @@ --- -"Test put inactive watch": +setup: - do: cluster.health: wait_for_status: yellow +--- +teardown: + - do: + xpack.watcher.delete_watch: + id: "my_watch" + ignore: 404 + +--- +"Test put inactive watch": - do: xpack.watcher.put_watch: id: "my_watch" master_timeout: "40s" active: false - body: > + body: > { "trigger": { "schedule": {