Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance Shard Level Metdata check in BlobStoreTestUtil (#75737) #76561

Merged
merged 1 commit into from
Aug 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public BlobStoreIndexShardSnapshot loadShardSnapshot(BlobContainer shardContaine

@Override
public BlobStoreIndexShardSnapshots getBlobStoreIndexShardSnapshots(IndexId indexId,
ShardId shardId,
int shardId,
ShardGeneration shardGen) throws IOException {
if (failLoadShardSnapshots) {
throw new FileNotFoundException("Failed to get blob store index shard snapshots");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,8 @@ public void testRepairBrokenShardGenerations() throws Exception {
* Tests that a shard snapshot with a corrupted shard index file can still be used for restore and incremental snapshots.
*/
public void testSnapshotWithCorruptedShardIndexFile() throws Exception {
disableRepoConsistencyCheck("This test intentionally corrupts the repository contents");

final Client client = client();
final Path repo = randomRepoPath();
final String indexName = "test-idx";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ private String getIndexMetadataId() throws IOException {
private BlobStoreIndexShardSnapshots getBlobStoreIndexShardSnapshots() throws IOException {
BlobStoreRepository blobStoreRepository = (BlobStoreRepository) repository;
final ShardGeneration shardGen = repositoryData.shardGenerations().getShardGen(indexId, shardId.getId());
return blobStoreRepository.getBlobStoreIndexShardSnapshots(indexId, shardId, shardGen);
return blobStoreRepository.getBlobStoreIndexShardSnapshots(indexId, shardId.getId(), shardGen);
}

private ShardSnapshotInfo createIndexShardSnapshotInfo(String indexMetadataId, SnapshotFiles snapshotFiles) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3329,13 +3329,9 @@ public BlobStoreIndexShardSnapshot loadShardSnapshot(BlobContainer shardContaine
* Loads all available snapshots in the repository using the given {@code generation} for a shard. When {@code shardGen}
* is null it tries to load it using the BwC mode, listing the available index- blobs in the shard container.
*/
public BlobStoreIndexShardSnapshots getBlobStoreIndexShardSnapshots(
IndexId indexId,
ShardId shardId,
@Nullable ShardGeneration shardGen
) throws IOException {
final int shard = shardId.getId();
final BlobContainer shardContainer = shardContainer(indexId, shard);
public BlobStoreIndexShardSnapshots getBlobStoreIndexShardSnapshots(IndexId indexId, int shardId, @Nullable ShardGeneration shardGen)
throws IOException {
final BlobContainer shardContainer = shardContainer(indexId, shardId);

Set<String> blobs = Collections.emptySet();
if (shardGen == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.index.snapshots.blobstore.BlobStoreIndexShardSnapshots;
import org.elasticsearch.repositories.GetSnapshotInfoContext;
import org.elasticsearch.repositories.IndexId;
import org.elasticsearch.repositories.RepositoryData;
Expand Down Expand Up @@ -305,6 +306,10 @@ private static void assertSnapshotInfosConsistency(BlobStoreRepository repositor
hasKey(String.format(Locale.ROOT, BlobStoreRepository.SNAPSHOT_NAME_FORMAT, snapshotId.getUUID())));
assertThat(shardPathContents.keySet().stream()
.filter(name -> name.startsWith(BlobStoreRepository.INDEX_FILE_PREFIX)).count(), lessThanOrEqualTo(2L));
final BlobStoreIndexShardSnapshots blobStoreIndexShardSnapshots = repository.getBlobStoreIndexShardSnapshots(
indexId, shardId, repositoryData.shardGenerations().getShardGen(indexId, shardId));
assertTrue(blobStoreIndexShardSnapshots.snapshots().stream()
.anyMatch(snapshotFiles -> snapshotFiles.snapshot().equals(snapshotId.getName())));
}
}
}
Expand Down