From 9ac25d350092f8e2adb5097ade184a3a35b769c0 Mon Sep 17 00:00:00 2001
From: Varac <varac@varac.net>
Date: Wed, 11 Aug 2021 13:24:00 +0200
Subject: [PATCH] Retry taiko tests multiple times until they succeed

---
 .gitlab-ci.yml | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 764eb00c6..2687d7fb6 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -26,6 +26,7 @@ include:
     echo "KANIKO_BUILD_IMAGENAME:    $KANIKO_BUILD_IMAGENAME"
     echo "KANIKO build image ref:    ${CI_REGISTRY_IMAGE}/${KANIKO_BUILD_IMAGENAME}:${CI_CONTAINER_TAG}"
     echo "SSH_KEY_ID:                $SSH_KEY_ID"
+    echo "SHELL                      $SHELL"
     echo
     [ -d $CLUSTER_DIR ] && find $CLUSTER_DIR || echo "directory ${CLUSTER_DIR} not found"
     echo
@@ -863,18 +864,28 @@ kube-prometheus-stack-alerts:
 
 .taiko:
   stage: integration-test
-  script:
+  before_script:
     - *debug_information
-    # Run the taiko tests for specific app
-    - unbuffer python3 -m openappstack $HOSTNAME test --apps $RESOURCE | ts -i | ts
-  retry: 2
+  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
   artifacts:
     paths:
       - test/taiko/Screenshot*
     expire_in: 1 month
     when: on_failure
-  extends:
-    - .ssh_setup
   interruptible: true
 
 grafana-taiko:
-- 
GitLab