mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2025-08-04 01:55:29 +02:00
{} and uppercase
This commit is contained in:
parent
6bff929b13
commit
0da7ee0c1d
5 changed files with 48 additions and 46 deletions
|
@ -1,7 +1,7 @@
|
|||
load 'test_helper/bats-support/load'
|
||||
load 'test_helper/bats-assert/load'
|
||||
|
||||
NAME=tvial/docker-mailserver:testing
|
||||
# NAME=tvial/docker-mailserver:testing
|
||||
|
||||
# default timeout is 120 seconds
|
||||
TEST_TIMEOUT_IN_SECONDS=${TEST_TIMEOUT_IN_SECONDS-120}
|
||||
|
@ -11,9 +11,9 @@ NUMBER_OF_LOG_LINES=${NUMBER_OF_LOG_LINES-10}
|
|||
# @param --fatal-test <command eval string> additional test whose failure aborts immediately
|
||||
# @param ... test to run
|
||||
function repeat_until_success_or_timeout {
|
||||
local fatal_failure_test_command
|
||||
local FATAL_FAILURE_TEST_COMMAND
|
||||
if [[ "${1}" == "--fatal-test" ]]; then
|
||||
fatal_failure_test_command="${2}"
|
||||
FATAL_FAILURE_TEST_COMMAND="${2}"
|
||||
shift 2
|
||||
fi
|
||||
if ! [[ "${1}" =~ ^[0-9]+$ ]]; then
|
||||
|
@ -25,8 +25,8 @@ function repeat_until_success_or_timeout {
|
|||
shift 1
|
||||
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
|
||||
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
|
||||
return 1
|
||||
fi
|
||||
sleep 1
|
||||
|
@ -75,7 +75,7 @@ function container_is_running() {
|
|||
# @param ${1} port
|
||||
# @param ${2} container name
|
||||
function wait_for_tcp_port_in_container() {
|
||||
repeat_until_success_or_timeout --fatal-test "container_is_running ${2}" "${TEST_TIMEOUT_IN_SECONDS}" docker exec ${2} /bin/sh -c "nc -z 0.0.0.0 ${1}"
|
||||
repeat_until_success_or_timeout --fatal-test "container_is_running ${2}" "${TEST_TIMEOUT_IN_SECONDS}" docker exec "${2}" /bin/sh -c "nc -z 0.0.0.0 ${1}"
|
||||
}
|
||||
|
||||
# @param ${1} name of the postfix container
|
||||
|
@ -90,13 +90,13 @@ function wait_for_amavis_port_in_container() {
|
|||
|
||||
# @param ${1} name of the postfix container
|
||||
function wait_for_finished_setup_in_container() {
|
||||
local status=0
|
||||
repeat_until_success_or_timeout --fatal-test "container_is_running ${1}" "${TEST_TIMEOUT_IN_SECONDS}" sh -c "docker logs ${1} | grep 'is up and running'" || status=1
|
||||
if [[ ${status} -eq 1 ]]; then
|
||||
local STATUS=0
|
||||
repeat_until_success_or_timeout --fatal-test "container_is_running ${1}" "${TEST_TIMEOUT_IN_SECONDS}" sh -c "docker logs ${1} | grep 'is up and running'" || STATUS=1
|
||||
if [[ ${STATUS} -eq 1 ]]; then
|
||||
echo "Last ${NUMBER_OF_LOG_LINES} lines of container \`${1}\`'s log"
|
||||
docker logs "${1}" | tail -n "${NUMBER_OF_LOG_LINES}"
|
||||
fi
|
||||
return ${status}
|
||||
return ${STATUS}
|
||||
}
|
||||
|
||||
SETUP_FILE_MARKER="${BATS_TMPDIR}/$(basename "${BATS_TEST_FILENAME}").setup_file"
|
||||
|
@ -177,6 +177,8 @@ function wait_for_service() {
|
|||
function wait_for_changes_to_be_detected_in_container() {
|
||||
local CONTAINER_NAME="${1}"
|
||||
local TIMEOUT=${TEST_TIMEOUT_IN_SECONDS}
|
||||
repeat_in_container_until_success_or_timeout "${TIMEOUT}" "${CONTAINER_NAME}" \
|
||||
repeat_in_container_until_success_or_timeout \
|
||||
"${TIMEOUT}" \
|
||||
"${CONTAINER_NAME}" \
|
||||
bash -c 'source /usr/local/bin/helper_functions.sh; cmp --silent -- <(_monitored_files_checksums) "${CHKSUM_FILE}" >/dev/null'
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue