From a7e17c39761fac710fda4770948ec8766c395e43 Mon Sep 17 00:00:00 2001 From: Maximilian Wittich <56642549+Maleware@users.noreply.github.com> Date: Thu, 29 Aug 2024 10:13:24 +0200 Subject: [PATCH] Adopting according to new readability and code style (#618) --- .../templates/kuttl/overrides/21-assert.yaml | 59 ++++++++++------ .../templates/kuttl/overrides/22-assert.yaml | 68 +++++++++++++------ 2 files changed, 89 insertions(+), 38 deletions(-) diff --git a/tests/templates/kuttl/overrides/21-assert.yaml b/tests/templates/kuttl/overrides/21-assert.yaml index 82f4ea70..b0819aff 100644 --- a/tests/templates/kuttl/overrides/21-assert.yaml +++ b/tests/templates/kuttl/overrides/21-assert.yaml @@ -7,22 +7,43 @@ commands: # Test envOverrides # - script: | - kubectl -n $NAMESPACE get sts druid-broker-default -o yaml | yq -e '.spec.template.spec.containers[] | select (.name == "druid") | .env[] | select (.name == "COMMON_VAR" and .value == "group-value")' - kubectl -n $NAMESPACE get sts druid-broker-default -o yaml | yq -e '.spec.template.spec.containers[] | select (.name == "druid") | .env[] | select (.name == "GROUP_VAR" and .value == "group-value")' - kubectl -n $NAMESPACE get sts druid-broker-default -o yaml | yq -e '.spec.template.spec.containers[] | select (.name == "druid") | .env[] | select (.name == "ROLE_VAR" and .value == "role-value")' - - script: | - kubectl -n $NAMESPACE get sts druid-coordinator-default -o yaml | yq -e '.spec.template.spec.containers[] | select (.name == "druid") | .env[] | select (.name == "COMMON_VAR" and .value == "group-value")' - kubectl -n $NAMESPACE get sts druid-coordinator-default -o yaml | yq -e '.spec.template.spec.containers[] | select (.name == "druid") | .env[] | select (.name == "GROUP_VAR" and .value == "group-value")' - kubectl -n $NAMESPACE get sts druid-coordinator-default -o yaml | yq -e '.spec.template.spec.containers[] | select (.name == "druid") | .env[] | select (.name == "ROLE_VAR" and .value == "role-value")' - - script: | - kubectl -n $NAMESPACE get sts druid-historical-default -o yaml | yq -e '.spec.template.spec.containers[] | select (.name == "druid") | .env[] | select (.name == "COMMON_VAR" and .value == "group-value")' - kubectl -n $NAMESPACE get sts druid-historical-default -o yaml | yq -e '.spec.template.spec.containers[] | select (.name == "druid") | .env[] | select (.name == "GROUP_VAR" and .value == "group-value")' - kubectl -n $NAMESPACE get sts druid-historical-default -o yaml | yq -e '.spec.template.spec.containers[] | select (.name == "druid") | .env[] | select (.name == "ROLE_VAR" and .value == "role-value")' - - script: | - kubectl -n $NAMESPACE get sts druid-middlemanager-default -o yaml | yq -e '.spec.template.spec.containers[] | select (.name == "druid") | .env[] | select (.name == "COMMON_VAR" and .value == "group-value")' - kubectl -n $NAMESPACE get sts druid-middlemanager-default -o yaml | yq -e '.spec.template.spec.containers[] | select (.name == "druid") | .env[] | select (.name == "GROUP_VAR" and .value == "group-value")' - kubectl -n $NAMESPACE get sts druid-middlemanager-default -o yaml | yq -e '.spec.template.spec.containers[] | select (.name == "druid") | .env[] | select (.name == "ROLE_VAR" and .value == "role-value")' - - script: | - kubectl -n $NAMESPACE get sts druid-router-default -o yaml | yq -e '.spec.template.spec.containers[] | select (.name == "druid") | .env[] | select (.name == "COMMON_VAR" and .value == "group-value")' - kubectl -n $NAMESPACE get sts druid-router-default -o yaml | yq -e '.spec.template.spec.containers[] | select (.name == "druid") | .env[] | select (.name == "GROUP_VAR" and .value == "group-value")' - kubectl -n $NAMESPACE get sts druid-router-default -o yaml | yq -e '.spec.template.spec.containers[] | select (.name == "druid") | .env[] | select (.name == "ROLE_VAR" and .value == "role-value")' + #!/usr/bin/env bash + set -euo pipefail + + # STS Spec Test Data + DRUID_BROKER_STS=$( kubectl -n "$NAMESPACE" get sts druid-broker-default -o yaml ) + DRUID_COORDINATOR_STS=$( kubectl -n "$NAMESPACE" get sts druid-coordinator-default -o yaml ) + DRUID_HISTORICAL_STS=$( kubectl -n "$NAMESPACE" get sts druid-historical-default -o yaml ) + DRUID_MIDDLEMANAGER_STS=$( kubectl -n "$NAMESPACE" get sts druid-middlemanager-default -o yaml ) + DRUID_ROUTER_STS=$( kubectl -n "$NAMESPACE" get sts druid-router-default -o yaml ) + YQ_FILTER=' + .spec.template.spec.containers[] + | select (.name == "druid") + | .env[] + | select (.name == strenv(KEY) and .value == strenv(VALUE)) + ' + + # DRUID_BROKER_STS Spec Test Assertions + echo "$DRUID_BROKER_STS" | KEY="COMMON_VAR" VALUE="group-value" yq -e "$YQ_FILTER" + echo "$DRUID_BROKER_STS" | KEY="GROUP_VAR" VALUE="group-value" yq -e "$YQ_FILTER" + echo "$DRUID_BROKER_STS" | KEY="ROLE_VAR" VALUE="role-value" yq -e "$YQ_FILTER" + + # DRUID_COORDINATOR_STS Spec Test Assertions + echo "$DRUID_COORDINATOR_STS" | KEY="COMMON_VAR" VALUE="group-value" yq -e "$YQ_FILTER" + echo "$DRUID_COORDINATOR_STS" | KEY="GROUP_VAR" VALUE="group-value" yq -e "$YQ_FILTER" + echo "$DRUID_COORDINATOR_STS" | KEY="ROLE_VAR" VALUE="role-value" yq -e "$YQ_FILTER" + + # DRUID_HISTORICAL_STS Spec Test Assertions + echo "$DRUID_HISTORICAL_STS" | KEY="COMMON_VAR" VALUE="group-value" yq -e "$YQ_FILTER" + echo "$DRUID_HISTORICAL_STS" | KEY="GROUP_VAR" VALUE="group-value" yq -e "$YQ_FILTER" + echo "$DRUID_HISTORICAL_STS" | KEY="ROLE_VAR" VALUE="role-value" yq -e "$YQ_FILTER" + + # DRUID_MIDDLEMANAGER_STS Spec Test Assertions + echo "$DRUID_MIDDLEMANAGER_STS" | KEY="COMMON_VAR" VALUE="group-value" yq -e "$YQ_FILTER" + echo "$DRUID_MIDDLEMANAGER_STS" | KEY="GROUP_VAR" VALUE="group-value" yq -e "$YQ_FILTER" + echo "$DRUID_MIDDLEMANAGER_STS" | KEY="ROLE_VAR" VALUE="role-value" yq -e "$YQ_FILTER" + + # DRUID_ROUTER_STS Spec Test Assertions + echo "$DRUID_ROUTER_STS" | KEY="COMMON_VAR" VALUE="group-value" yq -e "$YQ_FILTER" + echo "$DRUID_ROUTER_STS" | KEY="GROUP_VAR" VALUE="group-value" yq -e "$YQ_FILTER" + echo "$DRUID_ROUTER_STS" | KEY="ROLE_VAR" VALUE="role-value" yq -e "$YQ_FILTER" diff --git a/tests/templates/kuttl/overrides/22-assert.yaml b/tests/templates/kuttl/overrides/22-assert.yaml index 216a3ac8..b4e6c188 100644 --- a/tests/templates/kuttl/overrides/22-assert.yaml +++ b/tests/templates/kuttl/overrides/22-assert.yaml @@ -7,22 +7,52 @@ commands: # Test configOverrides # - script: | - kubectl -n $NAMESPACE get cm druid-broker-default -o yaml | yq -e '.data."runtime.properties"' | grep "prop.common=group-value" - kubectl -n $NAMESPACE get cm druid-broker-default -o yaml | yq -e '.data."runtime.properties"' | grep "prop.group=group-value" - kubectl -n $NAMESPACE get cm druid-broker-default -o yaml | yq -e '.data."runtime.properties"' | grep "prop.role=role-value" - - script: | - kubectl -n $NAMESPACE get cm druid-coordinator-default -o yaml | yq -e '.data."runtime.properties"' | grep "prop.common=group-value" - kubectl -n $NAMESPACE get cm druid-coordinator-default -o yaml | yq -e '.data."runtime.properties"' | grep "prop.group=group-value" - kubectl -n $NAMESPACE get cm druid-coordinator-default -o yaml | yq -e '.data."runtime.properties"' | grep "prop.role=role-value" - - script: | - kubectl -n $NAMESPACE get cm druid-historical-default -o yaml | yq -e '.data."runtime.properties"' | grep "prop.common=group-value" - kubectl -n $NAMESPACE get cm druid-historical-default -o yaml | yq -e '.data."runtime.properties"' | grep "prop.group=group-value" - kubectl -n $NAMESPACE get cm druid-historical-default -o yaml | yq -e '.data."runtime.properties"' | grep "prop.role=role-value" - - script: | - kubectl -n $NAMESPACE get cm druid-middlemanager-default -o yaml | yq -e '.data."runtime.properties"' | grep "prop.common=group-value" - kubectl -n $NAMESPACE get cm druid-middlemanager-default -o yaml | yq -e '.data."runtime.properties"' | grep "prop.group=group-value" - kubectl -n $NAMESPACE get cm druid-middlemanager-default -o yaml | yq -e '.data."runtime.properties"' | grep "prop.role=role-value" - - script: | - kubectl -n $NAMESPACE get cm druid-router-default -o yaml | yq -e '.data."runtime.properties"' | grep "prop.common=group-value" - kubectl -n $NAMESPACE get cm druid-router-default -o yaml | yq -e '.data."runtime.properties"' | grep "prop.group=group-value" - kubectl -n $NAMESPACE get cm druid-router-default -o yaml | yq -e '.data."runtime.properties"' | grep "prop.role=role-value" + #!/usr/bin/env bash + set -euo pipefail + + # Config Test Data + DRUID_BROKER_CONFIG=$( + kubectl -n "$NAMESPACE" get cm druid-broker-default -o yaml \ + | yq -e '.data."runtime.properties"' + ) + DRUID_COORDINATOR_CONFIG=$( + kubectl -n "$NAMESPACE" get cm druid-coordinator-default -o yaml \ + | yq -e '.data."runtime.properties"' + ) + DRUID_HISTORICAL_CONFIG=$( + kubectl -n "$NAMESPACE" get cm druid-historical-default -o yaml \ + | yq -e '.data."runtime.properties"' + ) + DRUID_MIDDLEMANAGER_CONFIG=$( + kubectl -n "$NAMESPACE" get cm druid-middlemanager-default -o yaml \ + | yq -e '.data."runtime.properties"' + ) + DRUID_ROUTER_CONFIG=$( + kubectl -n "$NAMESPACE" get cm druid-router-default -o yaml \ + | yq -e '.data."runtime.properties"' + ) + + # DRUID_BROKER_CONFIG Test Assertions + echo "$DRUID_BROKER_CONFIG" | grep "prop.common=group-value" + echo "$DRUID_BROKER_CONFIG" | grep "prop.group=group-value" + echo "$DRUID_BROKER_CONFIG" | grep "prop.role=role-value" + + # DRUID_COORDINATOR_CONFIG Test Assertions + echo "$DRUID_COORDINATOR_CONFIG" | grep "prop.common=group-value" + echo "$DRUID_COORDINATOR_CONFIG" | grep "prop.group=group-value" + echo "$DRUID_COORDINATOR_CONFIG" | grep "prop.role=role-value" + + # DRUID_HISTORICAL_CONFIG Test Assertions + echo "$DRUID_HISTORICAL_CONFIG" | grep "prop.common=group-value" + echo "$DRUID_HISTORICAL_CONFIG" | grep "prop.group=group-value" + echo "$DRUID_HISTORICAL_CONFIG" | grep "prop.role=role-value" + + # DRUID_MIDDLEMANAGER_CONFIG Test Assertions + echo "$DRUID_MIDDLEMANAGER_CONFIG" | grep "prop.common=group-value" + echo "$DRUID_MIDDLEMANAGER_CONFIG" | grep "prop.group=group-value" + echo "$DRUID_MIDDLEMANAGER_CONFIG" | grep "prop.role=role-value" + + # DRUID_ROUTER_CONFIG Test Assertions + echo "$DRUID_ROUTER_CONFIG" | grep "prop.common=group-value" + echo "$DRUID_ROUTER_CONFIG" | grep "prop.group=group-value" + echo "$DRUID_ROUTER_CONFIG" | grep "prop.role=role-value"