Skip to content

Commit 01482b3

Browse files
authored
chore: ensure that e2e tests cleanup clusters (#1057)
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.
1 parent a3b8f2c commit 01482b3

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

ci/cloudbuild/test.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,12 @@ steps:
231231
- |
232232
set -eux
233233
234+
cleanup() {
235+
echo $? > /workspace/${BUILD_ID}/_CREATE_GKE_CLUSTER
236+
exit 0
237+
}
238+
trap cleanup EXIT
239+
234240
if [ -z "${_FULL_RELEASE_BUCKET}" ]; then
235241
echo "_FULL_RELEASE_BUCKET is not set. Skipping GKE cluster creation..."
236242
exit 0
@@ -267,6 +273,12 @@ steps:
267273
- |
268274
set -euxo pipefail
269275
276+
cleanup() {
277+
echo $? > /workspace/${BUILD_ID}/_DEPLOY_CERTS
278+
exit 0
279+
}
280+
trap cleanup EXIT
281+
270282
export CLOUDSDK_COMPUTE_ZONE=$(cat /workspace/${BUILD_ID}/_CLOUDSDK_COMPUTE_ZONE)
271283
export CLOUDSDK_CONTAINER_CLUSTER=$(cat /workspace/${BUILD_ID}/_CLOUDSDK_CONTAINER_CLUSTER)
272284
export CLOUDSDK_CORE_PROJECT=${PROJECT_ID}
@@ -307,6 +319,12 @@ steps:
307319
- |
308320
set -eux
309321
322+
cleanup() {
323+
echo $? > /workspace/${BUILD_ID}/_STRESS_TESTS
324+
exit 0
325+
}
326+
trap cleanup EXIT
327+
310328
if [ "${_STRESS_TEST_BASELOAD_FACTOR}" -le "0" ]; then
311329
echo "_STRESS_TEST_BASELOAD_FACTOR is set to ${_STRESS_TEST_BASELOAD_FACTOR}. Skipping..."
312330
exit 0
@@ -425,6 +443,12 @@ steps:
425443
- |
426444
set -eu
427445
446+
cleanup() {
447+
echo $? > /workspace/${BUILD_ID}/_ACCEPTANCE_TESTS
448+
exit 0
449+
}
450+
trap cleanup EXIT
451+
428452
if [ "${_SKIP_ACCEPTANCE_TESTS}" == "true" ]; then
429453
echo "Skipping acceptance tests..."
430454
exit 0
@@ -589,6 +613,10 @@ steps:
589613
fi
590614
}
591615
616+
check /workspace/${BUILD_ID}/_CREATE_GKE_CLUSTER "Create GKE cluster"
617+
check /workspace/${BUILD_ID}/_DEPLOY_CERTS "Deploy certs"
618+
check /workspace/${BUILD_ID}/_STRESS_TESTS "Stress test"
619+
check /workspace/${BUILD_ID}/_ACCEPTANCE_TESTS "Acceptance tests"
592620
check /workspace/${BUILD_ID}/_INTEGRATION_EXIT_CODE "Integration tests"
593621
check /workspace/${BUILD_ID}/_DELETE_CLUSTER_EXIT_CODE "Delete GKE cluster"
594622

0 commit comments

Comments
 (0)