|
20 | 20 | package org.elasticsearch.snapshots; |
21 | 21 |
|
22 | 22 | import org.apache.lucene.util.BytesRef; |
23 | | -import org.apache.lucene.util.LuceneTestCase; |
24 | 23 | import org.elasticsearch.ElasticsearchException; |
25 | 24 | import org.elasticsearch.ExceptionsHelper; |
26 | 25 | import org.elasticsearch.Version; |
|
101 | 100 | import java.util.List; |
102 | 101 | import java.util.Locale; |
103 | 102 | import java.util.Map; |
| 103 | +import java.util.concurrent.ExecutionException; |
104 | 104 | import java.util.concurrent.TimeUnit; |
105 | 105 | import java.util.function.Consumer; |
106 | 106 | import java.util.function.Predicate; |
|
140 | 140 | import static org.hamcrest.Matchers.nullValue; |
141 | 141 |
|
142 | 142 | // The tests in here do a lot of state updates and other writes to disk and are slowed down too much by WindowsFS |
143 | | -@LuceneTestCase.SuppressFileSystems(value = "WindowsFS") |
144 | 143 | public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCase { |
145 | 144 |
|
146 | 145 | @Override |
@@ -423,8 +422,7 @@ public void testEmptySnapshot() throws Exception { |
423 | 422 | createRepository("test-repo", "fs"); |
424 | 423 |
|
425 | 424 | logger.info("--> snapshot"); |
426 | | - CreateSnapshotResponse createSnapshotResponse = client().admin().cluster().prepareCreateSnapshot("test-repo", "test-snap") |
427 | | - .setWaitForCompletion(true).get(); |
| 425 | + CreateSnapshotResponse createSnapshotResponse = startFullSnapshot("test-repo", "test-snap").get(); |
428 | 426 | assertThat(createSnapshotResponse.getSnapshotInfo().totalShards(), equalTo(0)); |
429 | 427 | assertThat(createSnapshotResponse.getSnapshotInfo().successfulShards(), equalTo(0)); |
430 | 428 |
|
@@ -1186,8 +1184,7 @@ public void testDeleteSnapshot() throws Exception { |
1186 | 1184 |
|
1187 | 1185 | assertDocCount("test-idx", 10L * numberOfSnapshots); |
1188 | 1186 |
|
1189 | | - logger.info("--> delete the last snapshot"); |
1190 | | - client.admin().cluster().prepareDeleteSnapshot("test-repo", lastSnapshot).get(); |
| 1187 | + startDeleteSnapshot("test-repo", lastSnapshot).get(); |
1191 | 1188 | logger.info("--> make sure that number of files is back to what it was when the first snapshot was made"); |
1192 | 1189 | assertFileCount(repo, numberOfFiles[0]); |
1193 | 1190 | } |
@@ -1318,8 +1315,7 @@ public void testDeleteSnapshotWithMissingIndexAndShardMetadata() throws Exceptio |
1318 | 1315 | Files.delete(shardZero.resolve("snap-" + snapshotInfo.snapshotId().getUUID() + ".dat")); |
1319 | 1316 | } |
1320 | 1317 |
|
1321 | | - logger.info("--> delete snapshot"); |
1322 | | - client.admin().cluster().prepareDeleteSnapshot("test-repo", "test-snap-1").get(); |
| 1318 | + startDeleteSnapshot("test-repo", "test-snap-1").get(); |
1323 | 1319 |
|
1324 | 1320 | logger.info("--> make sure snapshot doesn't exist"); |
1325 | 1321 |
|
@@ -1354,8 +1350,7 @@ public void testDeleteSnapshotWithMissingMetadata() throws Exception { |
1354 | 1350 | Path metadata = repo.resolve("meta-" + createSnapshotResponse.getSnapshotInfo().snapshotId().getUUID() + ".dat"); |
1355 | 1351 | Files.delete(metadata); |
1356 | 1352 |
|
1357 | | - logger.info("--> delete snapshot"); |
1358 | | - client.admin().cluster().prepareDeleteSnapshot("test-repo", "test-snap-1").get(); |
| 1353 | + startDeleteSnapshot("test-repo", "test-snap-1").get(); |
1359 | 1354 |
|
1360 | 1355 | logger.info("--> make sure snapshot doesn't exist"); |
1361 | 1356 | expectThrows(SnapshotMissingException.class, () -> client.admin().cluster().prepareGetSnapshots("test-repo") |
@@ -1388,8 +1383,7 @@ public void testDeleteSnapshotWithCorruptedSnapshotFile() throws Exception { |
1388 | 1383 | try(SeekableByteChannel outChan = Files.newByteChannel(snapshotPath, StandardOpenOption.WRITE)) { |
1389 | 1384 | outChan.truncate(randomInt(10)); |
1390 | 1385 | } |
1391 | | - logger.info("--> delete snapshot"); |
1392 | | - client.admin().cluster().prepareDeleteSnapshot("test-repo", "test-snap-1").get(); |
| 1386 | + startDeleteSnapshot("test-repo", "test-snap-1").get(); |
1393 | 1387 |
|
1394 | 1388 | logger.info("--> make sure snapshot doesn't exist"); |
1395 | 1389 | expectThrows(SnapshotMissingException.class, |
@@ -1442,7 +1436,7 @@ public void testDeleteSnapshotWithCorruptedGlobalState() throws Exception { |
1442 | 1436 | assertThat(snapshotStatusResponse.getSnapshots(), hasSize(1)); |
1443 | 1437 | assertThat(snapshotStatusResponse.getSnapshots().get(0).getSnapshot().getSnapshotId().getName(), equalTo("test-snap")); |
1444 | 1438 |
|
1445 | | - assertAcked(client().admin().cluster().prepareDeleteSnapshot("test-repo", "test-snap").get()); |
| 1439 | + assertAcked(startDeleteSnapshot("test-repo", "test-snap").get()); |
1446 | 1440 | expectThrows(SnapshotMissingException.class, () -> client().admin().cluster() |
1447 | 1441 | .prepareGetSnapshots("test-repo").addSnapshots("test-snap").get().getSnapshots("test-repo")); |
1448 | 1442 | assertRequestBuilderThrows(client().admin().cluster().prepareSnapshotStatus("test-repo").addSnapshots("test-snap"), |
@@ -2637,7 +2631,7 @@ public void testRestoreSnapshotWithCorruptedIndexMetadata() throws Exception { |
2637 | 2631 | } |
2638 | 2632 | } |
2639 | 2633 |
|
2640 | | - assertAcked(client().admin().cluster().prepareDeleteSnapshot("test-repo", snapshotInfo.snapshotId().getName()).get()); |
| 2634 | + assertAcked(startDeleteSnapshot("test-repo", snapshotInfo.snapshotId().getName()).get()); |
2641 | 2635 | } |
2642 | 2636 |
|
2643 | 2637 | /** |
@@ -2756,8 +2750,7 @@ public void testCannotCreateSnapshotsWithSameName() throws Exception { |
2756 | 2750 | assertThat(e.getMessage(), containsString("snapshot with the same name already exists")); |
2757 | 2751 | } |
2758 | 2752 |
|
2759 | | - logger.info("--> delete the first snapshot"); |
2760 | | - client.admin().cluster().prepareDeleteSnapshot(repositoryName, snapshotName).get(); |
| 2753 | + startDeleteSnapshot(repositoryName, snapshotName).get(); |
2761 | 2754 |
|
2762 | 2755 | logger.info("--> try creating a snapshot with the same name, now it should work because the first one was deleted"); |
2763 | 2756 | createSnapshotResponse = client.admin() |
@@ -2816,7 +2809,7 @@ public void testGetSnapshotsRequest() throws Exception { |
2816 | 2809 | assertEquals(1, getSnapshotsResponse.getSnapshots("test-repo").size()); |
2817 | 2810 | assertEquals("snap-on-empty-repo", getSnapshotsResponse.getSnapshots("test-repo").get(0).snapshotId().getName()); |
2818 | 2811 | unblockNode(repositoryName, initialBlockedNode); // unblock node |
2819 | | - client.admin().cluster().prepareDeleteSnapshot(repositoryName, "snap-on-empty-repo").get(); |
| 2812 | + startDeleteSnapshot(repositoryName, "snap-on-empty-repo").get(); |
2820 | 2813 |
|
2821 | 2814 | final int numSnapshots = randomIntBetween(1, 3) + 1; |
2822 | 2815 | logger.info("--> take {} snapshot(s)", numSnapshots - 1); |
@@ -3319,7 +3312,7 @@ public void testRestoreIncreasesPrimaryTerms() { |
3319 | 3312 | assertThat(restoredIndexMetadata.getSettings().get(IndexMetadata.SETTING_HISTORY_UUID), notNullValue()); |
3320 | 3313 | } |
3321 | 3314 |
|
3322 | | - public void testSnapshotDifferentIndicesBySameName() throws InterruptedException { |
| 3315 | + public void testSnapshotDifferentIndicesBySameName() throws InterruptedException, ExecutionException { |
3323 | 3316 | String indexName = "testindex"; |
3324 | 3317 | String repoName = "test-repo"; |
3325 | 3318 | Path absolutePath = randomRepoPath().toAbsolutePath(); |
@@ -3376,8 +3369,7 @@ public void testSnapshotDifferentIndicesBySameName() throws InterruptedException |
3376 | 3369 | snapshotToRestore = "snap-1"; |
3377 | 3370 | expectedCount = docCount; |
3378 | 3371 | } |
3379 | | - logger.info("--> deleting snapshot [{}]", snapshotToDelete); |
3380 | | - assertAcked(client().admin().cluster().prepareDeleteSnapshot(repoName, snapshotToDelete).get()); |
| 3372 | + assertAcked(startDeleteSnapshot(repoName, snapshotToDelete).get()); |
3381 | 3373 | logger.info("--> restoring snapshot [{}]", snapshotToRestore); |
3382 | 3374 | client().admin().cluster().prepareRestoreSnapshot(repoName, snapshotToRestore).setIndices(indexName).setRenamePattern(indexName) |
3383 | 3375 | .setRenameReplacement("restored-3").setWaitForCompletion(true).get(); |
|
0 commit comments