|
8 | 8 | package org.elasticsearch.xpack.ilm; |
9 | 9 |
|
10 | 10 | import org.elasticsearch.ElasticsearchException; |
11 | | -import org.elasticsearch.cluster.ClusterState; |
12 | 11 | import org.elasticsearch.cluster.metadata.IndexMetadata; |
13 | 12 | import org.elasticsearch.cluster.metadata.LifecycleExecutionState; |
14 | | -import org.elasticsearch.cluster.metadata.Metadata; |
15 | 13 | import org.elasticsearch.cluster.metadata.ProjectMetadata; |
16 | 14 | import org.elasticsearch.common.bytes.BytesReference; |
17 | 15 | import org.elasticsearch.common.settings.Settings; |
18 | | -import org.elasticsearch.common.xcontent.XContentHelper; |
19 | 16 | import org.elasticsearch.core.TimeValue; |
20 | 17 | import org.elasticsearch.index.Index; |
21 | 18 | import org.elasticsearch.index.IndexVersion; |
|
56 | 53 |
|
57 | 54 | import static org.elasticsearch.cluster.metadata.LifecycleExecutionState.ILM_CUSTOM_METADATA_KEY; |
58 | 55 | import static org.elasticsearch.xpack.core.ilm.PhaseCacheManagement.eligibleToCheckForRefresh; |
59 | | -import static org.elasticsearch.xpack.core.ilm.PhaseCacheManagementTests.refreshPhaseDefinition; |
60 | 56 | import static org.elasticsearch.xpack.ilm.IndexLifecycleRunnerTests.createOneStepPolicyStepRegistry; |
61 | 57 | import static org.elasticsearch.xpack.ilm.IndexLifecycleTransition.moveStateToNextActionAndUpdateCachedPhase; |
62 | 58 | import static org.elasticsearch.xpack.ilm.LifecyclePolicyTestsUtils.newTestLifecyclePolicy; |
@@ -946,75 +942,6 @@ public void testMoveToFailedStepDoesntRefreshCachedPhaseWhenUnsafe() { |
946 | 942 | assertThat(nextLifecycleExecutionState.step(), is(failedStep)); |
947 | 943 | } |
948 | 944 |
|
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 | | - |
1018 | 945 | public void testEligibleForRefresh() { |
1019 | 946 | IndexMetadata meta = IndexMetadata.builder("index") |
1020 | 947 | .settings( |
|
0 commit comments