Skip to content

Commit ed95aae

Browse files
authored
Use watcher get api instead of .watches index. (#64199)
Replaces querying .watches index with using the watcher get api where possible. These cases queried a specific watch by id and then checked if the count is 1 and some properties of the actual watch. This can be replaced by just using the get watch api. Relates to #62501
1 parent 9c9da2f commit ed95aae

File tree

5 files changed

+22
-66
lines changed

5 files changed

+22
-66
lines changed

x-pack/plugin/watcher/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/watcher/ack_watch/10_basic.yml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,11 @@
4646
- match: { "status.actions.test_index.ack.state" : "awaits_successful_execution" }
4747

4848
- do:
49-
warnings:
50-
- "this request accesses system indices: [.watches], but in a future major version, direct access to system indices will be prevented by default"
51-
search:
52-
rest_total_hits_as_int: true
53-
index: .watches
54-
body: { "query": { "term": { "_id": "my_watch" } } }
55-
- match: { hits.total: 1 }
56-
- match: { hits.hits.0._source.status.actions.test_index.ack.state: "awaits_successful_execution" }
49+
watcher.get_watch:
50+
id: "my_watch"
51+
- match: { found: true }
52+
- match: { _id: "my_watch" }
53+
- match: { status.actions.test_index.ack.state: "awaits_successful_execution" }
5754

5855
- do:
5956
watcher.delete_watch:

x-pack/plugin/watcher/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/watcher/activate_watch/10_basic.yml

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,6 @@
4949

5050
- match: { status.state.active : false }
5151

52-
- do:
53-
warnings:
54-
- "this request accesses system indices: [.watches], but in a future major version, direct access to system indices will be prevented by default"
55-
search:
56-
rest_total_hits_as_int: true
57-
index: .watches
58-
body: { "query": { "term": { "_id": "my_watch" } } }
59-
- match: { hits.total: 1 }
60-
- match: { hits.hits.0._source.status.state.active: false }
61-
6252
- do:
6353
watcher.get_watch:
6454
id: "my_watch"
@@ -72,16 +62,6 @@
7262

7363
- match: { status.state.active : true }
7464

75-
- do:
76-
warnings:
77-
- "this request accesses system indices: [.watches], but in a future major version, direct access to system indices will be prevented by default"
78-
search:
79-
rest_total_hits_as_int: true
80-
index: .watches
81-
body: { "query": { "term": { "_id": "my_watch" } } }
82-
- match: { hits.total: 1 }
83-
- match: { hits.hits.0._source.status.state.active: true }
84-
8565
- do:
8666
watcher.get_watch:
8767
id: "my_watch"

x-pack/plugin/watcher/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/watcher/delete_watch/10_basic.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,23 @@ teardown:
4848
- match: { _id: "my_watch" }
4949
- match: { created: true }
5050

51+
- do:
52+
watcher.get_watch:
53+
id: "my_watch"
54+
- match: { found: true }
55+
- match: { _id: "my_watch" }
56+
5157
- do:
5258
watcher.delete_watch:
5359
id: "my_watch"
5460
- match: { found: true }
5561

5662
- do:
57-
warnings:
58-
- "this request accesses system indices: [.watches], but in a future major version, direct access to system indices will be prevented by default"
59-
search:
60-
rest_total_hits_as_int: true
61-
index: .watches
62-
body: { "query": { "term": { "_id": "my_watch" } } }
63-
- match: { hits.total: 0 }
63+
catch: missing
64+
watcher.get_watch:
65+
id: "my_watch"
66+
- match: { found: false }
67+
- match: { _id: "my_watch" }
6468

6569
---
6670
"Non existent watch returns 404":

x-pack/plugin/watcher/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/watcher/get_watch/10_basic.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,6 @@ teardown:
4848
- match: { _id: "my_watch" }
4949
- match: { created: true }
5050

51-
- do:
52-
warnings:
53-
- "this request accesses system indices: [.watches], but in a future major version, direct access to system indices will be prevented by default"
54-
search:
55-
rest_total_hits_as_int: true
56-
index: .watches
57-
body: { "query": { "term": { "_id": "my_watch" } } }
58-
- match: { hits.total: 1 }
59-
6051
- do:
6152
watcher.get_watch:
6253
id: "my_watch"

x-pack/plugin/watcher/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/watcher/put_watch/80_put_get_watch_with_passwords.yml

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -262,25 +262,9 @@ setup:
262262
}
263263
264264
- do:
265-
warnings:
266-
- "this request accesses system indices: [.watches], but in a future major version, direct access to system indices will be prevented by default"
267-
search:
268-
rest_total_hits_as_int: true
269-
index: .watches
270-
body: >
271-
{
272-
"query": {
273-
"term": {
274-
"_id": {
275-
"value": "watch_with_seq_no"
276-
}
277-
}
278-
}
279-
}
280-
281-
282-
- match: { hits.total: 1 }
283-
- match: { hits.hits.0._id: "watch_with_seq_no" }
284-
- match: { hits.hits.0._source.input.http.request.auth.basic.username: "new_user" }
285-
- match: { hits.hits.0._source.input.http.request.auth.basic.password: "pass" }
286-
265+
watcher.get_watch:
266+
id: "watch_with_seq_no"
267+
- match: { found: true }
268+
- match: { _id: "watch_with_seq_no" }
269+
- match: { watch.input.http.request.auth.basic.username: "new_user" }
270+
- match: { watch.input.http.request.auth.basic.password: "::es_redacted::" }

0 commit comments

Comments
 (0)