| 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 `cylc vr` (Validate Reinstall restart) |
| 20 |
# Tests that VR doesn't modify the source directory for Cylc play. |
| 21 |
# See https://github.com/cylc/cylc-flow/issues/6209 |
| 22 |
|
| 23 |
. "$(dirname "$0")/test_header" |
| 24 |
set_test_number 9 |
| 25 |
|
| 26 |
# Setup (Run VIP, check that the play step fails in the correct way): |
| 27 |
WORKFLOW_NAME="cylctb-x$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c6)" |
| 28 |
cp "${TEST_SOURCE_DIR}/vr_workflow_fail_on_play/flow.cylc" . |
| 29 |
|
| 30 |
# Run Cylc VIP |
| 31 |
run_fail "setup (vip)" \ |
| 32 |
cylc vip --debug \ |
| 33 |
--workflow-name "${WORKFLOW_NAME}" \ |
| 34 |
--no-run-name |
| 35 |
validate1="$(grep -Po "WARNING - vip:(.*)" "setup (vip).stderr" | awk -F ':' '{print $2}')" |
| 36 |
play1="$(grep -Po "WARNING - play:(.*)" "setup (vip).stderr" | awk -F ':' '{print $2}')" |
| 37 |
|
| 38 |
# Change the workflow to make the reinstall happen: |
| 39 |
echo "" >> flow.cylc |
| 40 |
|
| 41 |
# Run Cylc VR: |
| 42 |
TEST_NAME="${TEST_NAME_BASE}" |
| 43 |
run_fail "${TEST_NAME}" cylc vr "${WORKFLOW_NAME}" |
| 44 |
validate2="$(grep -Po "WARNING - vr:(.*)" "${TEST_NAME_BASE}.stderr" | awk -F ':' '{print $2}')" |
| 45 |
play2="$(grep -Po "WARNING - play:(.*)" "${TEST_NAME_BASE}.stderr" | awk -F ':' '{print $2}')" |
| 46 |
|
| 47 |
# Test that the correct source directory is openened at different |
| 48 |
# stages of Cylc VIP & VR |
| 49 |
TEST_NAME="outputs-created" |
| 50 |
if [[ -n $validate1 && -n $validate2 && -n $play1 && -n $play2 ]]; then |
| 51 |
ok "${TEST_NAME}" |
| 52 |
else |
| 53 |
fail "${TEST_NAME}" |
| 54 |
fi |
| 55 |
|
| 56 |
|
| 57 |
TEST_NAME="vip validate and play operate on different folders" |
| 58 |
if [[ $validate1 != "${play1}" ]]; then |
| 59 |
ok "${TEST_NAME}" |
| 60 |
else |
| 61 |
fail "${TEST_NAME}" |
| 62 |
fi |
| 63 |
|
| 64 |
TEST_NAME="vr & vip validate operate on the same folder" |
| 65 |
if [[ $validate1 == "${validate2}" ]]; then |
| 66 |
ok "${TEST_NAME}" |
| 67 |
else |
| 68 |
fail "${TEST_NAME}" |
| 69 |
fi |
| 70 |
|
| 71 |
TEST_NAME="vr validate and play operate on different folders" |
| 72 |
if [[ $validate2 != "${play2}" ]]; then |
| 73 |
ok "${TEST_NAME}" |
| 74 |
else |
| 75 |
fail "${TEST_NAME}" |
| 76 |
fi |
| 77 |
|
| 78 |
TEST_NAME="vip play loads from a cylc-run subdir" |
| 79 |
if [[ "${play2}" =~ cylc-run ]]; then |
| 80 |
ok "${TEST_NAME}" |
| 81 |
else |
| 82 |
fail "${TEST_NAME}" |
| 83 |
fi |
| 84 |
|
| 85 |
TEST_NAME="vr play loads from a cylc-run subdir" |
| 86 |
if [[ "${play2}" =~ cylc-run ]]; then |
| 87 |
ok "${TEST_NAME}" |
| 88 |
else |
| 89 |
fail "${TEST_NAME}" |
| 90 |
fi |
| 91 |
|
| 92 |
# Clean Up: |
| 93 |
run_ok "${TEST_NAME_BASE}-stop cylc stop ${WORKFLOW_NAME} --now --now" |
| 94 |
purge |
| 95 |
exit 0 |