forked from FDio/govpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_integration.sh
executable file
·77 lines (64 loc) · 2.57 KB
/
run_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
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env bash
# // Copyright (c) 2022 Cisco and/or its affiliates.
# //
# // Licensed under the Apache License, Version 2.0 (the "License");
# // you may not use this file except in compliance with the License.
# // You may obtain a copy of the License at:
# //
# // http://www.apache.org/licenses/LICENSE-2.0
# //
# // Unless required by applicable law or agreed to in writing, software
# // distributed under the License is distributed on an "AS IS" BASIS,
# // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# // See the License for the specific language governing permissions and
# // limitations under the License.
set -euo pipefail
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd -P )"
args=($*)
echo "Preparing integration tests.."
VPP_REPO=${VPP_REPO:-release}
export CGO_ENABLED=0
export DOCKER_BUILDKIT=1
export GOTESTSUM_FORMAT="${GOTESTSUM_FORMAT:-testname}"
imgtag="govpp-integration"
go test -c -o test/integration.test \
-tags 'osusergo netgo e2e' \
-ldflags '-w -s -extldflags "-static"' \
-trimpath \
"${SCRIPT_DIR}/integration"
docker build --tag "${imgtag}" \
-f "${SCRIPT_DIR}"/build/Dockerfile.integration \
--build-arg VPP_REPO="${VPP_REPO}" \
"${SCRIPT_DIR}"/build
vppver=$(docker run --rm -i "${imgtag}" dpkg-query -f '${Version}' -W vpp)
if [ -n "${GITHUB_STEP_SUMMARY}" ]; then
echo "**VPP version**: \`${vppver}\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
fi
echo "=========================================================================="
echo " GOVPP INTEGRATION TEST - $(date) "
echo "=========================================================================="
echo "- VPP_REPO: $VPP_REPO"
echo "- VPP version: $vppver"
echo "--------------------------------------------------------------------------"
if docker run -i --privileged \
-e TEST=integration \
-e CGO_ENABLED=0 \
-e DEBUG_GOVPP \
-e GOTESTSUM_FORMAT \
-e CLICOLOR_FORCE \
-v "$(cd "${SCRIPT_DIR}/.." && pwd)":/src \
-w /src \
"${imgtag}" gotestsum --raw-command -- go tool test2json -t -p integration ./test/integration.test -test.v ${args[@]:-}
then
echo >&2 "-------------------------------------------------------------"
echo >&2 -e " \e[32mPASSED\e[0m (took: ${SECONDS}s)"
echo >&2 "-------------------------------------------------------------"
exit 0
else
res=$?
echo >&2 "-------------------------------------------------------------"
echo >&2 -e " \e[31mFAILED!\e[0m (exit code: $res)"
echo >&2 "-------------------------------------------------------------"
exit $res
fi