| 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 persistence of xtrigger results across restart. A cycling task depends |
| 20 |
# on a non cycle-point dependent custom xtrigger called "faker". In the first |
| 21 |
# cycle point the xtrigger succeeds and returns a result, then a task shuts |
| 22 |
# the workflow down. Then we replace the custom xtrigger function with one that |
| 23 |
# will fail if called again - which should not happen because the original |
| 24 |
# result should be remembered (as this xtrigger is not cycle point dependent). |
| 25 |
# Also test the correct result is broadcast to the dependent task before and |
| 26 |
# after workflow restart. |
| 27 |
|
| 28 |
. "$(dirname "$0")/test_header" |
| 29 |
set_test_number 6 |
| 30 |
|
| 31 |
install_workflow "${TEST_NAME_BASE}" "${TEST_NAME_BASE}" |
| 32 |
|
| 33 |
# Install the succeeding xtrigger function. |
| 34 |
cd "${WORKFLOW_RUN_DIR}" || exit 1 |
| 35 |
mkdir -p 'lib/python' |
| 36 |
cp "${WORKFLOW_RUN_DIR}/faker_succ.py" 'lib/python/faker.py' |
| 37 |
|
| 38 |
# Validate the test workflow. |
| 39 |
run_ok "${TEST_NAME_BASE}-val" cylc validate --debug "${WORKFLOW_NAME}" |
| 40 |
|
| 41 |
# Run the first cycle, till auto shutdown by task. |
| 42 |
TEST_NAME="${TEST_NAME_BASE}-run" |
| 43 |
workflow_run_ok "${TEST_NAME}" cylc play --no-detach --debug "${WORKFLOW_NAME}" |
| 44 |
|
| 45 |
# Check the broadcast result of xtrigger. |
| 46 |
cylc cat-log "${WORKFLOW_NAME}//2010/foo" >'2010.foo.out' |
| 47 |
grep_ok 'NAME is bob' '2010.foo.out' |
| 48 |
|
| 49 |
# Replace the xtrigger function with one that will fail if called again. |
| 50 |
cp "${WORKFLOW_RUN_DIR}/faker_fail.py" 'lib/python/faker.py' |
| 51 |
|
| 52 |
# Validate again (with the new xtrigger function). |
| 53 |
run_ok "${TEST_NAME_BASE}-val2" cylc validate --debug "${WORKFLOW_NAME}" |
| 54 |
|
| 55 |
# Restart the workflow, to run the final cycle point. |
| 56 |
TEST_NAME="${TEST_NAME_BASE}-restart" |
| 57 |
workflow_run_ok "${TEST_NAME}" cylc play --no-detach "${WORKFLOW_NAME}" |
| 58 |
|
| 59 |
# Check the broadcast result has persisted from first run. |
| 60 |
cylc cat-log "${WORKFLOW_NAME}//2011/foo" >'2011.foo.out' |
| 61 |
grep_ok 'NAME is bob' '2011.foo.out' |
| 62 |
|
| 63 |
purge |