Skip to content

Commit 4eb4e4f

Browse files
committed
wip
Signed-off-by: Kohya Shiozaki <[email protected]>
1 parent abf859c commit 4eb4e4f

File tree

3 files changed

+36
-2
lines changed

3 files changed

+36
-2
lines changed

test/e2e/full_backup_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package e2e
22

33
import (
4+
"path/filepath"
45
"time"
56

67
finv1 "github.com/cybozu-go/fin/api/v1"
@@ -51,6 +52,11 @@ func fullBackupTestSuite() {
5152
It("should create full backup", func(ctx SpecContext) {
5253
finbackup = CreateBackup(ctx, ctrlClient, rookNamespace, pvc, nodes[0])
5354

55+
By("verifying checksum file is created")
56+
rawChecksumPath := filepath.Join("/fin", pvc.Namespace, pvc.Name, "raw.img.csum")
57+
_, stderr, err := minikubeSSH(nodes[0], nil, "test", "-f", rawChecksumPath)
58+
Expect(err).NotTo(HaveOccurred(), "raw.img.csum should exist. stderr: "+string(stderr))
59+
5460
VerifyRawImage(pvc, nodes[0], writtenData)
5561
})
5662

@@ -205,6 +211,19 @@ func fullBackupTestSuite() {
205211
Expect(err).NotTo(HaveOccurred())
206212
}
207213

214+
By("deleting the backup and verifying checksum file is also removed")
215+
if finbackup != nil {
216+
err = DeleteFinBackup(ctx, ctrlClient, finbackup)
217+
Expect(err).NotTo(HaveOccurred())
218+
err = WaitForFinBackupDeletion(ctx, ctrlClient, finbackup, 2*time.Minute)
219+
Expect(err).NotTo(HaveOccurred())
220+
221+
By("verifying checksum file is deleted")
222+
rawChecksumPath := filepath.Join("/fin", pvc.Namespace, pvc.Name, "raw.img.csum")
223+
_, _, err := minikubeSSH(nodes[0], nil, "test", "!", "-e", rawChecksumPath)
224+
Expect(err).NotTo(HaveOccurred(), "raw.img.csum should be deleted")
225+
}
226+
208227
By("deleting the pod to write data to the PVC")
209228
err = DeletePod(ctx, k8sClient, podForBackupTargetPVC)
210229
Expect(err).NotTo(HaveOccurred())

test/e2e/incremental_test.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ func incrementalBackupTestSuite() {
106106
Expect(err).NotTo(HaveOccurred(), "stderr: "+string(stderr))
107107
Expect(rawImageData).To(Equal(dataOnFullBackup), "Data in raw.img does not match the expected data")
108108

109+
By("verifying the existence of checksum files")
110+
rawChecksumPath := filepath.Join(volumePath, "raw.img.csum")
111+
_, stderr, err = minikubeSSH(nodes[0], nil, "test", "-f", rawChecksumPath)
112+
Expect(err).NotTo(HaveOccurred(), "raw.img.csum should exist. stderr: "+string(stderr))
113+
109114
By("verifying the existence of the diff file")
110115
Expect(ctrlClient.Get(ctx, client.ObjectKeyFromObject(finbackup2), finbackup2)).NotTo(HaveOccurred())
111116
_, stderr, err = minikubeSSH(nodes[0], nil,
@@ -226,14 +231,19 @@ func incrementalBackupTestSuite() {
226231
err = ctrlClient.Get(ctx, client.ObjectKeyFromObject(finbackup2), &dummy)
227232
Expect(err).NotTo(HaveOccurred())
228233

229-
By("verifying the non-existence of the diff file")
234+
By("verifying the non-existence of the diff file and its checksum")
230235
Expect(ctrlClient.Get(ctx, client.ObjectKeyFromObject(finbackup2), finbackup2)).NotTo(HaveOccurred())
231236
var stderr []byte
232237
_, stderr, err = minikubeSSH(nodes[0], nil,
233238
"ls", filepath.Join(volumePath, "diff", strconv.Itoa(*finbackup2.Status.SnapID), "part-0"))
234-
Expect(err).To(HaveOccurred(), "stderr: "+string(stderr), "diff file does not exist")
239+
Expect(err).To(HaveOccurred(), "stderr: "+string(stderr), "diff file should not exist")
235240
ExpectDiffChecksumNotExists(nodes[0], finbackup2, pvc)
236241

242+
By("verifying raw.img.csum still exists after merge")
243+
rawChecksumPath := filepath.Join(volumePath, "raw.img.csum")
244+
_, stderr, err = minikubeSSH(nodes[0], nil, "test", "-f", rawChecksumPath)
245+
Expect(err).NotTo(HaveOccurred(), "raw.img.csum should still exist after merge. stderr: "+string(stderr))
246+
237247
By("verifying the data in raw.img as incremental backup")
238248
var rawImageData []byte
239249
rawImageData, stderr, err = minikubeSSH(nodes[0], nil,

test/e2e/verification_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ func verificationTestSuite() {
5656
// Arrange
5757
finbackup := CreateBackup(ctx, ctrlClient, rookNamespace, pvc, nodes[0])
5858

59+
By("verifying checksum file is created")
60+
rawChecksumPath := filepath.Join("/fin", pvc.Namespace, pvc.Name, "raw.img.csum")
61+
_, stderr, err := minikubeSSH(nodes[0], nil, "test", "-f", rawChecksumPath)
62+
Expect(err).NotTo(HaveOccurred(), "raw.img.csum should exist. stderr: "+string(stderr))
63+
5964
// Act
6065
By("restoring from the backup")
6166
finrestore := CreateRestore(ctx, ctrlClient,

0 commit comments

Comments
 (0)