| 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 |
# Validate and run the workflow-state/polling test workflow |
| 19 |
# The test workflow is in polling/; it depends on another workflow in upstream/ |
| 20 |
|
| 21 |
. "$(dirname "$0")/test_header" |
| 22 |
#------------------------------------------------------------------------------- |
| 23 |
set_test_number 7 |
| 24 |
#------------------------------------------------------------------------------- |
| 25 |
install_workflow "${TEST_NAME_BASE}" 'polling' |
| 26 |
#------------------------------------------------------------------------------- |
| 27 |
# copy the upstream workflow to the test directory and install it |
| 28 |
cp -r "${TEST_SOURCE_DIR}/upstream" "${TEST_DIR}/" |
| 29 |
# use full range of characters in the workflow-to-be-polled name: |
| 30 |
UPSTREAM="${WORKFLOW_NAME}-up_stre.am" |
| 31 |
cylc install "${TEST_DIR}/upstream" --workflow-name="${UPSTREAM}" --no-run-name |
| 32 |
#------------------------------------------------------------------------------- |
| 33 |
# validate both workflows as tests |
| 34 |
TEST_NAME="${TEST_NAME_BASE}-validate-upstream" |
| 35 |
run_ok "${TEST_NAME}" cylc validate --debug "${UPSTREAM}" |
| 36 |
|
| 37 |
TEST_NAME=${TEST_NAME_BASE}-validate-polling-y |
| 38 |
run_fail "${TEST_NAME}" \ |
| 39 |
cylc validate --set="UPSTREAM='${UPSTREAM}'" --set="OUTPUT=':y'" "${WORKFLOW_NAME}" |
| 40 |
|
| 41 |
contains_ok "${TEST_NAME}.stderr" <<__ERR__ |
| 42 |
WorkflowConfigError: Polling task "l-mess" must configure a target status or output message in \ |
| 43 |
the graph (:y) or task definition (message = "the quick brown fox") but not both. |
| 44 |
__ERR__ |
| 45 |
|
| 46 |
TEST_NAME=${TEST_NAME_BASE}-validate-polling |
| 47 |
run_ok "${TEST_NAME}" \ |
| 48 |
cylc validate --debug --set="UPSTREAM='${UPSTREAM}'" "${WORKFLOW_NAME}" |
| 49 |
|
| 50 |
#------------------------------------------------------------------------------- |
| 51 |
# run the upstream workflow and detach (not a test) |
| 52 |
cylc play "${UPSTREAM}" |
| 53 |
|
| 54 |
#------------------------------------------------------------------------------- |
| 55 |
# check auto-generated task script for lbad |
| 56 |
cylc config -d \ |
| 57 |
--set="UPSTREAM='${UPSTREAM}'" -i '[runtime][lbad]script' "${WORKFLOW_NAME}" \ |
| 58 |
>'lbad.script' |
| 59 |
cmp_ok 'lbad.script' << __END__ |
| 60 |
echo cylc workflow-state ${UPSTREAM}//\$CYLC_TASK_CYCLE_POINT/bad:failed --interval=2 --max-polls=20 |
| 61 |
cylc workflow-state ${UPSTREAM}//\$CYLC_TASK_CYCLE_POINT/bad:failed --interval=2 --max-polls=20 |
| 62 |
__END__ |
| 63 |
|
| 64 |
# check auto-generated task script for l-good |
| 65 |
cylc config -d \ |
| 66 |
--set="UPSTREAM='${UPSTREAM}'" -i '[runtime][l-good]script' "${WORKFLOW_NAME}" \ |
| 67 |
>'l-good.script' |
| 68 |
cmp_ok 'l-good.script' << __END__ |
| 69 |
echo cylc workflow-state ${UPSTREAM}//\$CYLC_TASK_CYCLE_POINT/good-stuff:succeeded --interval=2 --max-polls=20 |
| 70 |
cylc workflow-state ${UPSTREAM}//\$CYLC_TASK_CYCLE_POINT/good-stuff:succeeded --interval=2 --max-polls=20 |
| 71 |
__END__ |
| 72 |
|
| 73 |
#------------------------------------------------------------------------------- |
| 74 |
# run the workflow-state polling test workflow |
| 75 |
TEST_NAME="${TEST_NAME_BASE}-run" |
| 76 |
workflow_run_ok "${TEST_NAME}" \ |
| 77 |
cylc play --reference-test --debug --no-detach \ |
| 78 |
--set="UPSTREAM='${UPSTREAM}'" "${WORKFLOW_NAME}" |
| 79 |
|
| 80 |
#------------------------------------------------------------------------------- |
| 81 |
purge |
| 82 |
|
| 83 |
#------------------------------------------------------------------------------- |
| 84 |
# clean up the upstream workflow |
| 85 |
# just in case (expect error message here, but exit 0): |
| 86 |
cylc stop --now "${UPSTREAM}" --max-polls=20 --interval=2 >'/dev/null' 2>&1 |
| 87 |
purge "${UPSTREAM}" |
| 88 |
exit |