Skip to content
Merged
Changes from 13 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
117 changes: 101 additions & 16 deletions tests/templates/kuttl/overrides/31-assert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,108 @@ apiVersion: kuttl.dev/v1beta1
kind: TestAssert
timeout: 30
commands:
# master, default RG
- script: |
POD=$(kubectl -n $NAMESPACE get pod -l app.kubernetes.io/component=master,app.kubernetes.io/role-group=default -o name | head -n 1 | sed -e 's#pod/##')
kubectl -n $NAMESPACE get pod $POD -o yaml | yq '.spec.containers[0].env[] | select (.name == "TEST_VAR_FROM_MASTER").value' | grep 'MASTER'
kubectl -n $NAMESPACE get pod $POD -o yaml | yq '.spec.containers[0].env[] | select (.name == "TEST_VAR_FROM_MRG").value' | grep 'MASTER'
kubectl -n $NAMESPACE get pod $POD -o yaml | yq '.spec.containers[0].env[] | select (.name == "TEST_VAR").value' | grep 'MASTER_RG'
set -euo pipefail

# Get the name of the first pod by labels
POD=$(
kubectl get pod -n "$NAMESPACE" \
-l app.kubernetes.io/component=master \
-l app.kubernetes.io/role-group=default \
-o name \
| head -n 1 \
| sed -e 's#pod/##'
)

# Assert that environment variables have the correct values
kubectl get pod "$POD" -n "$NAMESPACE" -o yaml \
| yq -r '.spec.containers[0].env[] | select (.name == "TEST_VAR_FROM_MASTER").value' \
| grep '^MASTER$'

kubectl get pod "$POD" -n "$NAMESPACE" -o yaml \
| yq -r '.spec.containers[0].env[] | select (.name == "TEST_VAR_FROM_MRG").value' \
| grep '^MASTER$'

kubectl get pod "$POD" -n "$NAMESPACE" -o yaml \
| yq -r '.spec.containers[0].env[] | select (.name == "TEST_VAR").value' \
| grep '^MASTER_RG$'

# regionserver, resources-from-role RG
- script: |
POD=$(kubectl -n $NAMESPACE get pod -l app.kubernetes.io/component=regionserver,app.kubernetes.io/role-group=resources-from-role -o name | head -n 1 | sed -e 's#pod/##')
kubectl -n $NAMESPACE get pod $POD -o yaml | yq '.spec.containers[0].env[] | select (.name == "TEST_VAR_FROM_RS").value' | grep 'REGIONSERVER'
kubectl -n $NAMESPACE get pod $POD -o yaml | yq '.spec.containers[0].env[] | select (.name == "TEST_VAR_FROM_RFR").value' | grep 'REGIONSERVER'
kubectl -n $NAMESPACE get pod $POD -o yaml | yq '.spec.containers[0].env[] | select (.name == "TEST_VAR").value' | grep 'REGIONSERVER_RFR'
set -euo pipefail

# Get the name of the first pod by labels
POD=$(
kubectl get pod -n "$NAMESPACE" \
-l app.kubernetes.io/component=regionserver \
-l app.kubernetes.io/role-group=resources-from-role \
-o name \
| head -n 1 \
| sed -e 's#pod/##'
)

# Assert that environment variables have the correct values
kubectl get pod "$POD" -n "$NAMESPACE" -o yaml \
| yq -r '.spec.containers[0].env[] | select (.name == "TEST_VAR_FROM_RS").value' \
| grep '^REGIONSERVER$'

kubectl get pod "$POD" -n "$NAMESPACE" -o yaml \
| yq -r '.spec.containers[0].env[] | select (.name == "TEST_VAR_FROM_RFR").value' \
| grep '^REGIONSERVER$'

kubectl get pod "$POD" -n "$NAMESPACE" -o yaml \
| yq -r '.spec.containers[0].env[] | select (.name == "TEST_VAR").value' \
| grep '^REGIONSERVER_RFR$'

# regionserver, resources-from-role-group RG
- script: |
POD=$(kubectl -n $NAMESPACE get pod -l app.kubernetes.io/component=regionserver,app.kubernetes.io/role-group=resources-from-role-group -o name | head -n 1 | sed -e 's#pod/##')
kubectl -n $NAMESPACE get pod $POD -o yaml | yq '.spec.containers[0].env[] | select (.name == "TEST_VAR_FROM_RS").value' | grep 'REGIONSERVER'
kubectl -n $NAMESPACE get pod $POD -o yaml | yq '.spec.containers[0].env[] | select (.name == "TEST_VAR_FROM_RFRG").value' | grep 'REGIONSERVER'
kubectl -n $NAMESPACE get pod $POD -o yaml | yq '.spec.containers[0].env[] | select (.name == "TEST_VAR").value' | grep 'REGIONSERVER_RFRG'
set -euo pipefail

# Get the name of the first pod by labels
POD=$(
kubectl get pod \
-n "$NAMESPACE" \
-l app.kubernetes.io/component=regionserver \
-l app.kubernetes.io/role-group=resources-from-role-group \
-o name | head -n 1 | sed -e 's#pod/##'
)

# Assert that environment variables have the correct values
kubectl get pod "$POD" -n "$NAMESPACE" -o yaml \
| yq -r '.spec.containers[0].env[] | select (.name == "TEST_VAR_FROM_RS").value' \
| grep '^REGIONSERVER$'

kubectl get pod "$POD" -n "$NAMESPACE" -o yaml \
| yq -r '.spec.containers[0].env[] | select (.name == "TEST_VAR_FROM_RFRG").value' \
| grep '^REGIONSERVER$'

kubectl get pod "$POD" -n "$NAMESPACE" -o yaml \
| yq -r '.spec.containers[0].env[] | select (.name == "TEST_VAR").value' \
| grep '^REGIONSERVER_RFRG$'

# restserver, default RG
- script: |
POD=$(kubectl -n $NAMESPACE get pod -l app.kubernetes.io/component=restserver,app.kubernetes.io/role-group=default -o name | head -n 1 | sed -e 's#pod/##')
kubectl -n $NAMESPACE get pod $POD -o yaml | yq '.spec.containers[0].env[] | select (.name == "TEST_VAR_FROM_REST").value' | grep 'RESTSERVER'
kubectl -n $NAMESPACE get pod $POD -o yaml | yq '.spec.containers[0].env[] | select (.name == "TEST_VAR_FROM_REST_RG").value' | grep 'RESTSERVER'
kubectl -n $NAMESPACE get pod $POD -o yaml | yq '.spec.containers[0].env[] | select (.name == "TEST_VAR").value' | grep 'RESTSERVER_RG'
set -euo pipefail

# Get the name of the first pod by labels
POD=$(
kubectl get pod \
-n "$NAMESPACE" \
-l app.kubernetes.io/component=restserver \
-l app.kubernetes.io/role-group=default \
-o name | head -n 1 | sed -e 's#pod/##'
)

# Assert that environment variables have the correct values
kubectl get pod "$POD" -n "$NAMESPACE" -o yaml \
| yq -r '.spec.containers[0].env[] | select (.name == "TEST_VAR_FROM_REST").value' \
| grep '^RESTSERVER$'

kubectl get pod "$POD" -n "$NAMESPACE" -o yaml \
| yq -r '.spec.containers[0].env[] | select (.name == "TEST_VAR_FROM_REST_RG").value' \
| grep '^RESTSERVER$'

kubectl get pod "$POD" -n "$NAMESPACE" -o yaml \
| yq -r '.spec.containers[0].env[] | select (.name == "TEST_VAR").value' \
| grep '^RESTSERVER_RG$'
Loading