| 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 |
# Test "log/config/*-<mode>.cylc" files that are generated on workflow start up. |
| 19 |
. "$(dirname "$0")/test_header" |
| 20 |
set_test_number 10 |
| 21 |
|
| 22 |
init_workflow "${TEST_NAME_BASE}" <<'__FLOW_CONFIG__' |
| 23 |
#!Jinja2 |
| 24 |
[meta] |
| 25 |
title = a workflow that logs run, reload, and restart configs |
| 26 |
description = the weather is {{WEATHER | default("bad")}} |
| 27 |
[scheduler] |
| 28 |
[[events]] |
| 29 |
abort on stall timeout = True |
| 30 |
stall timeout = PT0S |
| 31 |
restart timeout = PT0S # shut down when restarted with empty pool |
| 32 |
[scheduling] |
| 33 |
[[graph]] |
| 34 |
R1 = reloader => whatever |
| 35 |
[runtime] |
| 36 |
[[reloader]] |
| 37 |
script = cylc reload "${CYLC_WORKFLOW_ID}" |
| 38 |
[[whatever]] |
| 39 |
script = true |
| 40 |
__FLOW_CONFIG__ |
| 41 |
|
| 42 |
run_ok "${TEST_NAME_BASE}-val-1" cylc validate "${WORKFLOW_NAME}" |
| 43 |
run_ok "${TEST_NAME_BASE}-val-2" \ |
| 44 |
cylc validate --set 'WEATHER="good"' "${WORKFLOW_NAME}" |
| 45 |
|
| 46 |
workflow_run_ok "${TEST_NAME_BASE}-run" cylc play --no-detach "${WORKFLOW_NAME}" |
| 47 |
workflow_run_ok "${TEST_NAME_BASE}-restart" \ |
| 48 |
cylc play --set 'WEATHER="good"' --no-detach "${WORKFLOW_NAME}" |
| 49 |
|
| 50 |
# Check for 4 generated *.cylc files |
| 51 |
LOGD="${RUN_DIR}/${WORKFLOW_NAME}/log/config" |
| 52 |
# shellcheck disable=SC2012 |
| 53 |
ls "${LOGD}" | sort >'ls.out' |
| 54 |
cmp_ok 'ls.out' <<'__OUT__' |
| 55 |
01-start-01.cylc |
| 56 |
02-reload-01.cylc |
| 57 |
03-restart-02.cylc |
| 58 |
flow-processed.cylc |
| 59 |
__OUT__ |
| 60 |
|
| 61 |
LOGD="${RUN_DIR}/${WORKFLOW_NAME}/log/config" |
| 62 |
START_CONFIG="$(ls "${LOGD}/"*-start*.cylc)" |
| 63 |
REL_CONFIG="$(ls "${LOGD}/"*-reload*.cylc)" |
| 64 |
RES_CONFIG="$(ls "${LOGD}/"*-restart*.cylc)" |
| 65 |
mkdir start_config |
| 66 |
mkdir res_config |
| 67 |
cp "$START_CONFIG" start_config/flow.cylc |
| 68 |
cp "$RES_CONFIG" res_config/flow.cylc |
| 69 |
# The generated *-start*.cylc and *-reload*.cylc should be identical |
| 70 |
# The generated *.cylc files should validate |
| 71 |
cmp_ok "${START_CONFIG}" "${REL_CONFIG}" |
| 72 |
run_ok "${TEST_NAME_BASE}-validate-start-config" cylc validate ./start_config |
| 73 |
run_ok "${TEST_NAME_BASE}-validate-restart-config" cylc validate ./res_config |
| 74 |
rm -rf start_config res_config |
| 75 |
|
| 76 |
diff -u "${START_CONFIG}" "${RES_CONFIG}" >'diff.out' |
| 77 |
contains_ok 'diff.out' <<'__DIFF__' |
| 78 |
- description = the weather is bad |
| 79 |
+ description = the weather is good |
| 80 |
__DIFF__ |
| 81 |
|
| 82 |
# Ensure that the start config is sparse. |
| 83 |
grep_fail "\[\[mail\]\]" "${START_CONFIG}" |
| 84 |
|
| 85 |
purge |
| 86 |
exit |