| 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 remote job logs retrieval custom command, requires compatible version of |
| 19 |
# cylc on remote job host. |
| 20 |
export REQUIRE_PLATFORM='loc:remote' |
| 21 |
. "$(dirname "$0")/test_header" |
| 22 |
set_test_number 3 |
| 23 |
|
| 24 |
create_test_global_config "" " |
| 25 |
[platforms] |
| 26 |
[[${CYLC_TEST_PLATFORM}]] |
| 27 |
retrieve job logs = True |
| 28 |
retrieve job logs command = my-rsync |
| 29 |
" |
| 30 |
OPT_SET='-s GLOBALCFG=True' |
| 31 |
|
| 32 |
install_workflow "${TEST_NAME_BASE}" "${TEST_NAME_BASE}" |
| 33 |
mkdir -p "${RUN_DIR}/${WORKFLOW_NAME}/bin" |
| 34 |
cat >"${RUN_DIR}/${WORKFLOW_NAME}/bin/my-rsync" <<'__BASH__' |
| 35 |
#!/usr/bin/env bash |
| 36 |
set -eu |
| 37 |
echo "$@" >>"${CYLC_WORKFLOW_LOG_DIR}/my-rsync.log" |
| 38 |
exec rsync -a "$@" |
| 39 |
__BASH__ |
| 40 |
chmod +x "${RUN_DIR}/${WORKFLOW_NAME}/bin/my-rsync" |
| 41 |
|
| 42 |
# shellcheck disable=SC2086 |
| 43 |
run_ok "${TEST_NAME_BASE}-validate" \ |
| 44 |
cylc validate ${OPT_SET} -s "PLATFORM='${CYLC_TEST_PLATFORM}'" "${WORKFLOW_NAME}" |
| 45 |
# shellcheck disable=SC2086 |
| 46 |
workflow_run_ok "${TEST_NAME_BASE}-run" \ |
| 47 |
cylc play --reference-test --debug --no-detach ${OPT_SET} \ |
| 48 |
-s "PLATFORM='${CYLC_TEST_PLATFORM}'" "${WORKFLOW_NAME}" |
| 49 |
|
| 50 |
WORKFLOW_LOG_D="${RUN_DIR}/${WORKFLOW_NAME}/log" |
| 51 |
sed 's/^.* -v //' "${WORKFLOW_LOG_D}/scheduler/my-rsync.log" >'my-rsync.log.edited' |
| 52 |
|
| 53 |
OPT_HEAD='--include=/1 --include=/1/t1' |
| 54 |
OPT_TAIL='--exclude=/**' |
| 55 |
ARGS="${CYLC_TEST_HOST}:cylc-run/${WORKFLOW_NAME}/log/job/ ${WORKFLOW_LOG_D}/job/" |
| 56 |
cmp_ok 'my-rsync.log.edited' <<__LOG__ |
| 57 |
${OPT_HEAD} --include=/1/t1/01 --include=/1/t1/01/** ${OPT_TAIL} ${ARGS} |
| 58 |
${OPT_HEAD} --include=/1/t1/02 --include=/1/t1/02/** ${OPT_TAIL} ${ARGS} |
| 59 |
${OPT_HEAD} --include=/1/t1/03 --include=/1/t1/03/** ${OPT_TAIL} ${ARGS} |
| 60 |
__LOG__ |
| 61 |
|
| 62 |
purge |
| 63 |
exit |