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: test for acl user #797

Merged
merged 6 commits into from
Mar 4, 2024
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
7 changes: 4 additions & 3 deletions .github/workflows/e2e-chainsaw.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
- ./tests/e2e-chainsaw/v1beta2/nodeport/
- ./tests/e2e-chainsaw/v1beta2/pvc-name/
- ./tests/e2e-chainsaw/v1beta2/keep-pvc/
- ./tests/e2e-chainsaw/v1beta2/acl-user/

steps:
- name: Checkout code
Expand All @@ -38,7 +39,7 @@ jobs:

- name: Check install
run: chainsaw version

- name: Install kubectl
run: |
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
Expand All @@ -55,7 +56,7 @@ jobs:
cluster_name: kind

- name: Load Docker image into Kind
run: |
run: |
kubectl cluster-info --context kind-kind
kind load docker-image redis-operator:e2e --name kind

Expand All @@ -66,6 +67,6 @@ jobs:
- name: Wait for Redis Operator to be ready
run: |
kubectl wait --for=condition=available --timeout=300s deployment/redis-operator-redis-operator -n redis-operator-system

- name: Run chainsaw test
run: chainsaw test --test-dir ${{ matrix.testpath }} --config tests/_config/chainsaw-configuration.yaml
6 changes: 3 additions & 3 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
run: |
curl -L https://github.com/kudobuilder/kuttl/releases/download/v0.15.0/kubectl-kuttl_0.15.0_linux_x86_64 -o /usr/local/bin/kuttl
chmod +x /usr/local/bin/kuttl

- name: Install kubectl
run: |
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
Expand All @@ -46,7 +46,7 @@ jobs:
cluster_name: kind

- name: Load Docker image into Kind
run: |
run: |
kubectl cluster-info --context kind-kind
kind load docker-image redis-operator:e2e --name kind

Expand All @@ -57,6 +57,6 @@ jobs:
- name: Wait for Redis Operator to be ready
run: |
kubectl wait --for=condition=available --timeout=300s deployment/redis-operator-redis-operator -n redis-operator-system

- name: Run kuttl test
run: kuttl test ${{ matrix.testpath }} --config tests/_config/kuttl-test.yaml
4 changes: 2 additions & 2 deletions tests/_config/chainsaw-configuration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: Configuration
metadata:
name: chainsaw-configuration
spec:
name: chainsaw-configuration
spec:
delayBeforeCleanup: 10s
timeouts:
apply: 5m
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
apiVersion: v1
kind: Secret
metadata:
name: acl-secret
type: Opaque
stringData:
# yamllint disable-line rule:line-length
user.acl: |
user opstree on ~* &* +@all >abc@123
user buildpiper on ~* &* +@all >abc@123
137 changes: 137 additions & 0 deletions tests/e2e-chainsaw/v1beta2/acl-user/redis-cluster/chainsaw-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
# 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-setup
spec:
steps:
- try:
- apply:
file: acl-secret.yaml
- assert:
resource:
apiVersion: v1
kind: Secret
metadata:
name: acl-secret
- apply:
file: cluster.yaml
- assert:
file: ready-cluster.yaml
- assert:
file: ready-sts.yaml
- assert:
file: ready-svc.yaml
- assert:
file: ready-pvc.yaml

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

- name: Ping Cluster Nodes
try:
- script:
content: |
kubectl exec --namespace ${NAMESPACE} --container redis-cluster-v1beta2-leader redis-cluster-v1beta2-leader-0 -- redis-cli -c -p 6379 ping
check:
($stdout=='PONG'): true
- script:
content: |
kubectl exec --namespace ${NAMESPACE} --container redis-cluster-v1beta2-leader redis-cluster-v1beta2-leader-1 -- redis-cli -c -p 6379 ping
check:
($stdout=='PONG'): true
- script:
content: |
kubectl exec --namespace ${NAMESPACE} --container redis-cluster-v1beta2-leader redis-cluster-v1beta2-leader-2 -- redis-cli -c -p 6379 ping
check:
($stdout=='PONG'): true
- script:
content: |
kubectl exec --namespace ${NAMESPACE} --container redis-cluster-v1beta2-follower redis-cluster-v1beta2-follower-0 -- redis-cli -c -p 6379 ping
check:
($stdout=='PONG'): true
- script:
content: |
kubectl exec --namespace ${NAMESPACE} --container redis-cluster-v1beta2-follower redis-cluster-v1beta2-follower-1 -- redis-cli -c -p 6379 ping
check:
($stdout=='PONG'): true
- script:
content: |
kubectl exec --namespace ${NAMESPACE} --container redis-cluster-v1beta2-follower redis-cluster-v1beta2-follower-2 -- redis-cli -c -p 6379 ping
check:
($stdout=='PONG'): true

- name: Check Cluster Slots Coverage
try:
- script:
content: |
kubectl exec --namespace ${NAMESPACE} --container redis-cluster-v1beta2-leader redis-cluster-v1beta2-leader-0 -- redis-cli --cluster check 127.0.0.1:6379 | grep 'All 16384 slots covered.'
check:
($stdout=='[OK] All 16384 slots covered.'): true
- script:
content: |
kubectl exec --namespace ${NAMESPACE} --container redis-cluster-v1beta2-leader redis-cluster-v1beta2-leader-1 -- redis-cli --cluster check 127.0.0.1:6379 | grep 'All 16384 slots covered'
check:
($stdout=='[OK] All 16384 slots covered.'): true
- script:
content: |
kubectl exec --namespace ${NAMESPACE} --container redis-cluster-v1beta2-leader redis-cluster-v1beta2-leader-2 -- redis-cli --cluster check 127.0.0.1:6379 | grep 'All 16384 slots covered'
check:
($stdout=='[OK] All 16384 slots covered.'): true
- script:
content: |
kubectl exec --namespace ${NAMESPACE} --container redis-cluster-v1beta2-follower redis-cluster-v1beta2-follower-0 -- redis-cli --cluster check 127.0.0.1:6379 | grep 'All 16384 slots covered'
check:
($stdout=='[OK] All 16384 slots covered.'): true
- script:
content: |
kubectl exec --namespace ${NAMESPACE} --container redis-cluster-v1beta2-follower redis-cluster-v1beta2-follower-1 -- redis-cli --cluster check 127.0.0.1:6379 | grep 'All 16384 slots covered'
check:
($stdout=='[OK] All 16384 slots covered.'): true
- script:
content: |
kubectl exec --namespace ${NAMESPACE} --container redis-cluster-v1beta2-follower redis-cluster-v1beta2-follower-2 -- redis-cli --cluster check 127.0.0.1:6379 | grep 'All 16384 slots covered'
check:
($stdout=='[OK] All 16384 slots covered.'): true

- name: Try saving a key With Password
try:
- script:
timeout: 30s
content: |
kubectl exec --namespace ${NAMESPACE} --container redis-cluster-v1beta2-leader redis-cluster-v1beta2-leader-0 -- redis-cli -c -p 6379 --user opstree --pass abc@123 set foo-0 bar-0
check:
($stdout=='OK'): true
- script:
timeout: 30s
content: |
kubectl exec --namespace ${NAMESPACE} --container redis-cluster-v1beta2-leader redis-cluster-v1beta2-leader-1 -- redis-cli -c -p 6379 --user opstree --pass abc@123 set foo-1 bar-1
check:
($stdout=='OK'): true
- script:
timeout: 30s
content: |
kubectl exec --namespace ${NAMESPACE} --container redis-cluster-v1beta2-leader redis-cluster-v1beta2-leader-2 -- redis-cli -c -p 6379 --user opstree --pass abc@123 set foo-2 bar-2
check:
($stdout=='OK'): true
- script:
timeout: 30s
content: |
kubectl exec --namespace ${NAMESPACE} --container redis-cluster-v1beta2-follower redis-cluster-v1beta2-follower-0 -- redis-cli -c -p 6379 --user opstree --pass abc@123 set foo-3 bar-3
check:
($stdout=='OK'): true
- script:
timeout: 30s
content: |
kubectl exec --namespace ${NAMESPACE} --container redis-cluster-v1beta2-follower redis-cluster-v1beta2-follower-1 -- redis-cli -c -p 6379 --user opstree --pass abc@123 set foo-4 bar-4
check:
($stdout=='OK'): true
- script:
timeout: 30s
content: |
kubectl exec --namespace ${NAMESPACE} --container redis-cluster-v1beta2-follower redis-cluster-v1beta2-follower-2 -- redis-cli -c -p 6379 --user opstree --pass abc@123 set foo-5 bar-5
check:
($stdout=='OK'): true
50 changes: 50 additions & 0 deletions tests/e2e-chainsaw/v1beta2/acl-user/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
acl:
secret:
secretName: acl-secret
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