This repository has been archived by the owner on Aug 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
maintest.sh
executable file
·72 lines (63 loc) · 2.02 KB
/
maintest.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
if ! oc whoami; then
echo "Must login using oc before running"
exit 1
fi
# Time to run tests now
scriptHome=$(dirname $(readlink -f $0))
level=$(date "+%Y-%m-%d_%H%M%S")
buildPath=$scriptHome/build_${level}
cd $scriptHome/tests
mkdir -p $buildPath
ln -fsvn $buildPath $scriptHome/build
let anyfail=0
failed=""
# find any .sh|test.yaml|test.yml
regressionTestScripts=$(find . -name [0-9]* -type f |egrep '*.sh|*.yml|*.yaml'| sort)
for testcase in $( echo "$regressionTestScripts") ; do
if [ -f "$testcase" ] ; then
testsuiteName=$(basename $(dirname $testcase))
testcaseScript=$(basename "$testcase")
testcaseName=${testcaseScript%.*}
testcasePath=$buildPath/$testsuiteName/$testcaseName
outputPath=$testcasePath/output
resultsPath=$testcasePath/results
mkdir -p $outputPath
mkdir -p $resultsPath
echo "*** Running testcase $testcase"
cd $(dirname "$testcase")
if [[ $testcase == *.sh ]] ; then
./$testcaseScript > >(tee -a $resultsPath/${testcaseScript}.stdout.txt) 2> >(tee -a $resultsPath/${testcaseScript}.stderr.txt >&2)
if [ $? -ne 0 ]; then
let anyfail+=1
failed="$failed $testcase"
touch $testcasePath/FAILED.TXT
else
touch $testcasePath/PASSED.TXT
fi
fi
if [[ $testcase == *.yaml ]] || [[ $testcase == *.yml ]] ; then
ansible-playbook $testcaseScript > >(tee -a $resultsPath/${testcaseScript}.stdout.txt) 2> >(tee -a $resultsPath/${testcaseScript}.stderr.txt >&2)
if [ $? -ne 0 ]; then
let anyfail+=1
failed="$failed $testcase"
touch $testcasePath/FAILED.TXT
else
touch $testcasePath/PASSED.TXT
fi
fi
cd -
else
echo "*** No test found in $testcase"
fi
done
# Summarize results
if [ $anyfail -eq 0 ] ; then
echo "*** All testcases ran without error"
else
echo "*** There were $anyfail testcase failures - $failed"
fi
# get the logs
cd $buildPath
$scriptHome/scripts/kabanero-mustgather.sh
exit $anyfail