-
Notifications
You must be signed in to change notification settings - Fork 8
/
check-tests.sh
executable file
·104 lines (90 loc) · 3.24 KB
/
check-tests.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/bin/bash
# Script checking the errors.txt file generated by the test.sh script
set -u
FILE_ENV="/workspace/env.list"
set -o allexport
source ${FILE_ENV}
DIR_TEST="/workspace/tests"
PATH_TEST_ERRORS="${DIR_TEST}/errors.txt"
TEST_MODE="${1:-local}"
# Check if there is a errors.txt file
if ! test -f ${PATH_TEST_ERRORS}
then
echo "There is no file ${PATH_TEST_ERRORS} with the errors."
exit 1
fi
# Check that for each distrib of each packtype, we have a build log and a test log
# Get the number of the build and test logs
NB_BUILD_LOGS=$(eval "find ${DIR_TEST}/build* | wc -l")
NB_TEST_LOGS=$(eval "find ${DIR_TEST}/test* | wc -l")
echo "Nb of build logs : ${NB_BUILD_LOGS}"
echo "Nb of test logs : ${NB_TEST_LOGS}"
DISTROS=$(eval "echo $DEBS $RPMS | tr '-' '_'")
if [[ "$TEST_MODE" = "local" ]]; then
DISTROS+=" alpine"
else
echo "Skip test static for TEST_MODE: $TEST_MODE"
fi
echo "List of distros : ${DISTROS}"
NB_DISTROS=$(eval "echo ${DISTROS} | wc -w")
# Reduce count of expected successful builds by one for each end of life
# distribution encountered, as end of life distributions will not be built successfully.
for EXCLUSION in "${EXCLUSIONS[@]}"; do
echo ${DISTROS} | grep -i "${EXCLUSION}"
if [[ $? == 0 ]]; then
NB_DISTROS=$(( $NB_DISTROS - 1 ))
fi
done
# Alpine build is tested only during local tests.
if [[ "$TEST_MODE" = "local" ]]; then
NB_DISTROS=$(( $NB_DISTROS + 1 ))
fi
echo "Nb of distros : ${NB_DISTROS}"
if [[ ${NB_BUILD_LOGS} == ${NB_DISTROS} ]] && [[ ${NB_TEST_LOGS} == ${NB_DISTROS} ]]
then
echo "~ Check the file ~"
TOTAL_ERRORS=`grep -c '1' ${PATH_TEST_ERRORS}`
echo "Total errors : ${TOTAL_ERRORS}"
if [[ ${TOTAL_ERRORS} -eq 0 ]]
then
echo "There is no error in the test log files. We can push to the shared COS Bucket. "
# Push no error
exit 0
else
echo "We have every log but there are ${TOTAL_ERRORS} errors in the test log files. "
# Push error
exit 1
fi
else
if [[ ${NB_BUILD_LOGS} -eq 0 ]] && [[ ${NB_TEST_LOGS} -eq 0 ]]
then
echo "There are no build logs or no test logs."
# Push error
exit 1
else
echo "There are build or test log files missing. "
for DISTRO in ${DISTROS}
do
TEST_LOG="${DIR_TEST}/test_${DISTRO}.log"
if ! test -f ${TEST_LOG}
then
# Print the DISTRO in the {PATH_TEST_ERRORS}
if [[ ${DISTRO} == "alpine" ]]
then
DISTRO_NAME="alpine"
DISTRO_VERS=""
else
DISTRO_NAME="$(cut -d'-' -f1 <<<"${DISTRO}")"
DISTRO_VERS="$(cut -d'-' -f2 <<<"${DISTRO}")"
fi
echo "DISTRO ${DISTRO_NAME} ${DISTRO_VERS} missing" 2>&1 | tee -a ${PATH_TEST_ERRORS}
echo "Missing" 2>&1 | tee -a ${PATH_TEST_ERRORS}
fi
done
TOTAL_MISSING=`grep -c 'missing' ${PATH_TEST_ERRORS}`
TOTAL_ERRORS=`grep -c 1 ${PATH_TEST_ERRORS}`
echo "There are ${TOTAL_MISSING} test log files missing and there are ${TOTAL_ERRORS} errors for the existing test log files."
# Push error
exit 1
fi
fi