forked from cloud-bulldozer/benchmark-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_test.sh
executable file
·58 lines (50 loc) · 1.62 KB
/
run_test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
set -x
ci_dir=$1
ci_test=`echo $1 | sed 's/-/_/g'`
retries=3
figlet $ci_test
# Random short sleep to avoid command collision
sleep $[ ( $RANDOM % 10 )]s
cd $ci_dir
source tests/common.sh
count=0
start_time=`date`
# Run the test up to a max of $retries
while [ $count -le $retries ]
do
wait_clean
# Test ci
if /bin/bash tests/$ci_test.sh >> $ci_test.out 2>&1
then
# if the test passes update the results and complete
end_time=`date`
duration=`date -ud@$(($(date -ud"$end_time" +%s)-$(date -ud"$start_time" +%s))) +%T`
echo "$ci_dir: Successful"
echo "$ci_dir: Successful" > ci_results
echo " <testcase classname=\"CI Results\" name=\"$ci_test\"/>" > results.xml
echo "$ci_test | Pass | $count | $duration" > results.markdown
count=$retries
else
# if the test failed check if we have done the max retries
if [ $count -lt $retries ]
then
echo "$ci_dir: Failed. Retrying"
echo "$ci_dir: Failed. Retrying" >> $ci_test.out
else
end_time=`date`
duration=`date -ud@$(($(date -ud"$end_time" +%s)-$(date -ud"$start_time" +%s))) +%T`
echo "$ci_dir: Failed retry"
echo "$ci_dir: Failed" > ci_results
echo " <testcase classname=\"CI Results\" name=\"$ci_test\" status=\"$ci_test failed\">" > results.xml
echo " <failure message=\"$ci_test failed\" type=\"test failure\"/>
</testcase>" >> results.xml
echo "$ci_test | Fail | $count | $duration" > results.markdown
echo "Logs for "$ci_dir
# Display the error log since we have failed to pass
cat $ci_test.out
fi
fi
((count++))
done
wait_clean