| 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 |
export REQUIRE_PLATFORM='loc:remote fs:shared runner:background' |
| 19 |
. "$(dirname "$0")/test_header" |
| 20 |
set_test_number 10 |
| 21 |
#------------------------------------------------------------------------------- |
| 22 |
# test the failure recovery mechanism |
| 23 |
BASE_GLOBAL_CONFIG=" |
| 24 |
[scheduler] |
| 25 |
[[main loop]] |
| 26 |
plugins = health check, auto restart |
| 27 |
[[[auto restart]]] |
| 28 |
interval = PT15S |
| 29 |
[[events]] |
| 30 |
abort on inactivity timeout = True |
| 31 |
abort on stall timeout = True |
| 32 |
inactivity timeout = PT2M |
| 33 |
stall timeout = PT2M |
| 34 |
[scheduler] |
| 35 |
[[run hosts]] |
| 36 |
available = localhost, ${CYLC_TEST_HOST}" |
| 37 |
|
| 38 |
TEST_NAME="${TEST_NAME_BASE}" |
| 39 |
init_workflow "${TEST_NAME}" <<< ' |
| 40 |
[scheduling] |
| 41 |
[[graph]] |
| 42 |
R1 = foo |
| 43 |
[runtime] |
| 44 |
[[foo]] |
| 45 |
' |
| 46 |
create_test_global_config '' "${BASE_GLOBAL_CONFIG}" |
| 47 |
run_ok "${TEST_NAME}-workflow-start" \ |
| 48 |
cylc play "${WORKFLOW_NAME}" --host=localhost --pause |
| 49 |
poll_workflow_running |
| 50 |
|
| 51 |
# corrupt workflow |
| 52 |
rm "${WORKFLOW_RUN_DIR}/flow.cylc" |
| 53 |
|
| 54 |
# condemn localhost |
| 55 |
create_test_global_config '' " |
| 56 |
${BASE_GLOBAL_CONFIG} |
| 57 |
[scheduler] |
| 58 |
[[run hosts]] |
| 59 |
condemned = $(hostname) |
| 60 |
" |
| 61 |
|
| 62 |
FILE=$(cylc cat-log "${WORKFLOW_NAME}" -m p |xargs readlink -f) |
| 63 |
log_scan "${TEST_NAME}-shutdown" "${FILE}" 20 1 \ |
| 64 |
'The Cylc workflow host will soon become un-available' \ |
| 65 |
'Workflow shutting down - REQUEST(NOW-NOW)' \ |
| 66 |
"Attempting to restart on \"${CYLC_TEST_HOST}\"" \ |
| 67 |
'Could not restart workflow will retry in 5s' \ |
| 68 |
"Attempting to restart on \"${CYLC_TEST_HOST}\"" \ |
| 69 |
'Could not restart workflow will retry in 5s' \ |
| 70 |
"Attempting to restart on \"${CYLC_TEST_HOST}\"" \ |
| 71 |
'Could not restart workflow will retry in 5s' \ |
| 72 |
'Workflow unable to automatically restart after 3 tries' |
| 73 |
|
| 74 |
# stop workflow - workflow should already by stopped but just to be safe |
| 75 |
cylc stop --max-polls=10 --interval=2 --kill "${WORKFLOW_NAME}" 2>'/dev/null' |
| 76 |
purge |