Skip to content

Commit

Permalink
test/e2e: multik8s: test when role is changed from primary to standal…
Browse files Browse the repository at this point in the history
…one during full backup

Signed-off-by: Ryotaro Banno <ryotaro.banno@gmail.com>
  • Loading branch information
ushitora-anqou committed Jan 16, 2025
1 parent ec62392 commit d001338
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
39 changes: 39 additions & 0 deletions test/e2e/multik8s/changetoprimary/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,45 @@ var _ = Describe("Mantle", func() {
})

func changePrimaryToStandaloneTemporarily() {
Describe("change role from primary to standalone during full backup", func() {
It("should cancel a full backup if the role is changed from primary to standalone", func(ctx SpecContext) {
namespace := util.GetUniqueName("ns-")
pvcName := util.GetUniqueName("pvc-")
backupName := util.GetUniqueName("mb-")
restoreName := util.GetUniqueName("mr-")

SetupEnvironment(namespace)

PauseObjectStorage(ctx)
defer ResumeObjectStorage(ctx)

By("should create a MantleBackup resource")
CreatePVC(ctx, PrimaryK8sCluster, namespace, pvcName)
writtenDataHash := WriteRandomDataToPV(ctx, PrimaryK8sCluster, namespace, pvcName)
CreateMantleBackup(PrimaryK8sCluster, namespace, pvcName, backupName)
WaitMantleBackupReadyToUse(PrimaryK8sCluster, namespace, backupName)

By("changing the primary mantle to standalone")
err := ChangeClusterRole(PrimaryK8sCluster, controller.RoleStandalone)
Expect(err).NotTo(HaveOccurred())

By("checking the MantleBackup in the primary K8s cluster remains")
Consistently(ctx, func(g Gomega) {
_, err := GetMB(PrimaryK8sCluster, namespace, backupName)
g.Expect(err).NotTo(HaveOccurred())
}, "10s", "1s").Should(Succeed())

EnsureCorrectRestoration(PrimaryK8sCluster, ctx, namespace, backupName, restoreName, writtenDataHash)

By("changing the standalone mantle to primary")
err = ChangeClusterRole(PrimaryK8sCluster, controller.RolePrimary)
Expect(err).NotTo(HaveOccurred())

ResumeObjectStorage(ctx)
WaitMantleBackupSynced(namespace, backupName)
})
})

Describe("change to primary", func() {
var (
namespace string
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/multik8s/testutil/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ func WaitMantleBackupReadyToUse(cluster int, namespace, backupName string) {

func WaitMantleBackupSynced(namespace, backupName string) {
GinkgoHelper()
By("checking MantleBackup's SyncedToRemote status")
By(fmt.Sprintf("checking MantleBackup's SyncedToRemote status: %s/%s", namespace, backupName))
Eventually(func() error {
mb, err := GetMB(PrimaryK8sCluster, namespace, backupName)
if err != nil {
Expand Down

0 comments on commit d001338

Please # to comment.