| 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 calling "cylc shutdown workflow1" from workflow2. |
| 19 |
# See https://github.com/cylc/cylc-flow/issues/1843 |
| 20 |
. "$(dirname "$0")/test_header" |
| 21 |
|
| 22 |
set_test_number 1 |
| 23 |
RUND="$RUN_DIR" |
| 24 |
NAME1="${CYLC_TEST_REG_BASE}/${TEST_SOURCE_DIR_BASE}/${TEST_NAME_BASE}-1" |
| 25 |
NAME2="${CYLC_TEST_REG_BASE}/${TEST_SOURCE_DIR_BASE}/${TEST_NAME_BASE}-2" |
| 26 |
WORKFLOW1_RUND="${RUND}/${NAME1}" |
| 27 |
RND_WORKFLOW_NAME=x$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c6) |
| 28 |
RND_WORKFLOW_SOURCE="$PWD/${RND_WORKFLOW_NAME}" |
| 29 |
mkdir -p "${RND_WORKFLOW_SOURCE}" |
| 30 |
cp -p "${TEST_SOURCE_DIR}/basic/flow.cylc" "${RND_WORKFLOW_SOURCE}" |
| 31 |
cylc install "${RND_WORKFLOW_SOURCE}" --workflow-name="${NAME1}" --no-run-name |
| 32 |
|
| 33 |
RND_WORKFLOW_NAME2=x$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c6) |
| 34 |
RND_WORKFLOW_SOURCE2="$PWD/${RND_WORKFLOW_NAME2}" |
| 35 |
mkdir -p "${RND_WORKFLOW_SOURCE2}" |
| 36 |
cat >"${RND_WORKFLOW_SOURCE2}/flow.cylc" <<__FLOW_CONFIG__ |
| 37 |
[scheduler] |
| 38 |
[[events]] |
| 39 |
[scheduling] |
| 40 |
[[graph]] |
| 41 |
R1=t1 |
| 42 |
[runtime] |
| 43 |
[[t1]] |
| 44 |
script=cylc shutdown "${NAME1}" |
| 45 |
__FLOW_CONFIG__ |
| 46 |
cylc install "${RND_WORKFLOW_SOURCE2}" --workflow-name="${NAME2}" --no-run-name |
| 47 |
cylc play --no-detach "${NAME1}" 1>'1.out' 2>&1 & |
| 48 |
WORKFLOW_RUN_DIR="${WORKFLOW1_RUND}" poll_workflow_running |
| 49 |
run_ok "${TEST_NAME_BASE}" cylc play --no-detach --abort-if-any-task-fails "${NAME2}" |
| 50 |
cylc shutdown "${NAME1}" --max-polls=20 --interval=1 1>'/dev/null' 2>&1 || true |
| 51 |
purge "${NAME1}" |
| 52 |
purge "${NAME2}" |
| 53 |
rm -rf "${RND_WORKFLOW_SOURCE}" |
| 54 |
rm -rf "${RND_WORKFLOW_SOURCE2}" |
| 55 |
exit |