Debian Codegraph @

tests/functional/events/18-workflow-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.
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 3
24 mock_smtpd_init
25 OPT_SET=
26 if [[ "${TEST_NAME_BASE}" == *-globalcfg ]]; then
27 create_test_global_config "" "
28 [scheduler]
29 [[events]]
30 mail events = startup, shutdown
31 [[mail]]
32 footer = see: http://localhost/stuff/%(owner)s/%(workflow)s/
33 smtp = ${TEST_SMTPD_HOST}"
34 OPT_SET='-s GLOBALCFG=True'
35 else
36 create_test_global_config "
37 [scheduler]
38 [[mail]]
39 smtp = ${TEST_SMTPD_HOST}
40 "
41 fi
42
43 install_workflow "${TEST_NAME_BASE}" "${TEST_NAME_BASE}"
44 # shellcheck disable=SC2086
45 run_ok "${TEST_NAME_BASE}-validate" \
46 cylc validate ${OPT_SET} "${WORKFLOW_NAME}"
47 # shellcheck disable=SC2086
48 workflow_run_ok "${TEST_NAME_BASE}-run" \
49 cylc play --reference-test --debug --no-detach ${OPT_SET} "${WORKFLOW_NAME}"
50
51 contains_ok "${TEST_SMTPD_LOG}" <<__LOG__
52 event: startup
53 message: workflow starting
54 event: shutdown
55 message: AUTOMATIC
56 see: http://localhost/stuff/${USER}/${WORKFLOW_NAME}/
57 __LOG__
58
59 purge
60 mock_smtpd_kill
61 exit