| 1 |
#!/bin/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 custom task prerequisites and the task_prerequisites DB table work as |
| 19 |
# expected |
| 20 |
|
| 21 |
. "$(dirname "$0")/test_header" |
| 22 |
|
| 23 |
set_test_number 7 |
| 24 |
|
| 25 |
install_workflow "${TEST_NAME_BASE}" "${TEST_NAME_BASE}" |
| 26 |
|
| 27 |
run_ok "${TEST_NAME_BASE}-validate" cylc validate "${WORKFLOW_NAME}" |
| 28 |
workflow_run_fail "${TEST_NAME_BASE}-run" cylc play "${WORKFLOW_NAME}" --stopcp=2 --no-detach |
| 29 |
|
| 30 |
DB_FILE="${WORKFLOW_RUN_DIR}/log/db" |
| 31 |
|
| 32 |
# Check task_prerequisites table: |
| 33 |
TEST_NAME="${TEST_NAME_BASE}-db-task-prereq" |
| 34 |
QUERY='SELECT * FROM task_prerequisites ORDER BY cycle, name, prereq_cycle;' |
| 35 |
run_ok "$TEST_NAME" sqlite3 "$DB_FILE" "$QUERY" |
| 36 |
cmp_ok "${TEST_NAME}.stdout" << '__EOF__' |
| 37 |
2|bar|[1]|foo|1|succeeded|0 |
| 38 |
2|bar|[1]|apollo|2|The Eagle has landed|satisfied naturally |
| 39 |
3|bar|[1]|foo|2|succeeded|satisfied naturally |
| 40 |
3|bar|[1]|apollo|3|The Eagle has landed|0 |
| 41 |
__EOF__ |
| 42 |
|
| 43 |
workflow_run_fail "${TEST_NAME_BASE}-restart" cylc play "${WORKFLOW_NAME}" --stopcp=3 --no-detach |
| 44 |
|
| 45 |
# Check 2/bar is still waiting (i.e. prereqs not satisfied): |
| 46 |
TEST_NAME="${TEST_NAME_BASE}-db-task-pool" |
| 47 |
QUERY='SELECT cycle, name, status FROM task_pool ORDER BY cycle, name;' |
| 48 |
run_ok "$TEST_NAME" sqlite3 "$DB_FILE" "$QUERY" |
| 49 |
cmp_ok "${TEST_NAME}.stdout" << '__EOF__' |
| 50 |
1|foo|failed |
| 51 |
2|bar|waiting |
| 52 |
4|apollo|waiting |
| 53 |
4|bar|waiting |
| 54 |
4|foo|waiting |
| 55 |
__EOF__ |
| 56 |
|
| 57 |
purge |
| 58 |
exit |