blob: b7580f5af7e6d486b35f32fd961d5387a8660ce9 [file] [log] [blame]
Filip Tehlar229f5fc2022-08-09 14:44:47 +00001#!/usr/bin/env bash
2
Dave Wallacebee28af2024-06-14 14:59:38 -04003if [ "$(lsb_release -is)" != Ubuntu ]; then
Maros Ondrejickaf643b6f2023-01-17 10:52:20 +01004 echo "Host stack test framework is supported only on Ubuntu"
5 exit 1
6fi
7
Filip Tehlar671cf512023-01-31 10:34:18 +01008export VPP_WS=../..
Dave Wallace5eaa15d2024-06-18 17:10:07 -04009OS_ARCH="$(uname -m)"
10DOCKER_BUILD_DIR="/scratch/docker-build"
11DOCKER_CACHE_DIR="${DOCKER_BUILD_DIR}/docker_cache"
12
13if [ -d "${DOCKER_BUILD_DIR}" ] ; then
14 mkdir -p "${DOCKER_CACHE_DIR}"
15 DOCKER_HST_BUILDER="hst_builder"
16 set -x
17 if ! docker buildx ls --format "{{.Name}}" | grep -q "${DOCKER_HST_BUILDER}"; then
18 docker buildx create --name=${DOCKER_HST_BUILDER} --driver=docker-container --use --bootstrap || true
19 fi
20 set -x
21 DOCKER_CACHE_ARGS="--builder=${DOCKER_HST_BUILDER} --load --cache-to type=local,dest=${DOCKER_CACHE_DIR},mode=max --cache-from type=local,src=${DOCKER_CACHE_DIR}"
22fi
Filip Tehlar671cf512023-01-31 10:34:18 +010023
24if [ "$1" == "debug" ]; then
25 VPP_BUILD_ROOT=${VPP_WS}/build-root/build-vpp_debug-native/vpp
adrianvillin85121452024-01-11 11:59:47 +010026elif [ "$1" == "gcov" ]; then
27 VPP_BUILD_ROOT=${VPP_WS}/build-root/build-vpp_gcov-native/vpp
Filip Tehlar671cf512023-01-31 10:34:18 +010028else
29 VPP_BUILD_ROOT=${VPP_WS}/build-root/build-vpp-native/vpp
30fi
31echo "Taking build objects from ${VPP_BUILD_ROOT}"
32
Dave Wallacebee28af2024-06-14 14:59:38 -040033export UBUNTU_VERSION=${UBUNTU_VERSION:-"$(lsb_release -rs)"}
Filip Tehlar671cf512023-01-31 10:34:18 +010034echo "Ubuntu version is set to ${UBUNTU_VERSION}"
35
Dave Wallace5eaa15d2024-06-18 17:10:07 -040036export HST_LDPRELOAD=${VPP_BUILD_ROOT}/lib/${OS_ARCH}-linux-gnu/libvcl_ldpreload.so
Filip Tehlar671cf512023-01-31 10:34:18 +010037echo "HST_LDPRELOAD is set to ${HST_LDPRELOAD}"
38
39export PATH=${VPP_BUILD_ROOT}/bin:$PATH
Filip Tehlar229f5fc2022-08-09 14:44:47 +000040
41bin=vpp-data/bin
42lib=vpp-data/lib
43
44mkdir -p ${bin} ${lib} || true
Filip Tehlar671cf512023-01-31 10:34:18 +010045rm -rf vpp-data/bin/* || true
46rm -rf vpp-data/lib/* || true
Filip Tehlar229f5fc2022-08-09 14:44:47 +000047
Filip Tehlar671cf512023-01-31 10:34:18 +010048cp ${VPP_BUILD_ROOT}/bin/* ${bin}
Maros Ondrejickaf643b6f2023-01-17 10:52:20 +010049res+=$?
Dave Wallace5eaa15d2024-06-18 17:10:07 -040050cp -r ${VPP_BUILD_ROOT}/lib/"${OS_ARCH}"-linux-gnu/* ${lib}
Maros Ondrejickaf643b6f2023-01-17 10:52:20 +010051res+=$?
52if [ $res -ne 0 ]; then
53 echo "Failed to copy VPP files. Is VPP built? Try running 'make build' in VPP directory."
54 exit 1
55fi
Filip Tehlar229f5fc2022-08-09 14:44:47 +000056
Filip Tehlar671cf512023-01-31 10:34:18 +010057docker_build () {
58 tag=$1
59 dockername=$2
Adrian Villinaedfd7c2024-07-17 15:03:42 +020060 set -ex
Dave Wallace5eaa15d2024-06-18 17:10:07 -040061 # shellcheck disable=2086
62 docker buildx build ${DOCKER_CACHE_ARGS} \
63 --build-arg UBUNTU_VERSION \
Matus Fabianc4b4cd52024-12-08 15:13:44 +010064 --build-arg OS_ARCH="$OS_ARCH" \
Dave Wallace5eaa15d2024-06-18 17:10:07 -040065 --build-arg http_proxy="$HTTP_PROXY" \
66 --build-arg https_proxy="$HTTP_PROXY" \
67 --build-arg HTTP_PROXY="$HTTP_PROXY" \
68 --build-arg HTTPS_PROXY="$HTTP_PROXY" \
69 -t "$tag" -f docker/Dockerfile."$dockername" .
Adrian Villinaedfd7c2024-07-17 15:03:42 +020070 set +ex
Filip Tehlar671cf512023-01-31 10:34:18 +010071}
72
73docker_build hs-test/vpp vpp
74docker_build hs-test/nginx-ldp nginx
Maros Ondrejickac2f76f42023-02-27 13:22:45 +010075docker_build hs-test/nginx-server nginx-server
Matus Fabian8792e5c2024-08-14 12:38:20 +020076docker_build hs-test/curl curl
Adrian Villin46ab0b22024-09-19 17:19:39 +020077docker_build hs-test/envoy envoy
Adrian Villin7bae9b02024-10-02 15:07:40 +020078docker_build hs-test/nginx-http3 nginx-http3
Matus Fabianc4b4cd52024-12-08 15:13:44 +010079docker_build hs-test/ab ab
80docker_build hs-test/wrk wrk
Filip Tehlare08fdf32023-04-26 18:03:35 +020081
82# cleanup detached images
83images=$(docker images --filter "dangling=true" -q --no-trunc)
84if [ "$images" != "" ]; then
Dave Wallacebee28af2024-06-14 14:59:38 -040085 # shellcheck disable=SC2086
Filip Tehlare08fdf32023-04-26 18:03:35 +020086 docker rmi $images
87fi