[Test] Account for auto-repairing for shard gen file (#112778)

Since #112337, missing shard gen files are automatically reconstructed
based on the existing shard snapshot files. If the list of shard
snapshot files is complete, it means the repository is effectively not
corrupted. This PR updates the test to account for this situation.

Resolves: #112769
This commit is contained in:
Yang Wang 2024-09-12 17:19:06 +10:00 committed by GitHub
parent e22bef6c4a
commit e1f78141de
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 6 deletions

View File

@ -208,9 +208,6 @@ tests:
- class: org.elasticsearch.smoketest.DocsClientYamlTestSuiteIT
method: test {yaml=reference/cluster/stats/line_1450}
issue: https://github.com/elastic/elasticsearch/issues/112732
- class: org.elasticsearch.repositories.blobstore.testkit.integrity.RepositoryVerifyIntegrityIT
method: testCorruption
issue: https://github.com/elastic/elasticsearch/issues/112769
- class: org.elasticsearch.script.StatsSummaryTests
method: testEqualsAndHashCode
issue: https://github.com/elastic/elasticsearch/issues/112439

View File

@ -344,16 +344,23 @@ public class RepositoryVerifyIntegrityIT extends AbstractSnapshotIntegTestCase {
? equalTo(testContext.indexNames().size())
: lessThan(testContext.indexNames().size())
);
assertThat(anomalies, not(empty()));
// Missing shard generation file is automatically repaired based on the shard snapshot files.
// See also BlobStoreRepository#buildBlobStoreIndexShardSnapshots
final boolean deletedShardGen = corruptedFileType == RepositoryFileType.SHARD_GENERATION && Files.exists(corruptedFile) == false;
assertThat(anomalies, deletedShardGen ? empty() : not(empty()));
assertThat(responseObjectPath.evaluate("results.total_anomalies"), greaterThanOrEqualTo(anomalies.size()));
assertEquals("fail", responseObjectPath.evaluate("results.result"));
assertEquals(deletedShardGen ? "pass" : "fail", responseObjectPath.evaluate("results.result"));
// remove permitted/expected anomalies to verify that no unexpected ones were seen
switch (corruptedFileType) {
case SNAPSHOT_INFO -> anomalies.remove("failed to load snapshot info");
case GLOBAL_METADATA -> anomalies.remove("failed to load global metadata");
case INDEX_METADATA -> anomalies.remove("failed to load index metadata");
case SHARD_GENERATION -> anomalies.remove("failed to load shard generation");
case SHARD_GENERATION -> {
if (deletedShardGen == false) {
anomalies.remove("failed to load shard generation");
}
}
case SHARD_SNAPSHOT_INFO -> anomalies.remove("failed to load shard snapshot");
case SHARD_DATA -> {
anomalies.remove("missing blob");