From 801f306681b477212b6b24f3e5f0e2cad6323f7f Mon Sep 17 00:00:00 2001 From: Yang Wang Date: Thu, 12 Sep 2024 17:19:06 +1000 Subject: [PATCH] [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 (cherry picked from commit e1f78141de1bd9721f035280d897b5632b8d19be) # Conflicts: # muted-tests.yml --- .../integrity/RepositoryVerifyIntegrityIT.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/x-pack/plugin/snapshot-repo-test-kit/src/internalClusterTest/java/org/elasticsearch/repositories/blobstore/testkit/integrity/RepositoryVerifyIntegrityIT.java b/x-pack/plugin/snapshot-repo-test-kit/src/internalClusterTest/java/org/elasticsearch/repositories/blobstore/testkit/integrity/RepositoryVerifyIntegrityIT.java index 4b0e0fdbb0955..5725b065aeb06 100644 --- a/x-pack/plugin/snapshot-repo-test-kit/src/internalClusterTest/java/org/elasticsearch/repositories/blobstore/testkit/integrity/RepositoryVerifyIntegrityIT.java +++ b/x-pack/plugin/snapshot-repo-test-kit/src/internalClusterTest/java/org/elasticsearch/repositories/blobstore/testkit/integrity/RepositoryVerifyIntegrityIT.java @@ -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");