rename pre-phase/pre-action to new/init (#32996)
this will keep things more consistent with the initial PhaseAfterStep, which has a phase name of `new`
This commit is contained in:
parent
55cb08a352
commit
dfc70ddcc7
|
@ -12,7 +12,7 @@ import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.index.Index;
|
import org.elasticsearch.index.Index;
|
||||||
|
|
||||||
public final class InitializePolicyContextStep extends ClusterStateActionStep {
|
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) {
|
public InitializePolicyContextStep(Step.StepKey key, StepKey nextStepKey) {
|
||||||
super(key, nextStepKey);
|
super(key, nextStepKey);
|
||||||
|
|
|
@ -177,7 +177,7 @@ public class LifecyclePolicyTests extends AbstractSerializingTestCase<LifecycleP
|
||||||
List<Step> steps = policy.toSteps(client, nowSupplier);
|
List<Step> steps = policy.toSteps(client, nowSupplier);
|
||||||
assertThat(steps.size(), equalTo(2));
|
assertThat(steps.size(), equalTo(2));
|
||||||
assertThat(steps.get(0), instanceOf(InitializePolicyContextStep.class));
|
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));
|
assertThat(steps.get(0).getNextStepKey(), equalTo(TerminalPolicyStep.KEY));
|
||||||
assertSame(steps.get(1), TerminalPolicyStep.INSTANCE);
|
assertSame(steps.get(1), TerminalPolicyStep.INSTANCE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,8 +108,8 @@ public class ExecuteStepsUpdateTaskTests extends ESTestCase {
|
||||||
IndexMetaData indexMetadata = IndexMetaData.builder(indexName)
|
IndexMetaData indexMetadata = IndexMetaData.builder(indexName)
|
||||||
.settings(settings(Version.CURRENT)
|
.settings(settings(Version.CURRENT)
|
||||||
.put(LifecycleSettings.LIFECYCLE_NAME, policyName)
|
.put(LifecycleSettings.LIFECYCLE_NAME, policyName)
|
||||||
.put(LifecycleSettings.LIFECYCLE_PHASE, "pre-phase")
|
.put(LifecycleSettings.LIFECYCLE_PHASE, "new")
|
||||||
.put(LifecycleSettings.LIFECYCLE_ACTION, "pre-action")
|
.put(LifecycleSettings.LIFECYCLE_ACTION, "init")
|
||||||
.put(LifecycleSettings.LIFECYCLE_STEP, "init"))
|
.put(LifecycleSettings.LIFECYCLE_STEP, "init"))
|
||||||
.numberOfShards(randomIntBetween(1, 5)).numberOfReplicas(randomIntBetween(0, 5)).build();
|
.numberOfShards(randomIntBetween(1, 5)).numberOfReplicas(randomIntBetween(0, 5)).build();
|
||||||
index = indexMetadata.getIndex();
|
index = indexMetadata.getIndex();
|
||||||
|
@ -133,6 +133,7 @@ public class ExecuteStepsUpdateTaskTests extends ESTestCase {
|
||||||
setupIndexPolicy(allClusterPolicyName);
|
setupIndexPolicy(allClusterPolicyName);
|
||||||
|
|
||||||
Step startStep = policyStepsRegistry.getFirstStep(allClusterPolicyName);
|
Step startStep = policyStepsRegistry.getFirstStep(allClusterPolicyName);
|
||||||
|
Step afterStep = policyStepsRegistry.getStep(index, startStep.getNextStepKey());
|
||||||
long now = randomNonNegativeLong();
|
long now = randomNonNegativeLong();
|
||||||
// test execute start till end of phase `new`
|
// test execute start till end of phase `new`
|
||||||
ExecuteStepsUpdateTask task = new ExecuteStepsUpdateTask(allClusterPolicyName, index, startStep, policyStepsRegistry, () -> now);
|
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
|
// Update the registry so the next phase's steps are loaded
|
||||||
policyStepsRegistry.update(newState, client, () -> now);
|
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());
|
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()));
|
assertThat(currentStepKey, equalTo(firstStep.getKey()));
|
||||||
// test execute all actions in same phase
|
// test execute all actions in same phase
|
||||||
task = new ExecuteStepsUpdateTask(allClusterPolicyName, index, firstStep, policyStepsRegistry, () -> now);
|
task = new ExecuteStepsUpdateTask(allClusterPolicyName, index, firstStep, policyStepsRegistry, () -> now);
|
||||||
|
|
|
@ -127,7 +127,7 @@ public class PolicyStepsRegistryTests extends ESTestCase {
|
||||||
.put("index.number_of_replicas", 0)
|
.put("index.number_of_replicas", 0)
|
||||||
.put("index.version.created", Version.CURRENT.id)
|
.put("index.version.created", Version.CURRENT.id)
|
||||||
.put(LifecycleSettings.LIFECYCLE_NAME, policyName)
|
.put(LifecycleSettings.LIFECYCLE_NAME, policyName)
|
||||||
.put(LifecycleSettings.LIFECYCLE_PHASE, "pre-phase")))
|
.put(LifecycleSettings.LIFECYCLE_PHASE, "new")))
|
||||||
.build();
|
.build();
|
||||||
try (XContentBuilder builder = JsonXContent.contentBuilder()) {
|
try (XContentBuilder builder = JsonXContent.contentBuilder()) {
|
||||||
builder.startObject();
|
builder.startObject();
|
||||||
|
|
Loading…
Reference in New Issue