Skip to content

Commit

Permalink
replace smtpd with aiosmtpd in the test_header file
Browse files Browse the repository at this point in the history
  • Loading branch information
wxtim committed Nov 7, 2023
1 parent 3183cab commit 8636bf3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ report-timings =
pandas==1.*
matplotlib
tests =
aiosmtpd
async_generator
bandit>=1.7.0
coverage>=5.0.0,<7.3.1
Expand Down
12 changes: 4 additions & 8 deletions tests/functional/events/18-workflow-event-mail.t
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions tests/functional/lib/bash/test_header
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8636bf3

Please sign in to comment.