| 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 |
# Ensure that xtriggers are preserved after reloads |
| 20 |
# See https://github.com/cylc/cylc-flow/issues/4866 |
| 21 |
|
| 22 |
. "$(dirname "$0")/test_header" |
| 23 |
|
| 24 |
set_test_number 6 |
| 25 |
|
| 26 |
init_workflow "${TEST_NAME_BASE}" <<'__FLOW_CONFIG__' |
| 27 |
[scheduling] |
| 28 |
[[graph]] |
| 29 |
R1 = """ |
| 30 |
broken |
| 31 |
reload |
| 32 |
""" |
| 33 |
|
| 34 |
[runtime] |
| 35 |
[[broken]] |
| 36 |
script = false |
| 37 |
# should be long enough for the reload to complete |
| 38 |
# (annoyingly we can't make this event driven) |
| 39 |
execution retry delays = PT1M |
| 40 |
# NOTE: "execution retry delays" is implemented as an xtrigger |
| 41 |
|
| 42 |
[[reload]] |
| 43 |
script = """ |
| 44 |
# wait for "broken" to fail |
| 45 |
cylc__job__poll_grep_workflow_log -E '1/broken/01.*failed/ERR' |
| 46 |
# fix "broken" to allow it to pass |
| 47 |
sed -i 's/false/true/' "${CYLC_WORKFLOW_RUN_DIR}/flow.cylc" |
| 48 |
# reload the workflow |
| 49 |
cylc reload "${CYLC_WORKFLOW_ID}" |
| 50 |
""" |
| 51 |
__FLOW_CONFIG__ |
| 52 |
|
| 53 |
run_ok "${TEST_NAME_BASE}-val" cylc validate "${WORKFLOW_NAME}" |
| 54 |
workflow_run_ok "${TEST_NAME_BASE}-run" cylc play "${WORKFLOW_NAME}" --no-detach -v |
| 55 |
|
| 56 |
# ensure the following order of events |
| 57 |
# 1. "1/broken" fails |
| 58 |
# 2. workflow is reloaded (by "1/reload") |
| 59 |
# 3. the retry xtrigger for "1/broken" is succeeded (after the reload) |
| 60 |
# (thus proving that the xtrigger survived the reload) |
| 61 |
# 4. "1/broken" succeeds |
| 62 |
|
| 63 |
log_scan "${TEST_NAME_BASE}-scan" \ |
| 64 |
"$(cylc cat-log -m p "${WORKFLOW_NAME}")" \ |
| 65 |
1 1 \ |
| 66 |
'1/broken/01.*failed/ERR' |
| 67 |
|
| 68 |
log_scan "${TEST_NAME_BASE}-scan" \ |
| 69 |
"$(cylc cat-log -m p "${WORKFLOW_NAME}")" 1 1 \ |
| 70 |
'Command "reload_workflow" actioned' \ |
| 71 |
|
| 72 |
log_scan "${TEST_NAME_BASE}-scan" \ |
| 73 |
"$(cylc cat-log -m p "${WORKFLOW_NAME}")" \ |
| 74 |
1 1 \ |
| 75 |
'xtrigger succeeded: _cylc_retry_1_broken' \ |
| 76 |
'1/broken.* => succeeded' |
| 77 |
|
| 78 |
purge |