mirror of
https://github.com/docker-mailserver/docker-mailserver.git
synced 2024-01-19 02:48:50 +00:00
chore: Remove delay starting the change detection service (#3064)
* chore: Only replace `CHKSUM_FILE` when a change has been processed * chore: Change Detection service should be the last daemon started * chore: Remove 10 second startup delay for change detector There should be no concern with conflicts as any writes should have already been done by the time this daemon service is started. * tests(fix): `smtp_delivery.bats` must wait for Amavis The change event for adding a user can be processed much sooner now, which means Amavis may not yet be ready. Added extra condition to wait on at least the Amavis port being reachable, and some failure asserts with the mail queue to better catch / debug when this problem occurs. * chore: Add some minor delay to avoid Amavis failing to connect
This commit is contained in:
parent
16f46c1e14
commit
1c8a160621
|
@ -29,9 +29,6 @@ fi
|
|||
|
||||
_log_with_date 'trace' "Using postmaster address '${POSTMASTER_ADDRESS}'"
|
||||
|
||||
# Change detection delayed during startup to avoid conflicting writes
|
||||
sleep 10
|
||||
|
||||
_log_with_date 'debug' "Changedetector is ready"
|
||||
|
||||
function _check_for_changes
|
||||
|
@ -64,10 +61,10 @@ function _check_for_changes
|
|||
|
||||
_remove_lock
|
||||
_log_with_date 'debug' 'Completed handling of detected change'
|
||||
fi
|
||||
|
||||
# mark changes as applied
|
||||
mv "${CHKSUM_FILE}.new" "${CHKSUM_FILE}"
|
||||
fi
|
||||
}
|
||||
|
||||
function _get_changed_files
|
||||
|
|
|
@ -185,8 +185,8 @@ function _register_functions
|
|||
[[ ${ENABLE_FAIL2BAN} -eq 1 ]] && _register_start_daemon '_start_daemon_fail2ban'
|
||||
[[ ${ENABLE_FETCHMAIL} -eq 1 ]] && _register_start_daemon '_start_daemon_fetchmail'
|
||||
[[ ${ENABLE_CLAMAV} -eq 1 ]] && _register_start_daemon '_start_daemon_clamav'
|
||||
[[ ${ACCOUNT_PROVISIONER} == 'FILE' ]] && _register_start_daemon '_start_daemon_changedetector'
|
||||
[[ ${ENABLE_AMAVIS} -eq 1 ]] && _register_start_daemon '_start_daemon_amavis'
|
||||
[[ ${ACCOUNT_PROVISIONER} == 'FILE' ]] && _register_start_daemon '_start_daemon_changedetector'
|
||||
}
|
||||
|
||||
function _register_start_daemon
|
||||
|
|
|
@ -261,7 +261,7 @@ function _wait_for_smtp_port_in_container() {
|
|||
_wait_for_tcp_port_in_container 25
|
||||
}
|
||||
|
||||
# Wait until the SMPT port (25) can respond.
|
||||
# Wait until the SMTP port (25) can respond.
|
||||
#
|
||||
# @param ${1} = name of the container [OPTIONAL]
|
||||
function _wait_for_smtp_port_in_container_to_respond() {
|
||||
|
|
|
@ -5,6 +5,8 @@ load "${REPOSITORY_ROOT}/test/helper/setup"
|
|||
BATS_TEST_NAME_PREFIX='[SMTP] (delivery) '
|
||||
CONTAINER_NAME='dms-test_smtp-delivery'
|
||||
|
||||
function teardown_file() { _default_teardown ; }
|
||||
|
||||
function setup_file() {
|
||||
_init_with_defaults
|
||||
|
||||
|
@ -49,7 +51,14 @@ function setup_file() {
|
|||
assert_success
|
||||
_wait_until_change_detection_event_completes
|
||||
|
||||
_wait_for_smtp_port_in_container
|
||||
# Even if the Amavis port is reachable at this point, it may still refuse connections?
|
||||
_wait_for_tcp_port_in_container 10024
|
||||
_wait_for_smtp_port_in_container_to_respond
|
||||
|
||||
# Amavis may still not be ready to receive mail, sleep a little to avoid connection failures:
|
||||
sleep 1
|
||||
|
||||
### Send mail to queue for delivery ###
|
||||
|
||||
# TODO: Move to clamav tests (For use when ClamAV is enabled):
|
||||
# _repeat_in_container_until_success_or_timeout 60 "${CONTAINER_NAME}" test -e /var/run/clamav/clamd.ctl
|
||||
|
@ -81,11 +90,16 @@ function setup_file() {
|
|||
_run_in_container_bash 'nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/sieve-spam-folder.txt'
|
||||
_run_in_container_bash 'nc 0.0.0.0 25 < /tmp/docker-mailserver-test/email-templates/sieve-pipe.txt'
|
||||
_run_in_container_bash 'sendmail root < /tmp/docker-mailserver-test/email-templates/root-email.txt'
|
||||
|
||||
_wait_for_empty_mail_queue_in_container
|
||||
}
|
||||
|
||||
function teardown_file() { _default_teardown ; }
|
||||
@test "should succeed at emptying mail queue" {
|
||||
# Try catch errors preventing emptying the queue ahead of waiting:
|
||||
_run_in_container mailq
|
||||
# Amavis (Port 10024) may not have been ready when first mail was sent:
|
||||
refute_output --partial 'Connection refused'
|
||||
refute_output --partial '(unknown mail transport error)'
|
||||
_wait_for_empty_mail_queue_in_container
|
||||
}
|
||||
|
||||
@test "should successfully authenticate with good password (plain)" {
|
||||
_run_in_container_bash 'nc -w 5 0.0.0.0 25 < /tmp/docker-mailserver-test/auth/smtp-auth-plain.txt'
|
||||
|
|
Loading…
Reference in a new issue