From b3cfc9c7d0f73967fd0df8c5f770a900891a037a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20B=C3=BCrk?= Date: Tue, 7 May 2024 13:08:57 +0200 Subject: [PATCH] [BUGFIX] Ensure correct service waits and container cleanup (#1285) This change now uses a bash trap to ensure proper container cleanup after some signals happend. The internal `waitFor()` is modified to emit a signal to cleanup containers if the waiting process does not process correctly and stop the script execution. Additionally, `--pull-never` as CI_PARAMS is no longer derived from the `$CI` variable and must now be handed over from the calling process. Further, the max retry value in `waitFor()` is increased to 20 to mitigate the slowed down startup of MySQL 8.0 container. Resolves: #1280 --- Build/Scripts/runTests.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Build/Scripts/runTests.sh b/Build/Scripts/runTests.sh index a9b98d9..a623f39 100755 --- a/Build/Scripts/runTests.sh +++ b/Build/Scripts/runTests.sh @@ -4,13 +4,15 @@ # TYPO3 core test runner based on docker. # +trap 'cleanUp;exit 2' SIGINT + waitFor() { local HOST=${1} local PORT=${2} local TESTCOMMAND=" COUNT=0; while ! nc -z ${HOST} ${PORT}; do - if [ \"\${COUNT}\" -gt 10 ]; then + if [ \"\${COUNT}\" -gt 20 ]; then echo \"Can not connect to ${HOST} port ${PORT}. Aborting.\"; exit 1; fi; @@ -19,6 +21,9 @@ waitFor() { done; " ${CONTAINER_BIN} run ${CONTAINER_COMMON_PARAMS} --name wait-for-${SUFFIX} ${XDEBUG_MODE} -e XDEBUG_CONFIG="${XDEBUG_CONFIG}" ${IMAGE_ALPINE} /bin/sh -c "${TESTCOMMAND}" + if [[ $? -gt 0 ]]; then + kill -SIGINT -$$ + fi } cleanUp() { @@ -313,7 +318,7 @@ HOST_PID=$(id -g) USERSET="" SUFFIX=$(echo $RANDOM) NETWORK="friendsoftypo3-tea-${SUFFIX}" -CI_PARAMS="" +CI_PARAMS="${CI_PARAMS:-}" CONTAINER_HOST="host.docker.internal" PHPSTAN_CONFIG_FILE="phpstan.neon" IS_CORE_CI=0 @@ -405,7 +410,6 @@ handleDbmsOptions if [ "${CI}" == "true" ]; then IS_CORE_CI=1 CONTAINER_INTERACTIVE="" - CI_PARAMS="--pull=never" fi # determine default container binary to use: 1. podman 2. docker