Skip to content

Commit 47d1bd5

Browse files
authored
Remove duplicate test in IndexLifecycleTransitionTests (#129045)
This exact test also exists in `PhaseCacheManagementTests` and that class is a more suitable place for it.
1 parent ffa423d commit 47d1bd5

File tree

1 file changed

+0
-73
lines changed

1 file changed

+0
-73
lines changed

x-pack/plugin/ilm/src/test/java/org/elasticsearch/xpack/ilm/IndexLifecycleTransitionTests.java

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,11 @@
88
package org.elasticsearch.xpack.ilm;
99

1010
import org.elasticsearch.ElasticsearchException;
11-
import org.elasticsearch.cluster.ClusterState;
1211
import org.elasticsearch.cluster.metadata.IndexMetadata;
1312
import org.elasticsearch.cluster.metadata.LifecycleExecutionState;
14-
import org.elasticsearch.cluster.metadata.Metadata;
1513
import org.elasticsearch.cluster.metadata.ProjectMetadata;
1614
import org.elasticsearch.common.bytes.BytesReference;
1715
import org.elasticsearch.common.settings.Settings;
18-
import org.elasticsearch.common.xcontent.XContentHelper;
1916
import org.elasticsearch.core.TimeValue;
2017
import org.elasticsearch.index.Index;
2118
import org.elasticsearch.index.IndexVersion;
@@ -56,7 +53,6 @@
5653

5754
import static org.elasticsearch.cluster.metadata.LifecycleExecutionState.ILM_CUSTOM_METADATA_KEY;
5855
import static org.elasticsearch.xpack.core.ilm.PhaseCacheManagement.eligibleToCheckForRefresh;
59-
import static org.elasticsearch.xpack.core.ilm.PhaseCacheManagementTests.refreshPhaseDefinition;
6056
import static org.elasticsearch.xpack.ilm.IndexLifecycleRunnerTests.createOneStepPolicyStepRegistry;
6157
import static org.elasticsearch.xpack.ilm.IndexLifecycleTransition.moveStateToNextActionAndUpdateCachedPhase;
6258
import static org.elasticsearch.xpack.ilm.LifecyclePolicyTestsUtils.newTestLifecyclePolicy;
@@ -946,75 +942,6 @@ public void testMoveToFailedStepDoesntRefreshCachedPhaseWhenUnsafe() {
946942
assertThat(nextLifecycleExecutionState.step(), is(failedStep));
947943
}
948944

949-
public void testRefreshPhaseJson() throws IOException {
950-
LifecycleExecutionState.Builder exState = LifecycleExecutionState.builder()
951-
.setPhase("hot")
952-
.setAction("rollover")
953-
.setStep("check-rollover-ready")
954-
.setPhaseDefinition("""
955-
{
956-
"policy" : "my-policy",
957-
"phase_definition" : {
958-
"min_age" : "20m",
959-
"actions" : {
960-
"rollover" : {
961-
"max_age" : "5s"
962-
},
963-
"set_priority" : {
964-
"priority" : 150
965-
}
966-
}
967-
},
968-
"version" : 1,
969-
"modified_date_in_millis" : 1578521007076
970-
}""");
971-
972-
IndexMetadata meta = buildIndexMetadata("my-policy", exState);
973-
String index = meta.getIndex().getName();
974-
975-
Map<String, LifecycleAction> actions = new HashMap<>();
976-
actions.put("rollover", new RolloverAction(null, null, null, 1L, null, null, null, null, null, null));
977-
actions.put("set_priority", new SetPriorityAction(100));
978-
Phase hotPhase = new Phase("hot", TimeValue.ZERO, actions);
979-
Map<String, Phase> phases = Map.of("hot", hotPhase);
980-
LifecyclePolicy newPolicy = new LifecyclePolicy("my-policy", phases);
981-
LifecyclePolicyMetadata policyMetadata = new LifecyclePolicyMetadata(newPolicy, Map.of(), 2L, 2L);
982-
983-
ClusterState existingState = ClusterState.builder(ClusterState.EMPTY_STATE)
984-
.metadata(Metadata.builder(Metadata.EMPTY_METADATA).put(meta, false).build())
985-
.build();
986-
987-
ClusterState changedState = refreshPhaseDefinition(existingState, index, policyMetadata);
988-
989-
IndexMetadata newIdxMeta = changedState.metadata().getProject().index(index);
990-
LifecycleExecutionState afterExState = newIdxMeta.getLifecycleExecutionState();
991-
Map<String, String> beforeState = new HashMap<>(exState.build().asMap());
992-
beforeState.remove("phase_definition");
993-
Map<String, String> afterState = new HashMap<>(afterExState.asMap());
994-
afterState.remove("phase_definition");
995-
// Check that no other execution state changes have been made
996-
assertThat(beforeState, equalTo(afterState));
997-
998-
// Check that the phase definition has been refreshed
999-
assertThat(afterExState.phaseDefinition(), equalTo(XContentHelper.stripWhitespace("""
1000-
{
1001-
"policy": "my-policy",
1002-
"phase_definition": {
1003-
"min_age": "0ms",
1004-
"actions": {
1005-
"rollover": {
1006-
"max_docs": 1
1007-
},
1008-
"set_priority": {
1009-
"priority": 100
1010-
}
1011-
}
1012-
},
1013-
"version": 2,
1014-
"modified_date_in_millis": 2
1015-
}""")));
1016-
}
1017-
1018945
public void testEligibleForRefresh() {
1019946
IndexMetadata meta = IndexMetadata.builder("index")
1020947
.settings(

0 commit comments

Comments
 (0)