Commit Graph

729 Commits

Author SHA1 Message Date
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 85ac38c622 REST tests: Bulk API expects an array not a hash
Original commit: elastic/x-pack-elasticsearch@20ee1d38e7
2015-05-07 15:42:37 +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
Joshua Rich bd1f67ec99 Merge pull request elastic/elasticsearch#402 from joshuar/master
Fix type: index to type: indexed.

Original commit: elastic/x-pack-elasticsearch@73a8d0ef2e
2015-05-07 10:57:55 +10:00
Martijn van Groningen 34a0de4b38 test: after first elected master node has been stopped assert that watcher is started and only running once.
Original commit: elastic/x-pack-elasticsearch@e193b80215
2015-05-07 00:54:44 +02:00
Martijn van Groningen 5e7ef773b3 test: change no master block assert and if it fails print which node doesn't have a master block.
Original commit: elastic/x-pack-elasticsearch@656a1bc3df
2015-05-07 00:40:39 +02:00
Martijn van Groningen e1beb6e9b3 Fixes a bug that prevents the actual job in the schedule engine not being adjusted if the watch's interval is being updated with the same interval unit.
Closes elastic/elasticsearch#388

Original commit: elastic/x-pack-elasticsearch@ecf991f42c
2015-05-07 00:11:53 +02:00
Brian Murphy cf23d54aed Fix execute REST API call
We weren't assigning the trigger event in the execute REST API

Original commit: elastic/x-pack-elasticsearch@cc8a6d043c
2015-05-06 17:05:43 -04:00
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
Brian Murphy bd9bf2810d Make log4j dependency a test only dependency
Original commit: elastic/x-pack-elasticsearch@cc8936ad8f
2015-05-06 15:59:06 -04:00
Brian Murphy 42fc43451c Unshade the javax.mail and javax.activation jars
This change removes these jars from shading and changes the assemblies file so that they are included as is.

Original commit: elastic/x-pack-elasticsearch@695f5e2b20
2015-05-06 15:59:05 -04:00
Martijn van Groningen 3f2070cc0a index template: Added support to add additional settings to the index templates.
Also removed the version checking from the index template support, so that if the settings are changed these settings always get stored in the index template. This means we always put two index templates once watcher started.

And also shutdown watcher after the cluster service has been stopped.

This was done caused deadlock in the integration test framework when we are stopping the test cluster.
If multiple nodes are stopped, a node may briefly try to or run Watcher during the test cluster shutdown.
As part if starting we always put an index template, which will block any other start or stop calls for the WatcherService.
A node was running a put index template call as part of the start procedure while the start framework would stop the node.
The stop call would wait because it doesn't own the lock yet.
The put index template call didn't return, which caused the stop call the keep waiting.

The reason why put index template was hanging is that it failed to return anything while it the node was stopped.
Likely the put index template request got queued up waiting for a change in the cluster state, the cluster service
got stopped and the request got lost, but the watcher start procedure was still waiting.

By stopping Watcher before we stop the cluster service we avoid the scenario described above.

Original commit: elastic/x-pack-elasticsearch@db94b2279e
2015-05-06 21:22:47 +02:00
uboness 1a9db6140a fixed Java API docs
- wrote an intro where we tell how to get the watcher jar and we tall about the `WatcherClient`
- cleaned up the code snippets
- removed a reference to the `Watch.Parser`

- Also renamed `WatcherStatsResponse#getWatchServiceState` to `watcherStatsResponse.getWatcherState`

Original commit: elastic/x-pack-elasticsearch@814329cba7
2015-05-06 20:50:21 +02:00
uboness 5ecf1dbdcd Introduced `XContentSource`
An absraction aover XContent byte reference that:

- implements `ToXContent`
- can resolve values given a dot-notation path
- Used in `GetWatchResponse` and `ExecuteWatchResponse`

Also

- Moved `WatchExecutionResult` to the `execution` package

Original commit: elastic/x-pack-elasticsearch@0b41f53f38
2015-05-06 18:37:00 +02:00
uboness 8730b066c1 Refactored `WatcherService.State`
- Moved it to its own top level enum `WatcherState`
- Also changed the key holding the current state in the `stats` API to `watcher_state`

Original commit: elastic/x-pack-elasticsearch@2e5ca90f57
2015-05-06 12:29:59 +02:00
Martijn van Groningen 70cc41d710 Changed internal indices naming pattern
The `.watch_history` indices names should be aligned with logstash and marvel indices patterns so changing them to `.watch_history-YY.MM.dd`

Closes elastic/elasticsearch#387

Original commit: elastic/x-pack-elasticsearch@20baa1018f
2015-05-06 11:16:14 +02:00
uboness 5687c91bf6 Update README.asciidoc
Original commit: elastic/x-pack-elasticsearch@f61bd59d86
2015-05-05 23:38:55 +02:00
uboness 690641d0c9 Cleaned up the `Script` and `Template` constructs
Change them to consistently serialize themselves the same way they deserialize themselves.

If the script (or template) is read from a `string` value, it will serialize it self to xcontent as a `string` value as well. Otherwise it will serialize as an object, holding only those fields that where configured in the first place.

Original commit: elastic/x-pack-elasticsearch@52a82e0bbe
2015-05-05 23:25:14 +02:00
Brian Murphy 75bdf7de0d [TEST] Change execute test watches to have cron schedules that trigger in 2099.
Original commit: elastic/x-pack-elasticsearch@dde1dbae86
2015-05-05 12:37:44 -04: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 b0fd2f9f59 Relocate guava and owasp under org.elasticsearch.watcher.common/common.owasp.
This change relocates the shaded jars for guava and owasp under org.elasticsearch.watcher.common and org.elasticsearch.watcher.common.owasp respectively.

Original commit: elastic/x-pack-elasticsearch@0e2d6303e0
2015-05-04 12:59:34 -04:00
Brian Murphy e6c4b53bf8 Move email html body sanitization to the EmailTemplate.render
This change moves the sanitization of the html body of emails to render time instead of at message send time.
Move the sanitization code the the EmailTemplate class.
Add <hr> tag to allowed html tags.
Add global setting `watcher.actions.email.sanitize_html` that defaults to true. If this is set to false html sanitization will be disabled
Add documentation for sanitization disable setting.
Enhance email tests to verify that sanitization is happening at construction time.

Fixes elastic/elasticsearch#356

Original commit: elastic/x-pack-elasticsearch@282a2d85c2
2015-05-04 12:44:43 -04:00
uboness 5e9f747005 Enable inlined xcontent structure in http input body
The body of the http input may hold xcontent data (json/yaml). The problem is that today, the body only accepts text and writing
 escapted json in text makes it very hard to maintain.

 This commit introduces another field settings - `xbody`. Now, use `xbody` for inlined xcontent and `body` for any text content. When `xbody` is used, we keep around the xcontent type and the http request that is then executed will include a content-type header that will match the xcontent type of input.

Original commit: elastic/x-pack-elasticsearch@7210908064
2015-05-04 13:28:32 +02:00
Martijn van Groningen 1dcb61654c Merge pull request elastic/elasticsearch#361 from martijnvg/tests/fix/HistoryTemplateTimeMappingsTests
Fix HistoryTemplateTimeMappingsTests

Original commit: elastic/x-pack-elasticsearch@834e84c57d
2015-05-04 13:24:19 +02:00
Martijn van Groningen e148b7e427 tests; added assertBusy(...) to get around the time issue in tests due to the async mapping update for fields introduced in tests.
Closes elastic/elasticsearch#351

Original commit: elastic/x-pack-elasticsearch@0df48aa7e8
2015-05-04 11:55:00 +02:00
uboness b63630496f Centralized all the date xcontent rendering
Original commit: elastic/x-pack-elasticsearch@08248c30cd
2015-05-04 04:53:47 +03:00
Brian Murphy d95e068a77 [TEST] Add html found during testing to cause problems for the sanitizer.
This change adds a html string that was found to cause problems for the sanitizer during testing.

Original commit: elastic/x-pack-elasticsearch@275e728674
2015-05-03 21:35:35 -04:00
Brian Murphy bc78dd36c9 Add and shade dependency on com.google.guava
This is needed for owasp to load the Sanitizers class at runtime.

Original commit: elastic/x-pack-elasticsearch@4ed5776509
2015-05-03 20:53:16 -04:00
Brian Murphy 0a545cb358 Change actual default of ignore_condition to false
Change default of ignore_codition to match docs as `false`.
Add test to verify defaults.

Fixes elastic/elasticsearch#348

Original commit: elastic/x-pack-elasticsearch@d740286a26
2015-05-03 19:33:04 -04:00
Brian Murphy 9bbaaa7588 [TEST] Mark HistoryTemplateTimeMappingsTests.testTimeFields awaitsfix.
Original commit: elastic/x-pack-elasticsearch@a9b59e23de
2015-05-03 13:30:59 -04:00
Brian Murphy 73e64292b0 [TEST] Add refresh to make sure watch record is in the index before checking the mappings.
Original commit: elastic/x-pack-elasticsearch@bd9b266af1
2015-05-03 12:53:14 -04:00
Brian Murphy 1d052e545d [TEST] Add logging to see why test is failing.
Log the metadata we get back to see why this test is failing on jenkins.

Original commit: elastic/x-pack-elasticsearch@7e2e4a5856
2015-05-03 12:36:23 -04:00
uboness dc6235a90a Updated watch_history template to better support aggregations
- added dynamic_templates to the index template that make sure not to analyze email addresses and http `path` and `host` under the `watch_execution` object. This will enabled building aggregations over these fields. Also make sure that different time fields in thw `watch_record` are mapped as date types.
- While at it changed the `watch_execution.input_result` mapping such that it's enabled and only disabled `watch_execution.input_result.payload` as different payloads from different sources may conflict with one another in terms of mappings
- Fixed a bug in the `EmailTemplate` building of the `reply_to` field.

- Also, added missing `execution_time` to the `watch_record` (under `watch_execution` object).

Closes elastic/elasticsearch#335

Original commit: elastic/x-pack-elasticsearch@dd28c70bca
2015-05-03 17:53:06 +03:00
Brian Murphy 7d8dc38c29 Change `meta` to metadata in the code.
The meta data field was known and `metadata` in the docs but the parsing logic expected `meta`.
This change unifies everything to use `metadata`. Also clean up Watch parsing to fail in a more consistent way when unknown fields are encountered.

Fixes elastic/elasticsearch#329

Original commit: elastic/x-pack-elasticsearch@a9013127d8
2015-05-03 07:44:35 -04:00
Brian Murphy 0d6fb1081a Hijack document APIs for .watches index
This change hijacks the document APIs for the .watches index and prevents direct access to these APIs via REST.
This hijacking is controlled by the "watcher.index.rest.direct_access" setting, this setting defaults to false which restricts access to the index. To allow direct access to the .watches index from the REST API set this setting to `true`
Copied json files from core es to test this feature and added comments to the json files indicating why they have been copied from es core.

Fixes elastic/elasticsearch#336

Original commit: elastic/x-pack-elasticsearch@22335750bd
2015-05-02 10:55:24 -04:00
Honza Král 86f0ea8d5a [API] don't include global parameter pretty
Original commit: elastic/x-pack-elasticsearch@15bc843bb1
2015-05-02 15:51:41 +02:00
Martijn van Groningen 299527c46a Serialize `input` field too.
Also added assertions to verify if all watch record not null field are expected to be there at parse time.

Original commit: elastic/x-pack-elasticsearch@42052ae02c
2015-05-02 11:31:52 +02:00
Martijn van Groningen 3b652d1772 test: fix failing tests
Original commit: elastic/x-pack-elasticsearch@3c35a828a4
2015-05-02 02:22:37 +02:00
Martijn van Groningen 31f039d1bd Make sure we skip over watches and watch records that are malformed during the Watcher starting phase.
Original commit: elastic/x-pack-elasticsearch@8bc37cdcc3
2015-05-02 01:45:21 +02:00
uboness c8a986cab7 Added a timeout to all watch write operations
The problem we have today is that since all write operations on a watch are blocked on the watch lock, if a watch is executing for a long time (for whatever reason) the action will simply block and by that hold a `management` thread for potentially a long time. This impacts elasticsearch as a whole - if for example there's an infinite loop in the condition script, then you try to delete/ack/update the watch 5 times (the default size of the management thread pool in elasticsearch is 5). You effectively block all management threads in elasticsearch and from that moment on, the only thing left to do is kill the node.

This commit introduces a timeout for the tree write watch actions - `put`, `ack` and `delete`. It is set to 10 seconds by default, but you can customize it both in java and in the rest API using the standard `master_timeout` query parameter.

Updated the relevant docs.

Fixes elastic/elasticsearch#309

Original commit: elastic/x-pack-elasticsearch@03292db37b
2015-05-01 19:02:29 +03:00
Brian Murphy b57e887095 Disallow the use of SCAN search type
This change disallows the SCAN search type in our search requests used by search input and search transform.
Add tests for this and update the current tests to both detect SCAN and not use SCAN in valid tests.

Original commit: elastic/x-pack-elasticsearch@c9d61930c8
2015-05-01 11:12:37 -04:00
Brian Murphy 56e422b9e8 Unify SearchRequest construction between SearchTransform and SearchInput.
This is a step between the old and elastic/elasticsearch#184 this change unifies the logic that generates the search requests from prototype for SearchTransforms and SearchInputs.
This change also adds the `executed_request` field to the `SearchTransform.Result` that was missing.
Add tests for SearchTransform.Result parsing and all different templating options for SearchTransform along with testing handling of search_type in SearchTransform which was being missed previously.

Fixes elastic/elasticsearch#311

Original commit: elastic/x-pack-elasticsearch@26e68576f5
2015-05-01 10:25:10 -04:00
Martijn van Groningen 118389bc06 shield: The rest layer can never use the Guice injected WatcherClient, but must always use the provided WatcherClient instance from the WatcherRestHandler base class.
Closes elastic/elasticsearch#316
Closes elastic/elasticsearch#317

Original commit: elastic/x-pack-elasticsearch@82df644895
2015-05-01 15:42:02 +02:00
Martijn van Groningen f66fc7575d test: moved all tests over to use source builders.
Original commit: elastic/x-pack-elasticsearch@e13e5b8b43
2015-05-01 11:54:56 +02:00
Brian Murphy 9df97fe845 Report the actual interval that was sent if less than 1000ms.
This change reports the actual interval that was used instead of just reporting the ms of the interval if the interval was less than 1000ms.

Fixes elastic/elasticsearch#301

Original commit: elastic/x-pack-elasticsearch@d625c952fe
2015-04-30 19:03:36 -04:00
Brian Murphy d0d646aa4c Remove default of 5m refresh on .watches and .watch_history* indices.
This default is far too high for normal use. It makes it very hard to build on top of watcher using the search APIs.

Fixes elastic/elasticsearch#279

Original commit: elastic/x-pack-elasticsearch@4e22d5c19e
2015-04-30 19:01:04 -04:00
Brian Murphy dad012fc2c Disable indexing of the WatchRecord.watch_exection.input_result
This input_result may contain different types for the same field names. This will cause mapping failures when we try to write the updated watch record.
This change disables this field and adds a test in the `ManualExecutionTests` to test this case.

Fixes elastic/elasticsearch#307

Original commit: elastic/x-pack-elasticsearch@5340761343
2015-04-30 18:05:16 -04:00
Brian Murphy 1819dc97f4 Throw exception when trying to use the default account but no accounts are configured.
This change throws an exception to let the user know that they are trying to send an email using the default account
but no accounts have been configured.

Fixes elastic/elasticsearch#303

Original commit: elastic/x-pack-elasticsearch@3e68bddf24
2015-04-30 16:45:36 -04:00
Brian Murphy ba3037f5fe When parsing a http request port is a required field.
The parser for http request had a bug and was accepting requests that did not specify a port.
This changes this.

Fixes elastic/elasticsearch#299

Original commit: elastic/x-pack-elasticsearch@e0eafe3787
2015-04-30 12:23:03 -04:00