| 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 |
export REQUIRE_PLATFORM='loc:remote fs:shared runner:background' |
| 19 |
. "$(dirname "$0")/test_header" |
| 20 |
set_test_number 3 |
| 21 |
#------------------------------------------------------------------------------- |
| 22 |
|
| 23 |
# The Cylc CLI can "infer" run numbers e.g. `cylc play foo` might run `foo/run1`. |
| 24 |
# This makes monitoring difficult because you can't see what workflow run a Cylc |
| 25 |
# process is running so when/if we re-invoke the `cylc play` command on a remote |
| 26 |
# host we use the full ID (including the run number) not the abbreviated version. |
| 27 |
|
| 28 |
# install a workflow *with* the standard run numbers |
| 29 |
echo ' |
| 30 |
[scheduler] |
| 31 |
allow implicit tasks = True |
| 32 |
[scheduling] |
| 33 |
[[graph]] |
| 34 |
R1 = one |
| 35 |
' > flow.cylc |
| 36 |
init_workflow "${TEST_NAME_BASE}" flow.cylc true |
| 37 |
WORKFLOW_RUN_DIR="$WORKFLOW_RUN_DIR/run1" # allow poll_workflow to work |
| 38 |
|
| 39 |
# get the workflow to startup on the test platform |
| 40 |
create_test_global_config '' " |
| 41 |
[scheduler] |
| 42 |
[[run hosts]] |
| 43 |
available = ${CYLC_TEST_HOST} |
| 44 |
" |
| 45 |
|
| 46 |
# run the workflow |
| 47 |
workflow_run_ok "${TEST_NAME_BASE}-run" cylc play --pause "${WORKFLOW_NAME}" |
| 48 |
poll_workflow_running |
| 49 |
|
| 50 |
# extract the command being run from the contact file |
| 51 |
run_ok "${TEST_NAME_BASE}-cmd" \ |
| 52 |
cylc get-workflow-contact "${WORKFLOW_NAME}" |
| 53 |
sed -n -i 's/CYLC_WORKFLOW_COMMAND=.*cylc //p' "${TEST_NAME_BASE}-cmd.stdout" |
| 54 |
|
| 55 |
# ensure the whole workflow ID is present in the command (including the run number) |
| 56 |
CMD="^play --pause ${WORKFLOW_NAME}/run1 --host=localhost --color=never$" |
| 57 |
if grep "${CMD}" "${TEST_NAME_BASE}-cmd.stdout"; then |
| 58 |
ok "${TEST_NAME_BASE}-re-invoked-id" |
| 59 |
else |
| 60 |
fail "${TEST_NAME_BASE}-re-invoked-id" |
| 61 |
fi |
| 62 |
|
| 63 |
# shutdown |
| 64 |
cylc stop "${WORKFLOW_NAME}" |
| 65 |
poll_workflow_stopped |
| 66 |
|
| 67 |
purge |
| 68 |
exit |