Extrract disabled clamav tests into own file

This commit is contained in:
Martin Schulze 2020-09-17 23:40:39 +02:00
parent 94c2a68bd5
commit d38ff4c122
4 changed files with 78 additions and 36 deletions

View file

@ -7,6 +7,9 @@ NAME=tvial/docker-mailserver:testing
TEST_TIMEOUT_IN_SECONDS=${TEST_TIMEOUT_IN_SECONDS-120}
NUMBER_OF_LOG_LINES=${NUMBER_OF_LOG_LINES-10}
# @param $1 timeout
# @param --fatal-test <command eval string> additional test whose failure aborts immediately
# @param ... test to run
function repeat_until_success_or_timeout {
if ! [[ "$1" =~ ^[0-9]+$ ]]; then
echo "First parameter for timeout must be an integer, recieved \"$1\""
@ -15,20 +18,33 @@ function repeat_until_success_or_timeout {
TIMEOUT=$1
STARTTIME=$SECONDS
shift 1
local fatal_failure_test_command
if [[ "$1" == "--fatal-test" ]]; then
fatal_failure_test_command="$2"
shift 2
fi
until "$@"
do
if [[ -n "$fatal_failure_test_command" ]] && ! eval "$fatal_failure_test_command"; then
echo "\`$fatal_failure_test_command\` failed, early aborting repeat_until_success of \`$*\`" >&2
exit 1
fi
sleep 5
if [[ $(($SECONDS - $STARTTIME )) -gt $TIMEOUT ]]; then
echo "Timed out on command: $@"
echo "Timed out on command: $@" >&2
return 1
fi
done
}
function container_is_running() {
[[ "$(docker inspect -f '{{.State.Running}}' "$1")" == "true" ]]
}
# @param $1 port
# @param $2 container name
function wait_for_tcp_port_in_container() {
repeat_until_success_or_timeout $TEST_TIMEOUT_IN_SECONDS docker exec $2 /bin/sh -c "nc -z 0.0.0.0 $1"
repeat_until_success_or_timeout $TEST_TIMEOUT_IN_SECONDS --fatal-test "container_is_running $2" docker exec $2 /bin/sh -c "nc -z 0.0.0.0 $1"
}
# @param $1 name of the postfix container