Debian Codegraph @

tests/functional/restart/38-auto-restart-stopping.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 export REQUIRE_PLATFORM='loc:remote fs:shared runner:background'
19 . "$(dirname "$0")/test_header"
20 set_test_number 3
21 if ${CYLC_TEST_DEBUG:-false}; then ERR=2; else ERR=1; fi
22 #-------------------------------------------------------------------------------
23 # ensure that workflows don't get auto stop-restarted if they are already stopping
24 BASE_GLOBAL_CONFIG="
25 [scheduler]
26 [[main loop]]
27 plugins = health check, auto restart
28 [[[auto restart]]]
29 interval = PT1S
30 [[events]]
31 abort on inactivity timeout = True
32 abort on stall timeout = True
33 inactivity timeout = PT1M
34 stall timeout = PT1M
35 [[run hosts]]
36 available = localhost, ${CYLC_TEST_HOST}"
37
38 TEST_NAME="${TEST_NAME_BASE}"
39
40 init_workflow "${TEST_NAME}" - <<'__FLOW_CONFIG__'
41 [scheduling]
42 [[graph]]
43 R1 = foo => bar
44 [runtime]
45 [[foo]]
46 script = cylc stop "${CYLC_WORKFLOW_ID}"; sleep 15
47 [[bar]]
48 __FLOW_CONFIG__
49
50 create_test_global_config '' "
51 ${BASE_GLOBAL_CONFIG}
52 "
53
54 run_ok "${TEST_NAME}-workflow-start" cylc play "${WORKFLOW_NAME}" --host=localhost
55 run_ok "wait-for-task-foo-to-start" \
56 cylc workflow-state "${WORKFLOW_NAME}//1/foo:started" --triggers --interval=1 --max-polls=20 >& $ERR
57
58 # condemn localhost
59 create_test_global_config '' "
60 ${BASE_GLOBAL_CONFIG}
61 [scheduler]
62 [[run hosts]]
63 condemned = $(hostname)
64 "
65
66 # wait for workflow to die of natural causes
67 poll_workflow_stopped
68 grep_ok 'Workflow shutting down - REQUEST(CLEAN)' \
69 "$(cylc cat-log "${WORKFLOW_NAME}" -m p)"
70
71 purge
72
73 exit