Commit Graph

13 Commits

Author SHA1 Message Date
Brian Murphy 8bf45f0340 [TEST] Watch action acking and throttling tests
This change adds tests to ack a subset of a watch's actions, use a different throttle period per action in a watch, also adds tests to make sure that both the watch level and global level throttle_period are applied correctly.
Also updates the REST tests to make sure that throttle periods can be set at a watch and action level and are returned from the GET API.

Original commit: elastic/x-pack-elasticsearch@4b006c7830
2015-06-06 02:35:42 +02:00
uboness fb893e774a Add the ability to ack specific actions
- now it's possible to ack specific actions via the `Ack Watch API`
- Added tests for acking specific actions
- Changed the watch status structure such that the action ack state can be referred to by `status.actions.<action_id>.ack` (instead of `status.actions.<action_id>.ack_status`... removed the extra redundant "_status")
- As part of this work, also added validation for watch/action ids, such that we disallow having whitespaces in them.
- Updated the docs around acking & throttling of watch actions

Closes elastic/elasticsearch#531
Closes elastic/elasticsearch#537

Original commit: elastic/x-pack-elasticsearch@813e601bf5
2015-05-27 19:29:46 +02:00
uboness e0a70722e0 Move acking/throttling to the action level
Until now, acking and throttling functionality was applied at the watch level. This has major drawbacks in different aspects:

- When multiple actions are defined on a watch, acking a watch effectively acks all the actions. This is conceptually wrong. Say you have two actions: `email` and `index`. It's very likely you'd like to ack the email action (to avoid receiving too many emails) but at the same time continue indexing the data in the `index` action. Right now it's not possible.

- Different actions types may require different throttling. An `email` action probably needs a longer throttle period compared to an `index` action. Also for different `webhook` actions, the throttling is ultimately determined by the 3rd party system that is called.

This commit changes how we do throttling & acking. Moving this functionality to the action level. Now, when acking, each action in the watch will be acked separately. During executiong, each action will determine whether it needs to be throttled or not. The throttler is not associated with the action, not with the watch.

The throttle period was enhanced. There is a default throttle period that is configured for watcher as a whole (using the `watcher.execution.default_throttle_period` setting. Next to that, each `watch` can define its own `throttle_period` that can serve as the default throttle period for the actions in the watch. Lastly, each action can have its own throttle period set.

Since the throttler is now an action "thing", the `throttle` package was renamed to `throttler` and moved under the `actions` package. Also, `WatchThrottler` was renamed to `ActionThrottler`.

With this change, the `Watch Execute API` changed as well. Now, when executing a watch, you can define an execution mode per action. The execution mode offers 4 types of execution:
- `execute`: executes the watch normally (actually executing the action and it may be throttled)
- `force_execute`: skips/ignores throttling and executes the watch
- `simulate`: simulates the watch execution yet it may be throttled
- `force_simulate`: skips/ignores throttling and simulates the watch execution

As part of this change, the structure of the watch status changed along with the xconent representing the `watch_record`. A new `ActionStatus` was introduced (as part of the `WatchStatus`) and is always set for every action in the watch. This status holds:
 - the current state of the action (`ackable`, `awaits_successful_execution`, `acked`)
 - the last execution state (success/failure + reason)
 - the last successful execution state
 - the last throttle state (timestamp + reason)

Original commit: elastic/x-pack-elasticsearch@32c2985ed8
2015-05-22 20:57:51 +02:00
Brian Murphy 6f2429afb4 [REST-TEST] Add master_timeout to the rest API specs
This change adds the parameter `master_timeout` to the rest requests that can write to a watch PUT, ACK and DELETE.
Also add support in the rest tests to verify that this is accepted.

Fixes: elastic/elasticsearch#416

Original commit: elastic/x-pack-elasticsearch@4cc1c50f2c
2015-05-07 19:19:49 -04:00
Clinton Gormley d76df0d590 Merge pull request elastic/elasticsearch#411 from clintongormley/wait_for_green
REST tests: Wait for yellow, not green

Original commit: elastic/x-pack-elasticsearch@296b312e17
2015-05-07 16:07:08 +02:00
Clinton Gormley 41b974b784 REST tests: Wait for yellow, not green
When testing on a single node, waiting for green times out

Original commit: elastic/x-pack-elasticsearch@ca91bbbbe6
2015-05-07 15:43:09 +02:00
Clinton Gormley 35d2d86beb REST tests: Fix bad YAML
Original commit: elastic/x-pack-elasticsearch@362aac9c96
2015-05-07 15:41:33 +02:00
Brian Murphy b5f5862146 Clean up Watch parsing to disallow arrays.
This change cleans up the watch parsing which had allowed arrays in actions as a hold over from when actions was an array.

Fixes elastic/elasticsearch#367

Original commit: elastic/x-pack-elasticsearch@3f4fb82124
2015-05-05 10:44:28 -04:00
Brian Murphy 2ff8e2fb4e [TEST] Fix ack watch test to not trigger while test is running.
Original commit: elastic/x-pack-elasticsearch@d0261b355d
2015-05-04 16:19:41 -04:00
Brian Murphy 94bea8f83a Change the watch specific actions to reflect that they operate on watches.
This change changes the watch specific actions put/get/delete/execute/ack to be watcher.<action>_watch.

Original commit: elastic/x-pack-elasticsearch@86a91cb141
2015-04-28 19:08:28 -04:00
Brian Murphy 4482d8d2ba Change watcher REST API call namespace to be watcher.
This change changes the API spec such that all of the watcher APIs are in the `watcher` namespace.

Original commit: elastic/x-pack-elasticsearch@f409ab4569
2015-04-28 18:50:07 -04:00
Brian Murphy 01c80e63b0 [TEST] Add automated tests that were missing.
SearchInput using inline, indexed and on disk templates.
ScriptedCondition where the script accesses the ctx.
ScriptedCondition where the script throws an exception.
ScriptedCondition where the script doesn't return a boolean.
Webhook tests using templated body, path and parameters.
Some REST test fixes.

Original commit: elastic/x-pack-elasticsearch@d02b6d1d7b
2015-04-27 17:56:55 -04:00
Brian Murphy 31fbbcfc9a Add support for testing all REST endpoints.
This change adds support for testing all watcher REST endpoints.
It also updates the api docs to be current with the latest code.
Change GetWatchResponse to only have the information in needs
GetWatchResponse used to contain a GetResponse this is not needed. Now it just contains the needed fields.

Closes elastic/elasticsearch#35

Original commit: elastic/x-pack-elasticsearch@905c5da318
2015-04-07 19:47:04 -04:00