| 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 |
# Check that workflow does not run beyond stopcp whether set in flow.cylc or |
| 19 |
# on the command line. |
| 20 |
|
| 21 |
. "$(dirname "$0")/test_header" |
| 22 |
|
| 23 |
dumpdbtables() { |
| 24 |
sqlite3 "${WORKFLOW_RUN_DIR}/log/db" \ |
| 25 |
"SELECT value FROM workflow_params WHERE key=='stopcp';" > db_stopcp.out |
| 26 |
sqlite3 "${WORKFLOW_RUN_DIR}/log/db" \ |
| 27 |
'SELECT cycle, name, status FROM task_pool ORDER BY cycle, name;' > db_taskpool.out.out |
| 28 |
} |
| 29 |
|
| 30 |
set_test_number 29 |
| 31 |
install_workflow "${TEST_NAME_BASE}" "${TEST_NAME_BASE}" |
| 32 |
|
| 33 |
# Set the config stop point (accessed via Jinja2) |
| 34 |
export CFG_STOPCP |
| 35 |
CFG_STOPCP="1970" |
| 36 |
|
| 37 |
run_ok "${TEST_NAME_BASE}-validate" cylc validate "${WORKFLOW_NAME}" |
| 38 |
|
| 39 |
|
| 40 |
# Check config stop point works |
| 41 |
workflow_run_ok "${TEST_NAME_BASE}-run" \ |
| 42 |
cylc play --no-detach "${WORKFLOW_NAME}" |
| 43 |
grep_workflow_log_ok "${TEST_NAME_BASE}-log-grep" "Stop point: 1970" |
| 44 |
dumpdbtables |
| 45 |
# Task 1971/hello (after stop point) should be spawned but not submitted |
| 46 |
cmp_ok db_taskpool.out.out << '__OUT__' |
| 47 |
1971|hello|waiting |
| 48 |
__OUT__ |
| 49 |
# Check that the config stop point does not get stored in DB |
| 50 |
cmp_ok db_stopcp.out <<< '' |
| 51 |
|
| 52 |
|
| 53 |
CFG_STOPCP="1972" |
| 54 |
|
| 55 |
# Check that changing config stop point has worked |
| 56 |
workflow_run_ok "${TEST_NAME_BASE}-restart" \ |
| 57 |
cylc play --no-detach "${WORKFLOW_NAME}" \ |
| 58 |
-s 'MANUAL_SHUTDOWN="1971"' |
| 59 |
grep_workflow_log_ok "${TEST_NAME_BASE}-log-grep" "Stop point: 1972" |
| 60 |
dumpdbtables |
| 61 |
# Note we have manually stopped at 1971 before the stop point at 1972: |
| 62 |
# 1972: waiting |
| 63 |
# 1973: waiting and runahead limited |
| 64 |
cmp_ok db_taskpool.out.out << '__OUT__' |
| 65 |
1972|hello|waiting |
| 66 |
1973|hello|waiting |
| 67 |
__OUT__ |
| 68 |
cmp_ok db_stopcp.out <<< '' |
| 69 |
|
| 70 |
|
| 71 |
# Check that the command line stop point works |
| 72 |
workflow_run_ok "${TEST_NAME_BASE}-restart-cli-stopcp" \ |
| 73 |
cylc play --no-detach --stopcp=1974 "${WORKFLOW_NAME}" \ |
| 74 |
-s 'MANUAL_SHUTDOWN="1973"' |
| 75 |
grep_workflow_log_ok "${TEST_NAME_BASE}-log-grep" "Stop point: 1974" |
| 76 |
dumpdbtables |
| 77 |
# Note we have manually stopped before the stop point |
| 78 |
cmp_ok db_taskpool.out.out << '__OUT__' |
| 79 |
1974|hello|waiting |
| 80 |
1975|hello|waiting |
| 81 |
__OUT__ |
| 82 |
# Check CLI stop point is stored in DB |
| 83 |
cmp_ok db_stopcp.out <<< '1974' |
| 84 |
|
| 85 |
|
| 86 |
# Check that the stop point stored in DB works on restart |
| 87 |
workflow_run_ok "${TEST_NAME_BASE}-restart-db-stopcp" \ |
| 88 |
cylc play --no-detach "${WORKFLOW_NAME}" |
| 89 |
grep_workflow_log_ok "${TEST_NAME_BASE}-log-grep" "Stop point: 1974" |
| 90 |
dumpdbtables |
| 91 |
cmp_ok db_taskpool.out.out <<'__OUT__' |
| 92 |
1975|hello|waiting |
| 93 |
__OUT__ |
| 94 |
# Stop point should be removed from DB once reached |
| 95 |
cmp_ok db_stopcp.out <<< '' |
| 96 |
|
| 97 |
|
| 98 |
# Restart again with new CLI stop point |
| 99 |
workflow_run_ok "${TEST_NAME_BASE}-restart-cli-stopcp-2" \ |
| 100 |
cylc play --no-detach --stopcp=1978 "${WORKFLOW_NAME}" \ |
| 101 |
-s 'MANUAL_SHUTDOWN="1975"' |
| 102 |
grep_workflow_log_ok "${TEST_NAME_BASE}-log-grep" "Stop point: 1978" |
| 103 |
dumpdbtables |
| 104 |
# Note we have manually stopped before the stop point |
| 105 |
cmp_ok db_taskpool.out.out << '__OUT__' |
| 106 |
1976|hello|waiting |
| 107 |
1977|hello|waiting |
| 108 |
__OUT__ |
| 109 |
cmp_ok db_stopcp.out <<< '1978' |
| 110 |
|
| 111 |
|
| 112 |
CFG_STOPCP="1979" |
| 113 |
|
| 114 |
# Check that --stopcp=reload takes value from flow.cylc on restart |
| 115 |
workflow_run_ok "${TEST_NAME_BASE}-restart-cli-stopcp-reload" \ |
| 116 |
cylc play --no-detach --stopcp=reload "${WORKFLOW_NAME}" \ |
| 117 |
-s 'MANUAL_SHUTDOWN="1976"' |
| 118 |
grep_workflow_log_ok "${TEST_NAME_BASE}-log-grep" "Stop point: 1979" |
| 119 |
dumpdbtables |
| 120 |
cmp_ok db_taskpool.out.out << '__OUT__' |
| 121 |
1977|hello|waiting |
| 122 |
1978|hello|waiting |
| 123 |
__OUT__ |
| 124 |
# Stop point should be removed from DB if --stopcp=reload used |
| 125 |
cmp_ok db_stopcp.out <<< '' |
| 126 |
|
| 127 |
|
| 128 |
CFG_STOPCP="1971" |
| 129 |
|
| 130 |
# Check that workflow stops immediately if restarted past stopcp |
| 131 |
workflow_run_ok "${TEST_NAME_BASE}-restart-past-stopcp" \ |
| 132 |
cylc play --no-detach "${WORKFLOW_NAME}" |
| 133 |
grep_workflow_log_ok "${TEST_NAME_BASE}-log-grep" "Stop point: 1971" |
| 134 |
dumpdbtables |
| 135 |
cmp_ok db_taskpool.out.out << '__OUT__' |
| 136 |
1977|hello|waiting |
| 137 |
1978|hello|waiting |
| 138 |
__OUT__ |
| 139 |
cmp_ok db_stopcp.out <<< '' |
| 140 |
|
| 141 |
purge |