Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
cupnes committed Mar 18, 2024
1 parent 7fe3ba5 commit 3f8c096
Showing 1 changed file with 27 additions and 16 deletions.
43 changes: 27 additions & 16 deletions e2e/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"testing"
"time"

backupv1 "github.com/cybozu-go/rbd-backup-system/api/v1"
"github.com/cybozu-go/rbd-backup-system/internal/controller"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand Down Expand Up @@ -284,6 +285,32 @@ var _ = Describe("rbd backup system", func() {
}).Should(Succeed())
})

It("should not delete RBDPVCBackup resource when delete backup target PVC", func() {
By("Deleting backup target PVC")
_, _, err := kubectl("-n", namespace, "delete", "pvc", pvcName2)
Expect(err).NotTo(HaveOccurred())

By("Checking backup target PVC deletion")
Eventually(func() error {
stdout, stderr, err := kubectl("-n", namespace, "get", "pvc", pvcName2)
if err != nil {
if strings.Contains(string(stderr), kubectlIsNotFoundMessage) {
return nil
}
return fmt.Errorf("get pvc %s failed. stderr: %s, err: %w", pvcName2, string(stderr), err)
}
return fmt.Errorf("PVC %s still exists. stdout: %s", pvcName2, stdout)
}).Should(Succeed())

By("Checking that the status.conditions of the RBDPVCBackup resource remain \"Bound\"")
stdout, _, err := kubectl("-n", namespace, "get", "rbdpvcbackup", rbdPVCBackupName3, "-o", "json")
Expect(err).NotTo(HaveOccurred())
var backup backupv1.RBDPVCBackup
err = yaml.Unmarshal(stdout, &backup)
Expect(err).NotTo(HaveOccurred())
Expect(backup.Status.Conditions).To(Equal(backupv1.RBDPVCBackupConditionsBound))
})

It("should delete RBDPVCBackup resource", func() {
By("Delete RBDPVCBackup")
_, _, err := kubectl("-n", namespace, "delete", "rbdpvcbackup", rbdPVCBackupName, "--wait=false")
Expand Down Expand Up @@ -330,22 +357,6 @@ var _ = Describe("rbd backup system", func() {
})

It("should delete RBDPVCBackup resource when backup target PVC is missing", func() {
By("Deleting backup target PVC")
_, _, err := kubectl("-n", namespace, "delete", "pvc", pvcName2)
Expect(err).NotTo(HaveOccurred())

By("Checking backup target PVC deletion")
Eventually(func() error {
stdout, stderr, err := kubectl("-n", namespace, "get", "pvc", pvcName2)
if err != nil {
if strings.Contains(string(stderr), kubectlIsNotFoundMessage) {
return nil
}
return fmt.Errorf("get pvc %s failed. stderr: %s, err: %w", pvcName2, string(stderr), err)
}
return fmt.Errorf("PVC %s still exists. stdout: %s", pvcName2, stdout)
}).Should(Succeed())

By("Deleting RBDPVCBackup resource")
_, _, err = kubectl("-n", namespace, "delete", "rbdpvcbackup", rbdPVCBackupName3)

Check failure on line 361 in e2e/suite_test.go

View workflow job for this annotation

GitHub Actions / build

undefined: err
Expect(err).NotTo(HaveOccurred())

Check failure on line 362 in e2e/suite_test.go

View workflow job for this annotation

GitHub Actions / build

undefined: err (typecheck)
Expand Down

0 comments on commit 3f8c096

Please sign in to comment.