Skip to content

Commit

Permalink
Fixing testcases
Browse files Browse the repository at this point in the history
  • Loading branch information
tanmayja committed Jul 1, 2024
1 parent 398326b commit 7d5fad2
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 22 deletions.
6 changes: 2 additions & 4 deletions controllers/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -1537,13 +1537,11 @@ func (r *SingleClusterReconciler) updateOperationStatus(restartedASDPodNames, re
statusPods := sets.New(statusOp.PodList...)

if statusOp.Kind == asdbv1.OperationWarmRestart && quickRestartsSet != nil {
statusOp.PodList = append(statusOp.PodList, quickRestartsSet.Intersection(specPods).
Difference(statusPods).UnsortedList()...)
statusOp.PodList = statusPods.Union(quickRestartsSet.Intersection(specPods)).UnsortedList()
}

if statusOp.Kind == asdbv1.OperationPodRestart && podRestartsSet != nil {
statusOp.PodList = append(statusOp.PodList, podRestartsSet.Intersection(specPods).
Difference(statusPods).UnsortedList()...)
statusOp.PodList = statusPods.Union(podRestartsSet.Intersection(specPods)).UnsortedList()
}
}
}
Expand Down
12 changes: 12 additions & 0 deletions test/access_control_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2191,6 +2191,8 @@ var _ = Describe(
racks := getDummyRackConf(1, 2)
aeroCluster.Spec.RackConfig.Racks = racks
aeroCluster.Spec.RackConfig.Namespaces = []string{"test"}
// Setting incorrect secret name so that access control reconciler could not set the password for admin.
aeroCluster.Spec.AerospikeAccessControl.Users[0].SecretName = "incorrectSecretName"
// This file is already added in the storage volume backed by the secret.
aeroCluster.Spec.AerospikeConfig.Value["security"] = map[string]interface{}{
"default-password-file": "/etc/aerospike/secret/password.conf",
Expand All @@ -2214,6 +2216,7 @@ var _ = Describe(
Eventually(func() error {
clientPolicy := getClientPolicy(aeroCluster, k8sClient)
clientPolicy.Password = pass
clientPolicy.FailIfNotConnected = true

client, cerr := getClientWithPolicy(
pkgLog, aeroCluster, k8sClient, clientPolicy)
Expand All @@ -2231,6 +2234,15 @@ var _ = Describe(
return nil
}, 5*time.Minute).ShouldNot(HaveOccurred())

aeroCluster, err = getCluster(k8sClient, ctx, clusterNamespacedName)
Expect(err).ToNot(HaveOccurred())

// Set correct secret name for admin user credentials.
aeroCluster.Spec.AerospikeAccessControl.Users[0].SecretName = authSecretName

err = updateCluster(k8sClient, ctx, aeroCluster)
Expect(err).ToNot(HaveOccurred())

By("Try scaleup")
err = scaleUpClusterTest(
k8sClient, ctx, clusterNamespacedName, 1,
Expand Down
36 changes: 18 additions & 18 deletions test/warm_restart_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,15 @@ var _ = Describe(
"WarmRestart", func() {
It(
"Should work with tini", func() {
WarmRestart(ctx)
WarmRestart(ctx, latestImage, true)
},
)
It(
"Should cold start without tini", func() {
PodRestart(ctx)
"Should not work without tini", func() {
image := fmt.Sprintf(
"aerospike/aerospike-server-enterprise:%s", "5.7.0.8",
)
WarmRestart(ctx, image, false)
},
)

Expand All @@ -39,15 +42,8 @@ var _ = Describe(
},
)

func WarmRestart(ctx goCtx.Context) {
rollCluster(ctx, latestImage, true)
}

func PodRestart(ctx goCtx.Context) {
image := fmt.Sprintf(
"aerospike/aerospike-server-enterprise:%s", "5.7.0.8",
)
rollCluster(ctx, image, false)
func WarmRestart(ctx goCtx.Context, image string, expectWarmStart bool) {
rollCluster(ctx, image, expectWarmStart)
}

func rollCluster(ctx goCtx.Context, image string, expectWarmStart bool) {
Expand Down Expand Up @@ -86,15 +82,19 @@ func rollCluster(ctx goCtx.Context, image string, expectWarmStart bool) {
err = rollingRestartClusterTest(
logger, k8sClient, ctx, clusterNamespacedName,
)
Expect(err).ToNot(HaveOccurred())
if !expectWarmStart {
Expect(err).Should(HaveOccurred())
} else {
Expect(err).ToNot(HaveOccurred())

podToMarkerPresent, err := isMarkerPresent(ctx, aeroCluster)
Expect(err).ToNot(HaveOccurred())
podToMarkerPresent, err := isMarkerPresent(ctx, aeroCluster)
Expect(err).ToNot(HaveOccurred())

pkgLog.Info("Rolling restarted", "Markers", podToMarkerPresent)
pkgLog.Info("Rolling restarted", "Markers", podToMarkerPresent)

for _, marker := range podToMarkerPresent {
Expect(marker).To(Equal(expectWarmStart))
for _, marker := range podToMarkerPresent {
Expect(marker).To(Equal(expectWarmStart))
}
}
}

Expand Down

0 comments on commit 7d5fad2

Please sign in to comment.