|
|
@@ -25,7 +25,6 @@ import org.elasticsearch.common.xcontent.json.JsonXContent;
|
|
|
import org.elasticsearch.core.CheckedRunnable;
|
|
|
import org.elasticsearch.core.Nullable;
|
|
|
import org.elasticsearch.core.TimeValue;
|
|
|
-import org.elasticsearch.index.IndexSettings;
|
|
|
import org.elasticsearch.index.engine.EngineConfig;
|
|
|
import org.elasticsearch.rest.action.admin.indices.RestPutIndexTemplateAction;
|
|
|
import org.elasticsearch.snapshots.SnapshotState;
|
|
|
@@ -143,24 +142,17 @@ public class TimeSeriesLifecycleActionsIT extends ESRestTestCase {
|
|
|
assertBusy(() -> assertFalse(indexExists(index)));
|
|
|
}
|
|
|
|
|
|
- public void testRetryFreezeDeleteAction() throws Exception {
|
|
|
+ public void testFreezeNoop() throws Exception {
|
|
|
createNewSingletonPolicy(client(), policy, "cold", new FreezeAction());
|
|
|
|
|
|
createIndexWithSettings(client(), index, alias, Settings.builder()
|
|
|
.put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
|
|
|
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
|
|
|
- .put(IndexMetadata.SETTING_READ_ONLY, true)
|
|
|
.put("index.lifecycle.name", policy));
|
|
|
|
|
|
- assertBusy(() -> assertThat((Integer) explainIndex(client(), index).get(FAILED_STEP_RETRY_COUNT_FIELD), greaterThanOrEqualTo(1)),
|
|
|
+ assertBusy(() -> assertThat(getStepKeyForIndex(client(), index), equalTo(PhaseCompleteStep.finalStep("cold").getKey())),
|
|
|
30, TimeUnit.SECONDS);
|
|
|
assertFalse(getOnlyIndexSettings(client(), index).containsKey("index.frozen"));
|
|
|
-
|
|
|
- Request request = new Request("PUT", index + "/_settings");
|
|
|
- request.setJsonEntity("{\"index.blocks.read_only\":false}");
|
|
|
- assertOK(client().performRequest(request));
|
|
|
-
|
|
|
- assertBusy(() -> assertThat(getOnlyIndexSettings(client(), index).get("index.frozen"), equalTo("true")));
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -416,61 +408,6 @@ public class TimeSeriesLifecycleActionsIT extends ESRestTestCase {
|
|
|
forceMergeActionWithCodec("best_compression");
|
|
|
}
|
|
|
|
|
|
- public void testFreezeAction() throws Exception {
|
|
|
- createIndexWithSettings(client(), index, alias, Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
|
|
|
- .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0));
|
|
|
- createNewSingletonPolicy(client(), policy, "cold", new FreezeAction());
|
|
|
- updatePolicy(client(), index, policy);
|
|
|
- assertBusy(() -> {
|
|
|
- Map<String, Object> settings = getOnlyIndexSettings(client(), index);
|
|
|
- assertThat(getStepKeyForIndex(client(), index), equalTo(PhaseCompleteStep.finalStep("cold").getKey()));
|
|
|
- assertThat(settings.get(IndexMetadata.INDEX_BLOCKS_WRITE_SETTING.getKey()), equalTo("true"));
|
|
|
- assertThat(settings.get(IndexSettings.INDEX_SEARCH_THROTTLED.getKey()), equalTo("true"));
|
|
|
- assertThat(settings.get("index.frozen"), equalTo("true"));
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- public void testFreezeDuringSnapshot() throws Exception {
|
|
|
- // Create the repository before taking the snapshot.
|
|
|
- Request request = new Request("PUT", "/_snapshot/repo");
|
|
|
- request.setJsonEntity(Strings
|
|
|
- .toString(JsonXContent.contentBuilder()
|
|
|
- .startObject()
|
|
|
- .field("type", "fs")
|
|
|
- .startObject("settings")
|
|
|
- .field("compress", randomBoolean())
|
|
|
- .field("location", System.getProperty("tests.path.repo"))
|
|
|
- .field("max_snapshot_bytes_per_sec", "256b")
|
|
|
- .endObject()
|
|
|
- .endObject()));
|
|
|
- assertOK(client().performRequest(request));
|
|
|
- // create delete policy
|
|
|
- createNewSingletonPolicy(client(), policy, "cold", new FreezeAction(), TimeValue.timeValueMillis(0));
|
|
|
- // create index without policy
|
|
|
- createIndexWithSettings(client(), index, alias, Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
|
|
|
- .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0));
|
|
|
- // index document so snapshot actually does something
|
|
|
- indexDocument(client(), index);
|
|
|
- // start snapshot
|
|
|
- request = new Request("PUT", "/_snapshot/repo/snapshot");
|
|
|
- request.addParameter("wait_for_completion", "false");
|
|
|
- request.setJsonEntity("{\"indices\": \"" + index + "\"}");
|
|
|
- assertOK(client().performRequest(request));
|
|
|
- // add policy and expect it to trigger delete immediately (while snapshot in progress)
|
|
|
- updatePolicy(client(), index, policy);
|
|
|
- // assert that the index froze
|
|
|
- assertBusy(() -> {
|
|
|
- Map<String, Object> settings = getOnlyIndexSettings(client(), index);
|
|
|
- assertThat(getStepKeyForIndex(client(), index), equalTo(PhaseCompleteStep.finalStep("cold").getKey()));
|
|
|
- assertThat(settings.get(IndexMetadata.INDEX_BLOCKS_WRITE_SETTING.getKey()), equalTo("true"));
|
|
|
- assertThat(settings.get(IndexSettings.INDEX_SEARCH_THROTTLED.getKey()), equalTo("true"));
|
|
|
- assertThat(settings.get("index.frozen"), equalTo("true"));
|
|
|
- }, 2, TimeUnit.MINUTES);
|
|
|
- // assert that snapshot is still in progress and clean up
|
|
|
- assertThat(getSnapshotState(client(), "snapshot"), equalTo("SUCCESS"));
|
|
|
- assertOK(client().performRequest(new Request("DELETE", "/_snapshot/repo/snapshot")));
|
|
|
- }
|
|
|
-
|
|
|
public void testSetPriority() throws Exception {
|
|
|
createIndexWithSettings(client(), index, alias, Settings.builder().put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
|
|
|
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0).put(IndexMetadata.INDEX_PRIORITY_SETTING.getKey(), 100));
|