Debian Codegraph @

tests/functional/events/45-task-event-handler-multi-warning.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 that simultaneous warnings from a task job are all handled by the
19 # warning event handler.
20 # https://github.com/cylc/cylc-flow/issues/2806
21
22 . "$(dirname "$0")/test_header"
23
24 set_test_number 3
25
26 init_workflow "${TEST_NAME_BASE}" <<'__FLOW_CONFIG__'
27 [scheduling]
28 [[graph]]
29 R1 = foo
30 [runtime]
31 [[foo]]
32 script = """
33 cylc message -s WARNING -- ${CYLC_WORKFLOW_ID} ${CYLC_TASK_JOB} "cat"
34 cylc message -s WARNING -- ${CYLC_WORKFLOW_ID} ${CYLC_TASK_JOB} "dog"
35 cylc message -s WARNING -- ${CYLC_WORKFLOW_ID} ${CYLC_TASK_JOB} "fish"
36 cylc message -s WARNING -- ${CYLC_WORKFLOW_ID} ${CYLC_TASK_JOB} "guinea pig"
37 """
38 [[[events]]]
39 handler events = warning
40 handlers = echo "HANDLED %(message)s"
41 __FLOW_CONFIG__
42
43 run_ok "${TEST_NAME_BASE}-validate" cylc validate "${WORKFLOW_NAME}"
44
45 workflow_run_ok "${TEST_NAME_BASE}-run" \
46 cylc play --debug --no-detach "${WORKFLOW_NAME}"
47
48 cylc cat-log "${WORKFLOW_NAME}" \
49 | sed -n -e 's/^.*\(\[(('"'"'event-handler-00'"'"'.*$\)/\1/p' >'log'
50
51 contains_ok log <<__END__
52 [(('event-handler-00', 'warning-1'), 1) cmd] echo "HANDLED cat"
53 [(('event-handler-00', 'warning-1'), 1) ret_code] 0
54 [(('event-handler-00', 'warning-1'), 1) out] HANDLED cat
55 [(('event-handler-00', 'warning-2'), 1) cmd] echo "HANDLED dog"
56 [(('event-handler-00', 'warning-2'), 1) ret_code] 0
57 [(('event-handler-00', 'warning-2'), 1) out] HANDLED dog
58 [(('event-handler-00', 'warning-3'), 1) cmd] echo "HANDLED fish"
59 [(('event-handler-00', 'warning-3'), 1) ret_code] 0
60 [(('event-handler-00', 'warning-3'), 1) out] HANDLED fish
61 [(('event-handler-00', 'warning-4'), 1) cmd] echo "HANDLED 'guinea pig'"
62 [(('event-handler-00', 'warning-4'), 1) ret_code] 0
63 [(('event-handler-00', 'warning-4'), 1) out] HANDLED 'guinea pig'
64 __END__
65
66 purge
67 exit