|
6 | 6 | */ |
7 | 7 | package org.elasticsearch.xpack.core.ilm; |
8 | 8 |
|
| 9 | +import org.elasticsearch.Version; |
| 10 | +import org.elasticsearch.cluster.ClusterName; |
| 11 | +import org.elasticsearch.cluster.ClusterState; |
| 12 | +import org.elasticsearch.cluster.metadata.IndexMetadata; |
| 13 | +import org.elasticsearch.cluster.metadata.Metadata; |
9 | 14 | import org.elasticsearch.common.io.stream.Writeable.Reader; |
10 | 15 | import org.elasticsearch.common.xcontent.XContentParser; |
11 | 16 | import org.elasticsearch.xpack.cluster.routing.allocation.DataTierAllocationDecider; |
|
14 | 19 | import java.io.IOException; |
15 | 20 | import java.util.List; |
16 | 21 |
|
| 22 | +import static org.elasticsearch.index.IndexModule.INDEX_STORE_TYPE_SETTING; |
17 | 23 | import static org.elasticsearch.xpack.core.DataTier.DATA_COLD; |
18 | 24 | import static org.elasticsearch.xpack.core.DataTier.DATA_HOT; |
19 | 25 | import static org.elasticsearch.xpack.core.DataTier.DATA_WARM; |
|
22 | 28 | import static org.elasticsearch.xpack.core.ilm.TimeseriesLifecycleType.DELETE_PHASE; |
23 | 29 | import static org.elasticsearch.xpack.core.ilm.TimeseriesLifecycleType.HOT_PHASE; |
24 | 30 | import static org.elasticsearch.xpack.core.ilm.TimeseriesLifecycleType.WARM_PHASE; |
| 31 | +import static org.elasticsearch.xpack.searchablesnapshots.SearchableSnapshotsConstants.SNAPSHOT_DIRECTORY_FACTORY_KEY; |
| 32 | +import static org.elasticsearch.xpack.searchablesnapshots.SearchableSnapshotsConstants.SNAPSHOT_PARTIAL_SETTING; |
25 | 33 | import static org.hamcrest.CoreMatchers.is; |
26 | 34 |
|
27 | 35 | public class MigrateActionTests extends AbstractActionTestCase<MigrateAction> { |
@@ -106,4 +114,51 @@ public void testMigrateActionsConfiguresTierPreference() { |
106 | 114 | is(DATA_COLD + "," + DATA_WARM + "," + DATA_HOT)); |
107 | 115 | } |
108 | 116 | } |
| 117 | + |
| 118 | + public void testMigrateActionWillSkipAPartiallyMountedIndex() { |
| 119 | + StepKey nextStepKey = new StepKey(randomAlphaOfLengthBetween(1, 10), randomAlphaOfLengthBetween(1, 10), |
| 120 | + randomAlphaOfLengthBetween(1, 10)); |
| 121 | + MigrateAction action = new MigrateAction(); |
| 122 | + |
| 123 | + // does not skip an ordinary index |
| 124 | + { |
| 125 | + IndexMetadata indexMetadata = IndexMetadata.builder(randomAlphaOfLength(5)) |
| 126 | + .settings(settings(Version.CURRENT)) |
| 127 | + .numberOfShards(1) |
| 128 | + .numberOfReplicas(2) |
| 129 | + .build(); |
| 130 | + |
| 131 | + ClusterState clusterState = ClusterState.builder(new ClusterName("_name")) |
| 132 | + .metadata(Metadata.builder().put(indexMetadata, true).build()) |
| 133 | + .build(); |
| 134 | + |
| 135 | + List<Step> steps = action.toSteps(null, HOT_PHASE, nextStepKey); |
| 136 | + BranchingStep firstStep = (BranchingStep) steps.get(0); |
| 137 | + UpdateSettingsStep secondStep = (UpdateSettingsStep) steps.get(1); |
| 138 | + firstStep.performAction(indexMetadata.getIndex(), clusterState); |
| 139 | + |
| 140 | + assertEquals(secondStep.getKey(), firstStep.getNextStepKey()); |
| 141 | + } |
| 142 | + |
| 143 | + // does skip a partially mounted |
| 144 | + { |
| 145 | + IndexMetadata indexMetadata = IndexMetadata.builder(randomAlphaOfLength(5)) |
| 146 | + .settings(settings(Version.CURRENT) |
| 147 | + .put(INDEX_STORE_TYPE_SETTING.getKey(), SNAPSHOT_DIRECTORY_FACTORY_KEY) |
| 148 | + .put(SNAPSHOT_PARTIAL_SETTING.getKey(), true)) |
| 149 | + .numberOfShards(1) |
| 150 | + .numberOfReplicas(2) |
| 151 | + .build(); |
| 152 | + |
| 153 | + ClusterState clusterState = ClusterState.builder(new ClusterName("_name")) |
| 154 | + .metadata(Metadata.builder().put(indexMetadata, true).build()) |
| 155 | + .build(); |
| 156 | + |
| 157 | + List<Step> steps = action.toSteps(null, HOT_PHASE, nextStepKey); |
| 158 | + BranchingStep firstStep = (BranchingStep) steps.get(0); |
| 159 | + firstStep.performAction(indexMetadata.getIndex(), clusterState); |
| 160 | + |
| 161 | + assertEquals(nextStepKey, firstStep.getNextStepKey()); |
| 162 | + } |
| 163 | + } |
109 | 164 | } |
0 commit comments