| 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 reinstallation expected failures |
| 20 |
. "$(dirname "$0")/test_header" |
| 21 |
set_test_number 23 |
| 22 |
|
| 23 |
# Test fail no workflow run dir |
| 24 |
|
| 25 |
TEST_NAME="${TEST_NAME_BASE}-reinstall-no-run-dir" |
| 26 |
make_rnd_workflow |
| 27 |
run_ok "${TEST_NAME}-install" cylc install "${RND_WORKFLOW_SOURCE}" --workflow-name="${RND_WORKFLOW_NAME}" --no-run-name |
| 28 |
rm -rf "${RND_WORKFLOW_RUNDIR}" |
| 29 |
run_fail "${TEST_NAME}-reinstall" cylc reinstall "${RND_WORKFLOW_NAME}" |
| 30 |
cmp_ok "${TEST_NAME}-reinstall.stderr" <<__ERR__ |
| 31 |
InputError: Workflow ID not found: ${RND_WORKFLOW_RUNDIR#*/cylc-run/} |
| 32 |
(Directory not found: ${RND_WORKFLOW_RUNDIR}) |
| 33 |
__ERR__ |
| 34 |
purge_rnd_workflow |
| 35 |
|
| 36 |
# Test fail no workflow source dir |
| 37 |
|
| 38 |
TEST_NAME="${TEST_NAME_BASE}-reinstall-no-source-dir" |
| 39 |
make_rnd_workflow |
| 40 |
run_ok "${TEST_NAME}-install" cylc install "${RND_WORKFLOW_SOURCE}" --workflow-name="${RND_WORKFLOW_NAME}" --no-run-name |
| 41 |
rm -rf "${RND_WORKFLOW_SOURCE}" |
| 42 |
run_fail "${TEST_NAME}-reinstall" cylc reinstall "${RND_WORKFLOW_NAME}" |
| 43 |
cmp_ok "${TEST_NAME}-reinstall.stderr" <<__ERR__ |
| 44 |
WorkflowFilesError: Workflow source dir is not accessible: "${RND_WORKFLOW_SOURCE}". |
| 45 |
Restore the source or modify the "${RND_WORKFLOW_RUNDIR}/_cylc-install/source" symlink to continue. |
| 46 |
__ERR__ |
| 47 |
purge_rnd_workflow |
| 48 |
|
| 49 |
# Test fail no flow.cylc or suite.rc file |
| 50 |
|
| 51 |
TEST_NAME="${TEST_NAME_BASE}-no-flow-file" |
| 52 |
make_rnd_workflow |
| 53 |
run_ok "${TEST_NAME}-install" cylc install "${RND_WORKFLOW_SOURCE}" --workflow-name="${RND_WORKFLOW_NAME}" --no-run-name |
| 54 |
rm -f "${RND_WORKFLOW_SOURCE}/flow.cylc" |
| 55 |
run_fail "${TEST_NAME}" cylc reinstall "${RND_WORKFLOW_NAME}" |
| 56 |
cmp_ok "${TEST_NAME}.stderr" <<__ERR__ |
| 57 |
WorkflowFilesError: No flow.cylc or suite.rc in ${RND_WORKFLOW_SOURCE} |
| 58 |
__ERR__ |
| 59 |
purge_rnd_workflow |
| 60 |
|
| 61 |
# Test fail both flow.cylc and suite.rc file |
| 62 |
|
| 63 |
TEST_NAME="${TEST_NAME_BASE}-both-flow-and-suite-file" |
| 64 |
make_rnd_workflow |
| 65 |
run_ok "${TEST_NAME}-install" cylc install "${RND_WORKFLOW_SOURCE}" --workflow-name="${RND_WORKFLOW_NAME}" --no-run-name |
| 66 |
touch "${RND_WORKFLOW_SOURCE}/suite.rc" |
| 67 |
run_fail "${TEST_NAME}" cylc reinstall "${RND_WORKFLOW_NAME}" |
| 68 |
cmp_ok "${TEST_NAME}.stderr" <<__ERR__ |
| 69 |
WorkflowFilesError: Both flow.cylc and suite.rc files are present in ${RND_WORKFLOW_SOURCE}. \ |
| 70 |
Please remove one and try again. For more information visit: \ |
| 71 |
https://cylc.github.io/cylc-doc/stable/html/7-to-8/summary.html#backward-compatibility |
| 72 |
__ERR__ |
| 73 |
purge_rnd_workflow |
| 74 |
|
| 75 |
# Test source dir can not contain '_cylc-install, log, share, work' dirs for cylc reinstall |
| 76 |
|
| 77 |
for DIR in 'work' 'share' 'log' '_cylc-install'; do |
| 78 |
TEST_NAME="${TEST_NAME_BASE}-${DIR}-forbidden-in-source" |
| 79 |
make_rnd_workflow |
| 80 |
pushd "${RND_WORKFLOW_SOURCE}" || exit 1 |
| 81 |
cylc install --no-run-name --workflow-name="${RND_WORKFLOW_NAME}" |
| 82 |
mkdir ${DIR} |
| 83 |
run_fail "${TEST_NAME}" cylc reinstall "${RND_WORKFLOW_NAME}" |
| 84 |
cmp_ok "${TEST_NAME}.stderr" <<__ERR__ |
| 85 |
WorkflowFilesError: ${RND_WORKFLOW_NAME} installation failed - ${DIR} exists in source directory. |
| 86 |
__ERR__ |
| 87 |
purge_rnd_workflow |
| 88 |
popd || exit 1 |
| 89 |
done |
| 90 |
|
| 91 |
# Test cylc reinstall raises error when no source dir. |
| 92 |
TEST_NAME="${TEST_NAME_BASE}-reinstall-no-source-raises-error" |
| 93 |
make_rnd_workflow |
| 94 |
pushd "${RND_WORKFLOW_SOURCE}" || exit 1 |
| 95 |
run_ok "${TEST_NAME}-install" cylc install --no-run-name --workflow-name="${RND_WORKFLOW_NAME}" |
| 96 |
pushd "${RND_WORKFLOW_RUNDIR}" || exit 1 |
| 97 |
rm -rf "_cylc-install" |
| 98 |
run_fail "${TEST_NAME}-reinstall" cylc reinstall "$RND_WORKFLOW_NAME" |
| 99 |
cmp_ok "${TEST_NAME}-reinstall.stderr" <<__ERR__ |
| 100 |
WorkflowFilesError: "${RND_WORKFLOW_NAME}" was not installed with cylc install. |
| 101 |
__ERR__ |
| 102 |
popd || exit 1 |
| 103 |
popd || exit 1 |
| 104 |
purge_rnd_workflow |
| 105 |
|
| 106 |
exit |