Skip to content

Commit

Permalink
adding negative testcase for dynamic config
Browse files Browse the repository at this point in the history
  • Loading branch information
tanmayja committed Apr 10, 2024
1 parent 27f19b6 commit aafd2ab
Showing 1 changed file with 85 additions and 0 deletions.
85 changes: 85 additions & 0 deletions test/dynamic_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package test
import (
goctx "context"
"fmt"
"time"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand Down Expand Up @@ -208,6 +209,90 @@ var _ = Describe(
)
},
)

Context(
"When doing invalid operations", func() {

clusterName := "dynamic-config-test"
clusterNamespacedName := getNamespacedName(
clusterName, namespace,
)
BeforeEach(
func() {
// Create a 2 node cluster
aeroCluster := createDummyAerospikeCluster(
clusterNamespacedName, 2,
)
aeroCluster.Spec.AerospikeConfig.Value["xdr"] = map[string]interface{}{
"dcs": []map[string]interface{}{
{
"name": "dc1",
"auth-mode": "internal",
"auth-user": "admin",
"node-address-ports": []string{
"aeroclusterdst-0-0 3000",
},
"auth-password-file": "/etc/aerospike/secret/password_DC1.txt",
"namespaces": []map[string]interface{}{
{
"name": "test",
},
},
},
},
}
err := deployCluster(k8sClient, ctx, aeroCluster)
Expect(err).ToNot(HaveOccurred())
},
)

AfterEach(
func() {
aeroCluster, err := getCluster(k8sClient, ctx, clusterNamespacedName)
Expect(err).ToNot(HaveOccurred())

_ = deleteCluster(k8sClient, ctx, aeroCluster)
},
)

It(
"Should fail dynamic config update for invalid config", func() {

By("Modify dynamic config with incorrect value")
aeroCluster, err := getCluster(
k8sClient, ctx, clusterNamespacedName,
)
Expect(err).ToNot(HaveOccurred())

podPIDMap, err := getPodIDs(ctx, aeroCluster)
Expect(err).ToNot(HaveOccurred())

// This change will lead to dynamic config update failure.
// Assuming it will fall back to rolling restart. Which leads to pod failures.
aeroCluster.Spec.AerospikeConfig.Value["service"].(map[string]interface{})["proto-fd-max"] = 9999999

err = updateClusterWithTO(k8sClient, ctx, aeroCluster, time.Minute*1)
Expect(err).To(HaveOccurred())

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

// Recovery
aeroCluster.Spec.AerospikeConfig.Value["service"].(map[string]interface{})["proto-fd-max"] = 15000

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

// As pods were failed, expectation is that pods will be cold restarted.
By("Verify cold restarts in Pods")
validateServerRestart(ctx, aeroCluster, podPIDMap, true)

},
)
},
)
},
)

Expand Down

0 comments on commit aafd2ab

Please sign in to comment.