|
1 | 1 | package e2e |
2 | 2 |
|
3 | 3 | import ( |
| 4 | + "context" |
4 | 5 | "fmt" |
5 | 6 | "time" |
6 | 7 |
|
| 8 | + "path/filepath" |
| 9 | + "strconv" |
| 10 | + |
7 | 11 | finv1 "github.com/cybozu-go/fin/api/v1" |
8 | 12 | "github.com/cybozu-go/fin/internal/controller" |
9 | 13 | "github.com/cybozu-go/fin/test/utils" |
@@ -118,4 +122,34 @@ func deleteIncrementalBackupTestSuite() { |
118 | 122 | return nil |
119 | 123 | }, "10s", "1s").WithContext(ctx).Should(Succeed()) |
120 | 124 | }) |
| 125 | + |
| 126 | + It("should fail deletion job when checksum file is corrupted", func(ctx SpecContext) { |
| 127 | + // Arrange |
| 128 | + pod := CreatePodForBlockPVC(ctx, k8sClient, pvc) |
| 129 | + _ = WriteRandomDataToPVC(ctx, pod, devicePathInPodForPVC, 1024) |
| 130 | + |
| 131 | + fullBackup := CreateBackup(ctx, ctrlClient, rookNamespace, pvc, nodes[0]) |
| 132 | + |
| 133 | + incremental, err := NewFinBackup(rookNamespace, utils.GetUniqueName("test-finbackup-"), pvc, nodes[0]) |
| 134 | + incremental.Annotations = map[string]string{controller.AnnotationSkipVerify: "true"} |
| 135 | + Expect(err).NotTo(HaveOccurred()) |
| 136 | + Expect(CreateFinBackup(ctx, ctrlClient, incremental)).NotTo(HaveOccurred()) |
| 137 | + Expect(WaitForFinBackupStoredToNode(ctx, ctrlClient, incremental, 2*time.Minute)).NotTo(HaveOccurred()) |
| 138 | + Expect(ctrlClient.Get(ctx, client.ObjectKeyFromObject(incremental), incremental)).NotTo(HaveOccurred()) |
| 139 | + ExpectDiffChecksumExists(nodes[0], incremental, pvc) |
| 140 | + |
| 141 | + diffChecksumPath := filepath.Join("/fin", pvc.Namespace, pvc.Name, "diff", strconv.Itoa(*incremental.Status.SnapID), "part-0.csum") |
| 142 | + CorruptFileOnNode(nodes[0], diffChecksumPath) |
| 143 | + |
| 144 | + // Act |
| 145 | + Expect(DeleteFinBackup(ctx, ctrlClient, incremental)).NotTo(HaveOccurred()) |
| 146 | + |
| 147 | + // Assert |
| 148 | + Expect(WaitForFinBackupChecksumMismatch(ctx, ctrlClient, incremental, 2*time.Minute)).NotTo(HaveOccurred()) |
| 149 | + |
| 150 | + // Cleanup |
| 151 | + ForceDeleteFinBackup(context.Background(), ctrlClient, incremental) |
| 152 | + ForceDeleteFinBackup(context.Background(), ctrlClient, fullBackup) |
| 153 | + _ = DeletePod(ctx, k8sClient, pod) |
| 154 | + }) |
121 | 155 | } |
0 commit comments