From dc6799db94e83e73a7f38b42058630904a4a3fde Mon Sep 17 00:00:00 2001 From: Oliver Sanders Date: Fri, 25 Oct 2019 13:58:22 +0100 Subject: [PATCH] test task retry timings --- tests/retries/02-xtriggers.t | 22 +++++++++++++ tests/retries/02-xtriggers/suite.rc | 49 +++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 tests/retries/02-xtriggers.t create mode 100644 tests/retries/02-xtriggers/suite.rc diff --git a/tests/retries/02-xtriggers.t b/tests/retries/02-xtriggers.t new file mode 100644 index 00000000000..fdd0667ce2d --- /dev/null +++ b/tests/retries/02-xtriggers.t @@ -0,0 +1,22 @@ +#!/bin/bash +# THIS FILE IS PART OF THE CYLC SUITE ENGINE. +# Copyright (C) 2008-2019 NIWA & British Crown (Met Office) & Contributors. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +#------------------------------------------------------------------------------- +# Test kill running jobs only +. "$(dirname "$0")/test_header" +set_test_number 2 +reftest +exit diff --git a/tests/retries/02-xtriggers/suite.rc b/tests/retries/02-xtriggers/suite.rc new file mode 100644 index 00000000000..cddef5d6e97 --- /dev/null +++ b/tests/retries/02-xtriggers/suite.rc @@ -0,0 +1,49 @@ +[scheduling] + [[graph]] + R1 = retry => test + + +[runtime] + [[retry]] + # capture task info - incl xtriggers + pre-script = """ + cylc show "${CYLC_SUITE_NAME}" \ + "${CYLC_TASK_NAME}.${CYLC_TASK_CYCLE_POINT}" \ + > "${CYLC_TASK_LOG_ROOT}-show" + """ + + # fail four times then pass + script = test "${CYLC_TASK_SUBMIT_NUMBER}" -ge 5 + + # stagger retries every two seconds + [[[job]]] + execution retry delays = 5*PT3S + + + [[test]] + script = """ + cylc cat-log "${CYLC_SUITE_NAME}" > log + + # get a list of the times cylc says tasks will retry after + mapfile -t RETRY_TIMES \ + < <(sed -n 's/.*retrying.*after \(.*\)).*/\1/p' log) + + # get a list of the times when the xtriggers were actually + # satisfied + mapfile -t XTRIGGER_TIMES \ + < <(sed -n 's/\(.*\) INFO.*xtrigger satisfied.*/\1/p' log) + + test "${#RETRY_TIMES[@]}" -eq 4 + test "${#XTRIGGER_TIMES[@]}" -eq 4 + + # make sure that tasks retried when they said they would + for N in $(seq 0 3); do + INTERVAL="$(isodatetime \ + "${RETRY_TIMES[$N]}" "${XTRIGGER_TIMES[$N]}" --as-total s)" + + echo "RETRY=${RETRY_TIMES[$N]}" + echo "XTRIGGER=${XTRIGGER_TIMES[$N]}" + echo "INTERVAL=${INTERVAL}" + python3 -c "assert ${INTERVAL} >= 0.0" + done + """