Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | |
Dave Wallace | bee28af | 2024-06-14 14:59:38 -0400 | [diff] [blame] | 3 | if [ "$(lsb_release -is)" != Ubuntu ]; then |
Maros Ondrejicka | f643b6f | 2023-01-17 10:52:20 +0100 | [diff] [blame] | 4 | echo "Host stack test framework is supported only on Ubuntu" |
| 5 | exit 1 |
| 6 | fi |
| 7 | |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 8 | export VPP_WS=../.. |
Dave Wallace | 5eaa15d | 2024-06-18 17:10:07 -0400 | [diff] [blame] | 9 | OS_ARCH="$(uname -m)" |
| 10 | DOCKER_BUILD_DIR="/scratch/docker-build" |
| 11 | DOCKER_CACHE_DIR="${DOCKER_BUILD_DIR}/docker_cache" |
| 12 | |
| 13 | if [ -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}" |
| 22 | fi |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 23 | |
| 24 | if [ "$1" == "debug" ]; then |
| 25 | VPP_BUILD_ROOT=${VPP_WS}/build-root/build-vpp_debug-native/vpp |
adrianvillin | 8512145 | 2024-01-11 11:59:47 +0100 | [diff] [blame] | 26 | elif [ "$1" == "gcov" ]; then |
| 27 | VPP_BUILD_ROOT=${VPP_WS}/build-root/build-vpp_gcov-native/vpp |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 28 | else |
| 29 | VPP_BUILD_ROOT=${VPP_WS}/build-root/build-vpp-native/vpp |
| 30 | fi |
| 31 | echo "Taking build objects from ${VPP_BUILD_ROOT}" |
| 32 | |
Dave Wallace | bee28af | 2024-06-14 14:59:38 -0400 | [diff] [blame] | 33 | export UBUNTU_VERSION=${UBUNTU_VERSION:-"$(lsb_release -rs)"} |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 34 | echo "Ubuntu version is set to ${UBUNTU_VERSION}" |
| 35 | |
Dave Wallace | 5eaa15d | 2024-06-18 17:10:07 -0400 | [diff] [blame] | 36 | export HST_LDPRELOAD=${VPP_BUILD_ROOT}/lib/${OS_ARCH}-linux-gnu/libvcl_ldpreload.so |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 37 | echo "HST_LDPRELOAD is set to ${HST_LDPRELOAD}" |
| 38 | |
| 39 | export PATH=${VPP_BUILD_ROOT}/bin:$PATH |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 40 | |
| 41 | bin=vpp-data/bin |
| 42 | lib=vpp-data/lib |
| 43 | |
| 44 | mkdir -p ${bin} ${lib} || true |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 45 | rm -rf vpp-data/bin/* || true |
| 46 | rm -rf vpp-data/lib/* || true |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 47 | |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 48 | cp ${VPP_BUILD_ROOT}/bin/* ${bin} |
Maros Ondrejicka | f643b6f | 2023-01-17 10:52:20 +0100 | [diff] [blame] | 49 | res+=$? |
Dave Wallace | 5eaa15d | 2024-06-18 17:10:07 -0400 | [diff] [blame] | 50 | cp -r ${VPP_BUILD_ROOT}/lib/"${OS_ARCH}"-linux-gnu/* ${lib} |
Maros Ondrejicka | f643b6f | 2023-01-17 10:52:20 +0100 | [diff] [blame] | 51 | res+=$? |
| 52 | if [ $res -ne 0 ]; then |
| 53 | echo "Failed to copy VPP files. Is VPP built? Try running 'make build' in VPP directory." |
| 54 | exit 1 |
| 55 | fi |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 56 | |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 57 | docker_build () { |
| 58 | tag=$1 |
| 59 | dockername=$2 |
Adrian Villin | aedfd7c | 2024-07-17 15:03:42 +0200 | [diff] [blame] | 60 | set -ex |
Dave Wallace | 5eaa15d | 2024-06-18 17:10:07 -0400 | [diff] [blame] | 61 | # shellcheck disable=2086 |
| 62 | docker buildx build ${DOCKER_CACHE_ARGS} \ |
| 63 | --build-arg UBUNTU_VERSION \ |
Matus Fabian | c4b4cd5 | 2024-12-08 15:13:44 +0100 | [diff] [blame^] | 64 | --build-arg OS_ARCH="$OS_ARCH" \ |
Dave Wallace | 5eaa15d | 2024-06-18 17:10:07 -0400 | [diff] [blame] | 65 | --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 Villin | aedfd7c | 2024-07-17 15:03:42 +0200 | [diff] [blame] | 70 | set +ex |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | docker_build hs-test/vpp vpp |
| 74 | docker_build hs-test/nginx-ldp nginx |
Maros Ondrejicka | c2f76f4 | 2023-02-27 13:22:45 +0100 | [diff] [blame] | 75 | docker_build hs-test/nginx-server nginx-server |
Matus Fabian | 8792e5c | 2024-08-14 12:38:20 +0200 | [diff] [blame] | 76 | docker_build hs-test/curl curl |
Adrian Villin | 46ab0b2 | 2024-09-19 17:19:39 +0200 | [diff] [blame] | 77 | docker_build hs-test/envoy envoy |
Adrian Villin | 7bae9b0 | 2024-10-02 15:07:40 +0200 | [diff] [blame] | 78 | docker_build hs-test/nginx-http3 nginx-http3 |
Matus Fabian | c4b4cd5 | 2024-12-08 15:13:44 +0100 | [diff] [blame^] | 79 | docker_build hs-test/ab ab |
| 80 | docker_build hs-test/wrk wrk |
Filip Tehlar | e08fdf3 | 2023-04-26 18:03:35 +0200 | [diff] [blame] | 81 | |
| 82 | # cleanup detached images |
| 83 | images=$(docker images --filter "dangling=true" -q --no-trunc) |
| 84 | if [ "$images" != "" ]; then |
Dave Wallace | bee28af | 2024-06-14 14:59:38 -0400 | [diff] [blame] | 85 | # shellcheck disable=SC2086 |
Filip Tehlar | e08fdf3 | 2023-04-26 18:03:35 +0200 | [diff] [blame] | 86 | docker rmi $images |
| 87 | fi |