|
@@ -10,6 +10,7 @@ package org.elasticsearch.xpack.ilm.actions;
|
|
|
import org.apache.http.entity.ContentType;
|
|
|
import org.apache.http.entity.StringEntity;
|
|
|
import org.apache.http.util.EntityUtils;
|
|
|
+import org.elasticsearch.client.Client;
|
|
|
import org.elasticsearch.client.Request;
|
|
|
import org.elasticsearch.client.Response;
|
|
|
import org.elasticsearch.cluster.metadata.DataStream;
|
|
@@ -19,6 +20,9 @@ import org.elasticsearch.common.Strings;
|
|
|
import org.elasticsearch.common.settings.Settings;
|
|
|
import org.elasticsearch.common.unit.TimeValue;
|
|
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
|
|
+import org.elasticsearch.common.xcontent.XContentHelper;
|
|
|
+import org.elasticsearch.common.xcontent.XContentType;
|
|
|
+import org.elasticsearch.test.client.NoOpClient;
|
|
|
import org.elasticsearch.test.rest.ESRestTestCase;
|
|
|
import org.elasticsearch.xpack.core.ilm.DeleteAction;
|
|
|
import org.elasticsearch.xpack.core.ilm.ForceMergeAction;
|
|
@@ -26,6 +30,7 @@ import org.elasticsearch.xpack.core.ilm.FreezeAction;
|
|
|
import org.elasticsearch.xpack.core.ilm.LifecycleAction;
|
|
|
import org.elasticsearch.xpack.core.ilm.LifecyclePolicy;
|
|
|
import org.elasticsearch.xpack.core.ilm.LifecycleSettings;
|
|
|
+import org.elasticsearch.xpack.core.ilm.MountSnapshotStep;
|
|
|
import org.elasticsearch.xpack.core.ilm.Phase;
|
|
|
import org.elasticsearch.xpack.core.ilm.PhaseCompleteStep;
|
|
|
import org.elasticsearch.xpack.core.ilm.RolloverAction;
|
|
@@ -33,10 +38,14 @@ import org.elasticsearch.xpack.core.ilm.SearchableSnapshotAction;
|
|
|
import org.elasticsearch.xpack.core.ilm.SetPriorityAction;
|
|
|
import org.elasticsearch.xpack.core.ilm.ShrinkAction;
|
|
|
import org.elasticsearch.xpack.core.ilm.Step;
|
|
|
+import org.elasticsearch.xpack.core.ilm.StepKeyTests;
|
|
|
+import org.elasticsearch.xpack.core.searchablesnapshots.MountSearchableSnapshotRequest;
|
|
|
import org.junit.Before;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
import java.util.Locale;
|
|
|
import java.util.Map;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
@@ -52,6 +61,7 @@ import static org.elasticsearch.xpack.TimeSeriesRestDriver.getNumberOfSegments;
|
|
|
import static org.elasticsearch.xpack.TimeSeriesRestDriver.getStepKeyForIndex;
|
|
|
import static org.elasticsearch.xpack.TimeSeriesRestDriver.indexDocument;
|
|
|
import static org.elasticsearch.xpack.TimeSeriesRestDriver.rolloverMaxOneDocCondition;
|
|
|
+import static org.hamcrest.Matchers.equalTo;
|
|
|
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
|
|
import static org.hamcrest.Matchers.is;
|
|
|
|
|
@@ -65,7 +75,7 @@ public class SearchableSnapshotActionIT extends ESRestTestCase {
|
|
|
public void refreshIndex() {
|
|
|
dataStream = "logs-" + randomAlphaOfLength(10).toLowerCase(Locale.ROOT);
|
|
|
policy = "policy-" + randomAlphaOfLength(5);
|
|
|
- snapshotRepo = randomAlphaOfLengthBetween(4, 10);
|
|
|
+ snapshotRepo = randomAlphaOfLengthBetween(10, 20);
|
|
|
logger.info("--> running [{}] with data stream [{}], snapshot repot [{}] and policy [{}]", getTestName(), dataStream,
|
|
|
snapshotRepo, policy);
|
|
|
}
|
|
@@ -77,7 +87,7 @@ public class SearchableSnapshotActionIT extends ESRestTestCase {
|
|
|
|
|
|
public void testSearchableSnapshotAction() throws Exception {
|
|
|
createSnapshotRepo(client(), snapshotRepo, randomBoolean());
|
|
|
- createNewSingletonPolicy(client(), policy, "cold", new SearchableSnapshotAction(snapshotRepo, true));
|
|
|
+ createNewSingletonPolicy(client(), policy, "cold", new SearchableSnapshotAction(snapshotRepo, true, null));
|
|
|
|
|
|
createComposableTemplate(client(), randomAlphaOfLengthBetween(5, 10).toLowerCase(), dataStream,
|
|
|
new Template(Settings.builder().put(LifecycleSettings.LIFECYCLE_NAME, policy).build(), null, null));
|
|
@@ -88,7 +98,7 @@ public class SearchableSnapshotActionIT extends ESRestTestCase {
|
|
|
rolloverMaxOneDocCondition(client(), dataStream);
|
|
|
|
|
|
String backingIndexName = DataStream.getDefaultBackingIndexName(dataStream, 1L);
|
|
|
- String restoredIndexName = SearchableSnapshotAction.RESTORED_INDEX_PREFIX + backingIndexName;
|
|
|
+ String restoredIndexName = SearchableSnapshotAction.FULL_RESTORED_INDEX_PREFIX + backingIndexName;
|
|
|
assertTrue(waitUntil(() -> {
|
|
|
try {
|
|
|
return indexExists(restoredIndexName);
|
|
@@ -103,7 +113,7 @@ public class SearchableSnapshotActionIT extends ESRestTestCase {
|
|
|
|
|
|
public void testSearchableSnapshotForceMergesIndexToOneSegment() throws Exception {
|
|
|
createSnapshotRepo(client(), snapshotRepo, randomBoolean());
|
|
|
- createNewSingletonPolicy(client(), policy, "cold", new SearchableSnapshotAction(snapshotRepo, true));
|
|
|
+ createNewSingletonPolicy(client(), policy, "cold", new SearchableSnapshotAction(snapshotRepo, true, null));
|
|
|
|
|
|
createComposableTemplate(client(), randomAlphaOfLengthBetween(5, 10).toLowerCase(), dataStream, new Template(null, null, null));
|
|
|
|
|
@@ -140,7 +150,7 @@ public class SearchableSnapshotActionIT extends ESRestTestCase {
|
|
|
}
|
|
|
}, 60, TimeUnit.SECONDS));
|
|
|
|
|
|
- String restoredIndexName = SearchableSnapshotAction.RESTORED_INDEX_PREFIX + backingIndexName;
|
|
|
+ String restoredIndexName = SearchableSnapshotAction.FULL_RESTORED_INDEX_PREFIX + backingIndexName;
|
|
|
assertTrue(waitUntil(() -> {
|
|
|
try {
|
|
|
return indexExists(restoredIndexName);
|
|
@@ -184,7 +194,7 @@ public class SearchableSnapshotActionIT extends ESRestTestCase {
|
|
|
|
|
|
String[] snapshotName = new String[1];
|
|
|
String backingIndexName = DataStream.getDefaultBackingIndexName(dataStream, 1L);
|
|
|
- String restoredIndexName = SearchableSnapshotAction.RESTORED_INDEX_PREFIX + backingIndexName;
|
|
|
+ String restoredIndexName = SearchableSnapshotAction.FULL_RESTORED_INDEX_PREFIX + backingIndexName;
|
|
|
assertTrue(waitUntil(() -> {
|
|
|
try {
|
|
|
Map<String, Object> explainIndex = explainIndex(client(), backingIndexName);
|
|
@@ -217,7 +227,7 @@ public class SearchableSnapshotActionIT extends ESRestTestCase {
|
|
|
new SearchableSnapshotAction(randomAlphaOfLengthBetween(4, 10)))),
|
|
|
new Phase("warm", TimeValue.ZERO, Map.of(ForceMergeAction.NAME, new ForceMergeAction(1, null))),
|
|
|
new Phase("cold", TimeValue.ZERO, Map.of(FreezeAction.NAME, new FreezeAction())),
|
|
|
- null
|
|
|
+ null, null
|
|
|
)
|
|
|
);
|
|
|
|
|
@@ -231,7 +241,7 @@ public class SearchableSnapshotActionIT extends ESRestTestCase {
|
|
|
new Phase("hot", TimeValue.ZERO, Map.of(RolloverAction.NAME, new RolloverAction(null, null, 1L), SearchableSnapshotAction.NAME,
|
|
|
new SearchableSnapshotAction(snapshotRepo))),
|
|
|
new Phase("warm", TimeValue.timeValueDays(30), Map.of(SetPriorityAction.NAME, new SetPriorityAction(999))),
|
|
|
- null, null
|
|
|
+ null, null, null
|
|
|
);
|
|
|
|
|
|
createComposableTemplate(client(), randomAlphaOfLengthBetween(5, 10).toLowerCase(), dataStream,
|
|
@@ -246,7 +256,7 @@ public class SearchableSnapshotActionIT extends ESRestTestCase {
|
|
|
indexDocument(client(), dataStream, true);
|
|
|
}
|
|
|
|
|
|
- String restoredIndexName = SearchableSnapshotAction.RESTORED_INDEX_PREFIX + DataStream.getDefaultBackingIndexName(dataStream, 1L);
|
|
|
+ String restoredIndexName = SearchableSnapshotAction.FULL_RESTORED_INDEX_PREFIX + DataStream.getDefaultBackingIndexName(dataStream, 1L);
|
|
|
assertTrue(waitUntil(() -> {
|
|
|
try {
|
|
|
return indexExists(restoredIndexName);
|
|
@@ -267,7 +277,7 @@ public class SearchableSnapshotActionIT extends ESRestTestCase {
|
|
|
Map.of(ShrinkAction.NAME, new ShrinkAction(1, null), ForceMergeAction.NAME, new ForceMergeAction(1, null))
|
|
|
),
|
|
|
new Phase("cold", TimeValue.ZERO, Map.of(SearchableSnapshotAction.NAME, new SearchableSnapshotAction(snapshotRepo))),
|
|
|
- null
|
|
|
+ null, null
|
|
|
);
|
|
|
|
|
|
// even though the index is now mounted as a searchable snapshot, the actions that can't operate on it should
|
|
@@ -286,7 +296,7 @@ public class SearchableSnapshotActionIT extends ESRestTestCase {
|
|
|
new Phase("hot", TimeValue.ZERO, Map.of(RolloverAction.NAME, new RolloverAction(null, null, 1L),
|
|
|
SearchableSnapshotAction.NAME, new SearchableSnapshotAction(snapshotRepo))),
|
|
|
new Phase("warm", TimeValue.timeValueDays(30), Map.of(SetPriorityAction.NAME, new SetPriorityAction(999))),
|
|
|
- null, null
|
|
|
+ null, null, null
|
|
|
);
|
|
|
|
|
|
createComposableTemplate(client(), randomAlphaOfLengthBetween(5, 10).toLowerCase(), dataStream,
|
|
@@ -301,7 +311,7 @@ public class SearchableSnapshotActionIT extends ESRestTestCase {
|
|
|
indexDocument(client(), dataStream, true);
|
|
|
}
|
|
|
|
|
|
- String searchableSnapMountedIndexName = SearchableSnapshotAction.RESTORED_INDEX_PREFIX +
|
|
|
+ String searchableSnapMountedIndexName = SearchableSnapshotAction.FULL_RESTORED_INDEX_PREFIX +
|
|
|
DataStream.getDefaultBackingIndexName(dataStream, 1L);
|
|
|
assertTrue(waitUntil(() -> {
|
|
|
try {
|
|
@@ -335,7 +345,7 @@ public class SearchableSnapshotActionIT extends ESRestTestCase {
|
|
|
Map.of(ShrinkAction.NAME, new ShrinkAction(1, null), ForceMergeAction.NAME, new ForceMergeAction(1, null))
|
|
|
),
|
|
|
new Phase("cold", TimeValue.ZERO, Map.of(FreezeAction.NAME, new FreezeAction())),
|
|
|
- null
|
|
|
+ null, null
|
|
|
);
|
|
|
|
|
|
// restore the datastream
|
|
@@ -353,4 +363,207 @@ public class SearchableSnapshotActionIT extends ESRestTestCase {
|
|
|
assertThat(stepKeyForIndex.getName(), is(PhaseCompleteStep.NAME));
|
|
|
}, 30, TimeUnit.SECONDS);
|
|
|
}
|
|
|
+
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
+ public void testIdenticalSearchableSnapshotActionIsNoop() throws Exception {
|
|
|
+ String index = "myindex-" + randomAlphaOfLength(4).toLowerCase(Locale.ROOT);
|
|
|
+ createSnapshotRepo(client(), snapshotRepo, randomBoolean());
|
|
|
+ MountSearchableSnapshotRequest.Storage storage = randomBoolean() ?
|
|
|
+ MountSearchableSnapshotRequest.Storage.FULL_COPY : MountSearchableSnapshotRequest.Storage.SHARED_CACHE;
|
|
|
+ createPolicy(client(), policy, null, null,
|
|
|
+ new Phase("cold", TimeValue.ZERO,
|
|
|
+ singletonMap(SearchableSnapshotAction.NAME, new SearchableSnapshotAction(snapshotRepo, randomBoolean(), storage))),
|
|
|
+ new Phase("frozen", TimeValue.ZERO,
|
|
|
+ singletonMap(SearchableSnapshotAction.NAME, new SearchableSnapshotAction(snapshotRepo, randomBoolean(), storage))),
|
|
|
+ null
|
|
|
+ );
|
|
|
+
|
|
|
+ createIndex(index, Settings.builder()
|
|
|
+ .put(LifecycleSettings.LIFECYCLE_NAME, policy)
|
|
|
+ .build());
|
|
|
+ ensureGreen(index);
|
|
|
+
|
|
|
+ final String searchableSnapMountedIndexName = (storage == MountSearchableSnapshotRequest.Storage.FULL_COPY ?
|
|
|
+ SearchableSnapshotAction.FULL_RESTORED_INDEX_PREFIX : SearchableSnapshotAction.PARTIAL_RESTORED_INDEX_PREFIX) + index;
|
|
|
+
|
|
|
+ assertBusy(() -> {
|
|
|
+ logger.info("--> waiting for [{}] to exist...", searchableSnapMountedIndexName);
|
|
|
+ assertTrue(indexExists(searchableSnapMountedIndexName));
|
|
|
+ }, 30, TimeUnit.SECONDS);
|
|
|
+
|
|
|
+ assertBusy(() -> {
|
|
|
+ Step.StepKey stepKeyForIndex = getStepKeyForIndex(client(), searchableSnapMountedIndexName);
|
|
|
+ assertThat(stepKeyForIndex.getPhase(), is("frozen"));
|
|
|
+ assertThat(stepKeyForIndex.getName(), is(PhaseCompleteStep.NAME));
|
|
|
+ }, 30, TimeUnit.SECONDS);
|
|
|
+
|
|
|
+ Request getSnaps = new Request("GET", "/_snapshot/" + snapshotRepo + "/_all");
|
|
|
+ Response response = client().performRequest(getSnaps);
|
|
|
+ Map<String, Object> responseMap;
|
|
|
+ try (InputStream is = response.getEntity().getContent()) {
|
|
|
+ responseMap = XContentHelper.convertToMap(XContentType.JSON.xContent(), is, true);
|
|
|
+ }
|
|
|
+ assertThat("expected to have only one snapshot, but got: " + responseMap,
|
|
|
+ ((List<Map<String, Object>>)
|
|
|
+ ((Map<String, Object>)
|
|
|
+ ((List<Object>) responseMap.get("responses")).get(0)).get("snapshots")).size(), equalTo(1));
|
|
|
+ }
|
|
|
+
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
+ public void testConvertingSearchableSnapshotFromFullToPartial() throws Exception {
|
|
|
+ String index = "myindex-" + randomAlphaOfLength(4).toLowerCase(Locale.ROOT);
|
|
|
+ createSnapshotRepo(client(), snapshotRepo, randomBoolean());
|
|
|
+ createPolicy(client(), policy, null, null,
|
|
|
+ new Phase("cold", TimeValue.ZERO,
|
|
|
+ singletonMap(SearchableSnapshotAction.NAME, new SearchableSnapshotAction(snapshotRepo, randomBoolean(),
|
|
|
+ MountSearchableSnapshotRequest.Storage.FULL_COPY))),
|
|
|
+ new Phase("frozen", TimeValue.ZERO,
|
|
|
+ singletonMap(SearchableSnapshotAction.NAME, new SearchableSnapshotAction(snapshotRepo, randomBoolean(),
|
|
|
+ MountSearchableSnapshotRequest.Storage.SHARED_CACHE))),
|
|
|
+ null
|
|
|
+ );
|
|
|
+
|
|
|
+ createIndex(index, Settings.builder()
|
|
|
+ .put(LifecycleSettings.LIFECYCLE_NAME, policy)
|
|
|
+ .build());
|
|
|
+ ensureGreen(index);
|
|
|
+ indexDocument(client(), index);
|
|
|
+
|
|
|
+ final String searchableSnapMountedIndexName = SearchableSnapshotAction.PARTIAL_RESTORED_INDEX_PREFIX +
|
|
|
+ SearchableSnapshotAction.FULL_RESTORED_INDEX_PREFIX + index;
|
|
|
+
|
|
|
+ assertBusy(() -> {
|
|
|
+ logger.info("--> waiting for [{}] to exist...", searchableSnapMountedIndexName);
|
|
|
+ assertTrue(indexExists(searchableSnapMountedIndexName));
|
|
|
+ }, 30, TimeUnit.SECONDS);
|
|
|
+
|
|
|
+ assertBusy(() -> {
|
|
|
+ Step.StepKey stepKeyForIndex = getStepKeyForIndex(client(), searchableSnapMountedIndexName);
|
|
|
+ assertThat(stepKeyForIndex.getPhase(), is("frozen"));
|
|
|
+ assertThat(stepKeyForIndex.getName(), is(PhaseCompleteStep.NAME));
|
|
|
+ }, 30, TimeUnit.SECONDS);
|
|
|
+
|
|
|
+ Request getSnaps = new Request("GET", "/_snapshot/" + snapshotRepo + "/_all");
|
|
|
+ Response response = client().performRequest(getSnaps);
|
|
|
+ Map<String, Object> responseMap;
|
|
|
+ try (InputStream is = response.getEntity().getContent()) {
|
|
|
+ responseMap = XContentHelper.convertToMap(XContentType.JSON.xContent(), is, true);
|
|
|
+ }
|
|
|
+ assertThat("expected to have only one snapshot, but got: " + responseMap,
|
|
|
+ ((List<Map<String, Object>>)
|
|
|
+ ((Map<String, Object>)
|
|
|
+ ((List<Object>) responseMap.get("responses")).get(0)).get("snapshots")).size(), equalTo(1));
|
|
|
+ }
|
|
|
+
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
+ public void testConvertingPartialSearchableSnapshotIntoFull() throws Exception {
|
|
|
+ String index = "myindex-" + randomAlphaOfLength(4).toLowerCase(Locale.ROOT);
|
|
|
+ createSnapshotRepo(client(), snapshotRepo, randomBoolean());
|
|
|
+ createPolicy(client(), policy, null, null,
|
|
|
+ new Phase("cold", TimeValue.ZERO,
|
|
|
+ singletonMap(SearchableSnapshotAction.NAME, new SearchableSnapshotAction(snapshotRepo, randomBoolean(),
|
|
|
+ MountSearchableSnapshotRequest.Storage.SHARED_CACHE))),
|
|
|
+ new Phase("frozen", TimeValue.ZERO,
|
|
|
+ singletonMap(SearchableSnapshotAction.NAME, new SearchableSnapshotAction(snapshotRepo, randomBoolean(),
|
|
|
+ MountSearchableSnapshotRequest.Storage.FULL_COPY))),
|
|
|
+ null
|
|
|
+ );
|
|
|
+
|
|
|
+ createIndex(index, Settings.builder()
|
|
|
+ .put(LifecycleSettings.LIFECYCLE_NAME, policy)
|
|
|
+ .build());
|
|
|
+ ensureGreen(index);
|
|
|
+ indexDocument(client(), index);
|
|
|
+
|
|
|
+ final String searchableSnapMountedIndexName = SearchableSnapshotAction.FULL_RESTORED_INDEX_PREFIX +
|
|
|
+ SearchableSnapshotAction.PARTIAL_RESTORED_INDEX_PREFIX + index;
|
|
|
+
|
|
|
+ assertBusy(() -> {
|
|
|
+ logger.info("--> waiting for [{}] to exist...", searchableSnapMountedIndexName);
|
|
|
+ assertTrue(indexExists(searchableSnapMountedIndexName));
|
|
|
+ }, 30, TimeUnit.SECONDS);
|
|
|
+
|
|
|
+ assertBusy(() -> {
|
|
|
+ Step.StepKey stepKeyForIndex = getStepKeyForIndex(client(), searchableSnapMountedIndexName);
|
|
|
+ assertThat(stepKeyForIndex.getPhase(), is("frozen"));
|
|
|
+ assertThat(stepKeyForIndex.getName(), is(PhaseCompleteStep.NAME));
|
|
|
+ }, 30, TimeUnit.SECONDS);
|
|
|
+
|
|
|
+ Request getSnaps = new Request("GET", "/_snapshot/" + snapshotRepo + "/_all");
|
|
|
+ Response response = client().performRequest(getSnaps);
|
|
|
+ Map<String, Object> responseMap;
|
|
|
+ try (InputStream is = response.getEntity().getContent()) {
|
|
|
+ responseMap = XContentHelper.convertToMap(XContentType.JSON.xContent(), is, true);
|
|
|
+ }
|
|
|
+ assertThat("expected to have only one snapshot, but got: " + responseMap,
|
|
|
+ ((List<Map<String, Object>>)
|
|
|
+ ((Map<String, Object>)
|
|
|
+ ((List<Object>) responseMap.get("responses")).get(0)).get("snapshots")).size(), equalTo(1));
|
|
|
+ }
|
|
|
+
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
+ @AwaitsFix(bugUrl = "functionality not yet implemented")
|
|
|
+ public void testSecondSearchableSnapshotChangesRepo() throws Exception {
|
|
|
+ String index = "myindex-" + randomAlphaOfLength(4).toLowerCase(Locale.ROOT);
|
|
|
+ String secondRepo = randomAlphaOfLengthBetween(10, 20);
|
|
|
+ createSnapshotRepo(client(), snapshotRepo, randomBoolean());
|
|
|
+ createSnapshotRepo(client(), secondRepo, randomBoolean());
|
|
|
+ createPolicy(client(), policy, null, null,
|
|
|
+ new Phase("cold", TimeValue.ZERO,
|
|
|
+ singletonMap(SearchableSnapshotAction.NAME, new SearchableSnapshotAction(snapshotRepo, randomBoolean(),
|
|
|
+ MountSearchableSnapshotRequest.Storage.FULL_COPY))),
|
|
|
+ new Phase("frozen", TimeValue.ZERO,
|
|
|
+ singletonMap(SearchableSnapshotAction.NAME, new SearchableSnapshotAction(secondRepo, randomBoolean(),
|
|
|
+ MountSearchableSnapshotRequest.Storage.SHARED_CACHE))),
|
|
|
+ null
|
|
|
+ );
|
|
|
+
|
|
|
+ createIndex(index, Settings.builder()
|
|
|
+ .put(LifecycleSettings.LIFECYCLE_NAME, policy)
|
|
|
+ .build());
|
|
|
+ ensureGreen(index);
|
|
|
+ indexDocument(client(), index);
|
|
|
+
|
|
|
+ final String searchableSnapMountedIndexName = SearchableSnapshotAction.PARTIAL_RESTORED_INDEX_PREFIX +
|
|
|
+ SearchableSnapshotAction.FULL_RESTORED_INDEX_PREFIX + index;
|
|
|
+
|
|
|
+ assertBusy(() -> {
|
|
|
+ logger.info("--> waiting for [{}] to exist...", searchableSnapMountedIndexName);
|
|
|
+ assertTrue(indexExists(searchableSnapMountedIndexName));
|
|
|
+ }, 30, TimeUnit.SECONDS);
|
|
|
+
|
|
|
+ assertBusy(() -> {
|
|
|
+ Step.StepKey stepKeyForIndex = getStepKeyForIndex(client(), searchableSnapMountedIndexName);
|
|
|
+ assertThat(stepKeyForIndex.getPhase(), is("frozen"));
|
|
|
+ assertThat(stepKeyForIndex.getName(), is(PhaseCompleteStep.NAME));
|
|
|
+ }, 30, TimeUnit.SECONDS);
|
|
|
+
|
|
|
+ // Check first repo has exactly 1 snapshot
|
|
|
+ {
|
|
|
+ Request getSnaps = new Request("GET", "/_snapshot/" + snapshotRepo + "/_all");
|
|
|
+ Response response = client().performRequest(getSnaps);
|
|
|
+ Map<String, Object> responseMap;
|
|
|
+ try (InputStream is = response.getEntity().getContent()) {
|
|
|
+ responseMap = XContentHelper.convertToMap(XContentType.JSON.xContent(), is, true);
|
|
|
+ }
|
|
|
+ assertThat("expected to have only one snapshot, but got: " + responseMap,
|
|
|
+ ((List<Map<String, Object>>)
|
|
|
+ ((Map<String, Object>)
|
|
|
+ ((List<Object>) responseMap.get("responses")).get(0)).get("snapshots")).size(), equalTo(1));
|
|
|
+ }
|
|
|
+
|
|
|
+ // Check second repo has exactly 1 snapshot
|
|
|
+ {
|
|
|
+ Request getSnaps = new Request("GET", "/_snapshot/" + secondRepo + "/_all");
|
|
|
+ Response response = client().performRequest(getSnaps);
|
|
|
+ Map<String, Object> responseMap;
|
|
|
+ try (InputStream is = response.getEntity().getContent()) {
|
|
|
+ responseMap = XContentHelper.convertToMap(XContentType.JSON.xContent(), is, true);
|
|
|
+ }
|
|
|
+ assertThat("expected to have only one snapshot, but got: " + responseMap,
|
|
|
+ ((List<Map<String, Object>>)
|
|
|
+ ((Map<String, Object>)
|
|
|
+ ((List<Object>) responseMap.get("responses")).get(0)).get("snapshots")).size(), equalTo(1));
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|