-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix passing params to template or script failed in watcher (#58559)
The main changes are: * Fix custom params are missing when using template or script in watcher's logging action or jira action. * Add yaml tests to test passing params to template or script successfully. Relates to #57625
- Loading branch information
1 parent
5065dbc
commit 500e12f
Showing
3 changed files
with
126 additions
and
1 deletion.
There are no files selected for viewing
67 changes: 67 additions & 0 deletions
67
...a/rest/src/yamlRestTest/resources/rest-api-spec/test/mustache/60_template_with_params.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
--- | ||
setup: | ||
- do: | ||
cluster.health: | ||
wait_for_status: yellow | ||
|
||
--- | ||
teardown: | ||
- do: | ||
watcher.delete_watch: | ||
id: "test_watch" | ||
ignore: 404 | ||
|
||
--- | ||
"Test executing logging action using template with params": | ||
- do: | ||
put_script: | ||
id: log-action | ||
body: > | ||
{ | ||
"script": | ||
{ | ||
"lang": "mustache", | ||
"source": "{{color}} alert" | ||
} | ||
} | ||
- do: | ||
watcher.put_watch: | ||
id: "test_watch" | ||
body: > | ||
{ | ||
"trigger": { | ||
"schedule" : { "interval": "1m" } | ||
}, | ||
"input": { | ||
"simple": { | ||
} | ||
}, | ||
"condition": { | ||
"always": {} | ||
}, | ||
"actions": { | ||
"log" : { | ||
"logging" : { | ||
"text" : { | ||
"id": "log-action", | ||
"params": { | ||
"color": "yellow" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
- match: { _id: "test_watch" } | ||
- match: { created: true } | ||
|
||
- do: | ||
watcher.execute_watch: | ||
id: "test_watch" | ||
|
||
- match: { watch_record.watch_id: "test_watch" } | ||
- match: { watch_record.result.actions.0.id: "log" } | ||
- match: { watch_record.result.actions.0.type: "logging" } | ||
- match: { watch_record.result.actions.0.status: "success" } | ||
- match: { watch_record.result.actions.0.logging.logged_text: "yellow alert" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters