deprecate types for watcher (#37594)
This commit adds deprecation warnings for index actions and search actions when executed via watcher. Unit and integration tests updated accordingly. relates #35190
This commit is contained in:
parent
9ceb218d85
commit
99b75a9bdf
|
@ -25,8 +25,7 @@
|
|||
"actions": {
|
||||
"test_index": {
|
||||
"index": {
|
||||
"index": "test",
|
||||
"doc_type": "test2"
|
||||
"index": "test"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,8 +25,7 @@
|
|||
"actions": {
|
||||
"test_index": {
|
||||
"index": {
|
||||
"index": "test",
|
||||
"doc_type": "test2"
|
||||
"index": "test"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,6 @@ teardown:
|
|||
"indexme" : {
|
||||
"index" : {
|
||||
"index" : "my_test_index",
|
||||
"doc_type" : "my-type",
|
||||
"doc_id": "my-id"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,6 @@ teardown:
|
|||
},
|
||||
"index" : {
|
||||
"index" : "my_test_index",
|
||||
"doc_type" : "my-type",
|
||||
"doc_id": "my-id"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,8 +25,7 @@
|
|||
"actions": {
|
||||
"test_index": {
|
||||
"index": {
|
||||
"index": "test",
|
||||
"doc_type": "test2"
|
||||
"index": "test"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,8 +38,7 @@ teardown:
|
|||
"actions": {
|
||||
"test_index": {
|
||||
"index": {
|
||||
"index": "test",
|
||||
"doc_type": "test2"
|
||||
"index": "test"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
"indexme" : {
|
||||
"index" : {
|
||||
"index" : "my_test_index",
|
||||
"doc_type" : "my-type",
|
||||
"doc_id": "my-id"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,8 +38,7 @@ teardown:
|
|||
"actions": {
|
||||
"test_index": {
|
||||
"index": {
|
||||
"index": "test",
|
||||
"doc_type": "test2"
|
||||
"index": "test"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,8 +30,7 @@
|
|||
"actions": {
|
||||
"test_index": {
|
||||
"index": {
|
||||
"index": "test",
|
||||
"doc_type": "test2"
|
||||
"index": "test"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,8 +29,7 @@
|
|||
"actions": {
|
||||
"test_index": {
|
||||
"index": {
|
||||
"index": "test",
|
||||
"doc_type": "test2"
|
||||
"index": "test"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,8 +39,7 @@ teardown:
|
|||
"actions": {
|
||||
"test_index": {
|
||||
"index": {
|
||||
"index": "test",
|
||||
"doc_type": "test2"
|
||||
"index": "test"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,8 +39,7 @@ teardown:
|
|||
"test_index": {
|
||||
"throttle_period" : "10s",
|
||||
"index": {
|
||||
"index": "test",
|
||||
"doc_type": "test2"
|
||||
"index": "test"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,8 +39,7 @@ teardown:
|
|||
"actions": {
|
||||
"test_index": {
|
||||
"index": {
|
||||
"index": "test",
|
||||
"doc_type": "test2"
|
||||
"index": "test"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,8 +43,7 @@ teardown:
|
|||
}
|
||||
},
|
||||
"index": {
|
||||
"index": "test",
|
||||
"doc_type": "test2"
|
||||
"index": "test"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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" }
|
||||
|
|
|
@ -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));
|
||||
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,
|
||||
@Nullable TimeValue timeout, @Nullable DateTimeZone dynamicNameTimeZone, @Nullable RefreshPolicy refreshPolicy) {
|
||||
|
@ -151,6 +156,7 @@ public class IndexAction implements Action {
|
|||
}
|
||||
} 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();
|
||||
|
|
|
@ -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.ParseField;
|
|||
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));
|
||||
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) {
|
||||
this.indices = indices;
|
||||
|
@ -203,6 +209,7 @@ public class WatcherSearchTemplateRequest implements ToXContentObject {
|
|||
}
|
||||
}
|
||||
} 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 class WatcherSearchTemplateRequest implements ToXContentObject {
|
|||
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())) {
|
||||
|
@ -305,7 +313,7 @@ public class WatcherSearchTemplateRequest implements ToXContentObject {
|
|||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -57,7 +57,9 @@ public class WatcherSearchTemplateService {
|
|||
|
||||
public SearchRequest toSearchRequest(WatcherSearchTemplateRequest request) throws IOException {
|
||||
SearchRequest searchRequest = new SearchRequest(request.getIndices());
|
||||
if (request.getTypes() != null) {
|
||||
searchRequest.types(request.getTypes());
|
||||
}
|
||||
searchRequest.searchType(request.getSearchType());
|
||||
searchRequest.indicesOptions(request.getIndicesOptions());
|
||||
SearchSourceBuilder sourceBuilder = SearchSourceBuilder.searchSource();
|
||||
|
|
|
@ -78,7 +78,6 @@ public class IndexActionTests extends ESTestCase {
|
|||
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);
|
||||
}
|
||||
|
@ -93,7 +92,6 @@ public class IndexActionTests extends ESTestCase {
|
|||
|
||||
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"));
|
||||
}
|
||||
|
@ -103,6 +101,19 @@ public class IndexActionTests extends ESTestCase {
|
|||
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);
|
||||
}
|
||||
|
||||
public void testParserFailure() throws Exception {
|
||||
// wrong type for field
|
||||
expectParseFailure(jsonBuilder()
|
||||
|
|
|
@ -90,7 +90,7 @@ public class WatcherUtilsTests extends ESTestCase {
|
|||
|
||||
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();
|
||||
|
@ -129,7 +129,6 @@ public class WatcherUtilsTests extends ESTestCase {
|
|||
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 class WatcherUtilsTests extends ESTestCase {
|
|||
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 class WatcherUtilsTests extends ESTestCase {
|
|||
|
||||
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 class WatcherUtilsTests extends ESTestCase {
|
|||
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 class WatcherUtilsTests extends ESTestCase {
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -39,6 +39,24 @@ public class WatcherSearchTemplateRequestTests extends ESTestCase {
|
|||
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();
|
||||
|
|
|
@ -89,7 +89,7 @@ public final class WatcherTestUtils {
|
|||
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);
|
||||
|
|
|
@ -586,7 +586,7 @@ public class WatchTests extends ESTestCase {
|
|||
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(),
|
||||
|
|
|
@ -24,9 +24,11 @@ import org.elasticsearch.test.rest.ESRestTestCase;
|
|||
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;
|
||||
|
@ -456,7 +458,10 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
|||
@SuppressWarnings("unchecked")
|
||||
private void assertWatchIndexContentsWork() throws Exception {
|
||||
// Fetch a basic watch
|
||||
Map<String, Object> 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<String, Object> bwcWatch = entityAsMap(client().performRequest(getRequest));
|
||||
|
||||
logger.error("-----> {}", bwcWatch);
|
||||
|
||||
|
@ -467,11 +472,13 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
|||
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<String, Object>) bwcWatch.get("watch");
|
||||
assertEquals(timeout, source.get("throttle_period_in_millis"));
|
||||
|
|
|
@ -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: >
|
||||
{
|
||||
|
|
|
@ -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: >
|
||||
{
|
||||
|
|
|
@ -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: >
|
||||
{
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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" }
|
||||
|
|
Loading…
Reference in New Issue