| 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 reloaded final point |
| 19 |
|
| 20 |
. "$(dirname "$0")/test_header" |
| 21 |
|
| 22 |
dumpdbtables() { |
| 23 |
sqlite3 "${WORKFLOW_RUN_DIR}/log/db" \ |
| 24 |
"SELECT * FROM workflow_params WHERE key=='fcp';" >'fcp.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 13 |
| 30 |
|
| 31 |
# Event should look like this: |
| 32 |
# Start workflow with final point = 2018 |
| 33 |
# Request workflow stop while at 2015 |
| 34 |
# Restart |
| 35 |
# Workflow runs to final cycle point == 2018 |
| 36 |
# Restart |
| 37 |
# Workflow stop immediately |
| 38 |
# Restart, reload final cycle point |
| 39 |
# Workflow runs to final cycle point == 2020 |
| 40 |
init_workflow "${TEST_NAME_BASE}" <<'__FLOW_CONFIG__' |
| 41 |
[scheduler] |
| 42 |
UTC mode=True |
| 43 |
cycle point format = %Y |
| 44 |
[[events]] |
| 45 |
abort on stall timeout = True |
| 46 |
stall timeout = PT0S |
| 47 |
abort on inactivity timeout = True |
| 48 |
inactivity timeout = P1M |
| 49 |
[scheduling] |
| 50 |
initial cycle point = 2015 |
| 51 |
final cycle point = 2018 |
| 52 |
[[graph]] |
| 53 |
P1Y = t1[-P1Y] => t1 |
| 54 |
[runtime] |
| 55 |
[[t1]] |
| 56 |
script = """ |
| 57 |
case "${CYLC_TASK_CYCLE_POINT}" in |
| 58 |
2015) |
| 59 |
cylc stop "${CYLC_WORKFLOW_ID}" |
| 60 |
:;; |
| 61 |
esac |
| 62 |
""" |
| 63 |
__FLOW_CONFIG__ |
| 64 |
|
| 65 |
run_ok "${TEST_NAME_BASE}-validate" cylc validate "${WORKFLOW_NAME}" |
| 66 |
|
| 67 |
workflow_run_ok "${TEST_NAME_BASE}-run" \ |
| 68 |
cylc play "${WORKFLOW_NAME}" --no-detach --fcp=2017 |
| 69 |
dumpdbtables |
| 70 |
cmp_ok 'fcp.out' <<<'fcp|2017' |
| 71 |
cmp_ok 'taskpool.out' <<'__OUT__' |
| 72 |
2016|t1|waiting |
| 73 |
__OUT__ |
| 74 |
|
| 75 |
workflow_run_ok "${TEST_NAME_BASE}-restart-1" \ |
| 76 |
cylc play "${WORKFLOW_NAME}" --no-detach |
| 77 |
dumpdbtables |
| 78 |
cmp_ok 'fcp.out' <<<'fcp|2017' |
| 79 |
cmp_ok 'taskpool.out' <'/dev/null' |
| 80 |
|
| 81 |
workflow_run_ok "${TEST_NAME_BASE}-restart-2" \ |
| 82 |
cylc play "${WORKFLOW_NAME}" --no-detach |
| 83 |
dumpdbtables |
| 84 |
cmp_ok 'fcp.out' <<<'fcp|2017' |
| 85 |
cmp_ok 'taskpool.out' <'/dev/null' |
| 86 |
|
| 87 |
workflow_run_ok "${TEST_NAME_BASE}-restart-3" \ |
| 88 |
cylc play "${WORKFLOW_NAME}" --no-detach --fcp=reload |
| 89 |
dumpdbtables |
| 90 |
cmp_ok 'fcp.out' <<<'fcp|' |
| 91 |
cmp_ok 'taskpool.out' <'/dev/null' |
| 92 |
|
| 93 |
purge |