| 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 |
#------------------------------------------------------------------------------ |
| 19 |
# Test workflow installation symlinking localhost |
| 20 |
|
| 21 |
. "$(dirname "$0")/test_header" |
| 22 |
|
| 23 |
if [[ -z ${TMPDIR:-} || -z ${USER:-} || $TMPDIR/$USER == "$HOME" ]]; then |
| 24 |
skip_all '"TMPDIR" or "USER" not defined or "TMPDIR"/"USER" is "HOME"' |
| 25 |
fi |
| 26 |
|
| 27 |
set_test_number 32 |
| 28 |
|
| 29 |
create_test_global_config "" " |
| 30 |
[install] |
| 31 |
[[symlink dirs]] |
| 32 |
[[[localhost]]] |
| 33 |
run = \$TMPDIR/\$USER/test_cylc_symlink/cylctb_tmp_run_dir |
| 34 |
share = \$TMPDIR/\$USER/test_cylc_symlink/ |
| 35 |
log = \$TMPDIR/\$USER/test_cylc_symlink/ |
| 36 |
log/job = \$TMPDIR/\$USER/test_cylc_symlink/job_log_dir |
| 37 |
share/cycle = \$TMPDIR/\$USER/test_cylc_symlink/cylctb_tmp_share_dir |
| 38 |
work = \$TMPDIR/\$USER/test_cylc_symlink/ |
| 39 |
" |
| 40 |
|
| 41 |
# Test "cylc install" ensure symlinks are created |
| 42 |
TEST_NAME="${TEST_NAME_BASE}-symlinks-created" |
| 43 |
make_rnd_workflow |
| 44 |
run_ok "${TEST_NAME}" cylc install --workflow-name="${RND_WORKFLOW_NAME}" "${RND_WORKFLOW_SOURCE}" |
| 45 |
contains_ok "${TEST_NAME}.stdout" <<__OUT__ |
| 46 |
INSTALLED $RND_WORKFLOW_NAME/run1 from ${RND_WORKFLOW_SOURCE} |
| 47 |
__OUT__ |
| 48 |
WORKFLOW_RUN_DIR="$HOME/cylc-run/${RND_WORKFLOW_NAME}/run1" |
| 49 |
TEST_SYM="${TEST_NAME_BASE}-run-glblcfg" |
| 50 |
run_ok "${TEST_SYM}" test "$(readlink "${WORKFLOW_RUN_DIR}")" \ |
| 51 |
= "$TMPDIR/${USER}/test_cylc_symlink/cylctb_tmp_run_dir/cylc-run/${RND_WORKFLOW_NAME}/run1" |
| 52 |
|
| 53 |
TEST_SYM="${TEST_NAME_BASE}-share-cycle-glblcfg" |
| 54 |
run_ok "${TEST_SYM}" test "$(readlink "${WORKFLOW_RUN_DIR}/share/cycle")" \ |
| 55 |
= "$TMPDIR/${USER}/test_cylc_symlink/cylctb_tmp_share_dir/cylc-run/${RND_WORKFLOW_NAME}/run1/share/cycle" |
| 56 |
|
| 57 |
TEST_SYM="${TEST_NAME_BASE}-log-job-glblcfg" |
| 58 |
run_ok "${TEST_SYM}" test "$(readlink "${WORKFLOW_RUN_DIR}/log/job")" \ |
| 59 |
= "$TMPDIR/${USER}/test_cylc_symlink/job_log_dir/cylc-run/${RND_WORKFLOW_NAME}/run1/log/job" |
| 60 |
|
| 61 |
for DIR in 'work' 'share' 'log'; do |
| 62 |
TEST_SYM="${TEST_NAME_BASE}-${DIR}-glbcfg" |
| 63 |
run_ok "${TEST_SYM}" test "$(readlink "${WORKFLOW_RUN_DIR}/${DIR}")" \ |
| 64 |
= "$TMPDIR/${USER}/test_cylc_symlink/cylc-run/${RND_WORKFLOW_NAME}/run1/${DIR}" |
| 65 |
done |
| 66 |
rm -rf "${TMPDIR}/${USER}/test_cylc_symlink/" |
| 67 |
purge_rnd_workflow |
| 68 |
|
| 69 |
# test cli --symlink-dirs overrides the glblcfg |
| 70 |
SYMDIR=${TMPDIR}/${USER}/test_cylc_cli_symlink/ |
| 71 |
|
| 72 |
TEST_NAME="${TEST_NAME_BASE}-cli-opt-install" |
| 73 |
make_rnd_workflow |
| 74 |
run_ok "${TEST_NAME}" cylc install "${RND_WORKFLOW_SOURCE}" \ |
| 75 |
--workflow-name="${RND_WORKFLOW_NAME}" \ |
| 76 |
--symlink-dirs="run= ${SYMDIR}cylctb_tmp_run_dir, log=${SYMDIR}, share=${SYMDIR}, \ |
| 77 |
work = ${SYMDIR}" |
| 78 |
contains_ok "${TEST_NAME}.stdout" <<__OUT__ |
| 79 |
INSTALLED $RND_WORKFLOW_NAME/run1 from ${RND_WORKFLOW_SOURCE} |
| 80 |
__OUT__ |
| 81 |
WORKFLOW_RUN_DIR="$HOME/cylc-run/${RND_WORKFLOW_NAME}/run1" |
| 82 |
|
| 83 |
TEST_SYM="${TEST_NAME_BASE}-run-cli" |
| 84 |
run_ok "$TEST_SYM" test "$(readlink "${WORKFLOW_RUN_DIR}")" \ |
| 85 |
= "$TMPDIR/${USER}/test_cylc_cli_symlink/cylctb_tmp_run_dir/cylc-run/${RND_WORKFLOW_NAME}/run1" |
| 86 |
|
| 87 |
|
| 88 |
for DIR in 'work' 'share' 'log'; do |
| 89 |
TEST_SYM="${TEST_NAME_BASE}-${DIR}-cli" |
| 90 |
run_ok "$TEST_SYM" test "$(readlink "${WORKFLOW_RUN_DIR}/${DIR}")" \ |
| 91 |
= "${TMPDIR}/${USER}/test_cylc_cli_symlink/cylc-run/${RND_WORKFLOW_NAME}/run1/${DIR}" |
| 92 |
done |
| 93 |
|
| 94 |
INSTALL_LOG="$(find "${WORKFLOW_RUN_DIR}/log/install" -type f -name '*.log')" |
| 95 |
|
| 96 |
for DIR in 'work' 'share' 'log'; do |
| 97 |
grep_ok "${TMPDIR}/${USER}/test_cylc_cli_symlink/cylc-run/${RND_WORKFLOW_NAME}/run1/${DIR}" "${INSTALL_LOG}" |
| 98 |
done |
| 99 |
|
| 100 |
# test cylc play symlinks after cli opts (mapping to different directories) |
| 101 |
|
| 102 |
pushd "${WORKFLOW_RUN_DIR}" || exit 1 |
| 103 |
cat > 'flow.cylc' << __FLOW__ |
| 104 |
[scheduling] |
| 105 |
[[graph]] |
| 106 |
R1 = foo |
| 107 |
[runtime] |
| 108 |
[[foo]] |
| 109 |
script = true |
| 110 |
__FLOW__ |
| 111 |
|
| 112 |
popd || exit 1 |
| 113 |
|
| 114 |
run_ok "${TEST_NAME_BASE}-play" cylc play "${RND_WORKFLOW_NAME}/runN" --debug --no-detach |
| 115 |
|
| 116 |
# test ensure symlinks, not in cli install are not created from glbl cfg. |
| 117 |
TEST_SYM="${TEST_NAME_BASE}-share-cycle-cli" |
| 118 |
run_fail "$TEST_SYM" test "$(readlink "${WORKFLOW_RUN_DIR}/share/cycle")" \ |
| 119 |
= "$TMPDIR/${USER}/test_cylc_symlink/cylctb_tmp_share_dir/cylc-run/${RND_WORKFLOW_NAME}/run1/share/cycle" |
| 120 |
|
| 121 |
rm -rf "${TMPDIR}/${USER}/test_cylc_cli_symlink/" |
| 122 |
purge_rnd_workflow |
| 123 |
|
| 124 |
|
| 125 |
# test no symlinks created with --symlink-dirs="" |
| 126 |
|
| 127 |
TEST_NAME="${TEST_NAME_BASE}-no-sym-dirs-cli" |
| 128 |
make_rnd_workflow |
| 129 |
run_ok "${TEST_NAME}" cylc install "${RND_WORKFLOW_SOURCE}" \ |
| 130 |
--workflow-name="${RND_WORKFLOW_NAME}" --symlink-dirs="" |
| 131 |
contains_ok "${TEST_NAME}.stdout" <<__OUT__ |
| 132 |
INSTALLED $RND_WORKFLOW_NAME/run1 from ${RND_WORKFLOW_SOURCE} |
| 133 |
__OUT__ |
| 134 |
WORKFLOW_RUN_DIR="$HOME/cylc-run/${RND_WORKFLOW_NAME}/run1" |
| 135 |
|
| 136 |
|
| 137 |
TEST_SYM="${TEST_NAME}-run" |
| 138 |
run_fail "${TEST_SYM}" test "$(readlink "${WORKFLOW_RUN_DIR}")" \ |
| 139 |
= "$TMPDIR/${USER}/test_cylc_symlink/cylctb_tmp_run_dir/cylc-run/${RND_WORKFLOW_NAME}/run1" |
| 140 |
|
| 141 |
TEST_SYM="${TEST_NAME}-share-cycle" |
| 142 |
run_fail "${TEST_SYM}" test "$(readlink "${WORKFLOW_RUN_DIR}/share/cycle")" \ |
| 143 |
= "$TMPDIR/${USER}/test_cylc_symlink/cylctb_tmp_share_dir/cylc-run/${RND_WORKFLOW_NAME}/run1/share/cycle" |
| 144 |
|
| 145 |
TEST_SYM="${TEST_NAME}-log-job" |
| 146 |
run_fail "${TEST_SYM}" test "$(readlink "${WORKFLOW_RUN_DIR}/log/job")" \ |
| 147 |
= "$TMPDIR/${USER}/test_cylc_symlink/job_log_dir/cylc-run/${RND_WORKFLOW_NAME}/run1/log/job" |
| 148 |
|
| 149 |
for DIR in 'work' 'share' 'log'; do |
| 150 |
TEST_SYM="${TEST_NAME}-${DIR}" |
| 151 |
run_fail "${TEST_SYM}" test "$(readlink "${WORKFLOW_RUN_DIR}/${DIR}")" \ |
| 152 |
= "$TMPDIR/${USER}/test_cylc_symlink/cylc-run/${RND_WORKFLOW_NAME}/run1/${DIR}" |
| 153 |
done |
| 154 |
|
| 155 |
pushd "${WORKFLOW_RUN_DIR}" || exit 1 |
| 156 |
cat > 'flow.cylc' << __FLOW__ |
| 157 |
[scheduling] |
| 158 |
[[graph]] |
| 159 |
R1 = foo |
| 160 |
[runtime] |
| 161 |
[[foo]] |
| 162 |
script = true |
| 163 |
__FLOW__ |
| 164 |
|
| 165 |
popd || exit 1 |
| 166 |
|
| 167 |
run_ok "${TEST_NAME_BASE}-play" cylc play "${RND_WORKFLOW_NAME}/runN" --debug --no-detach |
| 168 |
# test ensure localhost symlink dirs skipped for installed workflows. |
| 169 |
TEST_SYM="${TEST_NAME_BASE}-installed-workflow-skips-symdirs" |
| 170 |
run_fail "${TEST_SYM}" test "$(readlink "${WORKFLOW_RUN_DIR}")" \ |
| 171 |
= "$TMPDIR/${USER}/test_cylc_symlink/cylctb_tmp_run_dir/cylc-run/${RND_WORKFLOW_NAME}/run1" |
| 172 |
rm -rf "${TMPDIR}/${USER}/test_cylc_cli_symlink/" |
| 173 |
purge_rnd_workflow |
| 174 |
|
| 175 |
|
| 176 |
# test share and share/cycle same symlinks don't error |
| 177 |
SYMDIR=${TMPDIR}/${USER}/test_cylc_cli_symlink/ |
| 178 |
|
| 179 |
TEST_NAME="${TEST_NAME_BASE}-share-share-cycle-same-dirs" |
| 180 |
make_rnd_workflow |
| 181 |
# check install runs without failure |
| 182 |
run_ok "${TEST_NAME}" cylc install "${RND_WORKFLOW_SOURCE}" \ |
| 183 |
--workflow-name="${RND_WORKFLOW_NAME}" \ |
| 184 |
--symlink-dirs="share/cycle=${SYMDIR}, share=${SYMDIR}" |
| 185 |
contains_ok "${TEST_NAME}.stdout" <<__OUT__ |
| 186 |
INSTALLED $RND_WORKFLOW_NAME/run1 from ${RND_WORKFLOW_SOURCE} |
| 187 |
__OUT__ |
| 188 |
WORKFLOW_RUN_DIR="$HOME/cylc-run/${RND_WORKFLOW_NAME}/run1" |
| 189 |
|
| 190 |
TEST_SYM="${TEST_NAME_BASE}-share-cli" |
| 191 |
run_ok "$TEST_SYM" test "$(readlink "${WORKFLOW_RUN_DIR}/share")" \ |
| 192 |
= "${TMPDIR}/${USER}/test_cylc_cli_symlink/cylc-run/${RND_WORKFLOW_NAME}/run1/share" |
| 193 |
|
| 194 |
rm -rf "${TMPDIR}/${USER}/test_cylc_cli_symlink/" |
| 195 |
purge_rnd_workflow |