Commit Graph

7 Commits

Author SHA1 Message Date
uboness ebda02438e Cleanup and Refactoring of the inputs
* Split the action into two constructs: `Input` and `ExecutableInput`. The former holds all the input configuration, the latter can execute the input based on that configuration (an executable input holds an input)
 - This the code clearer to understand and maintain.
 - This also enabled to pull some common implementation code into the `ExecutableInput` and by that reduce the implementation details of each executable to the minimum required.

* Also, extracted the `Input.Parser` to its own top level class, and renamed it to - `InputFactory`. The main thing that the factory does is: 1) delegate to the parsing to the `Input` class, 2) construct & wire up the `ExecutableInput`.

* With the introduction of `Input`, we no longer need the `SourceBuilder` for inputs. Instead, we have an `Input.Builder` that help you build an input. This is much more intuitive from the client perspective.

* Changed the `request` xcontent field in the http input result to `sent_request` for clarity
* Changed the `request` xcontent field in the search input result to `executed_request` for clarity

Original commit: elastic/x-pack-elasticsearch@63b93f9c7b
2015-04-21 23:12:43 +02:00
Brian Murphy 0a7cf71152 Persist the Watch.Status if needed after execution
This change persists the Watch.Status if needed by marking the Status as `dirty` if the status mutates during watch execution.
If the status is dirty it will be persisted at the end of execution while the execution lock is held.
Change record_in_history to record_execution which also controls weither the status will be updated.

Fixes elastic/elasticsearch#222

Original commit: elastic/x-pack-elasticsearch@25869cabf0
2015-04-16 16:57:14 -04:00
Brian Murphy 7f0e4fab41 Fix REST execute API call with empty body.
Execute with an empty body will now just use the defaults.
Add REST test for empty body.
Fixes elastic/elasticsearch#217

Original commit: elastic/x-pack-elasticsearch@072cd47250
2015-04-16 15:27:08 -04:00
Brian Murphy 8c87cb0728 Add test for invalid license.
This change adds a new test class that runs the REST tests with the license disabled.
It checks the error message to make sure that all api access is blocked from all the apis we normally test.

Fixes elastic/elasticsearch#193

Original commit: elastic/x-pack-elasticsearch@a70de9b7a7
2015-04-14 13:57:55 -04:00
Brian Murphy 3e9c109079 This commit contains a major refactoring to some of the core constructs in watcher.
- What used to be the `HistoryService` is not named `ExecutionService`. In fact, it always was an execution context and was simply named wrong and place in the wrog place in the code.

- A new `execution` package was created, to contain all execution related contsructs which includes the new `ExecutionService`, `WatchExecutionContext`, `WatchExecutor`, `InternalWatchExecutor`.

- The `WatchExecutionContext` role in the execution process was extended to also enable it to "control" the execution. "control" in the sence that it can now provide default results to some of the contructs (for example, it can provide a default input and by that skip the execution of the input). Also, it enables simulating actions (more bellow).

- There are two implementations now of the `WatchExecutionContext`. A `TriggeredExecutionContext` which is used when the trigger service triggers the execution of a watch. And `ManualExecutionContext` enabling to manually execute a watch. The latter, can be configured such that different phases in the normal executions of the watch can be skipped. This is great for simulating a watch execution, that is, executing a watch without actually fully executing the actions (e.g. create the emails that the email action would have normally send, but without actually sending it). Both of these new context implementations also sit in the new `execution` package.

- With the changes described above, the actions now consult the execution context before actually performing their tasks. If the execution context indicates that the action should run in a "simulated" mode, the action will semi execute and return a `Simulated` result. Each action type defines what is "simulated mode" for it. For example, the email action creates the email and renders all its templats but doesn't actually send it, the returned `Email.Simulated` result will contain the email that would have been sent if it was running under normal conditions (non-simulated mode). The `index` action, doesn't actually indexes anything (just creating the index request that would have been executed), and the `webhook` action only creates the HTTP request but doesn't actually send it.

- A new `execute` API was introduced that utilizes all of the above and enables to manually execute registered watches. The API provides all the tools to control what actions are simulated and enables skipping the execution of the watch `input` and `condition`. By default it also skip the recording of the execution in the watch history (though this can be enabled if desired). This API is exposed both by the Java `WatcherClient` and via a dedicated REST endpoint. (documentation around this new API was added as well)

Closes elastic/elasticsearch#149

Original commit: elastic/x-pack-elasticsearch@ee8fe0490a
2015-04-10 18:02:48 -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
Brian Murphy 3a09914b67 Add support for rest tests
This commit adds support for rest tests using the same yaml and json formatting as for core elasticsearch.
Also added is support for shield in the rest tests.

Original commit: elastic/x-pack-elasticsearch@bbeb9c0fc9
2015-03-31 17:25:48 -04:00