mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-23 21:38:15 +00:00
Until now if a condition failed to execute (for whatever reason), an exception would be thrown and the watch would just abort. The problem with that approach is while the error message would have been logged in the watch record message, the result of the condition would have been lost. This commit moves the condition execution error to the condition result (just like we have it today with actions and inputs). - A `status` field was added to the condition result (can either be `success` or `failure`) - A `reason` field is added to the condition result in case its status is `failure` - If the condition result status is `failure`, the watch execution is aborted Updated the rest APIs to verify the status & type of both the `input` and `condition` results on execution. Original commit: elastic/x-pack-elasticsearch@dddca03ff5
49 lines
1.5 KiB
YAML
49 lines
1.5 KiB
YAML
---
|
|
"Test execute watch api with minimal body":
|
|
- do:
|
|
cluster.health:
|
|
wait_for_status: green
|
|
|
|
- do:
|
|
watcher.put_watch:
|
|
id: "my_logging_watch"
|
|
body: >
|
|
{
|
|
"trigger" : {
|
|
"schedule" : { "cron" : "0 0 0 1 * ? 2099" }
|
|
},
|
|
"input" : {
|
|
"simple" : {
|
|
"count" : 1
|
|
}
|
|
},
|
|
"condition" : {
|
|
"script" : "ctx.payload.count == 1"
|
|
},
|
|
"actions" : {
|
|
"logging" : {
|
|
"logging" : {
|
|
"text" : "foobar"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- match: { _id: "my_logging_watch" }
|
|
|
|
- do:
|
|
watcher.execute_watch:
|
|
id: "my_logging_watch"
|
|
|
|
- match: { "watch_record.watch_id": "my_logging_watch" }
|
|
- match: { "watch_record.state": "executed" }
|
|
- match: { "watch_record.result.input.type": "simple" }
|
|
- match: { "watch_record.result.input.status": "success" }
|
|
- match: { "watch_record.result.input.payload.count": 1 }
|
|
- match: { "watch_record.result.condition.type": "script" }
|
|
- match: { "watch_record.result.condition.status": "success" }
|
|
- match: { "watch_record.result.condition.met": true }
|
|
- match: { "watch_record.result.actions.0.id" : "logging" }
|
|
- 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" : "foobar" }
|