diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/action/RetryAction.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/action/RetryAction.java index 56a44cc3ad0..5868f8eeb06 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/action/RetryAction.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/action/RetryAction.java @@ -26,7 +26,7 @@ import java.util.Objects; public class RetryAction extends Action { public static final RetryAction INSTANCE = new RetryAction(); - public static final String NAME = "indices:admin/xpack/index_lifecycle/_retry/post"; + public static final String NAME = "indices:admin/xpack/index_lifecycle/retry"; protected RetryAction() { super(NAME); @@ -48,7 +48,8 @@ public class RetryAction extends Action implements IndicesRequest.Replaceable { - private String[] indices; + private String[] indices = Strings.EMPTY_ARRAY; + private IndicesOptions indicesOptions = IndicesOptions.strictExpandOpen(); public Request(String... indices) { this.indices = indices; @@ -70,8 +71,12 @@ public class RetryAction extends Action { - - @Override - protected Request createTestInstance() { - String[] indices = new String[randomIntBetween(1, 10)]; - for (int i = 0; i < indices.length; i++) { - indices[i] = randomAlphaOfLengthBetween(2, 5); - } - return new Request(indices); - } - - @Override - protected Request createBlankInstance() { - return new Request(); - } -} diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/action/RetryRequestTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/action/RetryRequestTests.java new file mode 100644 index 00000000000..5b8fc85cd96 --- /dev/null +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/action/RetryRequestTests.java @@ -0,0 +1,56 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + * + */ +package org.elasticsearch.xpack.core.indexlifecycle.action; + +import org.elasticsearch.action.support.IndicesOptions; +import org.elasticsearch.test.AbstractStreamableTestCase; +import org.elasticsearch.xpack.core.indexlifecycle.action.RetryAction.Request; + +import java.io.IOException; + +public class RetryRequestTests extends AbstractStreamableTestCase { + + @Override + protected Request createTestInstance() { + Request request = new Request(); + if (randomBoolean()) { + request.indices(generateRandomStringArray(20, 20, false)); + } + if (randomBoolean()) { + IndicesOptions indicesOptions = IndicesOptions.fromOptions(randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(), + randomBoolean(), randomBoolean(), randomBoolean()); + request.indicesOptions(indicesOptions); + } + return request; + } + + @Override + protected Request mutateInstance(Request instance) throws IOException { + String[] indices = instance.indices(); + IndicesOptions indicesOptions = instance.indicesOptions(); + switch (between(0, 1)) { + case 0: + indices = generateRandomStringArray(20, 10, false); + break; + case 1: + indicesOptions = randomValueOtherThan(indicesOptions, () -> IndicesOptions.fromOptions(randomBoolean(), randomBoolean(), + randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean(), randomBoolean())); + break; + default: + throw new AssertionError("Illegal randomisation branch"); + } + Request newRequest = new Request(); + newRequest.indices(indices); + newRequest.indicesOptions(indicesOptions); + return newRequest; + } + + @Override + protected Request createBlankInstance() { + return new Request(); + } +} diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/action/ReRunResponseTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/action/RetryResponseTests.java similarity index 92% rename from x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/action/ReRunResponseTests.java rename to x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/action/RetryResponseTests.java index 4cfb64482f8..24e758f9503 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/action/ReRunResponseTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/action/RetryResponseTests.java @@ -9,7 +9,7 @@ package org.elasticsearch.xpack.core.indexlifecycle.action; import org.elasticsearch.test.AbstractStreamableTestCase; import org.elasticsearch.xpack.core.indexlifecycle.action.RetryAction.Response; -public class ReRunResponseTests extends AbstractStreamableTestCase { +public class RetryResponseTests extends AbstractStreamableTestCase { @Override protected Response createTestInstance() { diff --git a/x-pack/plugin/index-lifecycle/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/RestRetryAction.java b/x-pack/plugin/index-lifecycle/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/RestRetryAction.java index c021651bdf3..4cfd2f1cb7a 100644 --- a/x-pack/plugin/index-lifecycle/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/RestRetryAction.java +++ b/x-pack/plugin/index-lifecycle/src/main/java/org/elasticsearch/xpack/indexlifecycle/action/RestRetryAction.java @@ -6,6 +6,7 @@ */ package org.elasticsearch.xpack.indexlifecycle.action; +import org.elasticsearch.action.support.IndicesOptions; import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; import org.elasticsearch.common.settings.Settings; @@ -20,7 +21,8 @@ public class RestRetryAction extends BaseRestHandler { public RestRetryAction(Settings settings, RestController controller) { super(settings); - controller.registerHandler(RestRequest.Method.POST, IndexLifecycle.BASE_PATH + "_retry/{index}", this); + controller.registerHandler(RestRequest.Method.POST, "_" + IndexLifecycle.NAME + "/retry", this); + controller.registerHandler(RestRequest.Method.POST, "{index}/_" + IndexLifecycle.NAME + "/retry", this); } @Override @@ -34,6 +36,8 @@ public class RestRetryAction extends BaseRestHandler { RetryAction.Request request = new RetryAction.Request(indices); request.timeout(restRequest.paramAsTime("timeout", request.timeout())); request.masterNodeTimeout(restRequest.paramAsTime("master_timeout", request.masterNodeTimeout())); + request.indices(indices); + request.indicesOptions(IndicesOptions.fromRequest(restRequest, IndicesOptions.strictExpandOpen())); return channel -> client.execute(RetryAction.INSTANCE, request, new RestToXContentListener<>(channel)); } } diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.index_lifecycle.retry.json b/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.index_lifecycle.retry.json index 9ac94985aa6..5f934b75aa8 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.index_lifecycle.retry.json +++ b/x-pack/plugin/src/test/resources/rest-api-spec/api/xpack.index_lifecycle.retry.json @@ -3,8 +3,8 @@ "documentation": "http://www.elastic.co/guide/en/index_lifecycle/current/index_lifecycle.html", "methods": [ "POST" ], "url": { - "path": "/_xpack/index_lifecycle/_retry/{index}", - "paths": ["/_xpack/index_lifecycle/_retry/{index}"], + "path": "/{index}/_index_lifecycle/retry", + "paths": ["/{index}/_index_lifecycle/retry", "/_index_lifecycle/retry"], "parts": { "index": { "type" : "string",