Skip to content

Commit

Permalink
test: enhance Redis cluster testing with data assertion scripts
Browse files Browse the repository at this point in the history
- Added new steps in the e2e test for Redis cluster to apply a data assertion tool, `data-assert`, for generating and validating data in the Redis cluster.
- Replaced the previous Redis GET/SET checks with a more comprehensive data generation and validation process using the `data-assert` tool.
- Introduced additional assertions to ensure data consistency after scaling operations.

This update improves the reliability of e2e tests by ensuring data integrity in Redis clusters.

Signed-off-by: drivebyer <wuyangmuc@gmail.com>
  • Loading branch information
drivebyer committed Jan 14, 2025
1 parent 5850e81 commit a829af6
Showing 1 changed file with 25 additions and 10 deletions.
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"
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"
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"
check:
(contains($stdout, 'OK')): true

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

0 comments on commit a829af6

Please sign in to comment.