From 61fd96b7a7a49387d169c95c8a4ba343c45202d8 Mon Sep 17 00:00:00 2001 From: Varac <varac@varac.net> Date: Wed, 11 Aug 2021 13:42:53 +0200 Subject: [PATCH] Use retry_cmd_until_success.sh script --- .gitlab-ci.yml | 14 +------ .gitlab/ci_scripts/retry_cmd_until_success.sh | 41 +++++++++++++++++++ 2 files changed, 42 insertions(+), 13 deletions(-) create mode 100755 .gitlab/ci_scripts/retry_cmd_until_success.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2687d7fb6..92d458e7f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -868,19 +868,7 @@ kube-prometheus-stack-alerts: - *debug_information script: # Retry taiko tests multiple times until they succeed - - | - set -o pipefail - i=0 - until unbuffer python3 -m openappstack $HOSTNAME test --apps $RESOURCE | ts -i | ts - do - if [[ $i -ge 20 ]] - then - exit 1 - fi - (( i++ )) - sleep 1 - echo -e "${i}. retry:\n" - done + - bash ./.gitlab/ci_scripts/retry_cmd_until_success.sh 20 unbuffer python3 -m openappstack $HOSTNAME test --apps $RESOURCE | ts -i | ts artifacts: paths: - test/taiko/Screenshot* diff --git a/.gitlab/ci_scripts/retry_cmd_until_success.sh b/.gitlab/ci_scripts/retry_cmd_until_success.sh new file mode 100755 index 000000000..33c8aa78d --- /dev/null +++ b/.gitlab/ci_scripts/retry_cmd_until_success.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +# +# Executes given cms multiple times until it is successful +# +# Usage: +# +# ./retry_cmd_until_success.sh [retries] [cmd] +# +# Example: +# +# ./retry_cmd_until_success.sh 10 ping ix.de + +retries=$1 +shift +cmd=$* + +if [[ ! $retries =~ ^-?[0-9]+$ ]] +then + echo "Please specify retries count." + exit 1 +fi + +if [[ -z "$cmd" ]] +then + echo "Please specify a cmd." + exit 1 +fi +echo "Retrying \"$cmd\" ${retries} times." + +i=0 +until eval $cmd +do + echo -e "return code: $?\n" + if [[ $i -ge 2 ]] + then + exit 1 + fi + (( i++ )) + sleep 1 + echo "${i}. retry:" +done -- GitLab