diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/InitializePolicyContextStep.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/InitializePolicyContextStep.java index feec3590109..157488bb5e3 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/InitializePolicyContextStep.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/indexlifecycle/InitializePolicyContextStep.java @@ -12,7 +12,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.Index; public final class InitializePolicyContextStep extends ClusterStateActionStep { - public static final StepKey KEY = new StepKey("pre-phase", "pre-action", "init"); + public static final StepKey KEY = new StepKey("new", "init", "init"); public InitializePolicyContextStep(Step.StepKey key, StepKey nextStepKey) { super(key, nextStepKey); diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/LifecyclePolicyTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/LifecyclePolicyTests.java index f739d7b5f71..1b4bbe0f4e5 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/LifecyclePolicyTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/indexlifecycle/LifecyclePolicyTests.java @@ -177,7 +177,7 @@ public class LifecyclePolicyTests extends AbstractSerializingTestCase steps = policy.toSteps(client, nowSupplier); assertThat(steps.size(), equalTo(2)); assertThat(steps.get(0), instanceOf(InitializePolicyContextStep.class)); - assertThat(steps.get(0).getKey(), equalTo(new StepKey("pre-phase", "pre-action", "init"))); + assertThat(steps.get(0).getKey(), equalTo(new StepKey("new", "init", "init"))); assertThat(steps.get(0).getNextStepKey(), equalTo(TerminalPolicyStep.KEY)); assertSame(steps.get(1), TerminalPolicyStep.INSTANCE); } diff --git a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/indexlifecycle/ExecuteStepsUpdateTaskTests.java b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/indexlifecycle/ExecuteStepsUpdateTaskTests.java index 0d1ecd27063..9f4d8811dc6 100644 --- a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/indexlifecycle/ExecuteStepsUpdateTaskTests.java +++ b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/indexlifecycle/ExecuteStepsUpdateTaskTests.java @@ -108,8 +108,8 @@ public class ExecuteStepsUpdateTaskTests extends ESTestCase { IndexMetaData indexMetadata = IndexMetaData.builder(indexName) .settings(settings(Version.CURRENT) .put(LifecycleSettings.LIFECYCLE_NAME, policyName) - .put(LifecycleSettings.LIFECYCLE_PHASE, "pre-phase") - .put(LifecycleSettings.LIFECYCLE_ACTION, "pre-action") + .put(LifecycleSettings.LIFECYCLE_PHASE, "new") + .put(LifecycleSettings.LIFECYCLE_ACTION, "init") .put(LifecycleSettings.LIFECYCLE_STEP, "init")) .numberOfShards(randomIntBetween(1, 5)).numberOfReplicas(randomIntBetween(0, 5)).build(); index = indexMetadata.getIndex(); @@ -133,6 +133,7 @@ public class ExecuteStepsUpdateTaskTests extends ESTestCase { setupIndexPolicy(allClusterPolicyName); Step startStep = policyStepsRegistry.getFirstStep(allClusterPolicyName); + Step afterStep = policyStepsRegistry.getStep(index, startStep.getNextStepKey()); long now = randomNonNegativeLong(); // test execute start till end of phase `new` ExecuteStepsUpdateTask task = new ExecuteStepsUpdateTask(allClusterPolicyName, index, startStep, policyStepsRegistry, () -> now); @@ -140,16 +141,9 @@ public class ExecuteStepsUpdateTaskTests extends ESTestCase { // Update the registry so the next phase's steps are loaded policyStepsRegistry.update(newState, client, () -> now); - Step afterStep = policyStepsRegistry.getStep(index, startStep.getNextStepKey()); + // verify that both the `new` phase was executed and the next phase is to begin StepKey currentStepKey = IndexLifecycleRunner.getCurrentStepKey(newState.metaData().index(index).getSettings()); - assertThat(currentStepKey, equalTo(afterStep.getKey())); - // test execute phase-after until firstStep - task = new ExecuteStepsUpdateTask(allClusterPolicyName, index, afterStep, policyStepsRegistry, () -> now); - newState = task.execute(newState); - policyStepsRegistry.update(newState, client, () -> now); - - currentStepKey = IndexLifecycleRunner.getCurrentStepKey(newState.metaData().index(index).getSettings()); assertThat(currentStepKey, equalTo(firstStep.getKey())); // test execute all actions in same phase task = new ExecuteStepsUpdateTask(allClusterPolicyName, index, firstStep, policyStepsRegistry, () -> now); diff --git a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/indexlifecycle/PolicyStepsRegistryTests.java b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/indexlifecycle/PolicyStepsRegistryTests.java index 8133e36e1ae..3ccf3e34c08 100644 --- a/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/indexlifecycle/PolicyStepsRegistryTests.java +++ b/x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/indexlifecycle/PolicyStepsRegistryTests.java @@ -127,7 +127,7 @@ public class PolicyStepsRegistryTests extends ESTestCase { .put("index.number_of_replicas", 0) .put("index.version.created", Version.CURRENT.id) .put(LifecycleSettings.LIFECYCLE_NAME, policyName) - .put(LifecycleSettings.LIFECYCLE_PHASE, "pre-phase"))) + .put(LifecycleSettings.LIFECYCLE_PHASE, "new"))) .build(); try (XContentBuilder builder = JsonXContent.contentBuilder()) { builder.startObject();