Skip to content

Commit

Permalink
test that Cylc VR unsets the --against-source mode after validation.
Browse files Browse the repository at this point in the history
  • Loading branch information
wxtim committed Jul 11, 2024
1 parent 9ec631b commit 959145c
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 0 deletions.
65 changes: 65 additions & 0 deletions tests/functional/cylc-combination-scripts/08-vr-against-src.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!/usr/bin/env bash
# THIS FILE IS PART OF THE CYLC WORKFLOW ENGINE.
# Copyright (C) NIWA & British Crown (Met Office) & Contributors.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

#------------------------------------------------------------------------------
# Test `cylc vr` (Validate Reinstall restart)
# Tests that VR doesn't modify the source directory for Cylc play.
# See https://github.com/cylc/cylc-flow/issues/6209

. "$(dirname "$0")/test_header"
set_test_number 8

# Setup (Run VIP, check that the play step fails in the correct way):
WORKFLOW_NAME="cylctb-x$(< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c6)"
cp "${TEST_SOURCE_DIR}/vr_workflow_fail_on_play/flow.cylc" .

# Run Cylc VIP
export THIS_TEST_RUN="1"
run_fail "setup (vip)" \
cylc vip --debug \
--workflow-name "${WORKFLOW_NAME}" \
--no-run-name \
-s 'fatal_flaw="true"'
validate1="$(grep -Po "WARNING - vip:(.*)" "setup (vip).stderr" | awk -F ':' '{print $2}')"
play1="$(grep -Po "WARNING - play:(.*)" "setup (vip).stderr" | awk -F ':' '{print $2}')"

# Change the workflow to make the reinstall happen:
echo "" >> flow.cylc

# Run Cylc VR:
TEST_NAME="${TEST_NAME_BASE}"
run_fail "${TEST_NAME}" cylc vr "${WORKFLOW_NAME}" -s 'fatal_flaw="true"'
validate2="$(grep -Po "WARNING - vr:(.*)" "${TEST_NAME_BASE}.stderr" | awk -F ':' '{print $2}')"
play2="$(grep -Po "WARNING - play:(.*)" "${TEST_NAME_BASE}.stderr" | awk -F ':' '{print $2}')"

# Test that the correct source directory is openened at different
# stages of Cylc VIP & VR
TEST_NAME="vip validate and play operate on different folders"
[[ $validate1 != $play1 ]] && ok "${TEST_NAME}" || fail "${TEST_NAME}"
TEST_NAME="vr & vip validate operate on the same folder"
[[ $validate1 == $validate2 ]] && ok "${TEST_NAME}" || fail "${TEST_NAME}"
TEST_NAME="vr validate and play operate on different folders"
[[ $validate2 != $play2 ]] && ok "${TEST_NAME}" || fail "${TEST_NAME}"
TEST_NAME="vip play loads from a cylc-run subdir"
[[ $play2 =~ 'cylc-run' ]] && ok "${TEST_NAME}" || fail "${TEST_NAME}"
TEST_NAME="vr play loads from a cylc-run subdir"
[[ $play2 =~ "cylc-run" ]] && ok "${TEST_NAME}" || fail "${TEST_NAME}"

# Clean Up:
run_ok "${TEST_NAME_BASE}-stop cylc stop ${WORKFLOW_NAME} --now --now"
purge
exit 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!jinja2
{% from "sys" import argv %}
{% from "cylc.flow" import LOG %}
{% from "pathlib" import Path %}
{% if argv[1] == "play" %}
this = should cause cylc play to fail
{% endif %}

{% set SPATH = Path.cwd().__str__() %}
{% do LOG.warning(argv[1] + ":" + SPATH) %}


[scheduling]
initial cycle point = 1500
[[graph]]
P1Y = foo

[runtime]
[[foo]]

0 comments on commit 959145c

Please sign in to comment.