| 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 that Cylc fails sensibly when a plaform group with no |
| 19 |
# accessible hosts is selected. |
| 20 |
# n.b. We don't care about definition order in this test becuase all |
| 21 |
# hosts and platforms fail. |
| 22 |
. "$(dirname "$0")/test_header" |
| 23 |
set_test_number 12 |
| 24 |
#------------------------------------------------------------------------------- |
| 25 |
|
| 26 |
# Uses a fake background job runner to get around the single host restriction. |
| 27 |
|
| 28 |
create_test_global_config "" " |
| 29 |
[platforms] |
| 30 |
[[badhostplatform1]] |
| 31 |
job runner = my_background |
| 32 |
hosts = bad_host1, bad_host2 |
| 33 |
[[badhostplatform2]] |
| 34 |
job runner = my_background |
| 35 |
hosts = bad_host3, bad_host4 |
| 36 |
|
| 37 |
[platform groups] |
| 38 |
[[badplatformgroup]] |
| 39 |
platforms = badhostplatform1, badhostplatform2 |
| 40 |
" |
| 41 |
|
| 42 |
install_workflow "${TEST_NAME_BASE}" "${TEST_NAME_BASE}" |
| 43 |
|
| 44 |
# Install the fake background job runner. |
| 45 |
cp -r "${TEST_SOURCE_DIR}/lib" "${WORKFLOW_RUN_DIR}" |
| 46 |
|
| 47 |
run_ok "${TEST_NAME_BASE}-validate" cylc validate "${WORKFLOW_NAME}" |
| 48 |
|
| 49 |
workflow_run_fail "${TEST_NAME_BASE}-run" \ |
| 50 |
cylc play --debug --no-detach "${WORKFLOW_NAME}" |
| 51 |
|
| 52 |
logfile="${WORKFLOW_RUN_DIR}/log/scheduler/log" |
| 53 |
|
| 54 |
# Check workflow fails for the reason we want it to fail |
| 55 |
named_grep_ok \ |
| 56 |
"Workflow stalled with 1/bad (submit-failed)" \ |
| 57 |
"1/bad did not complete the required outputs" \ |
| 58 |
"$logfile" |
| 59 |
|
| 60 |
# Look for message indicating that remote init has failed on each bad_host |
| 61 |
# on every bad platform. |
| 62 |
platform='badhostplatform1' |
| 63 |
for host in {1..2}; do |
| 64 |
host="bad_host${host}" |
| 65 |
log_scan \ |
| 66 |
"${TEST_NAME_BASE}-remote-init-fail-${host}" \ |
| 67 |
"${logfile}" 1 0 \ |
| 68 |
"platform: ${platform} - remote init (on ${host})" \ |
| 69 |
"platform: ${platform} - Could not connect to ${host}." |
| 70 |
done |
| 71 |
platform='badhostplatform2' |
| 72 |
for host in {3..4}; do |
| 73 |
host="bad_host${host}" |
| 74 |
log_scan \ |
| 75 |
"${TEST_NAME_BASE}-remote-init-fail-${host}" \ |
| 76 |
"${logfile}" 1 0 \ |
| 77 |
"platform: ${platform} - remote init (on ${host})" \ |
| 78 |
"platform: ${platform} - Could not connect to ${host}." |
| 79 |
done |
| 80 |
|
| 81 |
# Look for message indicating that remote init has failed. |
| 82 |
named_grep_ok \ |
| 83 |
"platform: badhostplatform. - initialisation did not complete (no hosts were reachable)" \ |
| 84 |
"platform: badhostplatform. - initialisation did not complete (no hosts were reachable)" \ |
| 85 |
"${logfile}" |
| 86 |
|
| 87 |
purge |
| 88 |
exit 0 |