Skip to content

Commit

Permalink
Drain 5th node before first scale down to avoid breaking quorum in th…
Browse files Browse the repository at this point in the history
…e test
  • Loading branch information
zimnx committed Jun 25, 2024
1 parent 055b943 commit 7828a7c
Showing 1 changed file with 35 additions and 35 deletions.
70 changes: 35 additions & 35 deletions test/e2e/set/scyllacluster/scyllacluster_scaling.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,41 +83,9 @@ var _ = g.Describe("ScyllaCluster", func() {

verifyCQLData(ctx, diRF3)

framework.By("Scaling the ScyllaCluster down to 4 replicas")
sc, err = f.ScyllaClient().ScyllaV1().ScyllaClusters(sc.Namespace).Patch(
ctx,
sc.Name,
types.JSONPatchType,
[]byte(`[{"op": "replace", "path": "/spec/datacenter/racks/0/members", "value": 4}]`),
metav1.PatchOptions{},
)
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(sc.Spec.Datacenter.Racks[0].Members).To(o.BeEquivalentTo(4))

framework.By("Waiting for the ScyllaCluster to roll out (RV=%s)", sc.ResourceVersion)
waitCtx3, waitCtx3Cancel := utils.ContextForRollout(ctx, sc)
defer waitCtx3Cancel()
sc, err = controllerhelpers.WaitForScyllaClusterState(waitCtx3, f.ScyllaClient().ScyllaV1().ScyllaClusters(sc.Namespace), sc.Name, controllerhelpers.WaitForStateOptions{}, utils.IsScyllaClusterRolledOut)
o.Expect(err).NotTo(o.HaveOccurred())

verifyScyllaCluster(ctx, f.KubeClient(), sc)
waitForFullQuorum(ctx, f.KubeClient().CoreV1(), sc)

oldHosts = hosts
oldHostIDs = hostIDs
hosts, hostIDs, err = utils.GetBroadcastRPCAddressesAndUUIDs(ctx, f.KubeClient().CoreV1(), sc)
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(oldHosts).To(o.HaveLen(5))
o.Expect(oldHostIDs).To(o.HaveLen(5))
o.Expect(hosts).To(o.HaveLen(4))
o.Expect(hostIDs).To(o.HaveLen(4))
o.Expect(oldHostIDs).To(o.ContainElements(hostIDs))

verifyCQLData(ctx, diRF3)

podName := naming.StatefulSetNameForRack(sc.Spec.Datacenter.Racks[0], sc) + "-1"
podName := naming.StatefulSetNameForRack(sc.Spec.Datacenter.Racks[0], sc) + "-4"
svcName := podName
framework.By("Marking ScyllaCluster node #2 (%s) for maintenance", podName)
framework.By("Marking ScyllaCluster node #4 (%s) for maintenance", podName)
svc := &corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{
Expand All @@ -136,7 +104,7 @@ var _ = g.Describe("ScyllaCluster", func() {
)
o.Expect(err).NotTo(o.HaveOccurred())

framework.By("Manually draining ScyllaCluster node #2 (%s)", podName)
framework.By("Manually draining ScyllaCluster node #4 (%s)", podName)
ec := &corev1.EphemeralContainer{
TargetContainerName: naming.ScyllaContainerName,
EphemeralContainerCommon: corev1.EphemeralContainerCommon{
Expand All @@ -154,6 +122,38 @@ var _ = g.Describe("ScyllaCluster", func() {
o.Expect(ephemeralContainerState.State.Terminated).NotTo(o.BeNil())
o.Expect(ephemeralContainerState.State.Terminated.ExitCode).To(o.BeEquivalentTo(0))

framework.By("Scaling the ScyllaCluster down to 4 replicas")
sc, err = f.ScyllaClient().ScyllaV1().ScyllaClusters(sc.Namespace).Patch(
ctx,
sc.Name,
types.JSONPatchType,
[]byte(`[{"op": "replace", "path": "/spec/datacenter/racks/0/members", "value": 4}]`),
metav1.PatchOptions{},
)
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(sc.Spec.Datacenter.Racks[0].Members).To(o.BeEquivalentTo(4))

framework.By("Waiting for the ScyllaCluster to roll out (RV=%s)", sc.ResourceVersion)
waitCtx3, waitCtx3Cancel := utils.ContextForRollout(ctx, sc)
defer waitCtx3Cancel()
sc, err = controllerhelpers.WaitForScyllaClusterState(waitCtx3, f.ScyllaClient().ScyllaV1().ScyllaClusters(sc.Namespace), sc.Name, controllerhelpers.WaitForStateOptions{}, utils.IsScyllaClusterRolledOut)
o.Expect(err).NotTo(o.HaveOccurred())

verifyScyllaCluster(ctx, f.KubeClient(), sc)
waitForFullQuorum(ctx, f.KubeClient().CoreV1(), sc)

oldHosts = hosts
oldHostIDs = hostIDs
hosts, hostIDs, err = utils.GetBroadcastRPCAddressesAndUUIDs(ctx, f.KubeClient().CoreV1(), sc)
o.Expect(err).NotTo(o.HaveOccurred())
o.Expect(oldHosts).To(o.HaveLen(5))
o.Expect(oldHostIDs).To(o.HaveLen(5))
o.Expect(hosts).To(o.HaveLen(4))
o.Expect(hostIDs).To(o.HaveLen(4))
o.Expect(oldHostIDs).To(o.ContainElements(hostIDs))

verifyCQLData(ctx, diRF3)

framework.By("Scaling the ScyllaCluster down to 3 replicas")
sc, err = f.ScyllaClient().ScyllaV1().ScyllaClusters(f.Namespace()).Patch(
ctx,
Expand Down

0 comments on commit 7828a7c

Please sign in to comment.