Debian Codegraph @

tests/functional/workflow-state/01-polling.t

raw
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 5
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 # this version uses a simple Rose-style workflow name [\w-]
30 UPSTREAM="${WORKFLOW_NAME}-upstream"
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"
38 run_ok "${TEST_NAME}" \
39 cylc validate --debug --set="UPSTREAM='${UPSTREAM}'" "${WORKFLOW_NAME}"
40
41 #-------------------------------------------------------------------------------
42 # check auto-generated task script for lbad
43 cylc config -d \
44 --set="UPSTREAM='${UPSTREAM}'" \
45 -i '[runtime][lbad]script' "${WORKFLOW_NAME}" >'lbad.script'
46 cmp_ok 'lbad.script' << __END__
47 echo cylc workflow-state ${UPSTREAM}//\$CYLC_TASK_CYCLE_POINT/bad:failed --interval=2 --max-polls=20
48 cylc workflow-state ${UPSTREAM}//\$CYLC_TASK_CYCLE_POINT/bad:failed --interval=2 --max-polls=20
49 __END__
50
51 # check auto-generated task script for l-good
52 cylc config -d \
53 --set="UPSTREAM='${UPSTREAM}'" \
54 -i '[runtime][l-good]script' "${WORKFLOW_NAME}" >'l-good.script'
55 cmp_ok 'l-good.script' << __END__
56 echo cylc workflow-state ${UPSTREAM}//\$CYLC_TASK_CYCLE_POINT/good-stuff:succeeded --interval=2 --max-polls=20
57 cylc workflow-state ${UPSTREAM}//\$CYLC_TASK_CYCLE_POINT/good-stuff:succeeded --interval=2 --max-polls=20
58 __END__
59
60 #-------------------------------------------------------------------------------
61 # run the upstream workflow and detach (not a test)
62 cylc play "${UPSTREAM}" 1>'upstream.out' 2>&1
63
64 #-------------------------------------------------------------------------------
65 # run the workflow-state polling test workflow
66 TEST_NAME="${TEST_NAME_BASE}-run"
67 workflow_run_ok "${TEST_NAME}" \
68 cylc play --reference-test --debug --no-detach --set="UPSTREAM='${UPSTREAM}'" \
69 "${WORKFLOW_NAME}"
70
71 #-------------------------------------------------------------------------------
72 purge
73
74 #-------------------------------------------------------------------------------
75 # clean up the upstream workflow
76 # just in case (expect error message here, but exit 0):
77 cylc stop --now "${UPSTREAM}" --max-polls=20 --interval=2 >'/dev/null' 2>&1
78 purge "${UPSTREAM}"
79 exit