From 46372d9f996772f3830a14bec4b52394057a9b91 Mon Sep 17 00:00:00 2001 From: Jake Landis Date: Thu, 17 Jan 2019 14:38:20 -0600 Subject: [PATCH 1/6] deprecate types for watcher this commit adds deprecation warnings for index actions and search actions when executed via watcher relates #35190 --- .../watcher/actions/index/IndexAction.java | 6 ++++++ .../search/WatcherSearchTemplateRequest.java | 8 ++++++++ .../actions/index/IndexActionTests.java | 1 + .../WatcherSearchTemplateRequestTests.java | 18 ++++++++++++++++++ 4 files changed, 33 insertions(+) diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/index/IndexAction.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/index/IndexAction.java index ceb6ac88f17f6..5fac9c8cfcfe6 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/index/IndexAction.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/index/IndexAction.java @@ -5,10 +5,12 @@ */ package org.elasticsearch.xpack.watcher.actions.index; +import org.apache.logging.log4j.LogManager; import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.action.support.WriteRequest.RefreshPolicy; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.ParseField; +import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.unit.TimeValue; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; @@ -34,6 +36,9 @@ public class IndexAction implements Action { @Nullable final DateTimeZone dynamicNameTimeZone; @Nullable final RefreshPolicy refreshPolicy; + private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(IndexAction.class)); + static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Specifying types in a watcher index action is deprecated."; + public IndexAction(@Nullable String index, @Nullable String docType, @Nullable String docId, @Nullable String executionTimeField, @Nullable TimeValue timeout, @Nullable DateTimeZone dynamicNameTimeZone, @Nullable RefreshPolicy refreshPolicy) { @@ -151,6 +156,7 @@ public static IndexAction parse(String watchId, String actionId, XContentParser } } else if (token == XContentParser.Token.VALUE_STRING) { if (Field.DOC_TYPE.match(currentFieldName, parser.getDeprecationHandler())) { + deprecationLogger.deprecatedAndMaybeLog("watcher_index_action", TYPES_DEPRECATION_MESSAGE); docType = parser.text(); } else if (Field.DOC_ID.match(currentFieldName, parser.getDeprecationHandler())) { docId = parser.text(); diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateRequest.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateRequest.java index 245093f3b385c..41aecd4a5907b 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateRequest.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateRequest.java @@ -5,6 +5,7 @@ */ package org.elasticsearch.xpack.watcher.support.search; +import org.apache.logging.log4j.LogManager; import org.elasticsearch.ElasticsearchParseException; import org.elasticsearch.action.search.SearchType; import org.elasticsearch.action.support.IndicesOptions; @@ -13,6 +14,7 @@ import org.elasticsearch.common.Strings; import org.elasticsearch.common.bytes.BytesArray; import org.elasticsearch.common.bytes.BytesReference; +import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.xcontent.ToXContentObject; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentFactory; @@ -43,6 +45,10 @@ public class WatcherSearchTemplateRequest implements ToXContentObject { private final BytesReference searchSource; private boolean restTotalHitsAsInt = true; + private static final DeprecationLogger deprecationLogger = + new DeprecationLogger(LogManager.getLogger(WatcherSearchTemplateRequest.class)); + static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Specifying types in a watcher search request is deprecated."; + public WatcherSearchTemplateRequest(String[] indices, String[] types, SearchType searchType, IndicesOptions indicesOptions, BytesReference searchSource) { this.indices = indices; @@ -203,6 +209,7 @@ public static WatcherSearchTemplateRequest fromXContent(XContentParser parser, S } } } else if (TYPES_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { + deprecationLogger.deprecatedAndMaybeLog("watcher_search_input", TYPES_DEPRECATION_MESSAGE); while ((token = parser.nextToken()) != XContentParser.Token.END_ARRAY) { if (token == XContentParser.Token.VALUE_STRING) { types.add(parser.textOrNull()); @@ -278,6 +285,7 @@ public static WatcherSearchTemplateRequest fromXContent(XContentParser parser, S String indicesStr = parser.text(); indices.addAll(Arrays.asList(Strings.delimitedListToStringArray(indicesStr, ",", " \t"))); } else if (TYPES_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { + deprecationLogger.deprecatedAndMaybeLog("watcher_search_input", TYPES_DEPRECATION_MESSAGE); String typesStr = parser.text(); types.addAll(Arrays.asList(Strings.delimitedListToStringArray(typesStr, ",", " \t"))); } else if (SEARCH_TYPE_FIELD.match(currentFieldName, parser.getDeprecationHandler())) { diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/index/IndexActionTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/index/IndexActionTests.java index 346b2d0e85cdf..5b3767d655872 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/index/IndexActionTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/index/IndexActionTests.java @@ -101,6 +101,7 @@ public void testParser() throws Exception { assertThat(executable.action().executionTimeField, equalTo(timestampField)); } assertThat(executable.action().timeout, equalTo(writeTimeout)); + assertWarnings(IndexAction.TYPES_DEPRECATION_MESSAGE); } public void testParserFailure() throws Exception { diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateRequestTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateRequestTests.java index 07fd3c7765485..c535e1036824a 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateRequestTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateRequestTests.java @@ -39,6 +39,24 @@ public void testDefaultHitCountsConfigured() throws IOException { assertHitCount(source, hitCountsAsInt); } + public void testDeprecationForSingleType() throws IOException { + String source = "{\"types\":\"mytype\"}"; + try (XContentParser parser = createParser(JsonXContent.jsonXContent, source)) { + parser.nextToken(); + WatcherSearchTemplateRequest.fromXContent(parser, SearchType.QUERY_THEN_FETCH); + } + assertWarnings(WatcherSearchTemplateRequest.TYPES_DEPRECATION_MESSAGE); + } + + public void testDeprecationForMultiType() throws IOException { + String source = "{\"types\":[\"mytype1\",\"mytype2\"]}"; + try (XContentParser parser = createParser(JsonXContent.jsonXContent, source)) { + parser.nextToken(); + WatcherSearchTemplateRequest.fromXContent(parser, SearchType.QUERY_THEN_FETCH); + } + assertWarnings(WatcherSearchTemplateRequest.TYPES_DEPRECATION_MESSAGE); + } + private void assertHitCount(String source, boolean expectedHitCountAsInt) throws IOException { try (XContentParser parser = createParser(JsonXContent.jsonXContent, source)) { parser.nextToken(); From 22936c5a84c8e566016292a02b75e4310b7cc634 Mon Sep 17 00:00:00 2001 From: Jake Landis Date: Fri, 18 Jan 2019 09:26:47 -0600 Subject: [PATCH 2/6] deprecated unit test --- .../watcher/actions/index/IndexActionTests.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/index/IndexActionTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/index/IndexActionTests.java index 5b3767d655872..c18cf2dc1e521 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/index/IndexActionTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/index/IndexActionTests.java @@ -78,7 +78,6 @@ public void testParser() throws Exception { if (includeIndex) { builder.field(IndexAction.Field.INDEX.getPreferredName(), "test-index"); } - builder.field(IndexAction.Field.DOC_TYPE.getPreferredName(), "test-type"); if (timestampField != null) { builder.field(IndexAction.Field.EXECUTION_TIME_FIELD.getPreferredName(), timestampField); } @@ -101,6 +100,18 @@ public void testParser() throws Exception { assertThat(executable.action().executionTimeField, equalTo(timestampField)); } assertThat(executable.action().timeout, equalTo(writeTimeout)); + } + + public void testDeprecationTypes() throws Exception { + XContentBuilder builder = jsonBuilder(); + builder.startObject(); + builder.field(IndexAction.Field.DOC_TYPE.getPreferredName(), "test-type"); + builder.endObject(); + IndexActionFactory actionParser = new IndexActionFactory(Settings.EMPTY, client); + XContentParser parser = createParser(builder); + parser.nextToken(); + ExecutableIndexAction executable = actionParser.parseExecutable(randomAlphaOfLength(5), randomAlphaOfLength(3), parser); + assertThat(executable.action().docType, equalTo("test-type")); assertWarnings(IndexAction.TYPES_DEPRECATION_MESSAGE); } From 85f41db5c02a29eab64ad402088ca35d40cfad19 Mon Sep 17 00:00:00 2001 From: Jake Landis Date: Fri, 18 Jan 2019 13:40:49 -0600 Subject: [PATCH 3/6] remove type from rest tests --- .../rest-api-spec/test/watcher/ack_watch/10_basic.yml | 3 +-- .../watcher/ack_watch/20_ack_individual_action.yml | 3 +-- .../ack_watch/30_reset_ack_after_unmet_condition.yml | 1 - .../40_reset_ack_after_unmet_action_condition.yml | 1 - .../test/watcher/activate_watch/10_basic.yml | 3 +-- .../test/watcher/delete_watch/10_basic.yml | 3 +-- .../test/watcher/execute_watch/10_basic.yml | 3 --- .../test/watcher/execute_watch/20_transform.yml | 7 ------- .../test/watcher/execute_watch/70_invalid.yml | 1 - .../rest-api-spec/test/watcher/get_watch/10_basic.yml | 3 +-- .../test/watcher/get_watch/20_missing.yml | 3 +-- .../rest-api-spec/test/watcher/put_watch/10_basic.yml | 3 +-- .../put_watch/20_put_watch_with_throttle_period.yml | 3 +-- .../30_put_watch_with_action_throttle_period.yml | 3 +-- .../watcher/put_watch/40_put_watch_as_inactive.yml | 3 +-- .../put_watch/60_put_watch_with_action_condition.yml | 3 +-- .../70_put_watch_with_index_action_using_id.yml | 10 +++------- .../watcher/put_watch/91_search_total_hits_as_int.yml | 3 --- .../rest-api-spec/test/10_templated_role_query.yml | 2 -- .../test/11_templated_role_query_runas.yml | 2 -- .../rest-api-spec/test/20_small_users_one_index.yml | 4 ---- .../rest-api-spec/test/30_search_template.yml | 2 -- .../20_test_run_as_execute_watch.yml | 9 --------- .../test/painless/60_chain_input_with_transform.yml | 2 -- 24 files changed, 14 insertions(+), 66 deletions(-) diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/ack_watch/10_basic.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/ack_watch/10_basic.yml index 385f2e9da6503..9c861e3dcd831 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/ack_watch/10_basic.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/ack_watch/10_basic.yml @@ -25,8 +25,7 @@ "actions": { "test_index": { "index": { - "index": "test", - "doc_type": "test2" + "index": "test" } } } diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/ack_watch/20_ack_individual_action.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/ack_watch/20_ack_individual_action.yml index b59fd561a7594..813e1f0c88899 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/ack_watch/20_ack_individual_action.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/ack_watch/20_ack_individual_action.yml @@ -25,8 +25,7 @@ "actions": { "test_index": { "index": { - "index": "test", - "doc_type": "test2" + "index": "test" } } } diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/ack_watch/30_reset_ack_after_unmet_condition.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/ack_watch/30_reset_ack_after_unmet_condition.yml index 2f3a815346484..2a9a4959de4c2 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/ack_watch/30_reset_ack_after_unmet_condition.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/ack_watch/30_reset_ack_after_unmet_condition.yml @@ -38,7 +38,6 @@ teardown: "indexme" : { "index" : { "index" : "my_test_index", - "doc_type" : "my-type", "doc_id": "my-id" } } diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/ack_watch/40_reset_ack_after_unmet_action_condition.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/ack_watch/40_reset_ack_after_unmet_action_condition.yml index 93639163ac04b..946f23a2f5a4e 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/ack_watch/40_reset_ack_after_unmet_action_condition.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/ack_watch/40_reset_ack_after_unmet_action_condition.yml @@ -38,7 +38,6 @@ teardown: }, "index" : { "index" : "my_test_index", - "doc_type" : "my-type", "doc_id": "my-id" } } diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/activate_watch/10_basic.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/activate_watch/10_basic.yml index 221887494c5eb..99459119e3cdf 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/activate_watch/10_basic.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/activate_watch/10_basic.yml @@ -25,8 +25,7 @@ "actions": { "test_index": { "index": { - "index": "test", - "doc_type": "test2" + "index": "test" } } } diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/delete_watch/10_basic.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/delete_watch/10_basic.yml index 44d4e187e3fb1..d22b66f85d188 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/delete_watch/10_basic.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/delete_watch/10_basic.yml @@ -38,8 +38,7 @@ teardown: "actions": { "test_index": { "index": { - "index": "test", - "doc_type": "test2" + "index": "test" } } } diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/execute_watch/10_basic.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/execute_watch/10_basic.yml index b3ad1e6d545ff..1fd3c06b2eee7 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/execute_watch/10_basic.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/execute_watch/10_basic.yml @@ -33,7 +33,6 @@ teardown: "indexme" : { "index" : { "index" : "my_test_index", - "doc_type" : "my-type", "doc_id": "my-id" } } @@ -87,7 +86,6 @@ teardown: "indexme" : { "index" : { "index" : "my_test_index", - "doc_type" : "my-type", "doc_id": "my-id" } } @@ -130,7 +128,6 @@ teardown: "indexme" : { "index" : { "index" : "my_test_index", - "doc_type" : "my-type", "refresh" : "wait_for", "doc_id": "my-id" } diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/execute_watch/20_transform.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/execute_watch/20_transform.yml index 59ebacbfe902d..3766cb6c4a788 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/execute_watch/20_transform.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/execute_watch/20_transform.yml @@ -9,7 +9,6 @@ setup: - do: index: index: my_test_index - type: doc id: my_id refresh: true body: > @@ -49,7 +48,6 @@ setup: "indexme" : { "index" : { "index" : "my_test_index", - "doc_type" : "doc", "doc_id": "my-id" } } @@ -64,7 +62,6 @@ setup: - do: get: index: my_test_index - type: doc id: my_id - match: { _source.key: "value" } @@ -82,7 +79,6 @@ setup: - do: index: index: my_test_index - type: doc id: my_id refresh: true body: > @@ -123,7 +119,6 @@ setup: "indexme" : { "index" : { "index" : "my_test_index", - "doc_type" : "doc", "doc_id": "my-id" } } @@ -138,7 +133,6 @@ setup: - do: get: index: my_test_index - type: doc id: my_id - match: { _source.key: "value" } @@ -183,7 +177,6 @@ setup: "indexme" : { "index" : { "index" : "my_test_index", - "doc_type" : "doc", "doc_id": "my-id" } } diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/execute_watch/70_invalid.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/execute_watch/70_invalid.yml index fc8687eb699b1..f13c5faf59959 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/execute_watch/70_invalid.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/execute_watch/70_invalid.yml @@ -38,7 +38,6 @@ "indexme" : { "index" : { "index" : "my_test_index", - "doc_type" : "my-type", "doc_id": "my-id" } } diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/get_watch/10_basic.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/get_watch/10_basic.yml index 180b72f2ba471..3ae5492328702 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/get_watch/10_basic.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/get_watch/10_basic.yml @@ -38,8 +38,7 @@ teardown: "actions": { "test_index": { "index": { - "index": "test", - "doc_type": "test2" + "index": "test" } } } diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/get_watch/20_missing.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/get_watch/20_missing.yml index ee4fd2e7e43a8..fc795005ac8a8 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/get_watch/20_missing.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/get_watch/20_missing.yml @@ -30,8 +30,7 @@ "actions": { "test_index": { "index": { - "index": "test", - "doc_type": "test2" + "index": "test" } } } diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/put_watch/10_basic.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/put_watch/10_basic.yml index b2ea5b8042f69..78d1b6e65e666 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/put_watch/10_basic.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/put_watch/10_basic.yml @@ -29,8 +29,7 @@ "actions": { "test_index": { "index": { - "index": "test", - "doc_type": "test2" + "index": "test" } } } diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/put_watch/20_put_watch_with_throttle_period.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/put_watch/20_put_watch_with_throttle_period.yml index 14bd682bd02d6..ab8d852dab3d4 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/put_watch/20_put_watch_with_throttle_period.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/put_watch/20_put_watch_with_throttle_period.yml @@ -39,8 +39,7 @@ teardown: "actions": { "test_index": { "index": { - "index": "test", - "doc_type": "test2" + "index": "test" } } } diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/put_watch/30_put_watch_with_action_throttle_period.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/put_watch/30_put_watch_with_action_throttle_period.yml index db4013bc38a25..a48d667066ef3 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/put_watch/30_put_watch_with_action_throttle_period.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/put_watch/30_put_watch_with_action_throttle_period.yml @@ -39,8 +39,7 @@ teardown: "test_index": { "throttle_period" : "10s", "index": { - "index": "test", - "doc_type": "test2" + "index": "test" } } } diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/put_watch/40_put_watch_as_inactive.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/put_watch/40_put_watch_as_inactive.yml index 23075ecfa7940..47b27d6b9be3e 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/put_watch/40_put_watch_as_inactive.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/put_watch/40_put_watch_as_inactive.yml @@ -39,8 +39,7 @@ teardown: "actions": { "test_index": { "index": { - "index": "test", - "doc_type": "test2" + "index": "test" } } } diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/put_watch/60_put_watch_with_action_condition.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/put_watch/60_put_watch_with_action_condition.yml index 670a64381d041..bc26a60e4702f 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/put_watch/60_put_watch_with_action_condition.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/put_watch/60_put_watch_with_action_condition.yml @@ -43,8 +43,7 @@ teardown: } }, "index": { - "index": "test", - "doc_type": "test2" + "index": "test" } } } diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/put_watch/70_put_watch_with_index_action_using_id.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/put_watch/70_put_watch_with_index_action_using_id.yml index 50420c1e4eeda..7bad6c8f1eebf 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/put_watch/70_put_watch_with_index_action_using_id.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/put_watch/70_put_watch_with_index_action_using_id.yml @@ -37,7 +37,6 @@ teardown: "test_index": { "index": { "index": "my_test_index", - "doc_type": "test2", "doc_id": "test_id1" } } @@ -86,8 +85,7 @@ teardown: "actions": { "test_index": { "index": { - "index": "my_test_index", - "doc_type": "test2" + "index": "my_test_index" } } } @@ -143,8 +141,7 @@ teardown: "actions": { "test_index": { "index": { - "index": "my_test_index", - "doc_type": "test2" + "index": "my_test_index" } } } @@ -202,8 +199,7 @@ teardown: "actions": { "test_index": { "index": { - "index": "my_test_index", - "doc_type": "test2" + "index": "my_test_index" } } } diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/put_watch/91_search_total_hits_as_int.yml b/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/put_watch/91_search_total_hits_as_int.yml index 46986438ee4a4..eba7f75a75968 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/put_watch/91_search_total_hits_as_int.yml +++ b/x-pack/plugin/src/test/resources/rest-api-spec/test/watcher/put_watch/91_search_total_hits_as_int.yml @@ -7,7 +7,6 @@ setup: - do: index: index: my_test_index - type: doc id: my_id refresh: true body: > @@ -97,7 +96,6 @@ setup: }, "index" : { "index" : "my_test_index", - "doc_type" : "doc", "doc_id": "my-id" } } @@ -108,7 +106,6 @@ setup: - do: get: index: my_test_index - type: doc id: my_id - match: { _source.key: "value" } diff --git a/x-pack/qa/smoke-test-security-with-mustache/src/test/resources/rest-api-spec/test/10_templated_role_query.yml b/x-pack/qa/smoke-test-security-with-mustache/src/test/resources/rest-api-spec/test/10_templated_role_query.yml index f1f6ab886375d..84d8d98e27384 100644 --- a/x-pack/qa/smoke-test-security-with-mustache/src/test/resources/rest-api-spec/test/10_templated_role_query.yml +++ b/x-pack/qa/smoke-test-security-with-mustache/src/test/resources/rest-api-spec/test/10_templated_role_query.yml @@ -110,7 +110,6 @@ setup: - do: index: index: foobar - type: type id: 1 body: > { @@ -119,7 +118,6 @@ setup: - do: index: index: foobar - type: type id: 2 body: > { diff --git a/x-pack/qa/smoke-test-security-with-mustache/src/test/resources/rest-api-spec/test/11_templated_role_query_runas.yml b/x-pack/qa/smoke-test-security-with-mustache/src/test/resources/rest-api-spec/test/11_templated_role_query_runas.yml index 0011fa7b4446b..2f4755943aa2d 100644 --- a/x-pack/qa/smoke-test-security-with-mustache/src/test/resources/rest-api-spec/test/11_templated_role_query_runas.yml +++ b/x-pack/qa/smoke-test-security-with-mustache/src/test/resources/rest-api-spec/test/11_templated_role_query_runas.yml @@ -110,7 +110,6 @@ setup: - do: index: index: foobar - type: type id: 1 body: > { @@ -119,7 +118,6 @@ setup: - do: index: index: foobar - type: type id: 2 body: > { diff --git a/x-pack/qa/smoke-test-security-with-mustache/src/test/resources/rest-api-spec/test/20_small_users_one_index.yml b/x-pack/qa/smoke-test-security-with-mustache/src/test/resources/rest-api-spec/test/20_small_users_one_index.yml index a8fa79a04fc27..4c4e673cd29ef 100644 --- a/x-pack/qa/smoke-test-security-with-mustache/src/test/resources/rest-api-spec/test/20_small_users_one_index.yml +++ b/x-pack/qa/smoke-test-security-with-mustache/src/test/resources/rest-api-spec/test/20_small_users_one_index.yml @@ -88,7 +88,6 @@ teardown: Authorization: "Basic am9lOngtcGFjay10ZXN0LXBhc3N3b3Jk" index: index: shared_logs - type: type pipeline: "my_pipeline" body: > { @@ -99,7 +98,6 @@ teardown: Authorization: "Basic am9objp4LXBhY2stdGVzdC1wYXNzd29yZA==" index: index: shared_logs - type: type pipeline: "my_pipeline" body: > { @@ -158,7 +156,6 @@ teardown: Authorization: "Basic am9lOngtcGFjay10ZXN0LXBhc3N3b3Jk" index: index: shared_logs - type: type pipeline: "my_pipeline" body: > { @@ -169,7 +166,6 @@ teardown: Authorization: "Basic am9objp4LXBhY2stdGVzdC1wYXNzd29yZA==" index: index: shared_logs - type: type pipeline: "my_pipeline" body: > { diff --git a/x-pack/qa/smoke-test-security-with-mustache/src/test/resources/rest-api-spec/test/30_search_template.yml b/x-pack/qa/smoke-test-security-with-mustache/src/test/resources/rest-api-spec/test/30_search_template.yml index 913979a4bb5e5..a208bda67cfe2 100644 --- a/x-pack/qa/smoke-test-security-with-mustache/src/test/resources/rest-api-spec/test/30_search_template.yml +++ b/x-pack/qa/smoke-test-security-with-mustache/src/test/resources/rest-api-spec/test/30_search_template.yml @@ -32,7 +32,6 @@ setup: - do: index: index: foobar - type: type id: 1 body: title: "contains some words" @@ -40,7 +39,6 @@ setup: - do: index: index: unauthorized_index - type: type id: 2 body: title: "contains some words too" diff --git a/x-pack/qa/smoke-test-watcher-with-security/src/test/resources/rest-api-spec/test/watcher/watcher_and_security/20_test_run_as_execute_watch.yml b/x-pack/qa/smoke-test-watcher-with-security/src/test/resources/rest-api-spec/test/watcher/watcher_and_security/20_test_run_as_execute_watch.yml index bd0d32ef9cc5f..ec0be2532a6ee 100644 --- a/x-pack/qa/smoke-test-watcher-with-security/src/test/resources/rest-api-spec/test/watcher/watcher_and_security/20_test_run_as_execute_watch.yml +++ b/x-pack/qa/smoke-test-watcher-with-security/src/test/resources/rest-api-spec/test/watcher/watcher_and_security/20_test_run_as_execute_watch.yml @@ -8,7 +8,6 @@ setup: - do: index: index: my_test_index - type: type id: 1 refresh: true body: > @@ -220,7 +219,6 @@ teardown: "index": { "index": { "index" : "my_test_index", - "doc_type" : "type", "doc_id": "my-id" } } @@ -236,7 +234,6 @@ teardown: - do: get: index: my_test_index - type: type id: my-id # this value is from the document in the my_text_index index, see the setup - match: { _source.hits.hits.0._source.value: "15" } @@ -272,7 +269,6 @@ teardown: "index": { "index": { "index" : "my_test_index", - "doc_type" : "type", "doc_id": "my-id" } } @@ -288,7 +284,6 @@ teardown: - do: get: index: my_test_index - type: type id: my-id - match: { _source.hits.total: 0 } @@ -315,7 +310,6 @@ teardown: "index": { "index": { "index" : "my_test_index", - "doc_type" : "type", "doc_id": "my-id" } } @@ -339,7 +333,6 @@ teardown: - do: get: index: my_test_index - type: type id: 1 - match: { _id: "1" } @@ -366,7 +359,6 @@ teardown: "index": { "index": { "index" : "index_not_allowed_to_read", - "doc_type" : "type", "doc_id": "my-id" } } @@ -390,7 +382,6 @@ teardown: - do: get: index: index_not_allowed_to_read - type: type id: 1 catch: forbidden diff --git a/x-pack/qa/smoke-test-watcher/src/test/resources/rest-api-spec/test/painless/60_chain_input_with_transform.yml b/x-pack/qa/smoke-test-watcher/src/test/resources/rest-api-spec/test/painless/60_chain_input_with_transform.yml index 08097e0cace17..69fd7b4d575ee 100644 --- a/x-pack/qa/smoke-test-watcher/src/test/resources/rest-api-spec/test/painless/60_chain_input_with_transform.yml +++ b/x-pack/qa/smoke-test-watcher/src/test/resources/rest-api-spec/test/painless/60_chain_input_with_transform.yml @@ -34,7 +34,6 @@ "index" : { "index" : { "index" : "my-index", - "doc_type" : "my-type", "doc_id" : "my-id" } } @@ -47,7 +46,6 @@ - do: get: index: my-index - type: my-type id: my-id - match: { _source.first.foo: "bar" } From 8406ad5be7456dd4efe508a382eb41a2ebbec4ac Mon Sep 17 00:00:00 2001 From: Jake Landis Date: Fri, 18 Jan 2019 14:27:49 -0600 Subject: [PATCH 4/6] Additional fixes --- .../watcher/actions/index/IndexAction.java | 2 +- .../search/WatcherSearchTemplateRequest.java | 4 ++-- .../search/WatcherSearchTemplateService.java | 4 +++- .../actions/index/IndexActionTests.java | 1 - .../watcher/support/WatcherUtilsTests.java | 16 +++++++++++--- .../xpack/watcher/test/WatcherTestUtils.java | 2 +- .../xpack/watcher/watch/WatchTests.java | 2 +- .../xpack/restart/FullClusterRestartIT.java | 22 +++++++++++++------ 8 files changed, 36 insertions(+), 17 deletions(-) diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/index/IndexAction.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/index/IndexAction.java index 5fac9c8cfcfe6..1b9bc373aae47 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/index/IndexAction.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/actions/index/IndexAction.java @@ -37,7 +37,7 @@ public class IndexAction implements Action { @Nullable final RefreshPolicy refreshPolicy; private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(IndexAction.class)); - static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Specifying types in a watcher index action is deprecated."; + public static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Specifying types in a watcher index action is deprecated."; public IndexAction(@Nullable String index, @Nullable String docType, @Nullable String docId, @Nullable String executionTimeField, diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateRequest.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateRequest.java index 41aecd4a5907b..670f4ffe66852 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateRequest.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateRequest.java @@ -47,7 +47,7 @@ public class WatcherSearchTemplateRequest implements ToXContentObject { private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(WatcherSearchTemplateRequest.class)); - static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Specifying types in a watcher search request is deprecated."; + public static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Specifying types in a watcher search request is deprecated."; public WatcherSearchTemplateRequest(String[] indices, String[] types, SearchType searchType, IndicesOptions indicesOptions, BytesReference searchSource) { @@ -313,7 +313,7 @@ public static WatcherSearchTemplateRequest fromXContent(XContentParser parser, S } WatcherSearchTemplateRequest request = new WatcherSearchTemplateRequest(indices.toArray(new String[0]), - types.toArray(new String[0]), searchType, indicesOptions, searchSource, template); + types.size() == 0 ? null : types.toArray(new String[0]), searchType, indicesOptions, searchSource, template); request.setRestTotalHitsAsInt(totalHitsAsInt); return request; } diff --git a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateService.java b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateService.java index 4cc3b0cb709aa..d86a63948c7ac 100644 --- a/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateService.java +++ b/x-pack/plugin/watcher/src/main/java/org/elasticsearch/xpack/watcher/support/search/WatcherSearchTemplateService.java @@ -57,7 +57,9 @@ public String renderTemplate(Script source, WatchExecutionContext ctx, Payload p public SearchRequest toSearchRequest(WatcherSearchTemplateRequest request) throws IOException { SearchRequest searchRequest = new SearchRequest(request.getIndices()); - searchRequest.types(request.getTypes()); + if (request.getTypes() != null) { + searchRequest.types(request.getTypes()); + } searchRequest.searchType(request.getSearchType()); searchRequest.indicesOptions(request.getIndicesOptions()); SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource(); diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/index/IndexActionTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/index/IndexActionTests.java index c18cf2dc1e521..85f17fbd0e8d1 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/index/IndexActionTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/actions/index/IndexActionTests.java @@ -92,7 +92,6 @@ public void testParser() throws Exception { ExecutableIndexAction executable = actionParser.parseExecutable(randomAlphaOfLength(5), randomAlphaOfLength(3), parser); - assertThat(executable.action().docType, equalTo("test-type")); if (includeIndex) { assertThat(executable.action().index, equalTo("test-index")); } diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherUtilsTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherUtilsTests.java index 401d101a469d3..195b0d3d312a2 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherUtilsTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherUtilsTests.java @@ -129,7 +129,6 @@ public void testSerializeSearchRequest() throws Exception { WatcherSearchTemplateRequest result = WatcherSearchTemplateRequest.fromXContent(parser, DEFAULT_SEARCH_TYPE); assertThat(result.getIndices(), arrayContainingInAnyOrder(expectedIndices != null ? expectedIndices : new String[0])); - assertThat(result.getTypes(), arrayContainingInAnyOrder(expectedTypes != null ? expectedTypes : new String[0])); assertThat(result.getIndicesOptions(), equalTo(expectedIndicesOptions)); assertThat(result.getSearchType(), equalTo(expectedSearchType)); @@ -143,6 +142,12 @@ public void testSerializeSearchRequest() throws Exception { assertThat(result.getTemplate().getIdOrCode(), equalTo(expectedSource.utf8ToString())); assertThat(result.getTemplate().getType(), equalTo(ScriptType.INLINE)); } + if (expectedTypes == null) { + assertNull(result.getTypes()); + } else { + assertThat(result.getTypes(), arrayContainingInAnyOrder(expectedTypes)); + assertWarnings(WatcherSearchTemplateRequest.TYPES_DEPRECATION_MESSAGE); + } } public void testDeserializeSearchRequest() throws Exception { @@ -161,7 +166,7 @@ public void testDeserializeSearchRequest() throws Exception { String[] types = Strings.EMPTY_ARRAY; if (randomBoolean()) { - types = generateRandomStringArray(2, 5, false); + types = generateRandomStringArray(2, 5, false, false); if (randomBoolean()) { builder.array("types", types); } else { @@ -220,7 +225,6 @@ public void testDeserializeSearchRequest() throws Exception { WatcherSearchTemplateRequest result = WatcherSearchTemplateRequest.fromXContent(parser, DEFAULT_SEARCH_TYPE); assertThat(result.getIndices(), arrayContainingInAnyOrder(indices)); - assertThat(result.getTypes(), arrayContainingInAnyOrder(types)); assertThat(result.getIndicesOptions(), equalTo(indicesOptions)); assertThat(result.getSearchType(), equalTo(searchType)); if (source == null) { @@ -236,6 +240,12 @@ public void testDeserializeSearchRequest() throws Exception { assertThat(result.getTemplate().getParams(), equalTo(template.getParams())); assertThat(result.getTemplate().getLang(), equalTo(stored ? null : "mustache")); } + if (types == Strings.EMPTY_ARRAY) { + assertNull(result.getTypes()); + } else { + assertThat(result.getTypes(), arrayContainingInAnyOrder(types)); + assertWarnings(WatcherSearchTemplateRequest.TYPES_DEPRECATION_MESSAGE); + } } } diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/WatcherTestUtils.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/WatcherTestUtils.java index bb5a6eabdd5b9..e22d3d6f0837c 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/WatcherTestUtils.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/test/WatcherTestUtils.java @@ -89,7 +89,7 @@ public static WatcherSearchTemplateRequest templateRequest(SearchSourceBuilder s try { XContentBuilder xContentBuilder = jsonBuilder(); xContentBuilder.value(sourceBuilder); - return new WatcherSearchTemplateRequest(indices, new String[0], searchType, + return new WatcherSearchTemplateRequest(indices, null, searchType, WatcherSearchTemplateRequest.DEFAULT_INDICES_OPTIONS, BytesReference.bytes(xContentBuilder)); } catch (IOException e) { throw new RuntimeException(e); diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/watch/WatchTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/watch/WatchTests.java index daf1f18f3bd2f..cb32c3eebec09 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/watch/WatchTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/watch/WatchTests.java @@ -586,7 +586,7 @@ private List randomActions() { DateTimeZone timeZone = randomBoolean() ? DateTimeZone.UTC : null; TimeValue timeout = randomBoolean() ? timeValueSeconds(between(1, 10000)) : null; WriteRequest.RefreshPolicy refreshPolicy = randomBoolean() ? null : randomFrom(WriteRequest.RefreshPolicy.values()); - IndexAction action = new IndexAction("_index", "_type", randomBoolean() ? "123" : null, null, timeout, timeZone, + IndexAction action = new IndexAction("_index", null, randomBoolean() ? "123" : null, null, timeout, timeZone, refreshPolicy); list.add(new ActionWrapper("_index_" + randomAlphaOfLength(8), randomThrottler(), AlwaysConditionTests.randomCondition(scriptService), randomTransform(), diff --git a/x-pack/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java b/x-pack/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java index e52a6dd3b4303..afea518f68585 100644 --- a/x-pack/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java +++ b/x-pack/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java @@ -8,6 +8,7 @@ import org.apache.http.util.EntityUtils; import org.elasticsearch.Version; import org.elasticsearch.client.Request; +import org.elasticsearch.client.RequestOptions; import org.elasticsearch.client.Response; import org.elasticsearch.client.ResponseException; import org.elasticsearch.common.settings.Settings; @@ -24,9 +25,11 @@ import org.elasticsearch.upgrades.AbstractFullClusterRestartTestCase; import org.elasticsearch.xpack.core.watcher.client.WatchSourceBuilder; import org.elasticsearch.xpack.security.support.SecurityIndexManager; +import org.elasticsearch.xpack.watcher.actions.index.IndexAction; import org.elasticsearch.xpack.watcher.actions.logging.LoggingAction; import org.elasticsearch.xpack.watcher.common.text.TextTemplate; import org.elasticsearch.xpack.watcher.condition.InternalAlwaysCondition; +import org.elasticsearch.xpack.watcher.support.search.WatcherSearchTemplateRequest; import org.elasticsearch.xpack.watcher.trigger.schedule.IntervalSchedule; import org.elasticsearch.xpack.watcher.trigger.schedule.ScheduleTrigger; import org.hamcrest.Matcher; @@ -193,7 +196,7 @@ public void testWatcher() throws Exception { logger.info("checking that upgrade procedure on the new cluster is no longer required"); Map responseAfter = entityAsMap(client().performRequest( - new Request("GET", "/_migration/assistance"))); + new Request("GET", "/_migration/assistance"))); @SuppressWarnings("unchecked") Map indicesAfter = (Map) responseAfter.get("indices"); assertNull(indicesAfter.get(".watches")); } else { @@ -207,7 +210,7 @@ public void testWatcher() throws Exception { Map statsWatchResponse = entityAsMap(client().performRequest(new Request("GET", "_watcher/stats"))); @SuppressWarnings("unchecked") List states = ((List) statsWatchResponse.get("stats")) - .stream().map(o -> ((Map) o).get("watcher_state")).collect(Collectors.toList()); + .stream().map(o -> ((Map) o).get("watcher_state")).collect(Collectors.toList()); assertThat(states, everyItem(is("started"))); }); @@ -223,10 +226,10 @@ public void testWatcher() throws Exception { assertThat(stopWatchResponse.get("acknowledged"), equalTo(Boolean.TRUE)); assertBusy(() -> { Map statsStoppedWatchResponse = entityAsMap(client().performRequest( - new Request("GET", "_watcher/stats"))); + new Request("GET", "_watcher/stats"))); @SuppressWarnings("unchecked") List states = ((List) statsStoppedWatchResponse.get("stats")) - .stream().map(o -> ((Map) o).get("watcher_state")).collect(Collectors.toList()); + .stream().map(o -> ((Map) o).get("watcher_state")).collect(Collectors.toList()); assertThat(states, everyItem(is("stopped"))); }); } @@ -456,7 +459,10 @@ private void assertOldTemplatesAreDeleted() throws IOException { @SuppressWarnings("unchecked") private void assertWatchIndexContentsWork() throws Exception { // Fetch a basic watch - Map bwcWatch = entityAsMap(client().performRequest(new Request("GET", "_watcher/watch/bwc_watch"))); + Request getRequest = new Request("GET", "_watcher/watch/bwc_watch"); + getRequest.setOptions(expectWarnings(IndexAction.TYPES_DEPRECATION_MESSAGE, + WatcherSearchTemplateRequest.TYPES_DEPRECATION_MESSAGE)); + Map bwcWatch = entityAsMap(client().performRequest(getRequest)); logger.error("-----> {}", bwcWatch); @@ -467,11 +473,13 @@ private void assertWatchIndexContentsWork() throws Exception { assertThat(ObjectPath.eval("input.search.timeout_in_millis", source), equalTo(timeout)); assertThat(ObjectPath.eval("actions.index_payload.transform.search.timeout_in_millis", source), equalTo(timeout)); assertThat(ObjectPath.eval("actions.index_payload.index.index", source), equalTo("bwc_watch_index")); - assertThat(ObjectPath.eval("actions.index_payload.index.doc_type", source), equalTo("bwc_watch_type")); assertThat(ObjectPath.eval("actions.index_payload.index.timeout_in_millis", source), equalTo(timeout)); // Fetch a watch with "fun" throttle periods - bwcWatch = entityAsMap(client().performRequest(new Request("GET", "_watcher/watch/bwc_throttle_period"))); + getRequest = new Request("GET", "_watcher/watch/bwc_throttle_period"); + getRequest.setOptions(expectWarnings(IndexAction.TYPES_DEPRECATION_MESSAGE, + WatcherSearchTemplateRequest.TYPES_DEPRECATION_MESSAGE)); + bwcWatch = entityAsMap(client().performRequest(getRequest)); assertThat(bwcWatch.get("found"), equalTo(true)); source = (Map) bwcWatch.get("watch"); assertEquals(timeout, source.get("throttle_period_in_millis")); From c5835088306c71b0cf3ba29e15d60dcfc71cd9b3 Mon Sep 17 00:00:00 2001 From: Jake Landis Date: Fri, 18 Jan 2019 18:59:02 -0600 Subject: [PATCH 5/6] remove unused import --- .../org/elasticsearch/xpack/restart/FullClusterRestartIT.java | 1 - 1 file changed, 1 deletion(-) diff --git a/x-pack/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java b/x-pack/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java index afea518f68585..d1aefb4000890 100644 --- a/x-pack/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java +++ b/x-pack/qa/full-cluster-restart/src/test/java/org/elasticsearch/xpack/restart/FullClusterRestartIT.java @@ -8,7 +8,6 @@ import org.apache.http.util.EntityUtils; import org.elasticsearch.Version; import org.elasticsearch.client.Request; -import org.elasticsearch.client.RequestOptions; import org.elasticsearch.client.Response; import org.elasticsearch.client.ResponseException; import org.elasticsearch.common.settings.Settings; From 833a0e4f4fc15a36af70ba4fb4309df1ca9fe916 Mon Sep 17 00:00:00 2001 From: Jake Landis Date: Fri, 18 Jan 2019 19:22:45 -0600 Subject: [PATCH 6/6] dis-allow empty types array in tests --- .../elasticsearch/xpack/watcher/support/WatcherUtilsTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherUtilsTests.java b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherUtilsTests.java index 195b0d3d312a2..7aab1d4d14504 100644 --- a/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherUtilsTests.java +++ b/x-pack/plugin/watcher/src/test/java/org/elasticsearch/xpack/watcher/support/WatcherUtilsTests.java @@ -90,7 +90,7 @@ public void testResponseToData() throws Exception { public void testSerializeSearchRequest() throws Exception { String[] expectedIndices = generateRandomStringArray(5, 5, true); - String[] expectedTypes = generateRandomStringArray(2, 5, true); + String[] expectedTypes = generateRandomStringArray(2, 5, true, false); IndicesOptions expectedIndicesOptions = IndicesOptions.fromOptions(randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(), WatcherSearchTemplateRequest.DEFAULT_INDICES_OPTIONS); SearchType expectedSearchType = getRandomSupportedSearchType();