Skip to content

Commit

Permalink
chore: ensure that e2e tests cleanup clusters (#1057)
Browse files Browse the repository at this point in the history
Ensures that the delete clusters flow executes even when

* cluster turnup succeeds partially (e.g. cluster created but various
kubectl apply operations fail)
 * other testing stages fail 

This reduces resource waste in our integration testing project.
  • Loading branch information
garethgeorge authored Oct 17, 2023
1 parent a3b8f2c commit 01482b3
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions ci/cloudbuild/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,12 @@ steps:
- |
set -eux
cleanup() {
echo $? > /workspace/${BUILD_ID}/_CREATE_GKE_CLUSTER
exit 0
}
trap cleanup EXIT
if [ -z "${_FULL_RELEASE_BUCKET}" ]; then
echo "_FULL_RELEASE_BUCKET is not set. Skipping GKE cluster creation..."
exit 0
Expand Down Expand Up @@ -267,6 +273,12 @@ steps:
- |
set -euxo pipefail
cleanup() {
echo $? > /workspace/${BUILD_ID}/_DEPLOY_CERTS
exit 0
}
trap cleanup EXIT
export CLOUDSDK_COMPUTE_ZONE=$(cat /workspace/${BUILD_ID}/_CLOUDSDK_COMPUTE_ZONE)
export CLOUDSDK_CONTAINER_CLUSTER=$(cat /workspace/${BUILD_ID}/_CLOUDSDK_CONTAINER_CLUSTER)
export CLOUDSDK_CORE_PROJECT=${PROJECT_ID}
Expand Down Expand Up @@ -307,6 +319,12 @@ steps:
- |
set -eux
cleanup() {
echo $? > /workspace/${BUILD_ID}/_STRESS_TESTS
exit 0
}
trap cleanup EXIT
if [ "${_STRESS_TEST_BASELOAD_FACTOR}" -le "0" ]; then
echo "_STRESS_TEST_BASELOAD_FACTOR is set to ${_STRESS_TEST_BASELOAD_FACTOR}. Skipping..."
exit 0
Expand Down Expand Up @@ -425,6 +443,12 @@ steps:
- |
set -eu
cleanup() {
echo $? > /workspace/${BUILD_ID}/_ACCEPTANCE_TESTS
exit 0
}
trap cleanup EXIT
if [ "${_SKIP_ACCEPTANCE_TESTS}" == "true" ]; then
echo "Skipping acceptance tests..."
exit 0
Expand Down Expand Up @@ -589,6 +613,10 @@ steps:
fi
}
check /workspace/${BUILD_ID}/_CREATE_GKE_CLUSTER "Create GKE cluster"
check /workspace/${BUILD_ID}/_DEPLOY_CERTS "Deploy certs"
check /workspace/${BUILD_ID}/_STRESS_TESTS "Stress test"
check /workspace/${BUILD_ID}/_ACCEPTANCE_TESTS "Acceptance tests"
check /workspace/${BUILD_ID}/_INTEGRATION_EXIT_CODE "Integration tests"
check /workspace/${BUILD_ID}/_DELETE_CLUSTER_EXIT_CODE "Delete GKE cluster"
Expand Down

0 comments on commit 01482b3

Please sign in to comment.