diff --git a/setup.cfg b/setup.cfg index d5fd84a80b8..258081301c9 100644 --- a/setup.cfg +++ b/setup.cfg @@ -103,6 +103,7 @@ report-timings = pandas==1.* matplotlib tests = + aiosmtpd async_generator bandit>=1.7.0 coverage>=5.0.0,<7.3.1 diff --git a/tests/functional/events/18-workflow-event-mail.t b/tests/functional/events/18-workflow-event-mail.t index fcde6da0bd7..0ed3b90d7d9 100755 --- a/tests/functional/events/18-workflow-event-mail.t +++ b/tests/functional/events/18-workflow-event-mail.t @@ -20,7 +20,7 @@ if ! command -v mail 2>'/dev/null'; then skip_all '"mail" command not available' fi -set_test_number 3 +set_test_number 7 mock_smtpd_init OPT_SET= if [[ "${TEST_NAME_BASE}" == *-globalcfg ]]; then @@ -48,13 +48,9 @@ run_ok "${TEST_NAME_BASE}-validate" \ workflow_run_ok "${TEST_NAME_BASE}-run" \ cylc play --reference-test --debug --no-detach ${OPT_SET} "${WORKFLOW_NAME}" -contains_ok "${TEST_SMTPD_LOG}" <<__LOG__ -b'event: startup' -b'message: workflow starting' -b'event: shutdown' -b'message: AUTOMATIC' -b'see: http://localhost/stuff/${USER}/${WORKFLOW_NAME}/' -__LOG__ +for searchterm in 'event: startup' 'message: workflow starting' 'event: shutdown' 'message: AUTOMATIC' "see: http://localhost/stuff/${USER}/${WORKFLOW_NAME}/"; do + grep_ok "$searchterm" "$TEST_SMTPD_LOG" +done purge mock_smtpd_kill diff --git a/tests/functional/lib/bash/test_header b/tests/functional/lib/bash/test_header index 458a7dc908c..c4a07603126 100644 --- a/tests/functional/lib/bash/test_header +++ b/tests/functional/lib/bash/test_header @@ -807,10 +807,13 @@ mock_smtpd_init() { # Logic borrowed from Rose local SMTPD_LOG="${TEST_DIR}/smtpd.log" local SMTPD_HOST="localhost:${SMTPD_PORT}" # Set up fake SMTP server to catch outgoing mail & redirect to log: - python3 -u -m 'smtpd' -c 'DebuggingServer' -d -n "${SMTPD_HOST}" \ + python3 -u -m 'aiosmtpd' \ + --class aiosmtpd.handlers.Debugging stdout \ + --debug --nosetuid \ + --listen "${SMTPD_HOST}" \ 1>"${SMTPD_LOG}" 2>&1 & # Runs in background local SMTPD_PID="$!" - while ! grep -q 'DebuggingServer started' "${SMTPD_LOG}" 2>'/dev/null' + while ! grep -q 'is listening' "${SMTPD_LOG}" 2>'/dev/null' do if ps "${SMTPD_PID}" 1>/dev/null 2>&1; then sleep 1 # Still waiting for fake server to start