Skip to content

Commit

Permalink
e2e: singlek8s: make sure no resources necessary only for primary/sec…
Browse files Browse the repository at this point in the history
…ondary mantle-controller are created

Signed-off-by: Ryotaro Banno <[email protected]>
  • Loading branch information
ushitora-anqou committed Dec 23, 2024
1 parent b086293 commit c1b1aed
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions test/e2e/singlek8s/backup_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package singlek8s

import (
"encoding/json"
"errors"
"fmt"
"strings"
Expand All @@ -9,6 +10,8 @@ import (
"github.com/cybozu-go/mantle/test/util"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
batchv1 "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1"
)

const (
Expand Down Expand Up @@ -165,6 +168,42 @@ func (test *backupTest) testCase1() {
}).Should(Succeed())
})

It("should not create any resources necessary only for primary or secondary mantle controller", func() {
// Check that export and upload Jobs are not created.
stdout, _, err := kubectl("-n", cephCluster1Namespace, "get", "job", "-o", "json")
Expect(err).NotTo(HaveOccurred())
var jobs batchv1.JobList
err = json.Unmarshal(stdout, &jobs)
Expect(err).NotTo(HaveOccurred())
for _, job := range jobs.Items {
Expect(strings.HasPrefix(job.GetName(), "mantle-export-")).To(BeFalse())
Expect(strings.HasPrefix(job.GetName(), "mantle-upload-")).To(BeFalse())
Expect(strings.HasPrefix(job.GetName(), "mantle-import-")).To(BeFalse())
Expect(strings.HasPrefix(job.GetName(), "mantle-discard-")).To(BeFalse())
}

// Check that export and discard PVC are not created.
stdout, _, err = kubectl("-n", cephCluster1Namespace, "get", "pvc", "-o", "json")
Expect(err).NotTo(HaveOccurred())
var pvcs corev1.PersistentVolumeClaimList
err = json.Unmarshal(stdout, &pvcs)
Expect(err).NotTo(HaveOccurred())
for _, pvc := range pvcs.Items {
Expect(strings.HasPrefix(pvc.GetName(), "mantle-export-")).To(BeFalse())
Expect(strings.HasPrefix(pvc.GetName(), "mantle-discard-")).To(BeFalse())
}

// Check that discard PV is not created.
stdout, _, err = kubectl("-n", cephCluster1Namespace, "get", "pv", "-o", "json")
Expect(err).NotTo(HaveOccurred())
var pvs corev1.PersistentVolumeList
err = json.Unmarshal(stdout, &pvs)
Expect(err).NotTo(HaveOccurred())
for _, pv := range pvs.Items {
Expect(strings.HasPrefix(pv.GetName(), "mantle-discard-")).To(BeFalse())
}
})

It("should not delete MantleBackup resource when delete backup target PVC", func() {
By("Deleting backup target PVC")
_, _, err := kubectl("-n", test.tenantNamespace, "delete", "pvc", test.pvcName2)
Expand Down

0 comments on commit c1b1aed

Please sign in to comment.