mirror of https://github.com/FriendsOfTYPO3/tea.git synced 2024-09-19 23:16:12 +02:00

[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
This commit is contained in:
Stefan Bürk 2024-05-07 13:08:57 +02:00 committed by GitHub
parent 823d4c406d
commit b3cfc9c7d0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -4,13 +4,15 @@
# TYPO3 core test runner based on docker. # TYPO3 core test runner based on docker.
# #
trap 'cleanUp;exit 2' SIGINT
waitFor() { waitFor() {
local HOST=${1} local HOST=${1}
local PORT=${2} local PORT=${2}
local TESTCOMMAND=" local TESTCOMMAND="
COUNT=0; COUNT=0;
while ! nc -z ${HOST} ${PORT}; do 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.\"; echo \"Can not connect to ${HOST} port ${PORT}. Aborting.\";
exit 1; exit 1;
fi; fi;
@ -19,6 +21,9 @@ waitFor() {
done; done;
" "
${CONTAINER_BIN} run ${CONTAINER_COMMON_PARAMS} --name wait-for-${SUFFIX} ${XDEBUG_MODE} -e XDEBUG_CONFIG="${XDEBUG_CONFIG}" ${IMAGE_ALPINE} /bin/sh -c "${TESTCOMMAND}" ${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() { cleanUp() {
@ -313,7 +318,7 @@ HOST_PID=$(id -g)
USERSET="" USERSET=""
SUFFIX=$(echo $RANDOM) SUFFIX=$(echo $RANDOM)
NETWORK="friendsoftypo3-tea-${SUFFIX}" NETWORK="friendsoftypo3-tea-${SUFFIX}"
CI_PARAMS="" CI_PARAMS="${CI_PARAMS:-}"
CONTAINER_HOST="host.docker.internal" CONTAINER_HOST="host.docker.internal"
PHPSTAN_CONFIG_FILE="phpstan.neon" PHPSTAN_CONFIG_FILE="phpstan.neon"
IS_CORE_CI=0 IS_CORE_CI=0
@ -405,7 +410,6 @@ handleDbmsOptions
if [ "${CI}" == "true" ]; then if [ "${CI}" == "true" ]; then
IS_CORE_CI=1 IS_CORE_CI=1
CONTAINER_INTERACTIVE="" CONTAINER_INTERACTIVE=""
CI_PARAMS="--pull=never"
fi fi
# determine default container binary to use: 1. podman 2. docker # determine default container binary to use: 1. podman 2. docker