Skip to content

Commit 4f17b4a

Browse files
authored
[Test] Account for auto-repairing for shard gen file (#112778) (#112788)
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 (cherry picked from commit e1f7814) # Conflicts: # muted-tests.yml
1 parent f217322 commit 4f17b4a

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

x-pack/plugin/snapshot-repo-test-kit/src/internalClusterTest/java/org/elasticsearch/repositories/blobstore/testkit/integrity/RepositoryVerifyIntegrityIT.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,16 +344,23 @@ public void testCorruption() throws IOException {
344344
? equalTo(testContext.indexNames().size())
345345
: lessThan(testContext.indexNames().size())
346346
);
347-
assertThat(anomalies, not(empty()));
347+
// Missing shard generation file is automatically repaired based on the shard snapshot files.
348+
// See also BlobStoreRepository#buildBlobStoreIndexShardSnapshots
349+
final boolean deletedShardGen = corruptedFileType == RepositoryFileType.SHARD_GENERATION && Files.exists(corruptedFile) == false;
350+
assertThat(anomalies, deletedShardGen ? empty() : not(empty()));
348351
assertThat(responseObjectPath.evaluate("results.total_anomalies"), greaterThanOrEqualTo(anomalies.size()));
349-
assertEquals("fail", responseObjectPath.evaluate("results.result"));
352+
assertEquals(deletedShardGen ? "pass" : "fail", responseObjectPath.evaluate("results.result"));
350353

351354
// remove permitted/expected anomalies to verify that no unexpected ones were seen
352355
switch (corruptedFileType) {
353356
case SNAPSHOT_INFO -> anomalies.remove("failed to load snapshot info");
354357
case GLOBAL_METADATA -> anomalies.remove("failed to load global metadata");
355358
case INDEX_METADATA -> anomalies.remove("failed to load index metadata");
356-
case SHARD_GENERATION -> anomalies.remove("failed to load shard generation");
359+
case SHARD_GENERATION -> {
360+
if (deletedShardGen == false) {
361+
anomalies.remove("failed to load shard generation");
362+
}
363+
}
357364
case SHARD_SNAPSHOT_INFO -> anomalies.remove("failed to load shard snapshot");
358365
case SHARD_DATA -> {
359366
anomalies.remove("missing blob");

0 commit comments

Comments
 (0)