| 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 restarting a simple workflow with a broadcast |
| 19 |
if [[ -z ${TEST_DIR:-} ]]; then |
| 20 |
. "$(dirname "$0")/test_header" |
| 21 |
fi |
| 22 |
#------------------------------------------------------------------------------- |
| 23 |
set_test_number 8 |
| 24 |
#------------------------------------------------------------------------------- |
| 25 |
install_workflow "${TEST_NAME_BASE}" 'broadcast' |
| 26 |
cp "$TEST_SOURCE_DIR/lib/flow-runtime-restart.cylc" "${WORKFLOW_RUN_DIR}/" |
| 27 |
#------------------------------------------------------------------------------- |
| 28 |
TEST_NAME="${TEST_NAME_BASE}-validate" |
| 29 |
run_ok "${TEST_NAME}" cylc validate "${WORKFLOW_NAME}" |
| 30 |
cmp_ok "${TEST_NAME}.stderr" <'/dev/null' |
| 31 |
#------------------------------------------------------------------------------- |
| 32 |
TEST_NAME="${TEST_NAME_BASE}-run" |
| 33 |
workflow_run_ok "${TEST_NAME}" cylc play --debug --no-detach --abort-if-any-task-fails "${WORKFLOW_NAME}" |
| 34 |
#------------------------------------------------------------------------------- |
| 35 |
TEST_NAME="${TEST_NAME_BASE}-restart-run" |
| 36 |
workflow_run_ok "${TEST_NAME}" cylc play --debug --no-detach --abort-if-any-task-fails "${WORKFLOW_NAME}" |
| 37 |
#------------------------------------------------------------------------------- |
| 38 |
grep_ok "send_a_broadcast_task|20130923T0000Z|1|1|succeeded" \ |
| 39 |
"${WORKFLOW_RUN_DIR}/pre-restart-db" |
| 40 |
contains_ok "${WORKFLOW_RUN_DIR}/post-restart-db" <<'__DB_DUMP__' |
| 41 |
send_a_broadcast_task|20130923T0000Z|1|1|succeeded |
| 42 |
shutdown|20130923T0000Z|1|1|succeeded |
| 43 |
__DB_DUMP__ |
| 44 |
"${WORKFLOW_RUN_DIR}/bin/ctb-select-task-states" "${WORKFLOW_RUN_DIR}" \ |
| 45 |
> "${TEST_DIR}/db" |
| 46 |
contains_ok "${TEST_DIR}/db" <<'__DB_DUMP__' |
| 47 |
broadcast_task|20130923T0000Z|1|1|succeeded |
| 48 |
finish|20130923T0000Z|1|1|succeeded |
| 49 |
output_states|20130923T0000Z|1|1|succeeded |
| 50 |
send_a_broadcast_task|20130923T0000Z|1|1|succeeded |
| 51 |
shutdown|20130923T0000Z|1|1|succeeded |
| 52 |
__DB_DUMP__ |
| 53 |
sqlite3 "${WORKFLOW_RUN_DIR}/log/db" ' |
| 54 |
SELECT |
| 55 |
point,namespace,key,value |
| 56 |
FROM |
| 57 |
broadcast_states |
| 58 |
ORDER BY |
| 59 |
point,namespace,key' >'select-broadcast-states.out' |
| 60 |
cmp_ok 'select-broadcast-states.out' \ |
| 61 |
<<<"20130923T0000Z|broadcast_task|[environment]MY_VALUE|'something'" |
| 62 |
#------------------------------------------------------------------------------- |
| 63 |
purge |