Brian Murphy 7d98358012 Change the ManualTriggerEvent to wrap a TriggerEvent
This change changes the manual trigger event to be a wrapper for another `TriggerEvent`.
TriggerEvent is required field for the execute API either via setTriggerEvent on the request or requestBuilder in the java API or `trigger_event` in the REST API

Original commit: elastic/x-pack-elasticsearch@790bdb96a5
2015-05-06 16:59:26 -04:00

83 lines
2.6 KiB
YAML

---
"Test execute watch api":
- do:
cluster.health:
wait_for_status: green
- do:
watcher.put_watch:
id: "my_exe_watch"
body: >
{
"trigger" : {
"schedule" : { "cron" : "0 0 0 1 * ? 2099" }
},
"input" : {
"search" : {
"request" : {
"indices" : [ "logstash*" ],
"body" : {
"query" : {
"filtered": {
"query": {
"match": {
"response": 404
}
},
"filter": {
"range": {
"@timestamp" : {
"from": "{{ctx.trigger.scheduled_time}}||-5m",
"to": "{{ctx.trigger.triggered_time}}"
}
}
}
}
}
}
}
}
},
"condition" : {
"script" : {
"script" : "ctx.payload.hits.total > 1"
}
},
"actions" : {
"EmailAdmin" : {
"email" : {
"to" : "someone@domain.host.com",
"subject" : "404 recently encountered"
}
}
}
}
- match: { _id: "my_exe_watch" }
- do:
watcher.execute_watch:
id: "my_exe_watch"
body: >
{
"ignore_condition" : true,
"ignore_throttle" : true,
"simulated_actions" : "_all",
"alternative_input" : {
"foo" : "bar"
},
"trigger_event" : {
"schedule" : {
"scheduled_time" : "2015-05-05T20:58:02.443Z",
"triggered_time" : "2015-05-05T20:58:02.443Z"
}
},
"record_execution" : true
}
- match: { "watch_id": "my_exe_watch" }
- match: { "watch_execution.condition_result.always": {} }
- match: { "state": "executed" }
- match: { "trigger_event.manual.schedule.scheduled_time": "2015-05-05T20:58:02.443Z" }
- match: { "watch_execution.input_result.simple.payload.foo": "bar" }
- match: { "watch_execution.actions_results.EmailAdmin.email.success" : true }
- match: { "watch_execution.actions_results.EmailAdmin.email.simulated_email.subject" : "404 recently encountered" }