Skip to content

Commit

Permalink
Add e2e test for scale down and up
Browse files Browse the repository at this point in the history
Signed-off-by: hoyhbx <[email protected]>
  • Loading branch information
hoyhbx committed Mar 18, 2023
1 parent 28d1f69 commit cd732b9
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions test/e2e/scale_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,43 @@ var _ = Describe("Perform scale for cluster upgrade", func() {
Expect(zk_e2eutil.WaitForClusterToTerminate(logger, k8sClient, zk)).NotTo(HaveOccurred())
})
})

Context("Scale down and up", func() {
FIt("should wait for orphan PVCs cleaned before scaling up", func() {
defaultCluster := zk_e2eutil.NewDefaultCluster(testNamespace)
defaultCluster.WithDefaults()

defaultCluster.Status.Init()
defaultCluster.Spec.Persistence.VolumeReclaimPolicy = "Delete"

zk, err := zk_e2eutil.CreateCluster(logger, k8sClient, defaultCluster)

Expect(err).NotTo(HaveOccurred())

// A default zk cluster should have 3 pods
podSize := 3
Expect(zk_e2eutil.WaitForClusterToBecomeReady(logger, k8sClient, zk, podSize)).NotTo(HaveOccurred())

// This is to get the latest zk cluster object
zk, err = zk_e2eutil.GetCluster(logger, k8sClient, zk)
Expect(err).NotTo(HaveOccurred())

// Scale down zk cluster, decrease replicas to 1
zk.Spec.Replicas = 1
podSize = 1
Expect(zk_e2eutil.UpdateCluster(logger, k8sClient, zk)).NotTo(HaveOccurred())

Expect(zk_e2eutil.WaitForClusterToBecomeReady(logger, k8sClient, zk, podSize)).NotTo(HaveOccurred())

zk, err = zk_e2eutil.GetCluster(logger, k8sClient, zk)
Expect(err).NotTo(HaveOccurred())

// Scale up zk cluster to 3 again, before the PVCs are cleaned up
zk.Spec.Replicas = 3
podSize = 3
Expect(zk_e2eutil.UpdateCluster(logger, k8sClient, zk)).NotTo(HaveOccurred())

Expect(zk_e2eutil.WaitForClusterToBecomeReady(logger, k8sClient, zk, podSize)).NotTo(HaveOccurred())
})
})
})

0 comments on commit cd732b9

Please sign in to comment.