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

Adopting according to new readability and code style #553

Merged
merged 15 commits into from
Sep 3, 2024
Merged
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
113 changes: 97 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,104 @@ 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 -eu

# Get the name of the first pod by labels
POD=$(
kubectl get pod -n "$NAMESPACE" \
-l app.kubernetes.io/component=master,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 -eu

# Get the name of the first pod by labels
POD=$(
kubectl get pod -n "$NAMESPACE" \
-l app.kubernetes.io/component=regionserver,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 -eu

# Get the name of the first pod by labels
POD=$(
kubectl get pod \
-n "$NAMESPACE" \
-l app.kubernetes.io/component=regionserver,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 -eu

# Get the name of the first pod by labels
POD=$(
kubectl get pod \
-n "$NAMESPACE" \
-l app.kubernetes.io/component=restserver,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