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: Setting Password on Redis Cluster #729

Merged
merged 5 commits into from
Dec 17, 2023
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
1 change: 1 addition & 0 deletions .github/workflows/e2e-chainsaw.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
- ./tests/e2e-chainsaw/v1beta2/teardown/
- ./tests/e2e-chainsaw/v1beta2/setup/
- ./tests/e2e-chainsaw/v1beta2/hostnetwork/
- ./tests/e2e-chainsaw/v1beta2/password/

steps:
- name: Checkout code
Expand Down
184 changes: 184 additions & 0 deletions tests/e2e-chainsaw/v1beta2/password/redis-cluster/chainsaw-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/kyverno/chainsaw/main/.schemas/json/test-chainsaw-v1alpha1.json

apiVersion: chainsaw.kyverno.io/v1alpha1
kind: Test
metadata:
name: redis-cluster-password
spec:
steps:
- try:
- apply:
file: cluster.yaml
- apply:
file: secret.yaml
- assert:
file: ready-cluster.yaml
- assert:
file: ready-sts.yaml
- assert:
file: ready-svc.yaml
- assert:
file: ready-pvc.yaml
- assert:
file: secret.yaml

- name: Sleep for five minutes
try:
- sleep:
duration: 5m

- name: Ping Cluster With Password
try:
- script:
timeout: 10s
content: |
kubectl exec --namespace ${NAMESPACE} --container redis-cluster-v1beta2-leader redis-cluster-v1beta2-leader-0 -- redis-cli -c -p 6379 -a Opstree@1234 ping
check:
($stdout=='PONG'): true
- script:
timeout: 10s
content: |
kubectl exec --namespace ${NAMESPACE} --container redis-cluster-v1beta2-leader redis-cluster-v1beta2-leader-1 -- redis-cli -c -p 6379 -a Opstree@1234 ping
check:
($stdout=='PONG'): true
- script:
timeout: 10s
content: |
kubectl exec --namespace ${NAMESPACE} --container redis-cluster-v1beta2-leader redis-cluster-v1beta2-leader-2 -- redis-cli -c -p 6379 -a Opstree@1234 ping
check:
($stdout=='PONG'): true
- script:
timeout: 10s
content: |
kubectl exec --namespace ${NAMESPACE} --container redis-cluster-v1beta2-follower redis-cluster-v1beta2-follower-0 -- redis-cli -c -p 6379 -a Opstree@1234 ping
check:
($stdout=='PONG'): true
- script:
timeout: 10s
content: |
kubectl exec --namespace ${NAMESPACE} --container redis-cluster-v1beta2-follower redis-cluster-v1beta2-follower-1 -- redis-cli -c -p 6379 -a Opstree@1234 ping
check:
($stdout=='PONG'): true
- script:
timeout: 10s
content: |
kubectl exec --namespace ${NAMESPACE} --container redis-cluster-v1beta2-follower redis-cluster-v1beta2-follower-2 -- redis-cli -c -p 6379 -a Opstree@1234 ping
check:
($stdout=='PONG'): true

- name: Try saving a key With Password
try:
- script:
timeout: 10s
content: |
kubectl exec --namespace ${NAMESPACE} --container redis-cluster-v1beta2-leader redis-cluster-v1beta2-leader-0 -- redis-cli -c -p 6379 -a Opstree@1234 set foo-0 bar-0
check:
($stdout=='OK'): true
- script:
timeout: 10s
content: |
kubectl exec --namespace ${NAMESPACE} --container redis-cluster-v1beta2-leader redis-cluster-v1beta2-leader-1 -- redis-cli -c -p 6379 -a Opstree@1234 set foo-1 bar-1
check:
($stdout=='OK'): true
- script:
timeout: 10s
content: |
kubectl exec --namespace ${NAMESPACE} --container redis-cluster-v1beta2-leader redis-cluster-v1beta2-leader-2 -- redis-cli -c -p 6379 -a Opstree@1234 set foo-2 bar-2
check:
($stdout=='OK'): true
- script:
timeout: 10s
content: |
kubectl exec --namespace ${NAMESPACE} --container redis-cluster-v1beta2-follower redis-cluster-v1beta2-follower-0 -- redis-cli -c -p 6379 -a Opstree@1234 set foo-3 bar-3
check:
($stdout=='OK'): true
- script:
timeout: 10s
content: |
kubectl exec --namespace ${NAMESPACE} --container redis-cluster-v1beta2-follower redis-cluster-v1beta2-follower-1 -- redis-cli -c -p 6379 -a Opstree@1234 set foo-4 bar-4
check:
($stdout=='OK'): true
- script:
timeout: 10s
content: |
kubectl exec --namespace ${NAMESPACE} --container redis-cluster-v1beta2-follower redis-cluster-v1beta2-follower-2 -- redis-cli -c -p 6379 -a Opstree@1234 set foo-5 bar-5
check:
($stdout=='OK'): true

- name: Ping Cluster Without Password
try:
- script:
timeout: 10s
content: |
kubectl exec --namespace ${NAMESPACE} --container redis-cluster-v1beta2-leader redis-cluster-v1beta2-leader-0 -- redis-cli -c -p 6379 ping
check:
($stdout=='NOAUTH Authentication required.'): true
- script:
timeout: 10s
content: |
kubectl exec --namespace ${NAMESPACE} --container redis-cluster-v1beta2-leader redis-cluster-v1beta2-leader-1 -- redis-cli -c -p 6379 ping
check:
($stdout=='NOAUTH Authentication required.'): true
- script:
timeout: 10s
content: |
kubectl exec --namespace ${NAMESPACE} --container redis-cluster-v1beta2-leader redis-cluster-v1beta2-leader-2 -- redis-cli -c -p 6379 ping
check:
($stdout=='NOAUTH Authentication required.'): true
- script:
timeout: 10s
content: |
kubectl exec --namespace ${NAMESPACE} --container redis-cluster-v1beta2-follower redis-cluster-v1beta2-follower-0 -- redis-cli -c -p 6379 ping
check:
($stdout=='NOAUTH Authentication required.'): true
- script:
timeout: 10s
content: |
kubectl exec --namespace ${NAMESPACE} --container redis-cluster-v1beta2-follower redis-cluster-v1beta2-follower-1 -- redis-cli -c -p 6379 ping
check:
($stdout=='NOAUTH Authentication required.'): true
- script:
timeout: 10s
content: |
kubectl exec --namespace ${NAMESPACE} --container redis-cluster-v1beta2-follower redis-cluster-v1beta2-follower-2 -- redis-cli -c -p 6379 ping
check:
($stdout=='NOAUTH Authentication required.'): true

- name: Try saving a key Without Password
try:
- script:
timeout: 10s
content: |
kubectl exec --namespace ${NAMESPACE} --container redis-cluster-v1beta2-leader redis-cluster-v1beta2-leader-0 -- redis-cli -c -p 6379 set foo-0 bar-0
check:
($stdout=='NOAUTH Authentication required.'): true
- script:
timeout: 10s
content: |
kubectl exec --namespace ${NAMESPACE} --container redis-cluster-v1beta2-leader redis-cluster-v1beta2-leader-1 -- redis-cli -c -p 6379 set foo-1 bar-1
check:
($stdout=='NOAUTH Authentication required.'): true
- script:
timeout: 10s
content: |
kubectl exec --namespace ${NAMESPACE} --container redis-cluster-v1beta2-leader redis-cluster-v1beta2-leader-2 -- redis-cli -c -p 6379 set foo-2 bar-2
check:
($stdout=='NOAUTH Authentication required.'): true
- script:
timeout: 10s
content: |
kubectl exec --namespace ${NAMESPACE} --container redis-cluster-v1beta2-follower redis-cluster-v1beta2-follower-0 -- redis-cli -c -p 6379 set foo-3 bar-3
check:
($stdout=='NOAUTH Authentication required.'): true
- script:
timeout: 10s
content: |
kubectl exec --namespace ${NAMESPACE} --container redis-cluster-v1beta2-follower redis-cluster-v1beta2-follower-1 -- redis-cli -c -p 6379 set foo-4 bar-4
check:
($stdout=='NOAUTH Authentication required.'): true
- script:
timeout: 10s
content: |
kubectl exec --namespace ${NAMESPACE} --container redis-cluster-v1beta2-follower redis-cluster-v1beta2-follower-2 -- redis-cli -c -p 6379 set foo-5 bar-5
check:
($stdout=='NOAUTH Authentication required.'): true
50 changes: 50 additions & 0 deletions tests/e2e-chainsaw/v1beta2/password/redis-cluster/cluster.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
apiVersion: redis.redis.opstreelabs.in/v1beta2
kind: RedisCluster
metadata:
name: redis-cluster-v1beta2
spec:
clusterSize: 3
clusterVersion: v7
persistenceEnabled: true
podSecurityContext:
runAsUser: 1000
fsGroup: 1000
kubernetesConfig:
image: quay.io/opstree/redis:latest
imagePullPolicy: Always
resources:
requests:
cpu: 101m
memory: 128Mi
limits:
cpu: 101m
memory: 128Mi
redisSecret:
name: redis-secret
key: password
redisExporter:
enabled: true
image: quay.io/opstree/redis-exporter:v1.44.0
imagePullPolicy: Always
resources:
requests:
cpu: 100m
memory: 128Mi
limits:
cpu: 100m
memory: 128Mi
storage:
volumeClaimTemplate:
spec:
# storageClassName: standard
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 1Gi
nodeConfVolume: true
nodeConfVolumeClaimTemplate:
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 1Gi
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: redis.redis.opstreelabs.in/v1beta2
kind: RedisCluster
metadata:
name: redis-cluster-v1beta2
status:
readyFollowerReplicas: 3
readyLeaderReplicas: 3
Loading
Loading