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 | |
Dave Wallace | bee28af | 2024-06-14 14:59:38 -0400 | [diff] [blame] | 8 | if [ -z "$(which ab)" ]; then |
Maros Ondrejicka | 2ddb2fd | 2023-02-15 17:44:46 +0100 | [diff] [blame] | 9 | 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 |
| 12 | fi |
| 13 | |
Dave Wallace | bee28af | 2024-06-14 14:59:38 -0400 | [diff] [blame] | 14 | if [ -z "$(which wrk)" ]; then |
Maros Ondrejicka | 2ddb2fd | 2023-02-15 17:44:46 +0100 | [diff] [blame] | 15 | echo "Host stack test framework requires wrk to be installed" |
| 16 | echo "It is recommended to run 'sudo make install-dep'" |
| 17 | exit 1 |
| 18 | fi |
| 19 | |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 20 | export VPP_WS=../.. |
Dave Wallace | 5eaa15d | 2024-06-18 17:10:07 -0400 | [diff] [blame] | 21 | OS_ARCH="$(uname -m)" |
| 22 | DOCKER_BUILD_DIR="/scratch/docker-build" |
| 23 | DOCKER_CACHE_DIR="${DOCKER_BUILD_DIR}/docker_cache" |
| 24 | |
| 25 | if [ -d "${DOCKER_BUILD_DIR}" ] ; then |
| 26 | mkdir -p "${DOCKER_CACHE_DIR}" |
| 27 | DOCKER_HST_BUILDER="hst_builder" |
| 28 | set -x |
| 29 | if ! docker buildx ls --format "{{.Name}}" | grep -q "${DOCKER_HST_BUILDER}"; then |
| 30 | docker buildx create --name=${DOCKER_HST_BUILDER} --driver=docker-container --use --bootstrap || true |
| 31 | fi |
| 32 | set -x |
| 33 | 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}" |
| 34 | fi |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 35 | |
| 36 | if [ "$1" == "debug" ]; then |
| 37 | VPP_BUILD_ROOT=${VPP_WS}/build-root/build-vpp_debug-native/vpp |
adrianvillin | 8512145 | 2024-01-11 11:59:47 +0100 | [diff] [blame] | 38 | elif [ "$1" == "gcov" ]; then |
| 39 | VPP_BUILD_ROOT=${VPP_WS}/build-root/build-vpp_gcov-native/vpp |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 40 | else |
| 41 | VPP_BUILD_ROOT=${VPP_WS}/build-root/build-vpp-native/vpp |
| 42 | fi |
| 43 | echo "Taking build objects from ${VPP_BUILD_ROOT}" |
| 44 | |
Dave Wallace | bee28af | 2024-06-14 14:59:38 -0400 | [diff] [blame] | 45 | export UBUNTU_VERSION=${UBUNTU_VERSION:-"$(lsb_release -rs)"} |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 46 | echo "Ubuntu version is set to ${UBUNTU_VERSION}" |
| 47 | |
Dave Wallace | 5eaa15d | 2024-06-18 17:10:07 -0400 | [diff] [blame] | 48 | 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] | 49 | echo "HST_LDPRELOAD is set to ${HST_LDPRELOAD}" |
| 50 | |
| 51 | export PATH=${VPP_BUILD_ROOT}/bin:$PATH |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 52 | |
| 53 | bin=vpp-data/bin |
| 54 | lib=vpp-data/lib |
| 55 | |
| 56 | mkdir -p ${bin} ${lib} || true |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 57 | rm -rf vpp-data/bin/* || true |
| 58 | rm -rf vpp-data/lib/* || true |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 59 | |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 60 | cp ${VPP_BUILD_ROOT}/bin/* ${bin} |
Maros Ondrejicka | f643b6f | 2023-01-17 10:52:20 +0100 | [diff] [blame] | 61 | res+=$? |
Dave Wallace | 5eaa15d | 2024-06-18 17:10:07 -0400 | [diff] [blame] | 62 | cp -r ${VPP_BUILD_ROOT}/lib/"${OS_ARCH}"-linux-gnu/* ${lib} |
Maros Ondrejicka | f643b6f | 2023-01-17 10:52:20 +0100 | [diff] [blame] | 63 | res+=$? |
| 64 | if [ $res -ne 0 ]; then |
| 65 | echo "Failed to copy VPP files. Is VPP built? Try running 'make build' in VPP directory." |
| 66 | exit 1 |
| 67 | fi |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 68 | |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 69 | docker_build () { |
| 70 | tag=$1 |
| 71 | dockername=$2 |
Adrian Villin | aedfd7c | 2024-07-17 15:03:42 +0200 | [diff] [blame] | 72 | set -ex |
Dave Wallace | 5eaa15d | 2024-06-18 17:10:07 -0400 | [diff] [blame] | 73 | # shellcheck disable=2086 |
| 74 | docker buildx build ${DOCKER_CACHE_ARGS} \ |
| 75 | --build-arg UBUNTU_VERSION \ |
| 76 | --build-arg http_proxy="$HTTP_PROXY" \ |
| 77 | --build-arg https_proxy="$HTTP_PROXY" \ |
| 78 | --build-arg HTTP_PROXY="$HTTP_PROXY" \ |
| 79 | --build-arg HTTPS_PROXY="$HTTP_PROXY" \ |
| 80 | -t "$tag" -f docker/Dockerfile."$dockername" . |
Adrian Villin | aedfd7c | 2024-07-17 15:03:42 +0200 | [diff] [blame] | 81 | set +ex |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 82 | } |
| 83 | |
| 84 | docker_build hs-test/vpp vpp |
| 85 | docker_build hs-test/nginx-ldp nginx |
Maros Ondrejicka | c2f76f4 | 2023-02-27 13:22:45 +0100 | [diff] [blame] | 86 | docker_build hs-test/nginx-server nginx-server |
Matus Fabian | 8792e5c | 2024-08-14 12:38:20 +0200 | [diff] [blame] | 87 | docker_build hs-test/curl curl |
Filip Tehlar | 31eaea9 | 2023-06-15 10:06:57 +0200 | [diff] [blame] | 88 | if [ "$HST_EXTENDED_TESTS" = true ] ; then |
| 89 | docker_build hs-test/nginx-http3 nginx-http3 |
Filip Tehlar | 31eaea9 | 2023-06-15 10:06:57 +0200 | [diff] [blame] | 90 | fi |
Filip Tehlar | e08fdf3 | 2023-04-26 18:03:35 +0200 | [diff] [blame] | 91 | |
| 92 | # cleanup detached images |
| 93 | images=$(docker images --filter "dangling=true" -q --no-trunc) |
| 94 | if [ "$images" != "" ]; then |
Dave Wallace | bee28af | 2024-06-14 14:59:38 -0400 | [diff] [blame] | 95 | # shellcheck disable=SC2086 |
Filip Tehlar | e08fdf3 | 2023-04-26 18:03:35 +0200 | [diff] [blame] | 96 | docker rmi $images |
| 97 | fi |