Debian Codegraph @

tests/functional/reload/22-remove-task-cycling.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 #------------------------------------------------------------------------
19 # Test orphaned tasks do not stall the workflow after reload - GitHub #3306.
20
21 . "$(dirname "$0")/test_header"
22
23 set_test_number 3
24
25 # A workflow designed to orphan a single copy of a task 'bar' on self-reload,
26 # or stall and abort if the orphaned task triggers the #3306 bug.
27
28 init_workflow "${TEST_NAME_BASE}" <<__FLOW_CONFIG__
29 [scheduler]
30 [[events]]
31 inactivity timeout = PT25S
32 abort on inactivity timeout = True
33 [scheduling]
34 initial cycle point = 1
35 final cycle point = 3
36 cycling mode = integer
37 runahead limit = P1
38 [[dependencies]]
39 [[[R/^/P1]]]
40 graph = """foo[-P1] => foo
41 bar[-P1] => bar # remove
42 bar:start => foo # remove
43 """
44 [runtime]
45 [[foo]]
46 script = """
47 # Use poll function from test_header.
48 $(declare -f poll)
49 $(declare -f poll_grep)
50
51 # Remove bar and tell the server to reload.
52 if (( CYLC_TASK_CYCLE_POINT == CYLC_WORKFLOW_INITIAL_CYCLE_POINT )); then
53 sed -i 's/^.*remove*$//g' "\${CYLC_WORKFLOW_RUN_DIR}/flow.cylc"
54 cylc reload "\${CYLC_WORKFLOW_ID}"
55 poll_grep -F 'Reload complete' "\${CYLC_WORKFLOW_RUN_DIR}/log/scheduler/log"
56 # kill the long-running orphaned bar task.
57 kill "\$(cat "\${CYLC_WORKFLOW_RUN_DIR}/work/1/bar/pid")"
58 fi
59 """
60 [[bar]]
61 script = """
62 # Long sleep to ensure that bar does not finish before the reload.
63 # Store long sleep PID to enable kill after the reload.
64 sleep 1000 &
65 echo \$! > pid
66 wait"""
67 __FLOW_CONFIG__
68
69 TEST_NAME="${TEST_NAME_BASE}-validate"
70 run_ok "${TEST_NAME}" cylc validate "${WORKFLOW_NAME}"
71
72 TEST_NAME="${TEST_NAME_BASE}-run"
73 workflow_run_ok "${TEST_NAME}" cylc play --debug --no-detach "${WORKFLOW_NAME}"
74
75 TEST_NAME="${TEST_NAME_BASE}-result"
76 cylc workflow-state --old-format "${WORKFLOW_NAME}" > workflow-state.log
77 contains_ok workflow-state.log << __END__
78 foo, 1, succeeded
79 bar, 1, succeeded
80 foo, 2, succeeded
81 foo, 3, succeeded
82 __END__
83
84 purge