|
@@ -321,7 +321,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
String indexName = "testindex";
|
|
|
String repoName = "test-restore-snapshot-repo";
|
|
|
String snapshotName = "test-restore-snapshot";
|
|
|
- String absolutePath = randomRepoPath().toAbsolutePath().toString();
|
|
|
+ Path absolutePath = randomRepoPath().toAbsolutePath();
|
|
|
logger.info("Path [{}]", absolutePath);
|
|
|
String restoredIndexName = indexName + "-restored";
|
|
|
String expectedValue = "expected";
|
|
@@ -331,11 +331,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
String docId = Integer.toString(randomInt());
|
|
|
indexDoc(indexName, docId, "value", expectedValue);
|
|
|
|
|
|
- logger.info("--> creating repository");
|
|
|
- assertAcked(client.admin().cluster().preparePutRepository(repoName)
|
|
|
- .setType("fs").setSettings(Settings.builder()
|
|
|
- .put("location", absolutePath)
|
|
|
- ));
|
|
|
+ createRepository(repoName, "fs", absolutePath);
|
|
|
|
|
|
logger.info("--> snapshot");
|
|
|
CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot(repoName, snapshotName)
|
|
@@ -480,9 +476,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
public void testRestoreAliases() throws Exception {
|
|
|
Client client = client();
|
|
|
|
|
|
- logger.info("--> creating repository");
|
|
|
- assertAcked(client.admin().cluster().preparePutRepository("test-repo")
|
|
|
- .setType("fs").setSettings(Settings.builder().put("location", randomRepoPath())));
|
|
|
+ createRepository("test-repo", "fs", randomRepoPath());
|
|
|
|
|
|
logger.info("--> create test indices");
|
|
|
createIndex("test-idx-1", "test-idx-2", "test-idx-3");
|
|
@@ -545,9 +539,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
public void testRestoreTemplates() throws Exception {
|
|
|
Client client = client();
|
|
|
|
|
|
- logger.info("--> creating repository");
|
|
|
- assertAcked(client.admin().cluster().preparePutRepository("test-repo")
|
|
|
- .setType("fs").setSettings(Settings.builder().put("location", randomRepoPath())));
|
|
|
+ createRepository("test-repo", "fs", randomRepoPath());
|
|
|
|
|
|
logger.info("--> creating test template");
|
|
|
assertThat(client.admin().indices()
|
|
@@ -597,10 +589,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
public void testIncludeGlobalState() throws Exception {
|
|
|
Client client = client();
|
|
|
|
|
|
- logger.info("--> creating repository");
|
|
|
- Path location = randomRepoPath();
|
|
|
- assertAcked(client.admin().cluster().preparePutRepository("test-repo")
|
|
|
- .setType("fs").setSettings(Settings.builder().put("location", location)));
|
|
|
+ createRepository("test-repo", "fs", randomRepoPath());
|
|
|
|
|
|
boolean testTemplate = randomBoolean();
|
|
|
boolean testPipeline = randomBoolean();
|
|
@@ -914,9 +903,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
|
|
|
Path repositoryLocation = randomRepoPath();
|
|
|
Client client = client();
|
|
|
- logger.info("--> creating repository");
|
|
|
- assertAcked(client.admin().cluster().preparePutRepository("test-repo")
|
|
|
- .setType("fs").setSettings(Settings.builder().put("location", repositoryLocation)));
|
|
|
+ createRepository("test-repo", "fs", repositoryLocation);
|
|
|
|
|
|
prepareCreate("test-idx").setSettings(Settings.builder().put("index.allocation.max_retries", Integer.MAX_VALUE)).get();
|
|
|
ensureGreen();
|
|
@@ -979,9 +966,8 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
|
|
|
Path repositoryLocation = randomRepoPath();
|
|
|
Client client = client();
|
|
|
- logger.info("--> creating repository");
|
|
|
- assertAcked(client.admin().cluster().preparePutRepository("test-repo")
|
|
|
- .setType("fs").setSettings(Settings.builder().put("location", repositoryLocation)));
|
|
|
+
|
|
|
+ createRepository("test-repo", "fs", repositoryLocation);
|
|
|
|
|
|
createIndex("test-idx");
|
|
|
ensureGreen();
|
|
@@ -1088,9 +1074,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
final Runnable fixUpAction) throws Exception {
|
|
|
// create a test repository
|
|
|
final Path repositoryLocation = randomRepoPath();
|
|
|
- assertAcked(client().admin().cluster().preparePutRepository("test-repo")
|
|
|
- .setType("fs")
|
|
|
- .setSettings(Settings.builder().put("location", repositoryLocation)));
|
|
|
+ createRepository("test-repo", "fs", repositoryLocation);
|
|
|
// create a test index
|
|
|
assertAcked(prepareCreate(indexName, Settings.builder().put(createIndexSettings)));
|
|
|
|
|
@@ -1157,9 +1141,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
}
|
|
|
|
|
|
// update the test repository in order to make it work
|
|
|
- assertAcked(client().admin().cluster().preparePutRepository("test-repo")
|
|
|
- .setType("fs")
|
|
|
- .setSettings(Settings.builder().put("location", repositoryLocation)));
|
|
|
+ createRepository("test-repo", "fs", repositoryLocation);
|
|
|
|
|
|
// execute action to eventually fix the situation
|
|
|
fixUpAction.run();
|
|
@@ -1181,9 +1163,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
public void testDeletionOfFailingToRecoverIndexShouldStopRestore() throws Exception {
|
|
|
Path repositoryLocation = randomRepoPath();
|
|
|
Client client = client();
|
|
|
- logger.info("--> creating repository");
|
|
|
- assertAcked(client.admin().cluster().preparePutRepository("test-repo")
|
|
|
- .setType("fs").setSettings(Settings.builder().put("location", repositoryLocation)));
|
|
|
+ createRepository("test-repo", "fs", repositoryLocation);
|
|
|
|
|
|
createIndex("test-idx");
|
|
|
ensureGreen();
|
|
@@ -1232,8 +1212,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
equalTo(restoreSnapshotResponse.getRestoreInfo().failedShards()));
|
|
|
|
|
|
logger.info("--> restoring working repository");
|
|
|
- assertAcked(client.admin().cluster().preparePutRepository("test-repo")
|
|
|
- .setType("fs").setSettings(Settings.builder().put("location", repositoryLocation)));
|
|
|
+ createRepository("test-repo", "fs", repositoryLocation);
|
|
|
|
|
|
logger.info("--> trying to restore index again");
|
|
|
restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap")
|
|
@@ -1247,10 +1226,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
public void testUnallocatedShards() throws Exception {
|
|
|
Client client = client();
|
|
|
|
|
|
- logger.info("--> creating repository");
|
|
|
- assertAcked(client.admin().cluster().preparePutRepository("test-repo")
|
|
|
- .setType("fs").setSettings(Settings.builder()
|
|
|
- .put("location", randomRepoPath())));
|
|
|
+ createRepository("test-repo", "fs", 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")
|
|
@@ -1672,10 +1648,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
public void testSnapshotClosedIndex() throws Exception {
|
|
|
Client client = client();
|
|
|
|
|
|
- logger.info("--> creating repository");
|
|
|
- assertAcked(client.admin().cluster().preparePutRepository("test-repo")
|
|
|
- .setType("fs").setSettings(Settings.builder()
|
|
|
- .put("location", randomRepoPath())));
|
|
|
+ createRepository("test-repo", "fs", randomRepoPath());
|
|
|
|
|
|
createIndex("test-idx", "test-idx-closed");
|
|
|
ensureGreen();
|
|
@@ -1695,10 +1668,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
public void testRenameOnRestore() throws Exception {
|
|
|
Client client = client();
|
|
|
|
|
|
- logger.info("--> creating repository");
|
|
|
- assertAcked(client.admin().cluster().preparePutRepository("test-repo")
|
|
|
- .setType("fs").setSettings(Settings.builder()
|
|
|
- .put("location", randomRepoPath())));
|
|
|
+ createRepository("test-repo", "fs", randomRepoPath());
|
|
|
|
|
|
createIndex("test-idx-1", "test-idx-2", "test-idx-3");
|
|
|
ensureGreen();
|
|
@@ -1869,8 +1839,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
cluster().wipeIndices("test-idx");
|
|
|
|
|
|
logger.info("--> replace mock repository with real one at the same location");
|
|
|
- assertAcked(client.admin().cluster().preparePutRepository("test-repo")
|
|
|
- .setType("fs").setSettings(Settings.builder().put("location", repositoryLocation)));
|
|
|
+ createRepository("test-repo", "fs", repositoryLocation);
|
|
|
|
|
|
logger.info("--> restore index");
|
|
|
RestoreSnapshotResponse restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap")
|
|
@@ -1955,8 +1924,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
cluster().wipeIndices("test-idx");
|
|
|
|
|
|
logger.info("--> replace mock repository with real one at the same location");
|
|
|
- assertAcked(client.admin().cluster().preparePutRepository("test-repo")
|
|
|
- .setType("fs").setSettings(Settings.builder().put("location", repositoryLocation)));
|
|
|
+ createRepository("test-repo", "fs", repositoryLocation);
|
|
|
|
|
|
logger.info("--> restore index");
|
|
|
RestoreSnapshotResponse restoreSnapshotResponse = client.admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap")
|
|
@@ -2666,11 +2634,8 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
public void testDeleteSnapshotWhileRestoringFails() throws Exception {
|
|
|
Client client = client();
|
|
|
|
|
|
- logger.info("--> creating repository");
|
|
|
final String repoName = "test-repo";
|
|
|
- assertAcked(client.admin().cluster().preparePutRepository(repoName)
|
|
|
- .setType("mock")
|
|
|
- .setSettings(Settings.builder().put("location", randomRepoPath())));
|
|
|
+ createRepository(repoName, "mock", randomRepoPath());
|
|
|
|
|
|
logger.info("--> creating index");
|
|
|
final String indexName = "test-idx";
|
|
@@ -2893,10 +2858,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
}
|
|
|
flushAndRefresh();
|
|
|
|
|
|
- assertAcked(client().admin().cluster().preparePutRepository("test-repo")
|
|
|
- .setType("fs")
|
|
|
- .setSettings(Settings.builder()
|
|
|
- .put("location", repo)));
|
|
|
+ createRepository("test-repo", "fs", repo);
|
|
|
|
|
|
CreateSnapshotResponse createSnapshotResponse = client().admin().cluster().prepareCreateSnapshot("test-repo", "test-snap")
|
|
|
.setWaitForCompletion(true)
|
|
@@ -2970,11 +2932,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
indexRandom(true, documents);
|
|
|
flushAndRefresh();
|
|
|
|
|
|
- logger.info("--> creating repository");
|
|
|
- assertAcked(client().admin().cluster().preparePutRepository("test-repo")
|
|
|
- .setType("fs")
|
|
|
- .setSettings(Settings.builder()
|
|
|
- .put("location", repo)));
|
|
|
+ createRepository("test-repo", "fs", repo);
|
|
|
|
|
|
final String snapshot1 = "test-snap-1";
|
|
|
logger.info("--> creating snapshot [{}]", snapshot1);
|
|
@@ -3360,8 +3318,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
}
|
|
|
|
|
|
logger.info("--> snapshot with no I/O failures");
|
|
|
- assertAcked(client.admin().cluster().preparePutRepository("test-repo-2").setType("mock").setSettings(
|
|
|
- Settings.builder().put("location", repoPath)));
|
|
|
+ createRepository("test-repo-2", "mock", repoPath);
|
|
|
CreateSnapshotResponse createSnapshotResponse =
|
|
|
client.admin().cluster().prepareCreateSnapshot("test-repo-2", "test-snap-2")
|
|
|
.setWaitForCompletion(true)
|
|
@@ -3500,7 +3457,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
.setVerbose(false)
|
|
|
.get();
|
|
|
assertEquals(indicesPerSnapshot.size(), response.getSnapshots("test-repo").size());
|
|
|
- verifySnapshotInfo("test-repo", response, indicesPerSnapshot);
|
|
|
+ verifySnapshotInfo(response, indicesPerSnapshot);
|
|
|
|
|
|
logger.info("--> verify wildcard returns snapshot info");
|
|
|
response = client().admin().cluster()
|
|
@@ -3509,7 +3466,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
.setVerbose(false)
|
|
|
.get();
|
|
|
assertEquals(indicesPerSnapshot.size(), response.getSnapshots("test-repo").size());
|
|
|
- verifySnapshotInfo("test-repo", response, indicesPerSnapshot);
|
|
|
+ verifySnapshotInfo(response, indicesPerSnapshot);
|
|
|
|
|
|
logger.info("--> verify individual requests return snapshot info");
|
|
|
for (int i = 0; i < numSnapshots; i++) {
|
|
@@ -3519,7 +3476,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
.setVerbose(false)
|
|
|
.get();
|
|
|
assertEquals(1, response.getSnapshots("test-repo").size());
|
|
|
- verifySnapshotInfo("test-repo", response, indicesPerSnapshot);
|
|
|
+ verifySnapshotInfo(response, indicesPerSnapshot);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -3602,7 +3559,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
String repoName = "test-restore-snapshot-repo";
|
|
|
String snapshotName1 = "test-restore-snapshot1";
|
|
|
String snapshotName2 = "test-restore-snapshot2";
|
|
|
- String absolutePath = randomRepoPath().toAbsolutePath().toString();
|
|
|
+ Path absolutePath = randomRepoPath().toAbsolutePath();
|
|
|
logger.info("Path [{}]", absolutePath);
|
|
|
String restoredIndexName1 = indexName1 + "-restored";
|
|
|
String restoredIndexName2 = indexName2 + "-restored";
|
|
@@ -3616,11 +3573,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
String docId2 = Integer.toString(randomInt());
|
|
|
indexDoc(indexName2, docId2, "value", expectedValue);
|
|
|
|
|
|
- logger.info("--> creating repository");
|
|
|
- assertAcked(client.admin().cluster().preparePutRepository(repoName)
|
|
|
- .setType("fs").setSettings(Settings.builder()
|
|
|
- .put("location", absolutePath)
|
|
|
- ));
|
|
|
+ createRepository(repoName, "fs", absolutePath);
|
|
|
|
|
|
logger.info("--> snapshot");
|
|
|
CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot(repoName, snapshotName1)
|
|
@@ -3663,7 +3616,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
String indexName2 = "testindex2";
|
|
|
String repoName = "test-restore-snapshot-repo";
|
|
|
String snapshotName = "test-restore-snapshot";
|
|
|
- String absolutePath = randomRepoPath().toAbsolutePath().toString();
|
|
|
+ Path absolutePath = randomRepoPath().toAbsolutePath();
|
|
|
logger.info("Path [{}]", absolutePath);
|
|
|
String restoredIndexName1 = indexName1 + "-restored";
|
|
|
String restoredIndexName2 = indexName2 + "-restored";
|
|
@@ -3677,11 +3630,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
String docId2 = Integer.toString(randomInt());
|
|
|
indexDoc(indexName2, docId2, "value", expectedValue);
|
|
|
|
|
|
- logger.info("--> creating repository");
|
|
|
- assertAcked(client.admin().cluster().preparePutRepository(repoName)
|
|
|
- .setType("fs").setSettings(Settings.builder()
|
|
|
- .put("location", absolutePath)
|
|
|
- ));
|
|
|
+ createRepository(repoName, "fs", absolutePath);
|
|
|
|
|
|
logger.info("--> snapshot");
|
|
|
CreateSnapshotResponse createSnapshotResponse = client.admin().cluster().prepareCreateSnapshot(repoName, snapshotName)
|
|
@@ -3760,7 +3709,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
public void testSnapshotDifferentIndicesBySameName() {
|
|
|
String indexName = "testindex";
|
|
|
String repoName = "test-repo";
|
|
|
- String absolutePath = randomRepoPath().toAbsolutePath().toString();
|
|
|
+ Path absolutePath = randomRepoPath().toAbsolutePath();
|
|
|
logger.info("Path [{}]", absolutePath);
|
|
|
|
|
|
final int initialShardCount = randomIntBetween(1, 10);
|
|
@@ -3773,10 +3722,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
indexDoc(indexName, Integer.toString(i), "foo", "bar" + i);
|
|
|
}
|
|
|
|
|
|
- logger.info("--> creating repository");
|
|
|
- assertAcked(client().admin().cluster().preparePutRepository(repoName)
|
|
|
- .setType("fs")
|
|
|
- .setSettings(Settings.builder().put("location", absolutePath)));
|
|
|
+ createRepository(repoName, "fs", absolutePath);
|
|
|
|
|
|
logger.info("--> snapshot with [{}] shards", initialShardCount);
|
|
|
final SnapshotInfo snapshot1 =
|
|
@@ -3837,7 +3783,7 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
|
|
assertHitCount(client().prepareSearch("restored-3").setSize(0).get(), expectedCount);
|
|
|
}
|
|
|
|
|
|
- private void verifySnapshotInfo(final String repo, final GetSnapshotsResponse response,
|
|
|
+ private void verifySnapshotInfo(final GetSnapshotsResponse response,
|
|
|
final Map<String, List<String>> indicesPerSnapshot) {
|
|
|
for (SnapshotInfo snapshotInfo : response.getSnapshots("test-repo")) {
|
|
|
final List<String> expected = snapshotInfo.indices();
|