Debian Codegraph @

tests/f/events/47-long-output.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 a long output from an event handler is not going to hang or die.
19
20 . "$(dirname "$0")/test_header"
21 if ! python3 -c 'from select import poll' 2>'/dev/null'; then
22 skip_all '"select.poll" not supported on this OS'
23 fi
24
25 set_test_number 10
26
27 create_test_global_config "" "
28 [scheduler]
29 process pool timeout = PT10S
30 "
31
32 # Long STDOUT output
33
34 init_workflow "${TEST_NAME_BASE}" <<__FLOW_CONFIG__
35 [scheduling]
36 [[graph]]
37 R1 = t1
38 [runtime]
39 [[t1]]
40 script = true
41 [[[events]]]
42 succeeded handlers = cat "${CYLC_REPO_DIR}/COPYING" "${CYLC_REPO_DIR}/COPYING" "${CYLC_REPO_DIR}/COPYING" && echo
43 __FLOW_CONFIG__
44 cd "$WORKFLOW_RUN_DIR" || exit 1
45 cat >'reference.log' <<'__REFLOG__'
46 Initial point: 1
47 Final point: 1
48 1/t1 -triggered off []
49 __REFLOG__
50 run_ok "${TEST_NAME_BASE}-validate" cylc validate "${WORKFLOW_NAME}"
51
52 workflow_run_ok "${TEST_NAME_BASE}-run" \
53 cylc play --debug --no-detach --reference-test "${WORKFLOW_NAME}"
54
55 cylc cat-log "${WORKFLOW_NAME}" >'catlog'
56 sed -n 's/^.*\(GNU GENERAL PUBLIC LICENSE\)/\1/p' 'catlog' >'log-1'
57 contains_ok 'log-1' <<'__LOG__'
58 GNU GENERAL PUBLIC LICENSE
59 GNU GENERAL PUBLIC LICENSE
60 GNU GENERAL PUBLIC LICENSE
61 __LOG__
62 run_ok "log-event-handler-00-out" \
63 grep -qF "[(('event-handler-00', 'succeeded'), 1) out]" 'catlog'
64 run_ok "log-event-handler-ret-code" \
65 grep -qF "[(('event-handler-00', 'succeeded'), 1) ret_code] 0" 'catlog'
66
67 purge
68
69 # REPEAT: Long STDERR output
70 init_workflow "${TEST_NAME_BASE}" <<__FLOW_CONFIG__
71 [scheduling]
72 [[graph]]
73 R1 = t1
74 [runtime]
75 [[t1]]
76 script = true
77 [[[events]]]
78 succeeded handlers = cat "${CYLC_REPO_DIR}/COPYING" "${CYLC_REPO_DIR}/COPYING" "${CYLC_REPO_DIR}/COPYING" >&2 && echo
79 __FLOW_CONFIG__
80 cd "${WORKFLOW_RUN_DIR}" || exit 1
81 cat >'reference.log' <<'__REFLOG__'
82 Initial point: 1
83 Final point: 1
84 1/t1 -triggered off []
85 __REFLOG__
86
87 run_ok "${TEST_NAME_BASE}-validate" cylc validate "${WORKFLOW_NAME}"
88
89 workflow_run_ok "${TEST_NAME_BASE}-run" \
90 cylc play --debug --no-detach --reference-test "${WORKFLOW_NAME}"
91
92 cylc cat-log "${WORKFLOW_NAME}" >'catlog'
93 sed -n 's/^.*\(GNU GENERAL PUBLIC LICENSE\)/\1/p' 'catlog' >'log-1'
94 contains_ok 'log-1' <<'__LOG__'
95 GNU GENERAL PUBLIC LICENSE
96 GNU GENERAL PUBLIC LICENSE
97 GNU GENERAL PUBLIC LICENSE
98 __LOG__
99 run_ok "log-event-handler-00-err" \
100 grep -qF "[(('event-handler-00', 'succeeded'), 1) err]" 'catlog'
101 run_ok "log-event-handler-00-ret-code" \
102 grep -qF "[(('event-handler-00', 'succeeded'), 1) ret_code] 0" 'catlog'
103
104 purge
105
106 exit