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.
This commit is contained in:
parent
01d8bb8cfa
commit
5662281562
|
@ -93,7 +93,6 @@ import org.elasticsearch.script.StoredScriptsIT;
|
||||||
import org.elasticsearch.snapshots.mockstore.MockRepository;
|
import org.elasticsearch.snapshots.mockstore.MockRepository;
|
||||||
import org.elasticsearch.threadpool.ThreadPool;
|
import org.elasticsearch.threadpool.ThreadPool;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.channels.SeekableByteChannel;
|
import java.nio.channels.SeekableByteChannel;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
@ -1523,20 +1522,14 @@ public class SharedClusterSnapshotRestoreIT extends AbstractSnapshotIntegTestCas
|
||||||
.setWaitForCompletion(true).setIndices("test-idx-*").get();
|
.setWaitForCompletion(true).setIndices("test-idx-*").get();
|
||||||
|
|
||||||
logger.info("--> deleting shard level index file");
|
logger.info("--> deleting shard level index file");
|
||||||
try (Stream<Path> files = Files.list(repo.resolve("indices"))) {
|
final Path indicesPath = repo.resolve("indices");
|
||||||
files.forEach(indexPath -> {
|
for (IndexId indexId : getRepositoryData("test-repo").getIndices().values()) {
|
||||||
try {
|
final Path shardGen;
|
||||||
final Path shardGen;
|
try (Stream<Path> shardFiles = Files.list(indicesPath.resolve(indexId.getId()).resolve("0"))) {
|
||||||
try (Stream<Path> shardFiles = Files.list(indexPath.resolve("0"))) {
|
shardGen = shardFiles.filter(file -> file.getFileName().toString().startsWith(BlobStoreRepository.INDEX_FILE_PREFIX))
|
||||||
shardGen = shardFiles
|
.findFirst().orElseThrow(() -> new AssertionError("Failed to find shard index blob"));
|
||||||
.filter(file -> file.getFileName().toString().startsWith(BlobStoreRepository.INDEX_FILE_PREFIX))
|
}
|
||||||
.findFirst().orElseThrow(() -> new AssertionError("Failed to find shard index blob"));
|
Files.delete(shardGen);
|
||||||
}
|
|
||||||
Files.delete(shardGen);
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException("Failed to delete expected file", e);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info("--> creating another snapshot");
|
logger.info("--> creating another snapshot");
|
||||||
|
|
Loading…
Reference in New Issue