Skip to content

Commit

Permalink
Fix ExtraFS Breaking SharedClusterSnapshotRestoreIT (#58026) (#58041)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
original-brownbear committed Jun 12, 2020
1 parent d53739d commit c5b49e5
Showing 1 changed file with 8 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@
import org.elasticsearch.snapshots.mockstore.MockRepository;
import org.elasticsearch.threadpool.ThreadPool;

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

logger.info("--> deleting shard level index file");
try (Stream<Path> files = Files.list(repo.resolve("indices"))) {
files.forEach(indexPath -> {
try {
final Path shardGen;
try (Stream<Path> shardFiles = Files.list(indexPath.resolve("0"))) {
shardGen = shardFiles
.filter(file -> file.getFileName().toString().startsWith(BlobStoreRepository.INDEX_FILE_PREFIX))
.findFirst().orElseThrow(() -> new AssertionError("Failed to find shard index blob"));
}
Files.delete(shardGen);
} catch (IOException e) {
throw new RuntimeException("Failed to delete expected file", e);
}
});
final Path indicesPath = repo.resolve("indices");
for (IndexId indexId : getRepositoryData("test-repo").getIndices().values()) {
final Path shardGen;
try (Stream<Path> shardFiles = Files.list(indicesPath.resolve(indexId.getId()).resolve("0"))) {
shardGen = shardFiles.filter(file -> file.getFileName().toString().startsWith(BlobStoreRepository.INDEX_FILE_PREFIX))
.findFirst().orElseThrow(() -> new AssertionError("Failed to find shard index blob"));
}
Files.delete(shardGen);
}

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

0 comments on commit c5b49e5

Please sign in to comment.