|
94 | 94 | import org.elasticsearch.snapshots.mockstore.MockRepository;
|
95 | 95 | import org.elasticsearch.threadpool.ThreadPool;
|
96 | 96 |
|
97 |
| -import java.io.IOException; |
98 | 97 | import java.nio.channels.SeekableByteChannel;
|
99 | 98 | import java.nio.file.Files;
|
100 | 99 | import java.nio.file.Path;
|
@@ -1527,20 +1526,14 @@ public void testSnapshotWithMissingShardLevelIndexFile() throws Exception {
|
1527 | 1526 | .setWaitForCompletion(true).setIndices("test-idx-*").get();
|
1528 | 1527 |
|
1529 | 1528 | logger.info("--> deleting shard level index file");
|
1530 |
| - try (Stream<Path> files = Files.list(repo.resolve("indices"))) { |
1531 |
| - files.forEach(indexPath -> { |
1532 |
| - try { |
1533 |
| - final Path shardGen; |
1534 |
| - try (Stream<Path> shardFiles = Files.list(indexPath.resolve("0"))) { |
1535 |
| - shardGen = shardFiles |
1536 |
| - .filter(file -> file.getFileName().toString().startsWith(BlobStoreRepository.INDEX_FILE_PREFIX)) |
1537 |
| - .findFirst().orElseThrow(() -> new AssertionError("Failed to find shard index blob")); |
1538 |
| - } |
1539 |
| - Files.delete(shardGen); |
1540 |
| - } catch (IOException e) { |
1541 |
| - throw new RuntimeException("Failed to delete expected file", e); |
1542 |
| - } |
1543 |
| - }); |
| 1529 | + final Path indicesPath = repo.resolve("indices"); |
| 1530 | + for (IndexId indexId : getRepositoryData("test-repo").getIndices().values()) { |
| 1531 | + final Path shardGen; |
| 1532 | + try (Stream<Path> shardFiles = Files.list(indicesPath.resolve(indexId.getId()).resolve("0"))) { |
| 1533 | + shardGen = shardFiles.filter(file -> file.getFileName().toString().startsWith(BlobStoreRepository.INDEX_FILE_PREFIX)) |
| 1534 | + .findFirst().orElseThrow(() -> new AssertionError("Failed to find shard index blob")); |
| 1535 | + } |
| 1536 | + Files.delete(shardGen); |
1544 | 1537 | }
|
1545 | 1538 |
|
1546 | 1539 | logger.info("--> creating another snapshot");
|
|
0 commit comments