Extract container mail_smtponly_without_config into test

This commit is contained in:
Martin Schulze 2020-09-18 00:02:38 +02:00
parent ad0be553d8
commit 06b137e5a8
3 changed files with 20 additions and 8 deletions

View file

@ -54,13 +54,6 @@ run:
-e DMS_DEBUG=0 \ -e DMS_DEBUG=0 \
-h mail.my-domain.com -t $(NAME) -h mail.my-domain.com -t $(NAME)
-@ sleep $(SLEEP) -@ sleep $(SLEEP)
docker run --rm -d --name mail_smtponly_without_config \
-e SMTP_ONLY=1 \
-e ENABLE_LDAP=1 \
-e PERMIT_DOCKER=network \
-e OVERRIDE_HOSTNAME=mail.mydomain.com \
-t $(NAME)
-@ sleep $(SLEEP)
docker run --rm -d --name mail_override_hostname \ docker run --rm -d --name mail_override_hostname \
-v "`pwd`/test/config":/tmp/docker-mailserver \ -v "`pwd`/test/config":/tmp/docker-mailserver \
-v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \ -v "`pwd`/test/test-files":/tmp/docker-mailserver-test:ro \

View file

@ -37,6 +37,16 @@ function repeat_until_success_or_timeout {
done done
} }
# @param $1 timeout
# @param $2 container name
# @param ... test command for container
function repeat_in_container_until_success_or_timeout() {
timeout="$1"
container_name="$2"
shift 2
repeat_until_success_or_timeout "$timeout" --fatal-test "container_is_running $container_name" docker exec "$container_name" "$@"
}
function container_is_running() { function container_is_running() {
[[ "$(docker inspect -f '{{.State.Running}}' "$1")" == "true" ]] [[ "$(docker inspect -f '{{.State.Running}}' "$1")" == "true" ]]
} }

View file

@ -407,7 +407,16 @@ EOF
} }
@test "checking opendkim: /etc/opendkim/KeyTable dummy file generated without keys provided" { @test "checking opendkim: /etc/opendkim/KeyTable dummy file generated without keys provided" {
run docker exec mail_smtponly_without_config /bin/bash -c "cat /etc/opendkim/KeyTable" docker run --rm -d --name mail_smtponly_without_config \
-e SMTP_ONLY=1 \
-e ENABLE_LDAP=1 \
-e PERMIT_DOCKER=network \
-e OVERRIDE_HOSTNAME=mail.mydomain.com \
-t ${NAME}
teardown() { docker rm -f mail_smtponly_without_config; }
run repeat_in_container_until_success_or_timeout 15 mail_smtponly_without_config /bin/bash -c "cat /etc/opendkim/KeyTable"
assert_success assert_success
} }