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=../.. |
| 21 | |
| 22 | if [ "$1" == "debug" ]; then |
| 23 | VPP_BUILD_ROOT=${VPP_WS}/build-root/build-vpp_debug-native/vpp |
adrianvillin | 8512145 | 2024-01-11 11:59:47 +0100 | [diff] [blame] | 24 | elif [ "$1" == "gcov" ]; then |
| 25 | VPP_BUILD_ROOT=${VPP_WS}/build-root/build-vpp_gcov-native/vpp |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 26 | else |
| 27 | VPP_BUILD_ROOT=${VPP_WS}/build-root/build-vpp-native/vpp |
| 28 | fi |
| 29 | echo "Taking build objects from ${VPP_BUILD_ROOT}" |
| 30 | |
Dave Wallace | bee28af | 2024-06-14 14:59:38 -0400 | [diff] [blame] | 31 | export UBUNTU_VERSION=${UBUNTU_VERSION:-"$(lsb_release -rs)"} |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 32 | echo "Ubuntu version is set to ${UBUNTU_VERSION}" |
| 33 | |
| 34 | export HST_LDPRELOAD=${VPP_BUILD_ROOT}/lib/x86_64-linux-gnu/libvcl_ldpreload.so |
| 35 | echo "HST_LDPRELOAD is set to ${HST_LDPRELOAD}" |
| 36 | |
| 37 | export PATH=${VPP_BUILD_ROOT}/bin:$PATH |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 38 | |
| 39 | bin=vpp-data/bin |
| 40 | lib=vpp-data/lib |
| 41 | |
| 42 | mkdir -p ${bin} ${lib} || true |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 43 | rm -rf vpp-data/bin/* || true |
| 44 | rm -rf vpp-data/lib/* || true |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 45 | |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 46 | cp ${VPP_BUILD_ROOT}/bin/* ${bin} |
Maros Ondrejicka | f643b6f | 2023-01-17 10:52:20 +0100 | [diff] [blame] | 47 | res+=$? |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 48 | cp -r ${VPP_BUILD_ROOT}/lib/x86_64-linux-gnu/* ${lib} |
Maros Ondrejicka | f643b6f | 2023-01-17 10:52:20 +0100 | [diff] [blame] | 49 | res+=$? |
| 50 | if [ $res -ne 0 ]; then |
| 51 | echo "Failed to copy VPP files. Is VPP built? Try running 'make build' in VPP directory." |
| 52 | exit 1 |
| 53 | fi |
Filip Tehlar | 229f5fc | 2022-08-09 14:44:47 +0000 | [diff] [blame] | 54 | |
Filip Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 55 | docker_build () { |
| 56 | tag=$1 |
| 57 | dockername=$2 |
Dave Wallace | bee28af | 2024-06-14 14:59:38 -0400 | [diff] [blame] | 58 | set -x |
Florin Coras | 98d24a5 | 2023-12-22 19:58:26 -0500 | [diff] [blame] | 59 | docker build --build-arg UBUNTU_VERSION \ |
Dave Wallace | bee28af | 2024-06-14 14:59:38 -0400 | [diff] [blame] | 60 | --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 Tehlar | 671cf51 | 2023-01-31 10:34:18 +0100 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | docker_build hs-test/vpp vpp |
| 69 | docker_build hs-test/nginx-ldp nginx |
Maros Ondrejicka | c2f76f4 | 2023-02-27 13:22:45 +0100 | [diff] [blame] | 70 | docker_build hs-test/nginx-server nginx-server |
Filip Tehlar | 31eaea9 | 2023-06-15 10:06:57 +0200 | [diff] [blame] | 71 | docker_build hs-test/build build |
| 72 | if [ "$HST_EXTENDED_TESTS" = true ] ; then |
| 73 | docker_build hs-test/nginx-http3 nginx-http3 |
Matus Fabian | b7a9ed7 | 2024-05-10 16:20:40 +0200 | [diff] [blame] | 74 | docker_build hs-test/curl curl |
Filip Tehlar | 31eaea9 | 2023-06-15 10:06:57 +0200 | [diff] [blame] | 75 | fi |
Filip Tehlar | e08fdf3 | 2023-04-26 18:03:35 +0200 | [diff] [blame] | 76 | |
| 77 | # cleanup detached images |
| 78 | images=$(docker images --filter "dangling=true" -q --no-trunc) |
| 79 | if [ "$images" != "" ]; then |
Dave Wallace | bee28af | 2024-06-14 14:59:38 -0400 | [diff] [blame] | 80 | # shellcheck disable=SC2086 |
Filip Tehlar | e08fdf3 | 2023-04-26 18:03:35 +0200 | [diff] [blame] | 81 | docker rmi $images |
| 82 | fi |