Add trap to cri-integration test script

The cri-integration.sh script sets errexit option. This does not
work properly on Bash in Windows, espectially when the script is
piped to something else ( tee in this case ). In this particular
case, the problem arises from the fact that if the script exits
prematurely, it will not get a chance to call test_teardown and
thus clean the remaining containerd process, thus the whole
command will hang indefinetly.

Adding a simple trap on EXIT to call test_teardown will easily
fix this.

Signed-off-by: Adelina Tuvenie <atuvenie@cloudbasesolutions.com>
This commit is contained in:
Adelina Tuvenie 2021-08-09 22:48:11 +03:00
parent 218db0f9af
commit e6538b8bce

View File

@ -21,6 +21,8 @@ set -o pipefail
basedir="$(dirname "${BASH_SOURCE[0]}")"
source "${basedir}/utils.sh"
trap test_teardown EXIT
ROOT="$( cd "${basedir}" && pwd )"/../..
cd "${ROOT}"
@ -46,6 +48,4 @@ ${sudo} bin/cri-integration.test --test.run="${FOCUS}" --test.v \
test_exit_code=$?
test_teardown
exit ${test_exit_code}