|
@@ -225,9 +225,11 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
}
|
|
|
|
|
|
logger.info("--> snapshot");
|
|
|
- CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap").setWaitForCompletion(true).setIndices(indicesToSnapshot).get();
|
|
|
+ CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap")
|
|
|
+ .setWaitForCompletion(true).setIndices(indicesToSnapshot).get();
|
|
|
assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), greaterThan(0));
|
|
|
- assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));
|
|
|
+ assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(),
|
|
|
+ equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));
|
|
|
|
|
|
List<SnapshotInfo> snapshotInfos = client.admin().cluster().prepareGetSnapshots("test-repo")
|
|
|
.setSnapshots(randomFrom("test-snap", "_all", "*", "*-snap", "test*")).get().getSnapshots();
|
|
@@ -255,7 +257,8 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
client.admin().indices().prepareClose("test-idx-1", "test-idx-2").get();
|
|
|
|
|
|
logger.info("--> restore all indices from the snapshot");
|
|
|
- RestoreSnapshotResponse restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap").setWaitForCompletion(true).execute().actionGet();
|
|
|
+ RestoreSnapshotResponse restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap")
|
|
|
+ .setWaitForCompletion(true).execute().actionGet();
|
|
|
assertThat(restoreSnapshotResponse.getRestoreInfo().totalShards(), greaterThan(0));
|
|
|
|
|
|
ensureGreen();
|
|
@@ -276,7 +279,8 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
logger.info("--> delete indices");
|
|
|
cluster().wipeIndices("test-idx-1", "test-idx-2");
|
|
|
logger.info("--> restore one index after deletion");
|
|
|
- restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap").setWaitForCompletion(true).setIndices("test-idx-*", "-test-idx-2").execute().actionGet();
|
|
|
+ restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap").setWaitForCompletion(true)
|
|
|
+ .setIndices("test-idx-*", "-test-idx-2").execute().actionGet();
|
|
|
assertThat(restoreSnapshotResponse.getRestoreInfo().totalShards(), greaterThan(0));
|
|
|
|
|
|
ensureGreen();
|
|
@@ -327,7 +331,8 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
.setIndices(indexName)
|
|
|
.get();
|
|
|
assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), greaterThan(0));
|
|
|
- assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));
|
|
|
+ assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(),
|
|
|
+ equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));
|
|
|
assertThat(createSnapshotResponse.getSnapshotInfo().state(), equalTo(SnapshotState.SUCCESS));
|
|
|
|
|
|
RestoreSnapshotResponse restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot(repoName, snapshotName)
|
|
@@ -347,20 +352,24 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
assertAcked(client.admin().cluster().preparePutRepository("test-repo").setType("fs").setSettings(randomRepoSettings()));
|
|
|
|
|
|
createIndex("test");
|
|
|
- String originalIndexUUID = client().admin().indices().prepareGetSettings("test").get().getSetting("test", IndexMetaData.SETTING_INDEX_UUID);
|
|
|
+ String originalIndexUUID = client().admin().indices().prepareGetSettings("test").get()
|
|
|
+ .getSetting("test", IndexMetaData.SETTING_INDEX_UUID);
|
|
|
assertTrue(originalIndexUUID, originalIndexUUID != null);
|
|
|
assertFalse(originalIndexUUID, originalIndexUUID.equals(IndexMetaData.INDEX_UUID_NA_VALUE));
|
|
|
ensureGreen();
|
|
|
- CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap").setWaitForCompletion(true).setIndices("test").get();
|
|
|
+ CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap")
|
|
|
+ .setWaitForCompletion(true).setIndices("test").get();
|
|
|
assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), greaterThan(0));
|
|
|
- assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));
|
|
|
+ assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(),
|
|
|
+ equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));
|
|
|
NumShards numShards = getNumShards("test");
|
|
|
|
|
|
cluster().wipeIndices("test");
|
|
|
assertAcked(prepareCreate("test").setSettings(Settings.builder()
|
|
|
.put(SETTING_NUMBER_OF_SHARDS, numShards.numPrimaries)));
|
|
|
ensureGreen();
|
|
|
- String newIndexUUID = client().admin().indices().prepareGetSettings("test").get().getSetting("test", IndexMetaData.SETTING_INDEX_UUID);
|
|
|
+ String newIndexUUID = client().admin().indices().prepareGetSettings("test").get()
|
|
|
+ .getSetting("test", IndexMetaData.SETTING_INDEX_UUID);
|
|
|
assertTrue(newIndexUUID, newIndexUUID != null);
|
|
|
assertFalse(newIndexUUID, newIndexUUID.equals(IndexMetaData.INDEX_UUID_NA_VALUE));
|
|
|
assertFalse(newIndexUUID, newIndexUUID.equals(originalIndexUUID));
|
|
@@ -368,20 +377,25 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
client.admin().indices().prepareClose("test").get();
|
|
|
|
|
|
logger.info("--> restore all indices from the snapshot");
|
|
|
- RestoreSnapshotResponse restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap").setWaitForCompletion(true).execute().actionGet();
|
|
|
+ RestoreSnapshotResponse restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap")
|
|
|
+ .setWaitForCompletion(true).execute().actionGet();
|
|
|
assertThat(restoreSnapshotResponse.getRestoreInfo().totalShards(), greaterThan(0));
|
|
|
|
|
|
ensureGreen();
|
|
|
- String newAfterRestoreIndexUUID = client().admin().indices().prepareGetSettings("test").get().getSetting("test", IndexMetaData.SETTING_INDEX_UUID);
|
|
|
- assertTrue("UUID has changed after restore: " + newIndexUUID + " vs. " + newAfterRestoreIndexUUID, newIndexUUID.equals(newAfterRestoreIndexUUID));
|
|
|
+ String newAfterRestoreIndexUUID = client().admin().indices().prepareGetSettings("test").get()
|
|
|
+ .getSetting("test", IndexMetaData.SETTING_INDEX_UUID);
|
|
|
+ assertTrue("UUID has changed after restore: " + newIndexUUID + " vs. " + newAfterRestoreIndexUUID,
|
|
|
+ newIndexUUID.equals(newAfterRestoreIndexUUID));
|
|
|
|
|
|
logger.info("--> restore indices with different names");
|
|
|
restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap")
|
|
|
.setRenamePattern("(.+)").setRenameReplacement("$1-copy").setWaitForCompletion(true).execute().actionGet();
|
|
|
assertThat(restoreSnapshotResponse.getRestoreInfo().totalShards(), greaterThan(0));
|
|
|
|
|
|
- String copyRestoreUUID = client().admin().indices().prepareGetSettings("test-copy").get().getSetting("test-copy", IndexMetaData.SETTING_INDEX_UUID);
|
|
|
- assertFalse("UUID has been reused on restore: " + copyRestoreUUID + " vs. " + originalIndexUUID, copyRestoreUUID.equals(originalIndexUUID));
|
|
|
+ String copyRestoreUUID = client().admin().indices().prepareGetSettings("test-copy").get()
|
|
|
+ .getSetting("test-copy", IndexMetaData.SETTING_INDEX_UUID);
|
|
|
+ assertFalse("UUID has been reused on restore: " + copyRestoreUUID + " vs. " + originalIndexUUID,
|
|
|
+ copyRestoreUUID.equals(originalIndexUUID));
|
|
|
}
|
|
|
|
|
|
public void testRestoreWithDifferentMappingsAndSettings() throws Exception {
|
|
@@ -400,14 +414,17 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
ensureGreen();
|
|
|
|
|
|
logger.info("--> snapshot it");
|
|
|
- CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap").setWaitForCompletion(true).setIndices("test-idx").get();
|
|
|
+ CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap")
|
|
|
+ .setWaitForCompletion(true).setIndices("test-idx").get();
|
|
|
assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), greaterThan(0));
|
|
|
- assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));
|
|
|
+ assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(),
|
|
|
+ equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));
|
|
|
|
|
|
logger.info("--> delete the index and recreate it with bar type");
|
|
|
cluster().wipeIndices("test-idx");
|
|
|
assertAcked(prepareCreate("test-idx", 2, Settings.builder()
|
|
|
- .put(SETTING_NUMBER_OF_SHARDS, numShards.numPrimaries).put(SETTING_NUMBER_OF_REPLICAS, between(0, 1)).put("refresh_interval", 5, TimeUnit.SECONDS)));
|
|
|
+ .put(SETTING_NUMBER_OF_SHARDS, numShards.numPrimaries).put(SETTING_NUMBER_OF_REPLICAS, between(0, 1))
|
|
|
+ .put("refresh_interval", 5, TimeUnit.SECONDS)));
|
|
|
assertAcked(client().admin().indices().preparePutMapping("test-idx").setType("bar").setSource("baz", "type=text"));
|
|
|
ensureGreen();
|
|
|
|
|
@@ -415,11 +432,13 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
client.admin().indices().prepareClose("test-idx").get();
|
|
|
|
|
|
logger.info("--> restore all indices from the snapshot");
|
|
|
- RestoreSnapshotResponse restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap").setWaitForCompletion(true).execute().actionGet();
|
|
|
+ RestoreSnapshotResponse restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap")
|
|
|
+ .setWaitForCompletion(true).execute().actionGet();
|
|
|
assertThat(restoreSnapshotResponse.getRestoreInfo().totalShards(), greaterThan(0));
|
|
|
|
|
|
logger.info("--> assert that old mapping is restored");
|
|
|
- ImmutableOpenMap<String, MappingMetaData> mappings = client().admin().cluster().prepareState().get().getState().getMetaData().getIndices().get("test-idx").getMappings();
|
|
|
+ ImmutableOpenMap<String, MappingMetaData> mappings = client().admin().cluster().prepareState().get().getState().getMetaData()
|
|
|
+ .getIndices().get("test-idx").getMappings();
|
|
|
assertThat(mappings.get("foo"), notNullValue());
|
|
|
assertThat(mappings.get("bar"), nullValue());
|
|
|
|
|
@@ -437,11 +456,13 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
assertThat(putRepositoryResponse.isAcknowledged(), equalTo(true));
|
|
|
|
|
|
logger.info("--> snapshot");
|
|
|
- CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap").setWaitForCompletion(true).get();
|
|
|
+ CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap")
|
|
|
+ .setWaitForCompletion(true).get();
|
|
|
assertThat(createSnapshotResponse.getSnapshotInfo().totalShards(), equalTo(0));
|
|
|
assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), equalTo(0));
|
|
|
|
|
|
- assertThat(client.admin().cluster().prepareGetSnapshots("test-repo").setSnapshots("test-snap").get().getSnapshots().get(0).state(), equalTo(SnapshotState.SUCCESS));
|
|
|
+ assertThat(client.admin().cluster().prepareGetSnapshots("test-repo").setSnapshots("test-snap").get().getSnapshots().get(0).state(),
|
|
|
+ equalTo(SnapshotState.SUCCESS));
|
|
|
}
|
|
|
|
|
|
public void testRestoreAliases() throws Exception {
|
|
@@ -465,16 +486,20 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
assertAliasesExist(client.admin().indices().prepareAliasesExist("alias-123").get());
|
|
|
|
|
|
logger.info("--> snapshot");
|
|
|
- assertThat(client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap").setIndices().setWaitForCompletion(true).get().getSnapshotInfo().state(), equalTo(SnapshotState.SUCCESS));
|
|
|
+ assertThat(client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap")
|
|
|
+ .setIndices().setWaitForCompletion(true).get().getSnapshotInfo().state(),
|
|
|
+ equalTo(SnapshotState.SUCCESS));
|
|
|
|
|
|
logger.info("--> delete all indices");
|
|
|
cluster().wipeIndices("test-idx-1", "test-idx-2", "test-idx-3");
|
|
|
assertAliasesMissing(client.admin().indices().prepareAliasesExist("alias-123", "alias-1").get());
|
|
|
|
|
|
logger.info("--> restore snapshot with aliases");
|
|
|
- RestoreSnapshotResponse restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap").setWaitForCompletion(true).setRestoreGlobalState(true).execute().actionGet();
|
|
|
+ RestoreSnapshotResponse restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap")
|
|
|
+ .setWaitForCompletion(true).setRestoreGlobalState(true).execute().actionGet();
|
|
|
// We don't restore any indices here
|
|
|
- assertThat(restoreSnapshotResponse.getRestoreInfo().successfulShards(), allOf(greaterThan(0), equalTo(restoreSnapshotResponse.getRestoreInfo().totalShards())));
|
|
|
+ assertThat(restoreSnapshotResponse.getRestoreInfo().successfulShards(), allOf(greaterThan(0),
|
|
|
+ equalTo(restoreSnapshotResponse.getRestoreInfo().totalShards())));
|
|
|
|
|
|
logger.info("--> check that aliases are restored");
|
|
|
assertAliasesExist(client.admin().indices().prepareAliasesExist("alias-123", "alias-1").get());
|
|
@@ -489,9 +514,11 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
assertAliasesMissing(client.admin().indices().prepareAliasesExist("alias-123", "alias-1").get());
|
|
|
|
|
|
logger.info("--> restore snapshot without aliases");
|
|
|
- restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap").setWaitForCompletion(true).setRestoreGlobalState(true).setIncludeAliases(false).execute().actionGet();
|
|
|
+ restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap").setWaitForCompletion(true)
|
|
|
+ .setRestoreGlobalState(true).setIncludeAliases(false).execute().actionGet();
|
|
|
// We don't restore any indices here
|
|
|
- assertThat(restoreSnapshotResponse.getRestoreInfo().successfulShards(), allOf(greaterThan(0), equalTo(restoreSnapshotResponse.getRestoreInfo().totalShards())));
|
|
|
+ assertThat(restoreSnapshotResponse.getRestoreInfo().successfulShards(), allOf(greaterThan(0),
|
|
|
+ equalTo(restoreSnapshotResponse.getRestoreInfo().totalShards())));
|
|
|
|
|
|
logger.info("--> check that aliases are not restored and existing aliases still exist");
|
|
|
assertAliasesMissing(client.admin().indices().prepareAliasesExist("alias-123", "alias-1").get());
|
|
@@ -528,10 +555,12 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
.get().isAcknowledged(), equalTo(true));
|
|
|
|
|
|
logger.info("--> snapshot");
|
|
|
- CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap").setIndices().setWaitForCompletion(true).get();
|
|
|
+ CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap")
|
|
|
+ .setIndices().setWaitForCompletion(true).get();
|
|
|
assertThat(createSnapshotResponse.getSnapshotInfo().totalShards(), equalTo(0));
|
|
|
assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), equalTo(0));
|
|
|
- assertThat(client.admin().cluster().prepareGetSnapshots("test-repo").setSnapshots("test-snap").get().getSnapshots().get(0).state(), equalTo(SnapshotState.SUCCESS));
|
|
|
+ assertThat(client.admin().cluster().prepareGetSnapshots("test-repo").setSnapshots("test-snap").get().getSnapshots().get(0).state(),
|
|
|
+ equalTo(SnapshotState.SUCCESS));
|
|
|
|
|
|
logger.info("--> delete test template");
|
|
|
assertThat(client.admin().indices().prepareDeleteTemplate("test-template").get().isAcknowledged(), equalTo(true));
|
|
@@ -539,7 +568,8 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
assertIndexTemplateMissing(getIndexTemplatesResponse, "test-template");
|
|
|
|
|
|
logger.info("--> restore cluster state");
|
|
|
- RestoreSnapshotResponse restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap").setWaitForCompletion(true).setRestoreGlobalState(true).execute().actionGet();
|
|
|
+ RestoreSnapshotResponse restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap")
|
|
|
+ .setWaitForCompletion(true).setRestoreGlobalState(true).execute().actionGet();
|
|
|
// We don't restore any indices here
|
|
|
assertThat(restoreSnapshotResponse.getRestoreInfo().totalShards(), equalTo(0));
|
|
|
|
|
@@ -607,21 +637,30 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
}
|
|
|
|
|
|
logger.info("--> snapshot without global state");
|
|
|
- CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap-no-global-state").setIndices().setIncludeGlobalState(false).setWaitForCompletion(true).get();
|
|
|
+ CreateSnapshotResponse createSnapshotResponse = client.admin().cluster()
|
|
|
+ .prepareCreateSnapshot("test-repo", "test-snap-no-global-state").setIndices().setIncludeGlobalState(false)
|
|
|
+ .setWaitForCompletion(true).get();
|
|
|
assertThat(createSnapshotResponse.getSnapshotInfo().totalShards(), equalTo(0));
|
|
|
assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), equalTo(0));
|
|
|
- assertThat(client.admin().cluster().prepareGetSnapshots("test-repo").setSnapshots("test-snap-no-global-state").get().getSnapshots().get(0).state(), equalTo(SnapshotState.SUCCESS));
|
|
|
- SnapshotsStatusResponse snapshotsStatusResponse = client.admin().cluster().prepareSnapshotStatus("test-repo").addSnapshots("test-snap-no-global-state").get();
|
|
|
+ assertThat(client.admin().cluster().prepareGetSnapshots("test-repo").setSnapshots("test-snap-no-global-state")
|
|
|
+ .get().getSnapshots().get(0).state(),
|
|
|
+ equalTo(SnapshotState.SUCCESS));
|
|
|
+ SnapshotsStatusResponse snapshotsStatusResponse = client.admin().cluster().prepareSnapshotStatus("test-repo")
|
|
|
+ .addSnapshots("test-snap-no-global-state").get();
|
|
|
assertThat(snapshotsStatusResponse.getSnapshots().size(), equalTo(1));
|
|
|
SnapshotStatus snapshotStatus = snapshotsStatusResponse.getSnapshots().get(0);
|
|
|
assertThat(snapshotStatus.includeGlobalState(), equalTo(false));
|
|
|
|
|
|
logger.info("--> snapshot with global state");
|
|
|
- createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap-with-global-state").setIndices().setIncludeGlobalState(true).setWaitForCompletion(true).get();
|
|
|
+ createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap-with-global-state")
|
|
|
+ .setIndices().setIncludeGlobalState(true).setWaitForCompletion(true).get();
|
|
|
assertThat(createSnapshotResponse.getSnapshotInfo().totalShards(), equalTo(0));
|
|
|
assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), equalTo(0));
|
|
|
- assertThat(client.admin().cluster().prepareGetSnapshots("test-repo").setSnapshots("test-snap-with-global-state").get().getSnapshots().get(0).state(), equalTo(SnapshotState.SUCCESS));
|
|
|
- snapshotsStatusResponse = client.admin().cluster().prepareSnapshotStatus("test-repo").addSnapshots("test-snap-with-global-state").get();
|
|
|
+ assertThat(client.admin().cluster().prepareGetSnapshots("test-repo").setSnapshots("test-snap-with-global-state")
|
|
|
+ .get().getSnapshots().get(0).state(),
|
|
|
+ equalTo(SnapshotState.SUCCESS));
|
|
|
+ snapshotsStatusResponse = client.admin().cluster().prepareSnapshotStatus("test-repo")
|
|
|
+ .addSnapshots("test-snap-with-global-state").get();
|
|
|
assertThat(snapshotsStatusResponse.getSnapshots().size(), equalTo(1));
|
|
|
snapshotStatus = snapshotsStatusResponse.getSnapshots().get(0);
|
|
|
assertThat(snapshotStatus.includeGlobalState(), equalTo(true));
|
|
@@ -644,7 +683,9 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
}
|
|
|
|
|
|
logger.info("--> try restoring cluster state from snapshot without global state");
|
|
|
- RestoreSnapshotResponse restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap-no-global-state").setWaitForCompletion(true).setRestoreGlobalState(true).execute().actionGet();
|
|
|
+ RestoreSnapshotResponse restoreSnapshotResponse = client.admin().cluster()
|
|
|
+ .prepareRestoreSnapshot("test-repo", "test-snap-no-global-state")
|
|
|
+ .setWaitForCompletion(true).setRestoreGlobalState(true).execute().actionGet();
|
|
|
assertThat(restoreSnapshotResponse.getRestoreInfo().totalShards(), equalTo(0));
|
|
|
|
|
|
logger.info("--> check that template wasn't restored");
|
|
@@ -652,7 +693,8 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
assertIndexTemplateMissing(getIndexTemplatesResponse, "test-template");
|
|
|
|
|
|
logger.info("--> restore cluster state");
|
|
|
- restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap-with-global-state").setWaitForCompletion(true).setRestoreGlobalState(true).execute().actionGet();
|
|
|
+ restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap-with-global-state")
|
|
|
+ .setWaitForCompletion(true).setRestoreGlobalState(true).execute().actionGet();
|
|
|
assertThat(restoreSnapshotResponse.getRestoreInfo().totalShards(), equalTo(0));
|
|
|
|
|
|
if (testTemplate) {
|
|
@@ -684,10 +726,14 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
assertThat(client.prepareSearch("test-idx").setSize(0).get().getHits().getTotalHits(), equalTo(100L));
|
|
|
|
|
|
logger.info("--> snapshot without global state but with indices");
|
|
|
- createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap-no-global-state-with-index").setIndices("test-idx").setIncludeGlobalState(false).setWaitForCompletion(true).get();
|
|
|
+ createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap-no-global-state-with-index")
|
|
|
+ .setIndices("test-idx").setIncludeGlobalState(false).setWaitForCompletion(true).get();
|
|
|
assertThat(createSnapshotResponse.getSnapshotInfo().totalShards(), greaterThan(0));
|
|
|
- assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));
|
|
|
- assertThat(client.admin().cluster().prepareGetSnapshots("test-repo").setSnapshots("test-snap-no-global-state-with-index").get().getSnapshots().get(0).state(), equalTo(SnapshotState.SUCCESS));
|
|
|
+ assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(),
|
|
|
+ equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));
|
|
|
+ assertThat(client.admin().cluster().prepareGetSnapshots("test-repo").setSnapshots("test-snap-no-global-state-with-index")
|
|
|
+ .get().getSnapshots().get(0).state(),
|
|
|
+ equalTo(SnapshotState.SUCCESS));
|
|
|
|
|
|
logger.info("--> delete global state and index ");
|
|
|
cluster().wipeIndices("test-idx");
|
|
@@ -706,7 +752,8 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
assertIndexTemplateMissing(getIndexTemplatesResponse, "test-template");
|
|
|
|
|
|
logger.info("--> try restoring index and cluster state from snapshot without global state");
|
|
|
- restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap-no-global-state-with-index").setWaitForCompletion(true).setRestoreGlobalState(true).execute().actionGet();
|
|
|
+ restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap-no-global-state-with-index")
|
|
|
+ .setWaitForCompletion(true).setRestoreGlobalState(true).execute().actionGet();
|
|
|
assertThat(restoreSnapshotResponse.getRestoreInfo().totalShards(), greaterThan(0));
|
|
|
assertThat(restoreSnapshotResponse.getRestoreInfo().failedShards(), equalTo(0));
|
|
|
|
|
@@ -743,7 +790,8 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
|
|
|
logger.info("--> snapshot");
|
|
|
try {
|
|
|
- CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap").setWaitForCompletion(true).setIndices("test-idx").get();
|
|
|
+ CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap")
|
|
|
+ .setWaitForCompletion(true).setIndices("test-idx").get();
|
|
|
if (createSnapshotResponse.getSnapshotInfo().totalShards() == createSnapshotResponse.getSnapshotInfo().successfulShards()) {
|
|
|
// If we are here, that means we didn't have any failures, let's check it
|
|
|
assertThat(getFailureCount("test-repo"), equalTo(0L));
|
|
@@ -755,7 +803,8 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
assertThat(shardFailure.nodeId(), notNullValue());
|
|
|
assertThat(shardFailure.index(), equalTo("test-idx"));
|
|
|
}
|
|
|
- GetSnapshotsResponse getSnapshotsResponse = client.admin().cluster().prepareGetSnapshots("test-repo").addSnapshots("test-snap").get();
|
|
|
+ GetSnapshotsResponse getSnapshotsResponse = client.admin().cluster().prepareGetSnapshots("test-repo")
|
|
|
+ .addSnapshots("test-snap").get();
|
|
|
assertThat(getSnapshotsResponse.getSnapshots().size(), equalTo(1));
|
|
|
SnapshotInfo snapshotInfo = getSnapshotsResponse.getSnapshots().get(0);
|
|
|
if (snapshotInfo.state() == SnapshotState.SUCCESS) {
|
|
@@ -791,7 +840,8 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
assertThat(client.prepareSearch("test-idx").setSize(0).get().getHits().getTotalHits(), equalTo(100L));
|
|
|
|
|
|
logger.info("--> snapshot");
|
|
|
- CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap").setWaitForCompletion(true).setIndices("test-idx").get();
|
|
|
+ CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap")
|
|
|
+ .setWaitForCompletion(true).setIndices("test-idx").get();
|
|
|
if (createSnapshotResponse.getSnapshotInfo().totalShards() == createSnapshotResponse.getSnapshotInfo().successfulShards()) {
|
|
|
logger.info("--> no failures");
|
|
|
// If we are here, that means we didn't have any failures, let's check it
|
|
@@ -804,7 +854,8 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
assertThat(shardFailure.nodeId(), notNullValue());
|
|
|
assertThat(shardFailure.index(), equalTo("test-idx"));
|
|
|
}
|
|
|
- GetSnapshotsResponse getSnapshotsResponse = client.admin().cluster().prepareGetSnapshots("test-repo").addSnapshots("test-snap").get();
|
|
|
+ GetSnapshotsResponse getSnapshotsResponse = client.admin().cluster().prepareGetSnapshots("test-repo")
|
|
|
+ .addSnapshots("test-snap").get();
|
|
|
assertThat(getSnapshotsResponse.getSnapshots().size(), equalTo(1));
|
|
|
SnapshotInfo snapshotInfo = getSnapshotsResponse.getSnapshots().get(0);
|
|
|
assertThat(snapshotInfo.state(), equalTo(SnapshotState.PARTIAL));
|
|
@@ -812,7 +863,8 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
assertThat(snapshotInfo.totalShards(), greaterThan(snapshotInfo.successfulShards()));
|
|
|
|
|
|
// Verify that snapshot status also contains the same failures
|
|
|
- SnapshotsStatusResponse snapshotsStatusResponse = client.admin().cluster().prepareSnapshotStatus("test-repo").addSnapshots("test-snap").get();
|
|
|
+ SnapshotsStatusResponse snapshotsStatusResponse = client.admin().cluster().prepareSnapshotStatus("test-repo")
|
|
|
+ .addSnapshots("test-snap").get();
|
|
|
assertThat(snapshotsStatusResponse.getSnapshots().size(), equalTo(1));
|
|
|
SnapshotStatus snapshotStatus = snapshotsStatusResponse.getSnapshots().get(0);
|
|
|
assertThat(snapshotStatus.getIndices().size(), equalTo(1));
|
|
@@ -855,9 +907,11 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
assertThat(client.prepareSearch("test-idx").setSize(0).get().getHits().getTotalHits(), equalTo(100L));
|
|
|
|
|
|
logger.info("--> snapshot");
|
|
|
- CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap").setWaitForCompletion(true).setIndices("test-idx").get();
|
|
|
+ CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap")
|
|
|
+ .setWaitForCompletion(true).setIndices("test-idx").get();
|
|
|
assertThat(createSnapshotResponse.getSnapshotInfo().state(), equalTo(SnapshotState.SUCCESS));
|
|
|
- assertThat(createSnapshotResponse.getSnapshotInfo().totalShards(), equalTo(createSnapshotResponse.getSnapshotInfo().successfulShards()));
|
|
|
+ assertThat(createSnapshotResponse.getSnapshotInfo().totalShards(),
|
|
|
+ equalTo(createSnapshotResponse.getSnapshotInfo().successfulShards()));
|
|
|
|
|
|
logger.info("--> update repository with mock version");
|
|
|
assertAcked(client.admin().cluster().preparePutRepository("test-repo")
|
|
@@ -1114,9 +1168,11 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
assertThat(client.prepareSearch("test-idx").setSize(0).get().getHits().getTotalHits(), equalTo(100L));
|
|
|
|
|
|
logger.info("--> snapshot");
|
|
|
- CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap").setWaitForCompletion(true).setIndices("test-idx").get();
|
|
|
+ CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap")
|
|
|
+ .setWaitForCompletion(true).setIndices("test-idx").get();
|
|
|
assertThat(createSnapshotResponse.getSnapshotInfo().state(), equalTo(SnapshotState.SUCCESS));
|
|
|
- assertThat(createSnapshotResponse.getSnapshotInfo().totalShards(), equalTo(createSnapshotResponse.getSnapshotInfo().successfulShards()));
|
|
|
+ assertThat(createSnapshotResponse.getSnapshotInfo().totalShards(),
|
|
|
+ equalTo(createSnapshotResponse.getSnapshotInfo().successfulShards()));
|
|
|
|
|
|
logger.info("--> update repository with mock version");
|
|
|
assertAcked(client.admin().cluster().preparePutRepository("test-repo")
|
|
@@ -1144,14 +1200,16 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
// Now read restore results and make sure it failed
|
|
|
RestoreSnapshotResponse restoreSnapshotResponse = restoreSnapshotResponseFuture.actionGet(TimeValue.timeValueSeconds(10));
|
|
|
assertThat(restoreSnapshotResponse.getRestoreInfo().failedShards(), greaterThan(0));
|
|
|
- assertThat(restoreSnapshotResponse.getRestoreInfo().totalShards(), equalTo(restoreSnapshotResponse.getRestoreInfo().failedShards()));
|
|
|
+ assertThat(restoreSnapshotResponse.getRestoreInfo().totalShards(),
|
|
|
+ equalTo(restoreSnapshotResponse.getRestoreInfo().failedShards()));
|
|
|
|
|
|
logger.info("--> restoring working repository");
|
|
|
assertAcked(client.admin().cluster().preparePutRepository("test-repo")
|
|
|
.setType("fs").setSettings(Settings.builder().put("location", repositoryLocation)));
|
|
|
|
|
|
logger.info("--> trying to restore index again");
|
|
|
- restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap").setWaitForCompletion(true).execute().actionGet();
|
|
|
+ restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap")
|
|
|
+ .setWaitForCompletion(true).execute().actionGet();
|
|
|
assertThat(restoreSnapshotResponse.getRestoreInfo().totalShards(), greaterThan(0));
|
|
|
assertThat(restoreSnapshotResponse.getRestoreInfo().failedShards(), equalTo(0));
|
|
|
SearchResponse countResponse = client.prepareSearch("test-idx").setSize(0).get();
|
|
@@ -1168,10 +1226,12 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
.put("location", randomRepoPath())));
|
|
|
|
|
|
logger.info("--> creating index that cannot be allocated");
|
|
|
- prepareCreate("test-idx", 2, Settings.builder().put(IndexMetaData.INDEX_ROUTING_INCLUDE_GROUP_SETTING.getKey() + "tag", "nowhere").put("index.number_of_shards", 3)).setWaitForActiveShards(ActiveShardCount.NONE).get();
|
|
|
+ prepareCreate("test-idx", 2, Settings.builder().put(IndexMetaData.INDEX_ROUTING_INCLUDE_GROUP_SETTING.getKey() + "tag", "nowhere")
|
|
|
+ .put("index.number_of_shards", 3)).setWaitForActiveShards(ActiveShardCount.NONE).get();
|
|
|
|
|
|
logger.info("--> snapshot");
|
|
|
- CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap").setWaitForCompletion(true).setIndices("test-idx").get();
|
|
|
+ CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap")
|
|
|
+ .setWaitForCompletion(true).setIndices("test-idx").get();
|
|
|
assertThat(createSnapshotResponse.getSnapshotInfo().state(), equalTo(SnapshotState.FAILED));
|
|
|
assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), equalTo(0));
|
|
|
assertThat(createSnapshotResponse.getSnapshotInfo().totalShards(), equalTo(3));
|
|
@@ -1201,9 +1261,11 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
}
|
|
|
refresh();
|
|
|
logger.info("--> snapshot {}", i);
|
|
|
- CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap-" + i).setWaitForCompletion(true).setIndices("test-idx").get();
|
|
|
+ CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap-" + i)
|
|
|
+ .setWaitForCompletion(true).setIndices("test-idx").get();
|
|
|
assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), greaterThan(0));
|
|
|
- assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));
|
|
|
+ assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(),
|
|
|
+ equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));
|
|
|
// Store number of files after each snapshot
|
|
|
numberOfFiles[i] = numberOfFiles(repo);
|
|
|
}
|
|
@@ -1224,7 +1286,8 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
|
|
|
logger.info("--> restore index");
|
|
|
String lastSnapshot = "test-snap-" + (numberOfSnapshots - 1);
|
|
|
- RestoreSnapshotResponse restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot("test-repo", lastSnapshot).setWaitForCompletion(true).execute().actionGet();
|
|
|
+ RestoreSnapshotResponse restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot("test-repo", lastSnapshot)
|
|
|
+ .setWaitForCompletion(true).execute().actionGet();
|
|
|
assertThat(restoreSnapshotResponse.getRestoreInfo().totalShards(), greaterThan(0));
|
|
|
|
|
|
assertThat(client.prepareSearch("test-idx").setSize(0).get().getHits().getTotalHits(), equalTo(10L * numberOfSnapshots));
|
|
@@ -1305,9 +1368,11 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
client().prepareIndex("test-idx-2", "_doc").setSource("foo", "bar"));
|
|
|
|
|
|
logger.info("--> creating snapshot");
|
|
|
- CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap-1").setWaitForCompletion(true).setIndices("test-idx-*").get();
|
|
|
+ CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap-1")
|
|
|
+ .setWaitForCompletion(true).setIndices("test-idx-*").get();
|
|
|
assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), greaterThan(0));
|
|
|
- assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));
|
|
|
+ assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(),
|
|
|
+ equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));
|
|
|
|
|
|
logger.info("--> delete global state metadata");
|
|
|
Path metadata = repo.resolve("meta-" + createSnapshotResponse.getSnapshotInfo().snapshotId().getUUID() + ".dat");
|
|
@@ -1338,9 +1403,11 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
client().prepareIndex("test-idx-2", "_doc").setSource("foo", "bar"));
|
|
|
|
|
|
logger.info("--> creating snapshot");
|
|
|
- CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap-1").setWaitForCompletion(true).setIndices("test-idx-*").get();
|
|
|
+ CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap-1")
|
|
|
+ .setWaitForCompletion(true).setIndices("test-idx-*").get();
|
|
|
assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), greaterThan(0));
|
|
|
- assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));
|
|
|
+ assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(),
|
|
|
+ equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));
|
|
|
|
|
|
logger.info("--> truncate snapshot file to make it unreadable");
|
|
|
Path snapshotPath = repo.resolve("snap-" + createSnapshotResponse.getSnapshotInfo().snapshotId().getUUID() + ".dat");
|
|
@@ -1354,9 +1421,11 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
assertThrows(client.admin().cluster().prepareGetSnapshots("test-repo").addSnapshots("test-snap-1"), SnapshotMissingException.class);
|
|
|
|
|
|
logger.info("--> make sure that we can create the snapshot again");
|
|
|
- createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap-1").setWaitForCompletion(true).setIndices("test-idx-*").get();
|
|
|
+ createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap-1")
|
|
|
+ .setWaitForCompletion(true).setIndices("test-idx-*").get();
|
|
|
assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), greaterThan(0));
|
|
|
- assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));
|
|
|
+ assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(),
|
|
|
+ equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));
|
|
|
}
|
|
|
|
|
|
/** Tests that a snapshot with a corrupted global state file can still be deleted */
|
|
@@ -1479,7 +1548,8 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
assertThat(stateResponse.getState().routingTable().index("test-idx-closed"), nullValue());
|
|
|
|
|
|
logger.info("--> snapshot");
|
|
|
- CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap").setWaitForCompletion(true).setIndices("test-idx*").get();
|
|
|
+ CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap")
|
|
|
+ .setWaitForCompletion(true).setIndices("test-idx*").get();
|
|
|
assertThat(createSnapshotResponse.getSnapshotInfo().indices().size(), equalTo(1));
|
|
|
assertThat(createSnapshotResponse.getSnapshotInfo().shardFailures().size(), equalTo(0));
|
|
|
|
|
@@ -1487,7 +1557,8 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
client.admin().cluster().prepareDeleteSnapshot("test-repo", "test-snap").get();
|
|
|
|
|
|
logger.info("--> snapshot with closed index");
|
|
|
- assertBlocked(client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap").setWaitForCompletion(true).setIndices("test-idx", "test-idx-closed"), MetaDataIndexStateService.INDEX_CLOSED_BLOCK);
|
|
|
+ assertBlocked(client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap").setWaitForCompletion(true)
|
|
|
+ .setIndices("test-idx", "test-idx-closed"), MetaDataIndexStateService.INDEX_CLOSED_BLOCK);
|
|
|
}
|
|
|
|
|
|
public void testSnapshotSingleClosedIndex() throws Exception {
|
|
@@ -1535,9 +1606,11 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
assertThat(client.prepareSearch("test-idx-2").setSize(0).get().getHits().getTotalHits(), equalTo(100L));
|
|
|
|
|
|
logger.info("--> snapshot");
|
|
|
- CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap").setWaitForCompletion(true).setIndices("test-idx-1", "test-idx-2").get();
|
|
|
+ CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap")
|
|
|
+ .setWaitForCompletion(true).setIndices("test-idx-1", "test-idx-2").get();
|
|
|
assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), greaterThan(0));
|
|
|
- assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));
|
|
|
+ assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(),
|
|
|
+ equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));
|
|
|
|
|
|
logger.info("--> restore indices with different names");
|
|
|
RestoreSnapshotResponse restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap")
|
|
@@ -1572,7 +1645,8 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
|
|
|
logger.info("--> try renaming indices using the same name");
|
|
|
try {
|
|
|
- client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap").setRenamePattern("(.+)").setRenameReplacement("same-name").setWaitForCompletion(true).execute().actionGet();
|
|
|
+ client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap").setRenamePattern("(.+)")
|
|
|
+ .setRenameReplacement("same-name").setWaitForCompletion(true).execute().actionGet();
|
|
|
fail("Shouldn't be here");
|
|
|
} catch (SnapshotRestoreException ex) {
|
|
|
// Expected
|
|
@@ -1580,7 +1654,8 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
|
|
|
logger.info("--> try renaming indices using the same name");
|
|
|
try {
|
|
|
- client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap").setRenamePattern("test-idx-2").setRenameReplacement("test-idx-1").setWaitForCompletion(true).execute().actionGet();
|
|
|
+ client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap").setRenamePattern("test-idx-2")
|
|
|
+ .setRenameReplacement("test-idx-1").setWaitForCompletion(true).execute().actionGet();
|
|
|
fail("Shouldn't be here");
|
|
|
} catch (SnapshotRestoreException ex) {
|
|
|
// Expected
|
|
@@ -1588,7 +1663,8 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
|
|
|
logger.info("--> try renaming indices using invalid index name");
|
|
|
try {
|
|
|
- client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap").setIndices("test-idx-1").setRenamePattern(".+").setRenameReplacement("__WRONG__").setWaitForCompletion(true).execute().actionGet();
|
|
|
+ client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap").setIndices("test-idx-1").setRenamePattern(".+")
|
|
|
+ .setRenameReplacement("__WRONG__").setWaitForCompletion(true).execute().actionGet();
|
|
|
fail("Shouldn't be here");
|
|
|
} catch (InvalidIndexNameException ex) {
|
|
|
// Expected
|
|
@@ -1596,7 +1672,8 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
|
|
|
logger.info("--> try renaming indices into existing alias name");
|
|
|
try {
|
|
|
- client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap").setIndices("test-idx-1").setRenamePattern(".+").setRenameReplacement("alias-3").setWaitForCompletion(true).execute().actionGet();
|
|
|
+ client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap").setIndices("test-idx-1").setRenamePattern(".+")
|
|
|
+ .setRenameReplacement("alias-3").setWaitForCompletion(true).execute().actionGet();
|
|
|
fail("Shouldn't be here");
|
|
|
} catch (InvalidIndexNameException ex) {
|
|
|
// Expected
|
|
@@ -1604,7 +1681,8 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
|
|
|
logger.info("--> try renaming indices into existing alias of itself");
|
|
|
try {
|
|
|
- client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap").setIndices("test-idx-1").setRenamePattern("test-idx").setRenameReplacement("alias").setWaitForCompletion(true).execute().actionGet();
|
|
|
+ client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap").setIndices("test-idx-1").setRenamePattern("test-idx")
|
|
|
+ .setRenameReplacement("alias").setWaitForCompletion(true).execute().actionGet();
|
|
|
fail("Shouldn't be here");
|
|
|
} catch (SnapshotRestoreException ex) {
|
|
|
// Expected
|
|
@@ -1612,7 +1690,8 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
|
|
|
logger.info("--> try renaming indices into existing alias of another restored index");
|
|
|
try {
|
|
|
- client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap").setIndices("test-idx-1", "test-idx-2").setRenamePattern("test-idx-1").setRenameReplacement("alias-2").setWaitForCompletion(true).execute().actionGet();
|
|
|
+ client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap").setIndices("test-idx-1", "test-idx-2")
|
|
|
+ .setRenamePattern("test-idx-1").setRenameReplacement("alias-2").setWaitForCompletion(true).execute().actionGet();
|
|
|
fail("Shouldn't be here");
|
|
|
} catch (SnapshotRestoreException ex) {
|
|
|
// Expected
|
|
@@ -1668,7 +1747,8 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
logger.info("Number of failed shards [{}]", snapshotInfo.shardFailures().size());
|
|
|
logger.info("--> done");
|
|
|
|
|
|
- List<SnapshotInfo> snapshotInfos = client().admin().cluster().prepareGetSnapshots("test-repo").setSnapshots("test-snap").get().getSnapshots();
|
|
|
+ List<SnapshotInfo> snapshotInfos = client().admin().cluster().prepareGetSnapshots("test-repo")
|
|
|
+ .setSnapshots("test-snap").get().getSnapshots();
|
|
|
|
|
|
assertThat(snapshotInfos.size(), equalTo(1));
|
|
|
assertThat(snapshotInfos.get(0).state(), equalTo(SnapshotState.SUCCESS));
|
|
@@ -1682,7 +1762,8 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
.setType("fs").setSettings(Settings.builder().put("location", repositoryLocation)));
|
|
|
|
|
|
logger.info("--> restore index");
|
|
|
- RestoreSnapshotResponse restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap").setWaitForCompletion(true).execute().actionGet();
|
|
|
+ RestoreSnapshotResponse restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap")
|
|
|
+ .setWaitForCompletion(true).execute().actionGet();
|
|
|
assertThat(restoreSnapshotResponse.getRestoreInfo().totalShards(), greaterThan(0));
|
|
|
|
|
|
assertThat(client.prepareSearch("test-idx").setSize(0).get().getHits().getTotalHits(), equalTo(100L));
|
|
@@ -1751,7 +1832,8 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
logger.info("Number of failed shards [{}]", snapshotInfo.shardFailures().size());
|
|
|
logger.info("--> done");
|
|
|
|
|
|
- List<SnapshotInfo> snapshotInfos = client().admin().cluster().prepareGetSnapshots("test-repo").setSnapshots("test-snap").get().getSnapshots();
|
|
|
+ List<SnapshotInfo> snapshotInfos = client().admin().cluster().prepareGetSnapshots("test-repo")
|
|
|
+ .setSnapshots("test-snap").get().getSnapshots();
|
|
|
|
|
|
assertThat(snapshotInfos.size(), equalTo(1));
|
|
|
assertThat(snapshotInfos.get(0).state(), equalTo(SnapshotState.SUCCESS));
|
|
@@ -1765,7 +1847,8 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
.setType("fs").setSettings(Settings.builder().put("location", repositoryLocation)));
|
|
|
|
|
|
logger.info("--> restore index");
|
|
|
- RestoreSnapshotResponse restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap").setWaitForCompletion(true).execute().actionGet();
|
|
|
+ RestoreSnapshotResponse restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap")
|
|
|
+ .setWaitForCompletion(true).execute().actionGet();
|
|
|
assertThat(restoreSnapshotResponse.getRestoreInfo().totalShards(), greaterThan(0));
|
|
|
|
|
|
assertThat(client.prepareSearch("test-idx").setSize(0).get().getHits().getTotalHits(), equalTo(100L));
|
|
@@ -1793,11 +1876,14 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
refresh();
|
|
|
|
|
|
logger.info("--> snapshot");
|
|
|
- CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap").setWaitForCompletion(true).setIndices("test-idx").get();
|
|
|
+ CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap")
|
|
|
+ .setWaitForCompletion(true).setIndices("test-idx").get();
|
|
|
assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), greaterThan(0));
|
|
|
- assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));
|
|
|
+ assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(),
|
|
|
+ equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));
|
|
|
|
|
|
- assertThat(client.admin().cluster().prepareGetSnapshots("test-repo").setSnapshots("test-snap").get().getSnapshots().get(0).state(), equalTo(SnapshotState.SUCCESS));
|
|
|
+ assertThat(client.admin().cluster().prepareGetSnapshots("test-repo").setSnapshots("test-snap").get().getSnapshots().get(0).state(),
|
|
|
+ equalTo(SnapshotState.SUCCESS));
|
|
|
|
|
|
logger.info("--> delete index");
|
|
|
cluster().wipeIndices("test-idx");
|
|
@@ -1810,7 +1896,8 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
.put("readonly", true)
|
|
|
.put("chunk_size", randomIntBetween(100, 1000), ByteSizeUnit.BYTES)));
|
|
|
logger.info("--> restore index after deletion");
|
|
|
- RestoreSnapshotResponse restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot("readonly-repo", "test-snap").setWaitForCompletion(true).setIndices("test-idx").execute().actionGet();
|
|
|
+ RestoreSnapshotResponse restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot("readonly-repo", "test-snap")
|
|
|
+ .setWaitForCompletion(true).setIndices("test-idx").execute().actionGet();
|
|
|
assertThat(restoreSnapshotResponse.getRestoreInfo().totalShards(), greaterThan(0));
|
|
|
|
|
|
assertThat(client.prepareSearch("test-idx").setSize(0).get().getHits().getTotalHits(), equalTo(100L));
|
|
@@ -1821,10 +1908,14 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
assertThat(getSnapshotsResponse.getSnapshots().size(), equalTo(1));
|
|
|
|
|
|
logger.info("--> try deleting snapshot");
|
|
|
- assertThrows(client.admin().cluster().prepareDeleteSnapshot("readonly-repo", "test-snap"), RepositoryException.class, "cannot delete snapshot from a readonly repository");
|
|
|
+ assertThrows(client.admin().cluster().prepareDeleteSnapshot("readonly-repo", "test-snap"), RepositoryException.class,
|
|
|
+ "cannot delete snapshot from a readonly repository");
|
|
|
|
|
|
logger.info("--> try making another snapshot");
|
|
|
- assertThrows(client.admin().cluster().prepareCreateSnapshot("readonly-repo", "test-snap-2").setWaitForCompletion(true).setIndices("test-idx"), RepositoryException.class, "cannot create snapshot in a readonly repository");
|
|
|
+ assertThrows(client.admin().cluster().prepareCreateSnapshot("readonly-repo", "test-snap-2")
|
|
|
+ .setWaitForCompletion(true).setIndices("test-idx"),
|
|
|
+ RepositoryException.class,
|
|
|
+ "cannot create snapshot in a readonly repository");
|
|
|
}
|
|
|
|
|
|
public void testThrottling() throws Exception {
|
|
@@ -1853,15 +1944,18 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
assertThat(client.prepareSearch("test-idx").setSize(0).get().getHits().getTotalHits(), equalTo(100L));
|
|
|
|
|
|
logger.info("--> snapshot");
|
|
|
- CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap").setWaitForCompletion(true).setIndices("test-idx").get();
|
|
|
+ CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap")
|
|
|
+ .setWaitForCompletion(true).setIndices("test-idx").get();
|
|
|
assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), greaterThan(0));
|
|
|
- assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));
|
|
|
+ assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(),
|
|
|
+ equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));
|
|
|
|
|
|
logger.info("--> delete index");
|
|
|
cluster().wipeIndices("test-idx");
|
|
|
|
|
|
logger.info("--> restore index");
|
|
|
- RestoreSnapshotResponse restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap").setWaitForCompletion(true).execute().actionGet();
|
|
|
+ RestoreSnapshotResponse restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap")
|
|
|
+ .setWaitForCompletion(true).execute().actionGet();
|
|
|
assertThat(restoreSnapshotResponse.getRestoreInfo().totalShards(), greaterThan(0));
|
|
|
assertThat(client.prepareSearch("test-idx").setSize(0).get().getHits().getTotalHits(), equalTo(100L));
|
|
|
|
|
@@ -1949,7 +2043,8 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
}
|
|
|
|
|
|
logger.info("--> checking that _current returns the currently running snapshot");
|
|
|
- GetSnapshotsResponse getResponse = client.admin().cluster().prepareGetSnapshots("test-repo").setCurrentSnapshot().execute().actionGet();
|
|
|
+ GetSnapshotsResponse getResponse = client.admin().cluster().prepareGetSnapshots("test-repo")
|
|
|
+ .setCurrentSnapshot().execute().actionGet();
|
|
|
assertThat(getResponse.getSnapshots().size(), equalTo(1));
|
|
|
SnapshotInfo snapshotInfo = getResponse.getSnapshots().get(0);
|
|
|
assertThat(snapshotInfo.state(), equalTo(SnapshotState.IN_PROGRESS));
|
|
@@ -1980,7 +2075,9 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
assertThat(response.getSnapshots().size(), equalTo(0));
|
|
|
|
|
|
logger.info("--> checking that _current no longer returns the snapshot");
|
|
|
- assertThat(client.admin().cluster().prepareGetSnapshots("test-repo").addSnapshots("_current").execute().actionGet().getSnapshots().isEmpty(), equalTo(true));
|
|
|
+ assertThat(client.admin().cluster().prepareGetSnapshots("test-repo").addSnapshots("_current")
|
|
|
+ .execute().actionGet().getSnapshots().isEmpty(),
|
|
|
+ equalTo(true));
|
|
|
|
|
|
// test that getting an unavailable snapshot status throws an exception if ignoreUnavailable is false on the request
|
|
|
SnapshotMissingException ex = expectThrows(SnapshotMissingException.class, () ->
|
|
@@ -2064,24 +2161,32 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
flushAndRefresh();
|
|
|
assertNoFailures(client().admin().indices().prepareForceMerge("test").setFlush(true).setMaxNumSegments(1).get());
|
|
|
|
|
|
- CreateSnapshotResponse createSnapshotResponseFirst = client.admin().cluster().prepareCreateSnapshot("test-repo", "test").setWaitForCompletion(true).setIndices("test").get();
|
|
|
+ CreateSnapshotResponse createSnapshotResponseFirst = client.admin().cluster().prepareCreateSnapshot("test-repo", "test")
|
|
|
+ .setWaitForCompletion(true).setIndices("test").get();
|
|
|
assertThat(createSnapshotResponseFirst.getSnapshotInfo().successfulShards(), greaterThan(0));
|
|
|
- assertThat(createSnapshotResponseFirst.getSnapshotInfo().successfulShards(), equalTo(createSnapshotResponseFirst.getSnapshotInfo().totalShards()));
|
|
|
- assertThat(client.admin().cluster().prepareGetSnapshots("test-repo").setSnapshots("test").get().getSnapshots().get(0).state(), equalTo(SnapshotState.SUCCESS));
|
|
|
+ assertThat(createSnapshotResponseFirst.getSnapshotInfo().successfulShards(),
|
|
|
+ equalTo(createSnapshotResponseFirst.getSnapshotInfo().totalShards()));
|
|
|
+ assertThat(client.admin().cluster().prepareGetSnapshots("test-repo").setSnapshots("test").get().getSnapshots().get(0).state(),
|
|
|
+ equalTo(SnapshotState.SUCCESS));
|
|
|
{
|
|
|
- SnapshotStatus snapshotStatus = client.admin().cluster().prepareSnapshotStatus("test-repo").setSnapshots("test").get().getSnapshots().get(0);
|
|
|
+ SnapshotStatus snapshotStatus = client.admin().cluster().prepareSnapshotStatus("test-repo")
|
|
|
+ .setSnapshots("test").get().getSnapshots().get(0);
|
|
|
List<SnapshotIndexShardStatus> shards = snapshotStatus.getShards();
|
|
|
for (SnapshotIndexShardStatus status : shards) {
|
|
|
assertThat(status.getStats().getProcessedFileCount(), greaterThan(1));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- CreateSnapshotResponse createSnapshotResponseSecond = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-1").setWaitForCompletion(true).setIndices("test").get();
|
|
|
+ CreateSnapshotResponse createSnapshotResponseSecond = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-1")
|
|
|
+ .setWaitForCompletion(true).setIndices("test").get();
|
|
|
assertThat(createSnapshotResponseSecond.getSnapshotInfo().successfulShards(), greaterThan(0));
|
|
|
- assertThat(createSnapshotResponseSecond.getSnapshotInfo().successfulShards(), equalTo(createSnapshotResponseSecond.getSnapshotInfo().totalShards()));
|
|
|
- assertThat(client.admin().cluster().prepareGetSnapshots("test-repo").setSnapshots("test-1").get().getSnapshots().get(0).state(), equalTo(SnapshotState.SUCCESS));
|
|
|
+ assertThat(createSnapshotResponseSecond.getSnapshotInfo().successfulShards(),
|
|
|
+ equalTo(createSnapshotResponseSecond.getSnapshotInfo().totalShards()));
|
|
|
+ assertThat(client.admin().cluster().prepareGetSnapshots("test-repo").setSnapshots("test-1").get().getSnapshots().get(0).state(),
|
|
|
+ equalTo(SnapshotState.SUCCESS));
|
|
|
{
|
|
|
- SnapshotStatus snapshotStatus = client.admin().cluster().prepareSnapshotStatus("test-repo").setSnapshots("test-1").get().getSnapshots().get(0);
|
|
|
+ SnapshotStatus snapshotStatus = client.admin().cluster().prepareSnapshotStatus("test-repo")
|
|
|
+ .setSnapshots("test-1").get().getSnapshots().get(0);
|
|
|
List<SnapshotIndexShardStatus> shards = snapshotStatus.getShards();
|
|
|
for (SnapshotIndexShardStatus status : shards) {
|
|
|
assertThat(status.getStats().getProcessedFileCount(), equalTo(0));
|
|
@@ -2089,12 +2194,16 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
}
|
|
|
|
|
|
client().prepareDelete("test", "_doc", "1").get();
|
|
|
- CreateSnapshotResponse createSnapshotResponseThird = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-2").setWaitForCompletion(true).setIndices("test").get();
|
|
|
+ CreateSnapshotResponse createSnapshotResponseThird = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-2")
|
|
|
+ .setWaitForCompletion(true).setIndices("test").get();
|
|
|
assertThat(createSnapshotResponseThird.getSnapshotInfo().successfulShards(), greaterThan(0));
|
|
|
- assertThat(createSnapshotResponseThird.getSnapshotInfo().successfulShards(), equalTo(createSnapshotResponseThird.getSnapshotInfo().totalShards()));
|
|
|
- assertThat(client.admin().cluster().prepareGetSnapshots("test-repo").setSnapshots("test-2").get().getSnapshots().get(0).state(), equalTo(SnapshotState.SUCCESS));
|
|
|
+ assertThat(createSnapshotResponseThird.getSnapshotInfo().successfulShards(),
|
|
|
+ equalTo(createSnapshotResponseThird.getSnapshotInfo().totalShards()));
|
|
|
+ assertThat(client.admin().cluster().prepareGetSnapshots("test-repo").setSnapshots("test-2").get().getSnapshots().get(0).state(),
|
|
|
+ equalTo(SnapshotState.SUCCESS));
|
|
|
{
|
|
|
- SnapshotStatus snapshotStatus = client.admin().cluster().prepareSnapshotStatus("test-repo").setSnapshots("test-2").get().getSnapshots().get(0);
|
|
|
+ SnapshotStatus snapshotStatus = client.admin().cluster().prepareSnapshotStatus("test-repo")
|
|
|
+ .setSnapshots("test-2").get().getSnapshots().get(0);
|
|
|
List<SnapshotIndexShardStatus> shards = snapshotStatus.getShards();
|
|
|
for (SnapshotIndexShardStatus status : shards) {
|
|
|
// we flush before the snapshot such that we have to process the segments_N files plus the .del file
|
|
@@ -2130,7 +2239,8 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
assertAcked(prepareCreate("test-idx", 2, indexSettings));
|
|
|
|
|
|
int numberOfShards = getNumShards("test-idx").numPrimaries;
|
|
|
- assertAcked(client().admin().indices().preparePutMapping("test-idx").setType("type1").setSource("field1", "type=text,analyzer=standard,search_analyzer=my_analyzer"));
|
|
|
+ assertAcked(client().admin().indices().preparePutMapping("test-idx").setType("type1")
|
|
|
+ .setSource("field1", "type=text,analyzer=standard,search_analyzer=my_analyzer"));
|
|
|
final int numdocs = randomIntBetween(10, 100);
|
|
|
IndexRequestBuilder[] builders = new IndexRequestBuilder[numdocs];
|
|
|
for (int i = 0; i < builders.length; i++) {
|
|
@@ -2144,9 +2254,11 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
assertHitCount(client.prepareSearch("test-idx").setSize(0).setQuery(matchQuery("field1", "bar")).get(), numdocs);
|
|
|
|
|
|
logger.info("--> snapshot it");
|
|
|
- CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap").setWaitForCompletion(true).setIndices("test-idx").get();
|
|
|
+ CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap")
|
|
|
+ .setWaitForCompletion(true).setIndices("test-idx").get();
|
|
|
assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), greaterThan(0));
|
|
|
- assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));
|
|
|
+ assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(),
|
|
|
+ equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));
|
|
|
|
|
|
logger.info("--> delete the index and recreate it while changing refresh interval and analyzer");
|
|
|
cluster().wipeIndices("test-idx");
|
|
@@ -2256,7 +2368,8 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap")
|
|
|
.setWaitForCompletion(true).setIndices("test-idx").get();
|
|
|
assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), greaterThan(0));
|
|
|
- assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));
|
|
|
+ assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(),
|
|
|
+ equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));
|
|
|
|
|
|
logger.info("--> remove blocks and delete index");
|
|
|
disableIndexBlock("test-idx", IndexMetaData.SETTING_BLOCKS_METADATA);
|
|
@@ -2404,7 +2517,8 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
assertThat(createSnapshotResponse.getSnapshotInfo().state(), equalTo((SnapshotState.PARTIAL)));
|
|
|
assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), greaterThan(0));
|
|
|
assertThat(createSnapshotResponse.getSnapshotInfo().failedShards(), greaterThan(0));
|
|
|
- assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), lessThan(createSnapshotResponse.getSnapshotInfo().totalShards()));
|
|
|
+ assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(),
|
|
|
+ lessThan(createSnapshotResponse.getSnapshotInfo().totalShards()));
|
|
|
} else {
|
|
|
logger.info("Snapshot successfully completed");
|
|
|
assertThat(createSnapshotResponse.getSnapshotInfo().state(), equalTo((SnapshotState.SUCCESS)));
|
|
@@ -2565,12 +2679,15 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
|
|
|
logger.info("--> snapshot");
|
|
|
final String snapshotName = "test-snap";
|
|
|
- CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot(repositoryName, snapshotName).setWaitForCompletion(true).setIndices(idxName).get();
|
|
|
+ CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot(repositoryName, snapshotName)
|
|
|
+ .setWaitForCompletion(true).setIndices(idxName).get();
|
|
|
assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), greaterThan(0));
|
|
|
- assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));
|
|
|
+ assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(),
|
|
|
+ equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));
|
|
|
|
|
|
logger.info("--> emulate an orphan snapshot");
|
|
|
- RepositoriesService repositoriesService = internalCluster().getInstance(RepositoriesService.class, internalCluster().getMasterName());
|
|
|
+ RepositoriesService repositoriesService = internalCluster().getInstance(RepositoriesService.class,
|
|
|
+ internalCluster().getMasterName());
|
|
|
final RepositoryData repositoryData = getRepositoryData(repositoriesService.repository(repositoryName));
|
|
|
final IndexId indexId = repositoryData.resolveIndexId(idxName);
|
|
|
|
|
@@ -2593,7 +2710,9 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
System.currentTimeMillis(),
|
|
|
repositoryData.getGenId(),
|
|
|
shards.build()));
|
|
|
- return ClusterState.builder(currentState).putCustom(SnapshotsInProgress.TYPE, new SnapshotsInProgress(Collections.unmodifiableList(entries))).build();
|
|
|
+ return ClusterState.builder(currentState)
|
|
|
+ .putCustom(SnapshotsInProgress.TYPE, new SnapshotsInProgress(Collections.unmodifiableList(entries)))
|
|
|
+ .build();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -2614,11 +2733,13 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
}
|
|
|
|
|
|
private boolean waitForIndex(final String index, TimeValue timeout) throws InterruptedException {
|
|
|
- return awaitBusy(() -> client().admin().indices().prepareExists(index).execute().actionGet().isExists(), timeout.millis(), TimeUnit.MILLISECONDS);
|
|
|
+ return awaitBusy(() -> client().admin().indices().prepareExists(index).execute().actionGet().isExists(),
|
|
|
+ timeout.millis(), TimeUnit.MILLISECONDS);
|
|
|
}
|
|
|
|
|
|
private boolean waitForRelocationsToStart(final String index, TimeValue timeout) throws InterruptedException {
|
|
|
- return awaitBusy(() -> client().admin().cluster().prepareHealth(index).execute().actionGet().getRelocatingShards() > 0, timeout.millis(), TimeUnit.MILLISECONDS);
|
|
|
+ return awaitBusy(() -> client().admin().cluster().prepareHealth(index).execute().actionGet().getRelocatingShards() > 0,
|
|
|
+ timeout.millis(), TimeUnit.MILLISECONDS);
|
|
|
}
|
|
|
|
|
|
public void testSnapshotName() throws Exception {
|
|
@@ -2658,13 +2779,17 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
client().prepareIndex("test-idx-3", "_doc").setSource("foo", "bar"));
|
|
|
|
|
|
logger.info("--> creating 2 snapshots");
|
|
|
- CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap-1").setWaitForCompletion(true).setIndices("test-idx-*").get();
|
|
|
+ CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap-1")
|
|
|
+ .setWaitForCompletion(true).setIndices("test-idx-*").get();
|
|
|
assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), greaterThan(0));
|
|
|
- assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));
|
|
|
+ assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(),
|
|
|
+ equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));
|
|
|
|
|
|
- createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap-2").setWaitForCompletion(true).setIndices("test-idx-*").get();
|
|
|
+ createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot("test-repo", "test-snap-2").setWaitForCompletion(true)
|
|
|
+ .setIndices("test-idx-*").get();
|
|
|
assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), greaterThan(0));
|
|
|
- assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));
|
|
|
+ assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(),
|
|
|
+ equalTo(createSnapshotResponse.getSnapshotInfo().totalShards()));
|
|
|
|
|
|
logger.info("--> truncate snapshot file to make it unreadable");
|
|
|
Path snapshotPath = repo.resolve("snap-" + createSnapshotResponse.getSnapshotInfo().snapshotId().getUUID() + ".dat");
|