blob: f3a8e2722072f32d1712cf8c360eef61d24dd724 [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
Dave Wallacebee28af2024-06-14 14:59:38 -04008if [ -z "$(which ab)" ]; then
Maros Ondrejicka2ddb2fd2023-02-15 17:44:46 +01009 echo "Host stack test framework requires apache2-utils to be installed"
10 echo "It is recommended to run 'sudo make install-dep'"
11 exit 1
12fi
13
Dave Wallacebee28af2024-06-14 14:59:38 -040014if [ -z "$(which wrk)" ]; then
Maros Ondrejicka2ddb2fd2023-02-15 17:44:46 +010015 echo "Host stack test framework requires wrk to be installed"
16 echo "It is recommended to run 'sudo make install-dep'"
17 exit 1
18fi
19
Filip Tehlar671cf512023-01-31 10:34:18 +010020export VPP_WS=../..
21
22if [ "$1" == "debug" ]; then
23 VPP_BUILD_ROOT=${VPP_WS}/build-root/build-vpp_debug-native/vpp
adrianvillin85121452024-01-11 11:59:47 +010024elif [ "$1" == "gcov" ]; then
25 VPP_BUILD_ROOT=${VPP_WS}/build-root/build-vpp_gcov-native/vpp
Filip Tehlar671cf512023-01-31 10:34:18 +010026else
27 VPP_BUILD_ROOT=${VPP_WS}/build-root/build-vpp-native/vpp
28fi
29echo "Taking build objects from ${VPP_BUILD_ROOT}"
30
Dave Wallacebee28af2024-06-14 14:59:38 -040031export UBUNTU_VERSION=${UBUNTU_VERSION:-"$(lsb_release -rs)"}
Filip Tehlar671cf512023-01-31 10:34:18 +010032echo "Ubuntu version is set to ${UBUNTU_VERSION}"
33
34export HST_LDPRELOAD=${VPP_BUILD_ROOT}/lib/x86_64-linux-gnu/libvcl_ldpreload.so
35echo "HST_LDPRELOAD is set to ${HST_LDPRELOAD}"
36
37export PATH=${VPP_BUILD_ROOT}/bin:$PATH
Filip Tehlar229f5fc2022-08-09 14:44:47 +000038
39bin=vpp-data/bin
40lib=vpp-data/lib
41
42mkdir -p ${bin} ${lib} || true
Filip Tehlar671cf512023-01-31 10:34:18 +010043rm -rf vpp-data/bin/* || true
44rm -rf vpp-data/lib/* || true
Filip Tehlar229f5fc2022-08-09 14:44:47 +000045
Filip Tehlar671cf512023-01-31 10:34:18 +010046cp ${VPP_BUILD_ROOT}/bin/* ${bin}
Maros Ondrejickaf643b6f2023-01-17 10:52:20 +010047res+=$?
Filip Tehlar671cf512023-01-31 10:34:18 +010048cp -r ${VPP_BUILD_ROOT}/lib/x86_64-linux-gnu/* ${lib}
Maros Ondrejickaf643b6f2023-01-17 10:52:20 +010049res+=$?
50if [ $res -ne 0 ]; then
51 echo "Failed to copy VPP files. Is VPP built? Try running 'make build' in VPP directory."
52 exit 1
53fi
Filip Tehlar229f5fc2022-08-09 14:44:47 +000054
Filip Tehlar671cf512023-01-31 10:34:18 +010055docker_build () {
56 tag=$1
57 dockername=$2
Dave Wallacebee28af2024-06-14 14:59:38 -040058 set -x
Florin Coras98d24a52023-12-22 19:58:26 -050059 docker build --build-arg UBUNTU_VERSION \
Dave Wallacebee28af2024-06-14 14:59:38 -040060 --build-arg http_proxy="$HTTP_PROXY" \
61 --build-arg https_proxy="$HTTP_PROXY" \
62 --build-arg HTTP_PROXY="$HTTP_PROXY" \
63 --build-arg HTTPS_PROXY="$HTTP_PROXY" \
64 -t "$tag" -f docker/Dockerfile."$dockername" .
65 set +x
Filip Tehlar671cf512023-01-31 10:34:18 +010066}
67
68docker_build hs-test/vpp vpp
69docker_build hs-test/nginx-ldp nginx
Maros Ondrejickac2f76f42023-02-27 13:22:45 +010070docker_build hs-test/nginx-server nginx-server
Filip Tehlar31eaea92023-06-15 10:06:57 +020071docker_build hs-test/build build
72if [ "$HST_EXTENDED_TESTS" = true ] ; then
73 docker_build hs-test/nginx-http3 nginx-http3
Matus Fabianb7a9ed72024-05-10 16:20:40 +020074 docker_build hs-test/curl curl
Filip Tehlar31eaea92023-06-15 10:06:57 +020075fi
Filip Tehlare08fdf32023-04-26 18:03:35 +020076
77# cleanup detached images
78images=$(docker images --filter "dangling=true" -q --no-trunc)
79if [ "$images" != "" ]; then
Dave Wallacebee28af2024-06-14 14:59:38 -040080 # shellcheck disable=SC2086
Filip Tehlare08fdf32023-04-26 18:03:35 +020081 docker rmi $images
82fi