| 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 failures |
| 20 |
|
| 21 |
|
| 22 |
. "$(dirname "$0")/test_header" |
| 23 |
set_test_number 45 |
| 24 |
|
| 25 |
create_test_global_config '' ' |
| 26 |
[install] |
| 27 |
max depth = 6 |
| 28 |
' |
| 29 |
|
| 30 |
# Test source directory between runs that are not consistent result in error |
| 31 |
|
| 32 |
TEST_NAME="${TEST_NAME_BASE}-forbid-inconsistent-source-dir-between-runs" |
| 33 |
SOURCE_DIR_1="test-install-${CYLC_TEST_TIME_INIT}/${TEST_NAME_BASE}" |
| 34 |
WORKFLOW_NAME="cylctb-${CYLC_TEST_TIME_INIT}/${TEST_SOURCE_DIR##*tests/}/${TEST_NAME}" |
| 35 |
mkdir -p "${PWD}/${SOURCE_DIR_1}" |
| 36 |
pushd "${SOURCE_DIR_1}" || exit 1 |
| 37 |
touch flow.cylc |
| 38 |
run_ok "${TEST_NAME}" cylc install --workflow-name "$WORKFLOW_NAME" |
| 39 |
popd || exit 1 |
| 40 |
|
| 41 |
SOURCE_DIR_2="test-install-${CYLC_TEST_TIME_INIT}2/${TEST_NAME_BASE}" |
| 42 |
WORKFLOW_NAME="cylctb-${CYLC_TEST_TIME_INIT}/${TEST_SOURCE_DIR##*tests/}/${TEST_NAME}" |
| 43 |
mkdir -p "${PWD}/${SOURCE_DIR_2}" |
| 44 |
pushd "${SOURCE_DIR_2}" || exit 1 |
| 45 |
touch flow.cylc |
| 46 |
run_fail "${TEST_NAME}" cylc install --workflow-name "$WORKFLOW_NAME" |
| 47 |
grep_ok "previous installations were from" "${TEST_NAME}.stderr" |
| 48 |
rm -rf "${PWD:?}/${SOURCE_DIR_1}" "${PWD:?}/${SOURCE_DIR_2}" |
| 49 |
purge |
| 50 |
popd || exit |
| 51 |
|
| 52 |
# ----------------------------------------------------------------------------- |
| 53 |
# Test fail no flow.cylc or suite.rc file |
| 54 |
|
| 55 |
make_rnd_workflow |
| 56 |
|
| 57 |
TEST_NAME="${TEST_NAME_BASE}-no-flow-file" |
| 58 |
rm -f "${RND_WORKFLOW_SOURCE}/flow.cylc" |
| 59 |
run_fail "${TEST_NAME}" cylc install --workflow-name="${RND_WORKFLOW_NAME}" "${RND_WORKFLOW_SOURCE}" |
| 60 |
contains_ok "${TEST_NAME}.stderr" <<__ERR__ |
| 61 |
WorkflowFilesError: No flow.cylc or suite.rc in ${RND_WORKFLOW_SOURCE} |
| 62 |
__ERR__ |
| 63 |
|
| 64 |
# ----------------------------------------------------------------------------- |
| 65 |
# Test fail both flow.cylc and suite.rc file |
| 66 |
|
| 67 |
make_rnd_workflow |
| 68 |
|
| 69 |
TEST_NAME="${TEST_NAME_BASE}-both-suite-and-flow-file" |
| 70 |
touch "${RND_WORKFLOW_SOURCE}/suite.rc" |
| 71 |
run_fail "${TEST_NAME}" cylc install --workflow-name="${RND_WORKFLOW_NAME}" "${RND_WORKFLOW_SOURCE}" |
| 72 |
contains_ok "${TEST_NAME}.stderr" <<__ERR__ |
| 73 |
WorkflowFilesError: Both flow.cylc and suite.rc files are present in ${RND_WORKFLOW_SOURCE}. \ |
| 74 |
Please remove one and try again. For more information visit: \ |
| 75 |
https://cylc.github.io/cylc-doc/stable/html/7-to-8/summary.html#backward-compatibility |
| 76 |
__ERR__ |
| 77 |
|
| 78 |
# Test fail no workflow source dir |
| 79 |
|
| 80 |
TEST_NAME="${TEST_NAME_BASE}-nodir" |
| 81 |
rm -rf "${RND_WORKFLOW_SOURCE}" |
| 82 |
run_fail "${TEST_NAME}" cylc install --workflow-name="${RND_WORKFLOW_NAME}" --no-run-name "${RND_WORKFLOW_SOURCE}" |
| 83 |
contains_ok "${TEST_NAME}.stderr" <<__ERR__ |
| 84 |
WorkflowFilesError: No flow.cylc or suite.rc in ${RND_WORKFLOW_SOURCE} |
| 85 |
__ERR__ |
| 86 |
|
| 87 |
purge_rnd_workflow |
| 88 |
|
| 89 |
# ----------------------------------------------------------------------------- |
| 90 |
# Test cylc install fails when given flow-name that is an absolute path |
| 91 |
|
| 92 |
make_rnd_workflow |
| 93 |
|
| 94 |
TEST_NAME="${TEST_NAME_BASE}-no-abs-path-flow-name" |
| 95 |
run_fail "${TEST_NAME}" cylc install --workflow-name="${RND_WORKFLOW_SOURCE}" "${RND_WORKFLOW_SOURCE}" |
| 96 |
contains_ok "${TEST_NAME}.stderr" <<__ERR__ |
| 97 |
WorkflowFilesError: workflow name cannot be an absolute path: ${RND_WORKFLOW_SOURCE} |
| 98 |
__ERR__ |
| 99 |
|
| 100 |
# Test cylc install fails when given forbidden run-name |
| 101 |
|
| 102 |
TEST_NAME="${TEST_NAME_BASE}-run-name-forbidden" |
| 103 |
run_fail "${TEST_NAME}" cylc install --run-name=_cylc-install "${RND_WORKFLOW_SOURCE}" |
| 104 |
cmp_ok "${TEST_NAME}.stderr" <<__ERR__ |
| 105 |
WorkflowFilesError: Workflow/run name cannot contain a directory named '_cylc-install' (that filename is reserved) |
| 106 |
__ERR__ |
| 107 |
|
| 108 |
# Test cylc install invalid flow-name |
| 109 |
|
| 110 |
TEST_NAME="${TEST_NAME_BASE}-invalid-flow-name" |
| 111 |
run_fail "${TEST_NAME}" cylc install --workflow-name=".invalid" "${RND_WORKFLOW_SOURCE}" |
| 112 |
contains_ok "${TEST_NAME}.stderr" <<__ERR__ |
| 113 |
WorkflowFilesError: invalid workflow name '.invalid' - cannot start with: \`.\`, \`-\`, numbers |
| 114 |
__ERR__ |
| 115 |
|
| 116 |
# Test --run-name and --no-run-name options are mutually exclusive |
| 117 |
|
| 118 |
TEST_NAME="${TEST_NAME_BASE}--no-run-name-and--run-name-forbidden" |
| 119 |
pushd "${RND_WORKFLOW_SOURCE}" || exit 1 |
| 120 |
run_fail "${TEST_NAME}" cylc install --run-name="${RND_WORKFLOW_NAME}" --no-run-name |
| 121 |
cmp_ok "${TEST_NAME}.stderr" <<__ERR__ |
| 122 |
InputError: options --no-run-name and --run-name are mutually exclusive. |
| 123 |
__ERR__ |
| 124 |
popd || exit 1 |
| 125 |
|
| 126 |
purge_rnd_workflow |
| 127 |
|
| 128 |
# ----------------------------------------------------------------------------- |
| 129 |
# Test source dir can not contain '_cylc-install, log, share, work' dirs |
| 130 |
|
| 131 |
for DIR in 'work' 'share' 'log' '_cylc-install'; do |
| 132 |
TEST_NAME="${TEST_NAME_BASE}-${DIR}-forbidden-in-source" |
| 133 |
make_rnd_workflow |
| 134 |
pushd "${RND_WORKFLOW_SOURCE}" || exit 1 |
| 135 |
mkdir ${DIR} |
| 136 |
run_fail "${TEST_NAME}" cylc install |
| 137 |
contains_ok "${TEST_NAME}.stderr" <<__ERR__ |
| 138 |
WorkflowFilesError: ${RND_WORKFLOW_NAME} installation failed - ${DIR} exists in source directory. |
| 139 |
__ERR__ |
| 140 |
purge_rnd_workflow |
| 141 |
popd || exit 1 |
| 142 |
done |
| 143 |
|
| 144 |
# ----------------------------------------------------------------------------- |
| 145 |
# Test running cylc install twice, first using --run-name, followed by standard run results in error |
| 146 |
|
| 147 |
TEST_NAME="${TEST_NAME_BASE}-install-twice-mix-options-1-1st-install" |
| 148 |
make_rnd_workflow |
| 149 |
pushd "${RND_WORKFLOW_SOURCE}" || exit 1 |
| 150 |
run_ok "${TEST_NAME}" cylc install --run-name=olaf |
| 151 |
contains_ok "${TEST_NAME}.stdout" <<__OUT__ |
| 152 |
INSTALLED ${RND_WORKFLOW_NAME}/olaf from ${RND_WORKFLOW_SOURCE} |
| 153 |
__OUT__ |
| 154 |
TEST_NAME="${TEST_NAME_BASE}-install-twice-mix-options-1-2nd-install" |
| 155 |
run_fail "${TEST_NAME}" cylc install |
| 156 |
contains_ok "${TEST_NAME}.stderr" <<__ERR__ |
| 157 |
WorkflowFilesError: Path: "${RND_WORKFLOW_RUNDIR}" contains an installed workflow. Use --run-name to create a new run. |
| 158 |
__ERR__ |
| 159 |
popd || exit 1 |
| 160 |
purge_rnd_workflow |
| 161 |
|
| 162 |
# ----------------------------------------------------------------------------- |
| 163 |
# Test running cylc install twice, first using standard run, followed by --run-name results in error |
| 164 |
|
| 165 |
TEST_NAME="${TEST_NAME_BASE}-install-twice-mix-options-2-1st-install" |
| 166 |
make_rnd_workflow |
| 167 |
pushd "${RND_WORKFLOW_SOURCE}" || exit 1 |
| 168 |
run_ok "${TEST_NAME}" cylc install |
| 169 |
contains_ok "${TEST_NAME}.stdout" <<__OUT__ |
| 170 |
INSTALLED ${RND_WORKFLOW_NAME}/run1 from ${RND_WORKFLOW_SOURCE} |
| 171 |
__OUT__ |
| 172 |
TEST_NAME="${TEST_NAME_BASE}-install-twice-mix-options-2-2nd-install" |
| 173 |
run_fail "${TEST_NAME}" cylc install --run-name=olaf |
| 174 |
contains_ok "${TEST_NAME}.stderr" <<__ERR__ |
| 175 |
WorkflowFilesError: --run-name option not allowed as '${RND_WORKFLOW_RUNDIR}' contains installed numbered runs. |
| 176 |
__ERR__ |
| 177 |
popd || exit 1 |
| 178 |
purge_rnd_workflow |
| 179 |
|
| 180 |
# ----------------------------------------------------------------------------- |
| 181 |
# Test running cylc install twice, using the same --run-name results in error |
| 182 |
|
| 183 |
TEST_NAME="${TEST_NAME_BASE}-install-twice-same-run-name-1st-install" |
| 184 |
make_rnd_workflow |
| 185 |
pushd "${RND_WORKFLOW_SOURCE}" || exit 1 |
| 186 |
run_ok "${TEST_NAME}" cylc install --run-name=olaf |
| 187 |
contains_ok "${TEST_NAME}.stdout" <<__OUT__ |
| 188 |
INSTALLED ${RND_WORKFLOW_NAME}/olaf from ${RND_WORKFLOW_SOURCE} |
| 189 |
__OUT__ |
| 190 |
TEST_NAME="${TEST_NAME_BASE}-install-twice-same-run-name-2nd-install" |
| 191 |
run_fail "${TEST_NAME}" cylc install --run-name=olaf |
| 192 |
contains_ok "${TEST_NAME}.stderr" <<__ERR__ |
| 193 |
WorkflowFilesError: '${RND_WORKFLOW_RUNDIR}/olaf' already exists |
| 194 |
__ERR__ |
| 195 |
popd || exit 1 |
| 196 |
purge_rnd_workflow |
| 197 |
|
| 198 |
# ----------------------------------------------------------------------------- |
| 199 |
# Test cylc install fails if installation would result in nested run dirs |
| 200 |
|
| 201 |
TEST_NAME="${TEST_NAME_BASE}-nested-rundir" |
| 202 |
make_rnd_workflow |
| 203 |
mkdir -p "${RND_WORKFLOW_RUNDIR}/.service" |
| 204 |
run_fail "${TEST_NAME}-install" cylc install "${RND_WORKFLOW_SOURCE}" \ |
| 205 |
--workflow-name="${RND_WORKFLOW_NAME}/nested" |
| 206 |
cmp_ok "${TEST_NAME}-install.stderr" <<__ERR__ |
| 207 |
WorkflowFilesError: Nested run directories not allowed - cannot install workflow in '${RND_WORKFLOW_RUNDIR}/nested/run1' as '${RND_WORKFLOW_RUNDIR}' is already a valid run directory. |
| 208 |
__ERR__ |
| 209 |
|
| 210 |
# Test moving source dir results in error |
| 211 |
|
| 212 |
TEST_NAME="${TEST_NAME_BASE}-install-moving-src-dir" |
| 213 |
make_rnd_workflow |
| 214 |
run_ok "${TEST_NAME}" cylc install "./${RND_WORKFLOW_NAME}" |
| 215 |
contains_ok "${TEST_NAME}.stdout" <<__OUT__ |
| 216 |
INSTALLED $RND_WORKFLOW_NAME/run1 from ${PWD}/${RND_WORKFLOW_NAME} |
| 217 |
__OUT__ |
| 218 |
rm -rf "${RND_WORKFLOW_SOURCE}" |
| 219 |
ALT_SOURCE="${TMPDIR}/${USER}/cylctb-x$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c6)" |
| 220 |
mkdir -p "${ALT_SOURCE}/${RND_WORKFLOW_NAME}" |
| 221 |
touch "${ALT_SOURCE}/${RND_WORKFLOW_NAME}/flow.cylc" |
| 222 |
|
| 223 |
|
| 224 |
TEST_NAME="${TEST_NAME_BASE}-install-twice-moving-src-dir-raises-error" |
| 225 |
run_fail "${TEST_NAME}" cylc install "${ALT_SOURCE}/${RND_WORKFLOW_NAME}" |
| 226 |
grep_ok "WorkflowFilesError: Symlink broken" "${TEST_NAME}.stderr" |
| 227 |
|
| 228 |
rm -rf "${ALT_SOURCE}" |
| 229 |
purge_rnd_workflow |
| 230 |
|
| 231 |
# ----------------------------------------------------------------------------- |
| 232 |
# --run-name cannot be a path |
| 233 |
|
| 234 |
make_rnd_workflow |
| 235 |
TEST_NAME="${TEST_NAME_BASE}-forbid-cylc-run-dir-install" |
| 236 |
BASE_NAME="test-install-${CYLC_TEST_TIME_INIT}" |
| 237 |
mkdir -p "${RUN_DIR}/${BASE_NAME}/${TEST_SOURCE_DIR_BASE}/${TEST_NAME}" && cd "$_" || exit |
| 238 |
touch flow.cylc |
| 239 |
run_fail "${TEST_NAME}" cylc install --run-name=foo/bar/baz --workflow-name "$RND_WORKFLOW_NAME" |
| 240 |
contains_ok "${TEST_NAME}.stderr" <<__ERR__ |
| 241 |
WorkflowFilesError: Run name cannot be a path. (You used foo/bar/baz) |
| 242 |
__ERR__ |
| 243 |
|
| 244 |
cd "${RUN_DIR}" || exit |
| 245 |
rm -rf "${BASE_NAME}" |
| 246 |
purge_rnd_workflow |
| 247 |
|
| 248 |
exit |