forked from klts-io/kubernetes-lts
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_integration.sh
executable file
·64 lines (50 loc) · 1.79 KB
/
test_integration.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
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
source "kit/helper.sh"
export KUBE_ROOT=$(dirname "$(readlink -f "$0")")/..
export TERM=linux
echo "KUBE_ROOT directory: $KUBE_ROOT"
cd "${WORKDIR}"
echo "WORKDIR directory: $WORKDIR"
TMPFILE="${TMPDIR}/test-integration.log"
# Etcd was added for testing in 1.21 and later
function test-integration() {
./build/shell.sh -c '
# generate .make/go-pkgdeps.mk
go install ./cmd/...
# run test-integration
KUBE_RUN_COPY_OUTPUT=y TERM=linux PATH=$(pwd)/third_party/etcd:${PATH} DBG_CODEGEN=1 make test-integration
'
}
test-integration 2>&1 | tee "${TMPFILE}" | grep -v -E '^I\w+ ' && exit 0
echo "-------print TMPFILE:"
cat "${TMPFILE}"
echo "-------TMPFILE end."
RETRY_CASES=$(cat "${TMPFILE}" | grep -E '^FAIL\s+k8s.io/kubernetes' | awk '{print $2}' || echo "")
TAG=$(helper::workdir::version)
FAILURES_TOLERATED=$(helper::config::get_test_integration_failures_tolerated ${TAG})
if [[ "${FAILURES_TOLERATED}" != "" ]]; then
echo "+++ Test failed, the case is as follows:"
echo "${RETRY_CASES}"
echo "+++ Failures tolerated, the case is as follows:"
echo "${FAILURES_TOLERATED}"
for tolerate in ${FAILURES_TOLERATED}; do
RETRY_CASES=$(echo "${RETRY_CASES}" | grep -v -E "^${tolerate}$" || echo "")
done
if [[ "${RETRY_CASES}" == "" ]]; then
exit 0
fi
fi
echo "+++ Test failed, will retry 5 times"
for n in {1..5}; do
echo "+++ Test retry ${n}, the case is as follows:"
echo "${RETRY_CASES}"
want=$(echo ${RETRY_CASES})
test-integration WHAT="${want}" 2>&1 | tee "${TMPFILE}" | grep -v -E '^I\w+ ' && exit 0
RETRY_CASES=$(cat "${TMPFILE}" | grep -E '^FAIL\s+k8s.io/kubernetes' | awk '{print $2}' || echo "")
done
echo "!!! Test failed, the case is as follows:"
echo "${RETRY_CASES}"
exit 1