Skip to content

Commit c5b49e5

Browse files
Fix ExtraFS Breaking SharedClusterSnapshotRestoreIT (#58026) (#58041)
If `ExtraFS` decides to put `extra0/0` into the indices folder then the previous logic in this test would have interpreted the `0` as shard `0` of index `extra0` and fail to list its contents (since it's a file and not an actual shard directory). => simplified the logic to use actually referenced `IndexId` for iterating over indices instead.
1 parent d53739d commit c5b49e5

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

server/src/internalClusterTest/java/org/elasticsearch/snapshots/SharedClusterSnapshotRestoreIT.java

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@
9494
import org.elasticsearch.snapshots.mockstore.MockRepository;
9595
import org.elasticsearch.threadpool.ThreadPool;
9696

97-
import java.io.IOException;
9897
import java.nio.channels.SeekableByteChannel;
9998
import java.nio.file.Files;
10099
import java.nio.file.Path;
@@ -1527,20 +1526,14 @@ public void testSnapshotWithMissingShardLevelIndexFile() throws Exception {
15271526
.setWaitForCompletion(true).setIndices("test-idx-*").get();
15281527

15291528
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);
15441537
}
15451538

15461539
logger.info("--> creating another snapshot");

0 commit comments

Comments
 (0)