| 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:indep comms:?(tcp|ssh)" |
| 19 |
. "$(dirname "$0")/test_header" |
| 20 |
set_test_number 3 |
| 21 |
#------------------------------------------------------------------------------- |
| 22 |
# It should retry job log retrieval even if all hosts are not contactable. |
| 23 |
#------------------------------------------------------------------------------- |
| 24 |
|
| 25 |
init_workflow "${TEST_NAME_BASE}-1" <<__FLOW_CONFIG__ |
| 26 |
[scheduling] |
| 27 |
[[graph]] |
| 28 |
R1 = """ |
| 29 |
remote |
| 30 |
""" |
| 31 |
|
| 32 |
[runtime] |
| 33 |
[[remote]] |
| 34 |
# script = sleep 1 |
| 35 |
platform = ${CYLC_TEST_PLATFORM} |
| 36 |
__FLOW_CONFIG__ |
| 37 |
|
| 38 |
# configure job retries on the test platform |
| 39 |
create_test_global_config '' " |
| 40 |
[platforms] |
| 41 |
[[${CYLC_TEST_PLATFORM}]] |
| 42 |
retrieve job logs = True |
| 43 |
retrieve job logs retry delays = 3*PT1S |
| 44 |
retrieve job logs command = fido |
| 45 |
" |
| 46 |
|
| 47 |
# * redirect retrieval attempts to a file where we can inspect them later |
| 48 |
# * make it look like retrieval failed due to network issues (255 ret code) |
| 49 |
JOB_LOG_RETR_CMD="${WORKFLOW_RUN_DIR}/bin/fido" |
| 50 |
RETRIEVAL_ATTEMPT_LOG="${WORKFLOW_RUN_DIR}/retrieval-attempt-log" |
| 51 |
mkdir "${WORKFLOW_RUN_DIR}/bin" |
| 52 |
cat > "${WORKFLOW_RUN_DIR}/bin/fido" <<__HERE__ |
| 53 |
#!/usr/bin/env bash |
| 54 |
echo "$@" >> "${RETRIEVAL_ATTEMPT_LOG}" |
| 55 |
exit 255 |
| 56 |
__HERE__ |
| 57 |
chmod +x "${JOB_LOG_RETR_CMD}" |
| 58 |
|
| 59 |
workflow_run_ok "${TEST_NAME_BASE}-play" \ |
| 60 |
cylc play --debug --no-detach "${WORKFLOW_NAME}" |
| 61 |
|
| 62 |
# it should try retrieval three times |
| 63 |
# Note: it should reset bad_hosts to allow retries to happen |
| 64 |
TEST_NAME="${TEST_NAME_BASE}-retrieve-attempts" |
| 65 |
# shellcheck disable=SC2002 |
| 66 |
# (cat'ting into pipe to avoid having to sed out the filename) |
| 67 |
if [[ $(cat "${RETRIEVAL_ATTEMPT_LOG}" | wc -l) -eq 3 ]]; then |
| 68 |
ok "${TEST_NAME}" |
| 69 |
else |
| 70 |
fail "${TEST_NAME}" |
| 71 |
fi |
| 72 |
|
| 73 |
# then fail once the retries have been exhausted |
| 74 |
grep_workflow_log_ok "${TEST_NAME_BASE}-retrieve-fail" \ |
| 75 |
'job-logs-retrieve for task event:succeeded failed' |
| 76 |
|
| 77 |
purge |