Skip to content

Commit 464fe85

Browse files
dnestorovjovanov
authored andcommitted
Add retry logic for failng tests
1 parent b5ab9c6 commit 464fe85

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed
Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#!/bin/bash
22

3-
# Usage: ./run-consecutive-tests.sh "<test-coordinates>" '[ "1.0", "2.0", "3.0" ]'
4-
53
set -u
64
set -x
75

@@ -13,14 +11,6 @@ fi
1311
# Input parameters
1412
TEST_COORDINATES="$1"
1513
VERSIONS_JSON="$2"
16-
PASSED_VERSIONS=()
17-
FAILED_VERSION=""
18-
19-
# Parse JSON array into Bash array using jq
20-
if ! command -v jq &> /dev/null; then
21-
echo "jq is required but not installed."
22-
exit 1
23-
fi
2414

2515
# Remove surrounding single quotes if present (when called from workflow)
2616
VERSIONS_JSON="${VERSIONS_JSON#"${VERSIONS_JSON%%[!\']*}"}"
@@ -33,15 +23,22 @@ for VERSION in "${VERSIONS[@]}"; do
3323
echo "Running test with GVM_TCK_LV=$VERSION and coordinates=$TEST_COORDINATES"
3424
GVM_TCK_LV="$VERSION" ./gradlew test -Pcoordinates="$TEST_COORDINATES"
3525
RESULT=$?
26+
27+
ATTEMPTS=1
28+
# maybe we failed because the test was flaky => try two more times to be sure
29+
while [ "$RESULT" -ne 0 ] && [ $ATTEMPTS -le 2 ]; do
30+
echo "Re-running the test with GVM_TCK_LV=$VERSION and coordinates=$TEST_COORDINATES"
31+
GVM_TCK_LV="$VERSION" ./gradlew clean test -Pcoordinates="$TEST_COORDINATES"
32+
RESULT=$?
33+
ATTEMPTS=$((ATTEMPTS + 1))
34+
done
35+
3636
if [ "$RESULT" -eq 0 ]; then
37-
PASSED_VERSIONS+=("$VERSION")
3837
echo "PASSED:$VERSION"
3938
else
40-
FAILED_VERSION="$VERSION"
4139
echo "FAILED:$VERSION"
4240
break
4341
fi
4442
done
4543

46-
# Script ends here; output already provided in loop for workflows to process
4744
exit 0

0 commit comments

Comments
 (0)