| 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 held tasks |
| 19 |
. "$(dirname "$0")/test_header" |
| 20 |
set_test_number 5 |
| 21 |
install_workflow "${TEST_NAME_BASE}" "${TEST_NAME_BASE}" |
| 22 |
|
| 23 |
run_ok "${TEST_NAME_BASE}-validate" cylc validate "${WORKFLOW_NAME}" |
| 24 |
workflow_run_ok "${TEST_NAME_BASE}-run" \ |
| 25 |
cylc play "${WORKFLOW_NAME}" --debug --no-detach --abort-if-any-task-fails |
| 26 |
|
| 27 |
T1_2016_PID="$(sed -n 's/CYLC_JOB_PID=//p' "${WORKFLOW_RUN_DIR}/log/job/2016/t1/01/job.status")" |
| 28 |
poll_pid_done "${T1_2016_PID}" |
| 29 |
|
| 30 |
sqlite3 "${WORKFLOW_RUN_DIR}/log/db" \ |
| 31 |
'SELECT cycle, name, status FROM task_pool WHERE is_held IS 1 ORDER by cycle, name' >'workflow-stopped.out' |
| 32 |
cmp_ok 'workflow-stopped.out' <<'__OUT__' |
| 33 |
2016|t2|waiting |
| 34 |
2017|t1|waiting |
| 35 |
__OUT__ |
| 36 |
|
| 37 |
# Restart |
| 38 |
cylc play "${WORKFLOW_NAME}" --debug --no-detach 1>"${TEST_NAME_BASE}-restart.out" 2>&1 & |
| 39 |
CYLC_RESTART_PID=$! |
| 40 |
poll_workflow_running |
| 41 |
|
| 42 |
cylc release "${WORKFLOW_NAME}//2016/t2" |
| 43 |
poll_grep 'CYLC_JOB_EXIT' "${WORKFLOW_RUN_DIR}/log/job/2016/t2/01/job.status" |
| 44 |
|
| 45 |
cylc release --all "${WORKFLOW_NAME}" |
| 46 |
cylc poll "${WORKFLOW_NAME}//*" |
| 47 |
|
| 48 |
# Ensure workflow has completed |
| 49 |
run_ok "${TEST_NAME_BASE}-restart" wait "${CYLC_RESTART_PID}" |
| 50 |
|
| 51 |
sqlite3 "${WORKFLOW_RUN_DIR}/log/db" \ |
| 52 |
'SELECT cycle, name, status FROM task_pool ORDER BY cycle, name' >'task-pool.out' |
| 53 |
cmp_ok 'task-pool.out' < /dev/null |
| 54 |
|
| 55 |
purge |
| 56 |
exit |