Skip to content

Commit

Permalink
Make sure we don't mask LB tests failures
Browse files Browse the repository at this point in the history
In `test-lb-service.sh` we do `trap "delete_resources" EXIT` to make
sure we cleanup resources on a test failure. In there, we only fetched
the `$?` after making a check for `${AUTO_CLEAN_UP}`, which itself
alters the code to 0, so function always returns success. This means
tests can never really fail.

This commit fixes it by making sure `$ERROR_CODE` is fetched at the very
beginning of the cleanup function.
  • Loading branch information
dulek committed Sep 7, 2023
1 parent 4efeaf4 commit 12c6e3d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tests/e2e/cloudprovider/test-lb-service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ LB_SUBNET_NAME=${LB_SUBNET_NAME:-"private-subnet"}
AUTO_CLEAN_UP=${AUTO_CLEAN_UP:-"true"}

function delete_resources() {
ERROR_CODE="$?"

if [[ ${AUTO_CLEAN_UP} != "true" ]]; then
exit ${ERROR_CODE}
fi

ERROR_CODE="$?"

printf "\n>>>>>>> Deleting k8s services\n"
kubectl -n ${NAMESPACE} get svc -o name | xargs -r kubectl -n $NAMESPACE delete
printf "\n>>>>>>> Deleting k8s deployments\n"
Expand Down

0 comments on commit 12c6e3d

Please sign in to comment.