Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: enhance Redis cluster testing with data assertion scripts #1209

Merged
merged 8 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tests/data-assert/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func genRedisDataCmd(cmd *cobra.Command, args []string) {
})
case "sentinel":
rdb = redis.NewFailoverClient(&redis.FailoverOptions{
MasterName: "mymaster",
MasterName: "myMaster",
SentinelAddrs: hosts,
Password: pass,
})
Expand Down Expand Up @@ -145,7 +145,7 @@ func checkRedisData() error {
})
case "sentinel":
rdb = redis.NewFailoverClient(&redis.FailoverOptions{
MasterName: "mymaster",
MasterName: "myMaster",
SentinelAddrs: hosts,
Password: pass,
})
Expand Down
4 changes: 2 additions & 2 deletions tests/data-assert/resources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ data:
})
case "sentinel":
rdb = redis.NewFailoverClient(&redis.FailoverOptions{
MasterName: "mymaster",
MasterName: "myMaster",
SentinelAddrs: hosts,
Password: pass,
})
Expand Down Expand Up @@ -152,7 +152,7 @@ data:
})
case "sentinel":
rdb = redis.NewFailoverClient(&redis.FailoverOptions{
MasterName: "mymaster",
MasterName: "myMaster",
SentinelAddrs: hosts,
Password: pass,
})
Expand Down
22 changes: 22 additions & 0 deletions tests/e2e-chainsaw/v1beta2/setup/ha/chainsaw-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ spec:
- try:
- apply:
file: ha.yaml
- apply:
file: ../../../../data-assert/resources.yaml

- name: Test Master IP consistency
try:
Expand All @@ -31,6 +33,16 @@ spec:
check:
(contains($stdout, 'OK')): true

- name: Put data
try:
- script:
timeout: 30s
content: >
kubectl exec --namespace ${NAMESPACE} --container data-assert data-assert --
bash -c "cd /go/src/data-assert && go run main.go gen-redis-data --host redis-sentinel-sentinel.${NAMESPACE}.svc.cluster.local:26379 --mode sentinel"
check:
(contains($stdout, 'OK')): true

# New created cluster, the first pod is master
- name: Terminate the redis-replication-0 pod
try:
Expand All @@ -53,3 +65,13 @@ spec:
if [ "$MASTER_IP_FROM_SENTINEL" = "$MASTER_IP_FROM_LABEL" ] && [ "$MASTER_IP_FROM_SENTINEL" = "$MASTER_IP_FROM_STATUS" ]; then echo "OK"; else echo "FAIL"; fi
check:
(contains($stdout, 'OK')): true

- name: Assert data
try:
- script:
timeout: 30s
content: >
kubectl exec --namespace ${NAMESPACE} --container data-assert data-assert --
bash -c "cd /go/src/data-assert && go run main.go chk-redis-data --host redis-sentinel-sentinel.${NAMESPACE}.svc.cluster.local:26379 --mode sentinel"
check:
(contains($stdout, 'OK')): true
35 changes: 25 additions & 10 deletions tests/e2e-chainsaw/v1beta2/setup/redis-cluster/chainsaw-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ spec:
file: cluster.yaml
- apply:
file: secret.yaml
- apply:
file: ../../../../data-assert/resources.yaml
- assert:
file: ready-cluster.yaml
- assert:
Expand All @@ -22,22 +24,15 @@ spec:
- assert:
file: secret.yaml

- name: Check Redis GET/SET
- name: Put data
try:
- script:
timeout: 30s
content: >
kubectl exec --namespace ${NAMESPACE} --container redis-cluster-v1beta2-leader redis-cluster-v1beta2-leader-0 --
redis-cli -c -p 6379 -a Opstree1234 set foo-0 bar-0
kubectl exec --namespace ${NAMESPACE} --container data-assert data-assert --
bash -c "cd /go/src/data-assert && go run main.go gen-redis-data --host redis-cluster-v1beta2-leader.${NAMESPACE}.svc.cluster.local:6379 --mode cluster --password Opstree1234"
check:
(contains($stdout, 'OK')): true
- script:
timeout: 30s
content: >
kubectl exec --namespace ${NAMESPACE} --container redis-cluster-v1beta2-leader redis-cluster-v1beta2-leader-0 --
redis-cli -c -p 6379 -a Opstree1234 get foo-0
check:
(contains($stdout, 'bar-0')): true

- name: Scale Out Redis Cluster
try:
Expand All @@ -64,13 +59,33 @@ spec:
- assert:
file: cluster-scale-out-status-03.yaml

- name: Assert data
try:
- script:
timeout: 30s
content: >
kubectl exec --namespace ${NAMESPACE} --container data-assert data-assert --
bash -c "cd /go/src/data-assert && go run main.go chk-redis-data --host redis-cluster-v1beta2-leader.${NAMESPACE}.svc.cluster.local:6379 --mode cluster --password Opstree1234"
check:
(contains($stdout, 'OK')): true

- name: Scale In Redis Cluster
try:
- apply:
file: cluster.yaml
- assert:
file: ready-cluster.yaml

- name: Assert data
try:
- script:
timeout: 30s
content: >
kubectl exec --namespace ${NAMESPACE} --container data-assert data-assert --
bash -c "cd /go/src/data-assert && go run main.go chk-redis-data --host redis-cluster-v1beta2-leader.${NAMESPACE}.svc.cluster.local:6379 --mode cluster --password Opstree1234"
check:
(contains($stdout, 'OK')): true

- name: redis-cluster-uninstall
try:
- delete:
Expand Down
Loading