Skip to content

Commit

Permalink
chore(test-resources): don't run tests against remote K8s contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
basti1302 committed Jul 3, 2024
1 parent 1866be6 commit 89f9242
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions test-resources/.env.template
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
DASH0_OTEL_EXPORTER_OTLP_ENDPOINT=ingress.eu-west-1.aws.dash0-dev.com:4317
DASH0_AUTHORIZATION_TOKEN=
LOCAL_KUBECTX=docker-desktop
4 changes: 4 additions & 0 deletions test-resources/bin/test-cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ cd "$(dirname ${BASH_SOURCE})"/../..
target_namespace=${1:-test-namespace}
delete_namespace=${2:-true}

source test-resources/bin/util
load_env_file
verify_kubectx

kubectl delete -n ${target_namespace} -k config/samples || true

make undeploy-via-helm || true
Expand Down
1 change: 1 addition & 0 deletions test-resources/bin/test-roundtrip-01-aum-operator-cr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ kind=${2:-deployment}

source test-resources/bin/util
load_env_file
verify_kubectx
setup_test_environment

echo "STEP 1: creating target namespace (if necessary)"
Expand Down
1 change: 1 addition & 0 deletions test-resources/bin/test-roundtrip-02-operator-cr-aum.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ kind=${2:-deployment}

source test-resources/bin/util
load_env_file
verify_kubectx
setup_test_environment

echo "STEP 1: creating target namespace (if necessary)"
Expand Down
8 changes: 8 additions & 0 deletions test-resources/bin/util
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ load_env_file () {
source test-resources/.env
}

verify_kubectx() {
current_kubectx=$(kubectl config current-context)
if [[ "$current_kubectx" != "${LOCAL_KUBECTX:-}" ]]; then
echo "error: The current kubectx is not the expected local kubectx \"${LOCAL_KUBECTX:-}\". Please switch to the local context or set LOCAL_KUBECTX differently in .env. Refusing to run test scenarios/cleanup in a potentially remote context."
exit 1
fi
}

setup_test_environment () {
install_cert_manager_if_necessary
test-resources/bin/render-templates.sh
Expand Down

0 comments on commit 89f9242

Please sign in to comment.