Debian Codegraph @

tests/functional/events/09-task-event-mail.t

raw
1 #!/usr/bin/env bash
2 # THIS FILE IS PART OF THE CYLC WORKFLOW ENGINE.
3 # Copyright (C) NIWA & British Crown (Met Office) & Contributors.
4 #
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #-------------------------------------------------------------------------------
18 # Test event mail, 2 different task events
19 . "$(dirname "$0")/test_header"
20 if ! command -v mail 2>'/dev/null'; then
21 skip_all '"mail" command not available'
22 fi
23 set_test_number 6
24 mock_smtpd_init
25 OPT_SET=
26 if [[ "${TEST_NAME_BASE}" == *-globalcfg ]]; then
27 create_test_global_config "" "
28 [scheduler]
29 [[mail]]
30 footer = see: http://localhost/stuff/%(owner)s/%(workflow)s/
31 smtp = ${TEST_SMTPD_HOST}
32 [task events]
33 mail events = failed, retry, succeeded
34 "
35 OPT_SET='-s GLOBALCFG=True'
36 else
37 create_test_global_config "
38 [scheduler]
39 [[mail]]
40 smtp = ${TEST_SMTPD_HOST}
41 "
42 fi
43
44 install_workflow "${TEST_NAME_BASE}" "${TEST_NAME_BASE}"
45 # shellcheck disable=SC2086
46 run_ok "${TEST_NAME_BASE}-validate" \
47 cylc validate ${OPT_SET} "${WORKFLOW_NAME}"
48 # shellcheck disable=SC2086
49 workflow_run_ok "${TEST_NAME_BASE}-run" \
50 cylc play --reference-test --debug --no-detach ${OPT_SET} "${WORKFLOW_NAME}"
51
52 run_ok "${TEST_NAME_BASE}-grep-log-1" \
53 grep -Pizo 'job: 1/t1/01.*\n.*event: retry' "${TEST_SMTPD_LOG}"
54 run_ok "${TEST_NAME_BASE}-grep-log-2" \
55 grep -Pizo 'job: 1/t1/02.*\n.*event: succeeded' "${TEST_SMTPD_LOG}"
56
57 run_ok "${TEST_NAME_BASE}-grep-log-3" \
58 grep -Pizo "Subject: \[1/t1/01 retry\].*(\n)?.* ${WORKFLOW_NAME}" "${TEST_SMTPD_LOG}"
59 run_ok "${TEST_NAME_BASE}-grep-log-4" \
60 grep -Pizo "Subject: \[1/t1/02 succeeded\].*(\n)?.* ${WORKFLOW_NAME}" "${TEST_SMTPD_LOG}"
61
62 purge
63 mock_smtpd_kill
64 exit