| 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 restart with stop task |
| 19 |
|
| 20 |
. "$(dirname "$0")/test_header" |
| 21 |
|
| 22 |
dumpdbtables() { |
| 23 |
sqlite3 "${WORKFLOW_RUN_DIR}/log/db" \ |
| 24 |
"SELECT value FROM workflow_params WHERE key=='stop_task';" >'stoptask.out' |
| 25 |
sqlite3 "${WORKFLOW_RUN_DIR}/log/db" \ |
| 26 |
'SELECT cycle, name, status FROM task_pool ORDER BY cycle, name;' >'taskpool.out' |
| 27 |
} |
| 28 |
|
| 29 |
set_test_number 10 |
| 30 |
|
| 31 |
# Event should look like this: |
| 32 |
# Start workflow |
| 33 |
# At 1/t1, set stop task to 1/t5 |
| 34 |
# At 1/t2, stop workflow at 1/t2 |
| 35 |
# Restart |
| 36 |
# Workflow runs to stop task 1/t5, reset stop task. |
| 37 |
# Restart |
| 38 |
# Workflow stops normally at 1/t8 |
| 39 |
init_workflow "${TEST_NAME_BASE}" <<'__FLOW_CONFIG__' |
| 40 |
[task parameters] |
| 41 |
i = 1..8 |
| 42 |
[scheduler] |
| 43 |
[[events]] |
| 44 |
abort on stall timeout = True |
| 45 |
stall timeout = PT0S |
| 46 |
abort on inactivity timeout = True |
| 47 |
inactivity timeout = P1M |
| 48 |
[scheduling] |
| 49 |
[[graph]] |
| 50 |
R1 = t<i-1> => t<i> |
| 51 |
[runtime] |
| 52 |
[[t<i>]] |
| 53 |
script = true |
| 54 |
[[t<i=1>]] |
| 55 |
script = cylc stop "${CYLC_WORKFLOW_ID}//1/t_i5" |
| 56 |
[[t<i=2>]] |
| 57 |
script = cylc stop "${CYLC_WORKFLOW_ID}" |
| 58 |
__FLOW_CONFIG__ |
| 59 |
|
| 60 |
run_ok "${TEST_NAME_BASE}-validate" cylc validate "${WORKFLOW_NAME}" |
| 61 |
|
| 62 |
workflow_run_ok "${TEST_NAME_BASE}-run" cylc play "${WORKFLOW_NAME}" --no-detach |
| 63 |
dumpdbtables |
| 64 |
cmp_ok 'stoptask.out' <<<'1/t_i5' |
| 65 |
cmp_ok 'taskpool.out' <<'__OUT__' |
| 66 |
1|t_i3|waiting |
| 67 |
__OUT__ |
| 68 |
|
| 69 |
workflow_run_ok "${TEST_NAME_BASE}-restart-1" \ |
| 70 |
cylc play "${WORKFLOW_NAME}" --no-detach |
| 71 |
dumpdbtables |
| 72 |
cmp_ok 'stoptask.out' <<<'' |
| 73 |
cmp_ok 'taskpool.out' <<'__OUT__' |
| 74 |
1|t_i6|waiting |
| 75 |
__OUT__ |
| 76 |
|
| 77 |
workflow_run_ok "${TEST_NAME_BASE}-restart-2" \ |
| 78 |
cylc play "${WORKFLOW_NAME}" --no-detach |
| 79 |
dumpdbtables |
| 80 |
cmp_ok 'stoptask.out' <<<'' |
| 81 |
cmp_ok 'taskpool.out' <'/dev/null' |
| 82 |
|
| 83 |
purge |
| 84 |
exit |