From 197aa9ba73a16f18a936d822a2f28f451ea29da5 Mon Sep 17 00:00:00 2001 From: Maxi Wittich Date: Thu, 29 Aug 2024 16:06:11 +0200 Subject: [PATCH 01/15] Adopting according to new readability and code style --- .../templates/kuttl/overrides/31-assert.yaml | 62 +++++++++++++------ 1 file changed, 43 insertions(+), 19 deletions(-) diff --git a/tests/templates/kuttl/overrides/31-assert.yaml b/tests/templates/kuttl/overrides/31-assert.yaml index 9467e610..82d48faa 100644 --- a/tests/templates/kuttl/overrides/31-assert.yaml +++ b/tests/templates/kuttl/overrides/31-assert.yaml @@ -4,22 +4,46 @@ kind: TestAssert timeout: 30 commands: - 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' - - 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' - - 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' - - 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' + #!/usr/bin/env bash + set -euo pipefail + + # POD Test Names + POD_MASTER=$(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/##') + POD_REGIONSERVER_ROLE=$(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/##') + POD_REGIONSERVER_ROLE_GROUP=$(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/##') + POD_RESTSERVER=$(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/##') + + # Config Test Data + POD_MASTER_DATA=$(kubectl -n $NAMESPACE get pod $POD_MASTER -o yaml) + POD_REGIONSERVER_ROLE_DATA=$(kubectl -n $NAMESPACE get pod $POD_REGIONSERVER_ROLE -o yaml) + POD_REGIONSERVER_ROLE_GROUP_DATA=$(kubectl -n $NAMESPACE get pod $POD_REGIONSERVER_ROLE_GROUP -o yaml) + POD_RESTSERVER_DATA=$(kubectl -n $NAMESPACE get pod $POD_RESTSERVER -o yaml) + echo "$POD_MASTER_DATA" + echo "$POD_REGIONSERVER_ROLE_DATA" + echo "$POD_REGIONSERVER_ROLE_GROUP_DATA" + echo "$POD_RESTSERVER_DATA" + + YQ_FILTER=' + .spec.containers[0].env[] + | select (.name == strenv(KEY) and .value == strenv(VALUE)) + ' + + # POD_MASTER Test Assertions + echo "$POD_MASTER_DATA" | KEY="TEST_VAR_FROM_MASTER" VALUE="MASTER" yq -e "$YQ_FILTER" + echo "$POD_MASTER_DATA" | KEY="TEST_VAR_FROM_MRG" VALUE="MASTER" yq -e "$YQ_FILTER" + echo "$POD_MASTER_DATA" | KEY="TEST_VAR" VALUE="MASTER_RG" yq -e "$YQ_FILTER" + + # POD_REGIONSERVER_ROLE Test Assertions + echo "$POD_REGIONSERVER_ROLE_DATA" | KEY="TEST_VAR_FROM_RS" VALUE="REGIONSERVER" yq -e "$YQ_FILTER" + echo "$POD_REGIONSERVER_ROLE_DATA" | KEY="TEST_VAR_FROM_RFR" VALUE="REGIONSERVER" yq -e "$YQ_FILTER" + echo "$POD_REGIONSERVER_ROLE_DATA" | KEY="TEST_VAR" VALUE="REGIONSERVER_RFR" yq -e "$YQ_FILTER" + + # POD_REGIONSERVER_ROLE_GROUP_DATA Test Assertions + echo "$POD_REGIONSERVER_ROLE_GROUP_DATA" | KEY="TEST_VAR_FROM_RS" VALUE="REGIONSERVER" yq -e "$YQ_FILTER" + echo "$POD_REGIONSERVER_ROLE_GROUP_DATA" | KEY="TEST_VAR_FROM_RFRG" VALUE="REGIONSERVER" yq -e "$YQ_FILTER" + echo "$POD_REGIONSERVER_ROLE_GROUP_DATA" | KEY="TEST_VAR" VALUE="REGIONSERVER_RFRG" yq -e "$YQ_FILTER" + + # POD_RESTSERVER_DATA Test Assertions + echo "$POD_RESTSERVER_DATA" | KEY="TEST_VAR_FROM_REST" VALUE="RESTSERVER" yq -e "$YQ_FILTER" + echo "$POD_RESTSERVER_DATA" | KEY="TEST_VAR_FROM_REST_RG" VALUE="RESTSERVER" yq -e "$YQ_FILTER" + echo "$POD_RESTSERVER_DATA" | KEY="TEST_VAR" VALUE="RESTSERVER_RG" yq -e "$YQ_FILTER" From 40708301ca19bbfb2c89da89b7b29ebc2cfc7e20 Mon Sep 17 00:00:00 2001 From: Maxi Wittich Date: Thu, 29 Aug 2024 16:10:01 +0200 Subject: [PATCH 02/15] Removing whitespace --- tests/templates/kuttl/overrides/31-assert.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/templates/kuttl/overrides/31-assert.yaml b/tests/templates/kuttl/overrides/31-assert.yaml index 82d48faa..063f4b3b 100644 --- a/tests/templates/kuttl/overrides/31-assert.yaml +++ b/tests/templates/kuttl/overrides/31-assert.yaml @@ -26,7 +26,7 @@ commands: YQ_FILTER=' .spec.containers[0].env[] | select (.name == strenv(KEY) and .value == strenv(VALUE)) - ' + ' # POD_MASTER Test Assertions echo "$POD_MASTER_DATA" | KEY="TEST_VAR_FROM_MASTER" VALUE="MASTER" yq -e "$YQ_FILTER" From fcd0901305cb8ea33ac98cd6c53e11e902d342c2 Mon Sep 17 00:00:00 2001 From: Maxi Wittich Date: Thu, 29 Aug 2024 16:17:17 +0200 Subject: [PATCH 03/15] Making shellcheck happy --- .../templates/kuttl/overrides/31-assert.yaml | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/tests/templates/kuttl/overrides/31-assert.yaml b/tests/templates/kuttl/overrides/31-assert.yaml index 063f4b3b..f4ac6f5c 100644 --- a/tests/templates/kuttl/overrides/31-assert.yaml +++ b/tests/templates/kuttl/overrides/31-assert.yaml @@ -8,20 +8,16 @@ commands: set -euo pipefail # POD Test Names - POD_MASTER=$(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/##') - POD_REGIONSERVER_ROLE=$(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/##') - POD_REGIONSERVER_ROLE_GROUP=$(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/##') - POD_RESTSERVER=$(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/##') + POD_MASTER=$(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/##') + POD_REGIONSERVER_ROLE=$(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/##') + POD_REGIONSERVER_ROLE_GROUP=$(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/##') + POD_RESTSERVER=$(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/##') # Config Test Data - POD_MASTER_DATA=$(kubectl -n $NAMESPACE get pod $POD_MASTER -o yaml) - POD_REGIONSERVER_ROLE_DATA=$(kubectl -n $NAMESPACE get pod $POD_REGIONSERVER_ROLE -o yaml) - POD_REGIONSERVER_ROLE_GROUP_DATA=$(kubectl -n $NAMESPACE get pod $POD_REGIONSERVER_ROLE_GROUP -o yaml) - POD_RESTSERVER_DATA=$(kubectl -n $NAMESPACE get pod $POD_RESTSERVER -o yaml) - echo "$POD_MASTER_DATA" - echo "$POD_REGIONSERVER_ROLE_DATA" - echo "$POD_REGIONSERVER_ROLE_GROUP_DATA" - echo "$POD_RESTSERVER_DATA" + POD_MASTER_DATA=$(kubectl -n "$NAMESPACE" get pod "$POD_MASTER" -o yaml) + POD_REGIONSERVER_ROLE_DATA=$(kubectl -n "$NAMESPACE" get pod "$POD_REGIONSERVER_ROLE" -o yaml) + POD_REGIONSERVER_ROLE_GROUP_DATA=$(kubectl -n "$NAMESPACE" get pod "$POD_REGIONSERVER_ROLE_GROUP" -o yaml) + POD_RESTSERVER_DATA=$(kubectl -n "$NAMESPACE" get pod "$POD_RESTSERVER" -o yaml) YQ_FILTER=' .spec.containers[0].env[] From 10d00ccd9344c95e43eb291a25cf324f4b9469c1 Mon Sep 17 00:00:00 2001 From: Nick Larsen Date: Thu, 29 Aug 2024 18:11:30 +0200 Subject: [PATCH 04/15] chore(test): revert previous styling changes See: https://github.com/stackabletech/hbase-operator/pull/553#issuecomment-2318215071 --- .../templates/kuttl/overrides/31-assert.yaml | 58 ++++++------------- 1 file changed, 19 insertions(+), 39 deletions(-) diff --git a/tests/templates/kuttl/overrides/31-assert.yaml b/tests/templates/kuttl/overrides/31-assert.yaml index f4ac6f5c..9467e610 100644 --- a/tests/templates/kuttl/overrides/31-assert.yaml +++ b/tests/templates/kuttl/overrides/31-assert.yaml @@ -4,42 +4,22 @@ kind: TestAssert timeout: 30 commands: - script: | - #!/usr/bin/env bash - set -euo pipefail - - # POD Test Names - POD_MASTER=$(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/##') - POD_REGIONSERVER_ROLE=$(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/##') - POD_REGIONSERVER_ROLE_GROUP=$(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/##') - POD_RESTSERVER=$(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/##') - - # Config Test Data - POD_MASTER_DATA=$(kubectl -n "$NAMESPACE" get pod "$POD_MASTER" -o yaml) - POD_REGIONSERVER_ROLE_DATA=$(kubectl -n "$NAMESPACE" get pod "$POD_REGIONSERVER_ROLE" -o yaml) - POD_REGIONSERVER_ROLE_GROUP_DATA=$(kubectl -n "$NAMESPACE" get pod "$POD_REGIONSERVER_ROLE_GROUP" -o yaml) - POD_RESTSERVER_DATA=$(kubectl -n "$NAMESPACE" get pod "$POD_RESTSERVER" -o yaml) - - YQ_FILTER=' - .spec.containers[0].env[] - | select (.name == strenv(KEY) and .value == strenv(VALUE)) - ' - - # POD_MASTER Test Assertions - echo "$POD_MASTER_DATA" | KEY="TEST_VAR_FROM_MASTER" VALUE="MASTER" yq -e "$YQ_FILTER" - echo "$POD_MASTER_DATA" | KEY="TEST_VAR_FROM_MRG" VALUE="MASTER" yq -e "$YQ_FILTER" - echo "$POD_MASTER_DATA" | KEY="TEST_VAR" VALUE="MASTER_RG" yq -e "$YQ_FILTER" - - # POD_REGIONSERVER_ROLE Test Assertions - echo "$POD_REGIONSERVER_ROLE_DATA" | KEY="TEST_VAR_FROM_RS" VALUE="REGIONSERVER" yq -e "$YQ_FILTER" - echo "$POD_REGIONSERVER_ROLE_DATA" | KEY="TEST_VAR_FROM_RFR" VALUE="REGIONSERVER" yq -e "$YQ_FILTER" - echo "$POD_REGIONSERVER_ROLE_DATA" | KEY="TEST_VAR" VALUE="REGIONSERVER_RFR" yq -e "$YQ_FILTER" - - # POD_REGIONSERVER_ROLE_GROUP_DATA Test Assertions - echo "$POD_REGIONSERVER_ROLE_GROUP_DATA" | KEY="TEST_VAR_FROM_RS" VALUE="REGIONSERVER" yq -e "$YQ_FILTER" - echo "$POD_REGIONSERVER_ROLE_GROUP_DATA" | KEY="TEST_VAR_FROM_RFRG" VALUE="REGIONSERVER" yq -e "$YQ_FILTER" - echo "$POD_REGIONSERVER_ROLE_GROUP_DATA" | KEY="TEST_VAR" VALUE="REGIONSERVER_RFRG" yq -e "$YQ_FILTER" - - # POD_RESTSERVER_DATA Test Assertions - echo "$POD_RESTSERVER_DATA" | KEY="TEST_VAR_FROM_REST" VALUE="RESTSERVER" yq -e "$YQ_FILTER" - echo "$POD_RESTSERVER_DATA" | KEY="TEST_VAR_FROM_REST_RG" VALUE="RESTSERVER" yq -e "$YQ_FILTER" - echo "$POD_RESTSERVER_DATA" | KEY="TEST_VAR" VALUE="RESTSERVER_RG" yq -e "$YQ_FILTER" + 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' + - 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' + - 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' + - 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' From 6e99f7fdcae0d7c9948f03dbf32b3b4f66d6db3d Mon Sep 17 00:00:00 2001 From: Nick Larsen Date: Thu, 29 Aug 2024 18:12:32 +0200 Subject: [PATCH 05/15] chore(test): wrap variables in double quotes This would be picked up by `shellcheck` in CI if the script wasn't inlined. We should consider moving test scripts out of yaml files. --- .../templates/kuttl/overrides/31-assert.yaml | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/templates/kuttl/overrides/31-assert.yaml b/tests/templates/kuttl/overrides/31-assert.yaml index 9467e610..ee68a3b9 100644 --- a/tests/templates/kuttl/overrides/31-assert.yaml +++ b/tests/templates/kuttl/overrides/31-assert.yaml @@ -4,22 +4,22 @@ kind: TestAssert timeout: 30 commands: - 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' + 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' - 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' + 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' - 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' + 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' - 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' + 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' From e43955d99ab837fb1670ad36b0df0079db02d44c Mon Sep 17 00:00:00 2001 From: Nick Larsen Date: Thu, 29 Aug 2024 18:13:38 +0200 Subject: [PATCH 06/15] chore(test): use bash strict mode According to [kuttl docs], scripts are executed via `sh -c`. The docs do not suggest if strict mode is enabled, so we should set it. There also doesn't seem to be a way to choose the shell (whithout calling a shell youself from within the script). Without strict mode on, only the final commands exist status is considered - meaning assertions before the last could fail and never be picked up. [kuttl docs]: https://kuttl.dev/docs/testing/steps.html#shell-scripts --- tests/templates/kuttl/overrides/31-assert.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/templates/kuttl/overrides/31-assert.yaml b/tests/templates/kuttl/overrides/31-assert.yaml index ee68a3b9..b61bd075 100644 --- a/tests/templates/kuttl/overrides/31-assert.yaml +++ b/tests/templates/kuttl/overrides/31-assert.yaml @@ -4,21 +4,25 @@ kind: TestAssert timeout: 30 commands: - script: | + set -euo pipefail 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' - script: | + set -euo pipefail 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' - script: | + set -euo pipefail 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' - script: | + set -euo pipefail 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' From 0826712ba3617b04676356c525bfb3e7ac3d3fd6 Mon Sep 17 00:00:00 2001 From: Nick Larsen Date: Thu, 29 Aug 2024 18:26:44 +0200 Subject: [PATCH 07/15] chore(test): add comments to tests It might seem trivial, but it can help reviewers quickly understand what the command line is for, and quickly assert whether that lines up with what the command line is actually doing. --- tests/templates/kuttl/overrides/31-assert.yaml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/templates/kuttl/overrides/31-assert.yaml b/tests/templates/kuttl/overrides/31-assert.yaml index b61bd075..d5307538 100644 --- a/tests/templates/kuttl/overrides/31-assert.yaml +++ b/tests/templates/kuttl/overrides/31-assert.yaml @@ -5,25 +5,41 @@ timeout: 30 commands: - script: | set -euo pipefail + + # Get the name of the first pod by labels 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/##') + + # Assert that environment variables contain the correct values 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' - script: | set -euo pipefail + + # Get the name of the first pod by labels 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/##') + + # Assert that environment variables contain the correct values 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' - script: | set -euo pipefail + + # Get the name of the first pod by labels 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/##') + + # Assert that environment variables contain the correct values 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' - script: | set -euo pipefail + + # Get the name of the first pod by labels 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/##') + + # Assert that environment variables contain the correct values 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' From 49434454765301c5b68fc9c2d2650dee161f3e46 Mon Sep 17 00:00:00 2001 From: Nick Larsen Date: Thu, 29 Aug 2024 18:29:18 +0200 Subject: [PATCH 08/15] chore(test): make assertions more precise with exact matching with grep We should test exact matches with grep. By default, `yq` will output strings with double quotes, so those should be removed with `-r` or `--unwrapScalar` for yq-go (the python yq which has the same options as jq can use `-r` or `--raw-output`). Note: I just leart about the `-w` option, which would remove the need for '^$'. --- .../templates/kuttl/overrides/31-assert.yaml | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/templates/kuttl/overrides/31-assert.yaml b/tests/templates/kuttl/overrides/31-assert.yaml index d5307538..b85dea03 100644 --- a/tests/templates/kuttl/overrides/31-assert.yaml +++ b/tests/templates/kuttl/overrides/31-assert.yaml @@ -9,37 +9,37 @@ commands: # Get the name of the first pod by labels 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/##') - # Assert that environment variables contain the correct values - 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' + # Assert that environment variables have the correct values + kubectl -n "$NAMESPACE" get pod "$POD" -o yaml | yq -r '.spec.containers[0].env[] | select (.name == "TEST_VAR_FROM_MASTER").value' | grep '^MASTER$' + kubectl -n "$NAMESPACE" get pod "$POD" -o yaml | yq -r '.spec.containers[0].env[] | select (.name == "TEST_VAR_FROM_MRG").value' | grep '^MASTER$' + kubectl -n "$NAMESPACE" get pod "$POD" -o yaml | yq -r '.spec.containers[0].env[] | select (.name == "TEST_VAR").value' | grep '^MASTER_RG$' - script: | set -euo pipefail # Get the name of the first pod by labels 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/##') - # Assert that environment variables contain the correct values - 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' + # Assert that environment variables have the correct values + kubectl -n "$NAMESPACE" get pod "$POD" -o yaml | yq -r '.spec.containers[0].env[] | select (.name == "TEST_VAR_FROM_RS").value' | grep '^REGIONSERVER$' + kubectl -n "$NAMESPACE" get pod "$POD" -o yaml | yq -r '.spec.containers[0].env[] | select (.name == "TEST_VAR_FROM_RFR").value' | grep '^REGIONSERVER$' + kubectl -n "$NAMESPACE" get pod "$POD" -o yaml | yq -r '.spec.containers[0].env[] | select (.name == "TEST_VAR").value' | grep '^REGIONSERVER_RFR$' - script: | set -euo pipefail # Get the name of the first pod by labels 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/##') - # Assert that environment variables contain the correct values - 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' + # Assert that environment variables have the correct values + kubectl -n "$NAMESPACE" get pod "$POD" -o yaml | yq -r '.spec.containers[0].env[] | select (.name == "TEST_VAR_FROM_RS").value' | grep '^REGIONSERVER$' + kubectl -n "$NAMESPACE" get pod "$POD" -o yaml | yq -r '.spec.containers[0].env[] | select (.name == "TEST_VAR_FROM_RFRG").value' | grep '^REGIONSERVER$' + kubectl -n "$NAMESPACE" get pod "$POD" -o yaml | yq -r '.spec.containers[0].env[] | select (.name == "TEST_VAR").value' | grep '^REGIONSERVER_RFRG$' - script: | set -euo pipefail # Get the name of the first pod by labels 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/##') - # Assert that environment variables contain the correct values - 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' + # Assert that environment variables have the correct values + kubectl -n "$NAMESPACE" get pod "$POD" -o yaml | yq -r '.spec.containers[0].env[] | select (.name == "TEST_VAR_FROM_REST").value' | grep '^RESTSERVER$' + kubectl -n "$NAMESPACE" get pod "$POD" -o yaml | yq -r '.spec.containers[0].env[] | select (.name == "TEST_VAR_FROM_REST_RG").value' | grep '^RESTSERVER$' + kubectl -n "$NAMESPACE" get pod "$POD" -o yaml | yq -r '.spec.containers[0].env[] | select (.name == "TEST_VAR").value' | grep '^RESTSERVER_RG$' From 730d506e51d825a66187d55005bde49eb7b6b832 Mon Sep 17 00:00:00 2001 From: Nick Larsen Date: Thu, 29 Aug 2024 18:47:42 +0200 Subject: [PATCH 09/15] chore(test): split long commands into multi-line commands, split label options into multiple args Instead of splitting by line-length, I am: - Splitting by pipe - Splitting by flag/option This is to make reviews simpler when using split panes (side-by-side). --- .../templates/kuttl/overrides/31-assert.yaml | 98 ++++++++++++++++--- 1 file changed, 82 insertions(+), 16 deletions(-) diff --git a/tests/templates/kuttl/overrides/31-assert.yaml b/tests/templates/kuttl/overrides/31-assert.yaml index b85dea03..2f2a727f 100644 --- a/tests/templates/kuttl/overrides/31-assert.yaml +++ b/tests/templates/kuttl/overrides/31-assert.yaml @@ -3,43 +3,109 @@ apiVersion: kuttl.dev/v1beta1 kind: TestAssert timeout: 30 commands: + # master, default RG - script: | set -euo pipefail # Get the name of the first pod by labels - 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/##') + 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 -n "$NAMESPACE" get pod "$POD" -o yaml | yq -r '.spec.containers[0].env[] | select (.name == "TEST_VAR_FROM_MASTER").value' | grep '^MASTER$' - kubectl -n "$NAMESPACE" get pod "$POD" -o yaml | yq -r '.spec.containers[0].env[] | select (.name == "TEST_VAR_FROM_MRG").value' | grep '^MASTER$' - kubectl -n "$NAMESPACE" get pod "$POD" -o yaml | yq -r '.spec.containers[0].env[] | select (.name == "TEST_VAR").value' | grep '^MASTER_RG$' + 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: | set -euo pipefail # Get the name of the first pod by labels - 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/##') + 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 -n "$NAMESPACE" get pod "$POD" -o yaml | yq -r '.spec.containers[0].env[] | select (.name == "TEST_VAR_FROM_RS").value' | grep '^REGIONSERVER$' - kubectl -n "$NAMESPACE" get pod "$POD" -o yaml | yq -r '.spec.containers[0].env[] | select (.name == "TEST_VAR_FROM_RFR").value' | grep '^REGIONSERVER$' - kubectl -n "$NAMESPACE" get pod "$POD" -o yaml | yq -r '.spec.containers[0].env[] | select (.name == "TEST_VAR").value' | grep '^REGIONSERVER_RFR$' + 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: | set -euo pipefail # Get the name of the first pod by labels - 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/##') + 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 -n "$NAMESPACE" get pod "$POD" -o yaml | yq -r '.spec.containers[0].env[] | select (.name == "TEST_VAR_FROM_RS").value' | grep '^REGIONSERVER$' - kubectl -n "$NAMESPACE" get pod "$POD" -o yaml | yq -r '.spec.containers[0].env[] | select (.name == "TEST_VAR_FROM_RFRG").value' | grep '^REGIONSERVER$' - kubectl -n "$NAMESPACE" get pod "$POD" -o yaml | yq -r '.spec.containers[0].env[] | select (.name == "TEST_VAR").value' | grep '^REGIONSERVER_RFRG$' + 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: | set -euo pipefail # Get the name of the first pod by labels - 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/##') + 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 -n "$NAMESPACE" get pod "$POD" -o yaml | yq -r '.spec.containers[0].env[] | select (.name == "TEST_VAR_FROM_REST").value' | grep '^RESTSERVER$' - kubectl -n "$NAMESPACE" get pod "$POD" -o yaml | yq -r '.spec.containers[0].env[] | select (.name == "TEST_VAR_FROM_REST_RG").value' | grep '^RESTSERVER$' - kubectl -n "$NAMESPACE" get pod "$POD" -o yaml | yq -r '.spec.containers[0].env[] | select (.name == "TEST_VAR").value' | grep '^RESTSERVER_RG$' + 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$' + From fc6fd797c76689c7fd8d2fd115e42fa6e715217e Mon Sep 17 00:00:00 2001 From: Nick Larsen Date: Thu, 29 Aug 2024 18:54:53 +0200 Subject: [PATCH 10/15] chore(test): suggestion: use long-options where possible I went to town on this one. You could argue that trivial cases (eg: `sed -e`) are ok. This is just for demonstration. --- .../templates/kuttl/overrides/31-assert.yaml | 94 ++++++++++--------- 1 file changed, 49 insertions(+), 45 deletions(-) diff --git a/tests/templates/kuttl/overrides/31-assert.yaml b/tests/templates/kuttl/overrides/31-assert.yaml index 2f2a727f..3e1a7188 100644 --- a/tests/templates/kuttl/overrides/31-assert.yaml +++ b/tests/templates/kuttl/overrides/31-assert.yaml @@ -9,25 +9,25 @@ commands: # 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/##' + kubectl get pod --namespace "$NAMESPACE" \ + --label app.kubernetes.io/component=master \ + --label app.kubernetes.io/role-group=default \ + --output name \ + | head --lines 1 \ + | sed --expression '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' \ + kubectl get pod "$POD" --namespace "$NAMESPACE" --output yaml \ + | yq --unwrapScalar '.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' \ + kubectl get pod "$POD" --namespace "$NAMESPACE" --output yaml \ + | yq --unwrapScalar '.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' \ + kubectl get pod "$POD" --namespace "$NAMESPACE" --output yaml \ + | yq --unwrapScalar '.spec.containers[0].env[] | select (.name == "TEST_VAR").value' \ | grep '^MASTER_RG$' # regionserver, resources-from-role RG @@ -36,25 +36,26 @@ commands: # 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/##' + kubectl get pod \ + --namespace "$NAMESPACE" \ + --label app.kubernetes.io/component=regionserver \ + --label app.kubernetes.io/role-group=resources-from-role \ + --output name \ + | head --lines 1 \ + | sed --expression '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' \ + kubectl get pod "$POD" --namespace "$NAMESPACE" --output yaml \ + | yq --unwrapScalar '.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' \ + kubectl get pod "$POD" --namespace "$NAMESPACE" --output yaml \ + | yq --unwrapScalar '.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' \ + kubectl get pod "$POD" --namespace "$NAMESPACE" --output yaml \ + | yq --unwrapScalar '.spec.containers[0].env[] | select (.name == "TEST_VAR").value' \ | grep '^REGIONSERVER_RFR$' # regionserver, resources-from-role-group RG @@ -64,23 +65,25 @@ commands: # 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/##' + --namespace "$NAMESPACE" \ + --label app.kubernetes.io/component=regionserver \ + --label app.kubernetes.io/role-group=resources-from-role-group \ + --output name \ + | head --lines 1 \ + | sed --expression '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' \ + kubectl get pod "$POD" --namespace "$NAMESPACE" --output yaml \ + | yq --unwrapScalar '.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' \ + kubectl get pod "$POD" --namespace "$NAMESPACE" --output yaml \ + | yq --unwrapScalar '.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' \ + kubectl get pod "$POD" --namespace "$NAMESPACE" --output yaml \ + | yq --unwrapScalar '.spec.containers[0].env[] | select (.name == "TEST_VAR").value' \ | grep '^REGIONSERVER_RFRG$' # restserver, default RG @@ -90,22 +93,23 @@ commands: # 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/##' + --namespace "$NAMESPACE" \ + --label app.kubernetes.io/component=restserver \ + --label app.kubernetes.io/role-group=default \ + --output name \ + | head --lines 1 \ + | sed --expression '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' \ + kubectl get pod "$POD" --namespace "$NAMESPACE" --output yaml \ + | yq --unwrapScalar '.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' \ + kubectl get pod "$POD" --namespace "$NAMESPACE" --output yaml \ + | yq --unwrapScalar '.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' \ + kubectl get pod "$POD" --namespace "$NAMESPACE" --output yaml \ + | yq --unwrapScalar '.spec.containers[0].env[] | select (.name == "TEST_VAR").value' \ | grep '^RESTSERVER_RG$' - From 24ed1ed73b6506a4b99aad7bf2fd597f0a75db9a Mon Sep 17 00:00:00 2001 From: Nick Larsen Date: Thu, 29 Aug 2024 19:37:29 +0200 Subject: [PATCH 11/15] chore(test): fix yamllint --- tests/templates/kuttl/overrides/31-assert.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/templates/kuttl/overrides/31-assert.yaml b/tests/templates/kuttl/overrides/31-assert.yaml index 3e1a7188..d90f6404 100644 --- a/tests/templates/kuttl/overrides/31-assert.yaml +++ b/tests/templates/kuttl/overrides/31-assert.yaml @@ -3,7 +3,7 @@ apiVersion: kuttl.dev/v1beta1 kind: TestAssert timeout: 30 commands: - # master, default RG + # master, default RG - script: | set -euo pipefail @@ -30,7 +30,7 @@ commands: | yq --unwrapScalar '.spec.containers[0].env[] | select (.name == "TEST_VAR").value' \ | grep '^MASTER_RG$' - # regionserver, resources-from-role RG + # regionserver, resources-from-role RG - script: | set -euo pipefail @@ -58,7 +58,7 @@ commands: | yq --unwrapScalar '.spec.containers[0].env[] | select (.name == "TEST_VAR").value' \ | grep '^REGIONSERVER_RFR$' - # regionserver, resources-from-role-group RG + # regionserver, resources-from-role-group RG - script: | set -euo pipefail @@ -86,7 +86,7 @@ commands: | yq --unwrapScalar '.spec.containers[0].env[] | select (.name == "TEST_VAR").value' \ | grep '^REGIONSERVER_RFRG$' - # restserver, default RG + # restserver, default RG - script: | set -euo pipefail From 5f0b874fd15609fd67e858587aac29db5267ea1f Mon Sep 17 00:00:00 2001 From: Nick Larsen Date: Mon, 2 Sep 2024 09:34:37 +0200 Subject: [PATCH 12/15] Revert "chore(test): suggestion: use long-options where possible" This reverts commit fc6fd797c76689c7fd8d2fd115e42fa6e715217e. --- .../templates/kuttl/overrides/31-assert.yaml | 94 +++++++++---------- 1 file changed, 45 insertions(+), 49 deletions(-) diff --git a/tests/templates/kuttl/overrides/31-assert.yaml b/tests/templates/kuttl/overrides/31-assert.yaml index d90f6404..1673bc8e 100644 --- a/tests/templates/kuttl/overrides/31-assert.yaml +++ b/tests/templates/kuttl/overrides/31-assert.yaml @@ -9,25 +9,25 @@ commands: # Get the name of the first pod by labels POD=$( - kubectl get pod --namespace "$NAMESPACE" \ - --label app.kubernetes.io/component=master \ - --label app.kubernetes.io/role-group=default \ - --output name \ - | head --lines 1 \ - | sed --expression 's#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" --namespace "$NAMESPACE" --output yaml \ - | yq --unwrapScalar '.spec.containers[0].env[] | select (.name == "TEST_VAR_FROM_MASTER").value' \ + 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" --namespace "$NAMESPACE" --output yaml \ - | yq --unwrapScalar '.spec.containers[0].env[] | select (.name == "TEST_VAR_FROM_MRG").value' \ + 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" --namespace "$NAMESPACE" --output yaml \ - | yq --unwrapScalar '.spec.containers[0].env[] | select (.name == "TEST_VAR").value' \ + 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 @@ -36,26 +36,25 @@ commands: # Get the name of the first pod by labels POD=$( - kubectl get pod \ - --namespace "$NAMESPACE" \ - --label app.kubernetes.io/component=regionserver \ - --label app.kubernetes.io/role-group=resources-from-role \ - --output name \ - | head --lines 1 \ - | sed --expression 's#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" --namespace "$NAMESPACE" --output yaml \ - | yq --unwrapScalar '.spec.containers[0].env[] | select (.name == "TEST_VAR_FROM_RS").value' \ + 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" --namespace "$NAMESPACE" --output yaml \ - | yq --unwrapScalar '.spec.containers[0].env[] | select (.name == "TEST_VAR_FROM_RFR").value' \ + 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" --namespace "$NAMESPACE" --output yaml \ - | yq --unwrapScalar '.spec.containers[0].env[] | select (.name == "TEST_VAR").value' \ + 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 @@ -65,25 +64,23 @@ commands: # Get the name of the first pod by labels POD=$( kubectl get pod \ - --namespace "$NAMESPACE" \ - --label app.kubernetes.io/component=regionserver \ - --label app.kubernetes.io/role-group=resources-from-role-group \ - --output name \ - | head --lines 1 \ - | sed --expression 's#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" --namespace "$NAMESPACE" --output yaml \ - | yq --unwrapScalar '.spec.containers[0].env[] | select (.name == "TEST_VAR_FROM_RS").value' \ + 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" --namespace "$NAMESPACE" --output yaml \ - | yq --unwrapScalar '.spec.containers[0].env[] | select (.name == "TEST_VAR_FROM_RFRG").value' \ + 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" --namespace "$NAMESPACE" --output yaml \ - | yq --unwrapScalar '.spec.containers[0].env[] | select (.name == "TEST_VAR").value' \ + 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 @@ -93,23 +90,22 @@ commands: # Get the name of the first pod by labels POD=$( kubectl get pod \ - --namespace "$NAMESPACE" \ - --label app.kubernetes.io/component=restserver \ - --label app.kubernetes.io/role-group=default \ - --output name \ - | head --lines 1 \ - | sed --expression 's#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" --namespace "$NAMESPACE" --output yaml \ - | yq --unwrapScalar '.spec.containers[0].env[] | select (.name == "TEST_VAR_FROM_REST").value' \ + 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" --namespace "$NAMESPACE" --output yaml \ - | yq --unwrapScalar '.spec.containers[0].env[] | select (.name == "TEST_VAR_FROM_REST_RG").value' \ + 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" --namespace "$NAMESPACE" --output yaml \ - | yq --unwrapScalar '.spec.containers[0].env[] | select (.name == "TEST_VAR").value' \ + kubectl get pod "$POD" -n "$NAMESPACE" -o yaml \ + | yq -r '.spec.containers[0].env[] | select (.name == "TEST_VAR").value' \ | grep '^RESTSERVER_RG$' + From 75d6eb13e6b84a33d1281ac1b5e802f3ff94d219 Mon Sep 17 00:00:00 2001 From: Nick Larsen Date: Mon, 2 Sep 2024 09:38:17 +0200 Subject: [PATCH 13/15] chore(test): fix yamllint --- tests/templates/kuttl/overrides/31-assert.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/templates/kuttl/overrides/31-assert.yaml b/tests/templates/kuttl/overrides/31-assert.yaml index 1673bc8e..a9f9d4b0 100644 --- a/tests/templates/kuttl/overrides/31-assert.yaml +++ b/tests/templates/kuttl/overrides/31-assert.yaml @@ -108,4 +108,3 @@ commands: kubectl get pod "$POD" -n "$NAMESPACE" -o yaml \ | yq -r '.spec.containers[0].env[] | select (.name == "TEST_VAR").value' \ | grep '^RESTSERVER_RG$' - From 62dd3cbaa409651278449539d0ca74f2f3fed2ce Mon Sep 17 00:00:00 2001 From: Nick Larsen Date: Tue, 3 Sep 2024 10:01:11 +0200 Subject: [PATCH 14/15] chore(test): remove -o pipefail bash option --- tests/templates/kuttl/overrides/31-assert.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/templates/kuttl/overrides/31-assert.yaml b/tests/templates/kuttl/overrides/31-assert.yaml index a9f9d4b0..cb579e43 100644 --- a/tests/templates/kuttl/overrides/31-assert.yaml +++ b/tests/templates/kuttl/overrides/31-assert.yaml @@ -5,7 +5,7 @@ timeout: 30 commands: # master, default RG - script: | - set -euo pipefail + set -eu # Get the name of the first pod by labels POD=$( @@ -32,7 +32,7 @@ commands: # regionserver, resources-from-role RG - script: | - set -euo pipefail + set -eu # Get the name of the first pod by labels POD=$( @@ -59,7 +59,7 @@ commands: # regionserver, resources-from-role-group RG - script: | - set -euo pipefail + set -eu # Get the name of the first pod by labels POD=$( @@ -85,7 +85,7 @@ commands: # restserver, default RG - script: | - set -euo pipefail + set -eu # Get the name of the first pod by labels POD=$( From 980a1c68ba2b6a14cbfef3f7086c12d76362e95e Mon Sep 17 00:00:00 2001 From: Nick Larsen Date: Tue, 3 Sep 2024 10:13:44 +0200 Subject: [PATCH 15/15] chore(test): undo ORed labels --- tests/templates/kuttl/overrides/31-assert.yaml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/tests/templates/kuttl/overrides/31-assert.yaml b/tests/templates/kuttl/overrides/31-assert.yaml index cb579e43..87d01193 100644 --- a/tests/templates/kuttl/overrides/31-assert.yaml +++ b/tests/templates/kuttl/overrides/31-assert.yaml @@ -10,8 +10,7 @@ commands: # 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 \ + -l app.kubernetes.io/component=master,app.kubernetes.io/role-group=default \ -o name \ | head -n 1 \ | sed -e 's#pod/##' @@ -37,8 +36,7 @@ commands: # 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 \ + -l app.kubernetes.io/component=regionserver,app.kubernetes.io/role-group=resources-from-role \ -o name \ | head -n 1 \ | sed -e 's#pod/##' @@ -65,8 +63,7 @@ commands: POD=$( kubectl get pod \ -n "$NAMESPACE" \ - -l app.kubernetes.io/component=regionserver \ - -l app.kubernetes.io/role-group=resources-from-role-group \ + -l app.kubernetes.io/component=regionserver,app.kubernetes.io/role-group=resources-from-role-group \ -o name | head -n 1 | sed -e 's#pod/##' ) @@ -91,8 +88,7 @@ commands: POD=$( kubectl get pod \ -n "$NAMESPACE" \ - -l app.kubernetes.io/component=restserver \ - -l app.kubernetes.io/role-group=default \ + -l app.kubernetes.io/component=restserver,app.kubernetes.io/role-group=default \ -o name | head -n 1 | sed -e 's#pod/##' )