Skip to content

Commit

Permalink
[Test] Account for auto-repairing for shard gen file (elastic#112778)
Browse files Browse the repository at this point in the history
Since elastic#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: elastic#112769
(cherry picked from commit e1f7814)

# Conflicts:
#	muted-tests.yml
  • Loading branch information
ywangd committed Sep 12, 2024
1 parent f217322 commit 801f306
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -344,16 +344,23 @@ public void testCorruption() throws IOException {
? 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");
Expand Down

0 comments on commit 801f306

Please sign in to comment.