From bee28afbb29992c4f332dcb319fbc3eacdc6e52b Mon Sep 17 00:00:00 2001 From: Dave Wallace Date: Fri, 14 Jun 2024 14:59:38 -0400 Subject: hs-test: output docker build command for ci console log - clean up shellcheck warnings - rename extras/hs-test/test script - add -x attribute to compress script for consistancy Type: test Change-Id: I5d1a9d16eeaff18562461b1e445e32ac696266d3 Signed-off-by: Dave Wallace --- extras/hs-test/Makefile | 6 +- extras/hs-test/hs_test.sh | 92 +++++++++++++++++++++++++++++++ extras/hs-test/script/build_boringssl.sh | 2 +- extras/hs-test/script/build_hst.sh | 23 ++++---- extras/hs-test/script/build_nginx.sh | 2 +- extras/hs-test/script/compress.sh | 0 extras/hs-test/script/nginx_ldp.sh | 3 +- extras/hs-test/test | 94 -------------------------------- 8 files changed, 111 insertions(+), 111 deletions(-) create mode 100644 extras/hs-test/hs_test.sh mode change 100644 => 100755 extras/hs-test/script/compress.sh delete mode 100644 extras/hs-test/test (limited to 'extras/hs-test') diff --git a/extras/hs-test/Makefile b/extras/hs-test/Makefile index 07423e527ed..c51f70bfde6 100644 --- a/extras/hs-test/Makefile +++ b/extras/hs-test/Makefile @@ -115,7 +115,7 @@ build-vpp-gcov: test: .deps.ok .build.ok @# '-' ignores the exit status, it is set in compress.sh @# necessary so gmake won't skip executing the bash script - @-bash ./test --persist=$(PERSIST) --verbose=$(VERBOSE) \ + @-bash ./hs_test.sh --persist=$(PERSIST) --verbose=$(VERBOSE) \ --unconfigure=$(UNCONFIGURE) --debug=$(DEBUG) --test=$(TEST) --cpus=$(CPUS) \ --vppsrc=$(VPPSRC) --parallel=$(PARALLEL) --repeat=$(REPEAT) @bash ./script/compress.sh @@ -124,14 +124,14 @@ test: .deps.ok .build.ok test-debug: .deps.ok .build_debug.ok @# '-' ignores the exit status, it is set in compress.sh @# necessary so gmake won't skip executing the bash script - @-bash ./test --persist=$(PERSIST) --verbose=$(VERBOSE) \ + @-bash ./hs_test.sh --persist=$(PERSIST) --verbose=$(VERBOSE) \ --unconfigure=$(UNCONFIGURE) --debug=$(DEBUG) --test=$(TEST) --cpus=$(CPUS) \ --vppsrc=$(VPPSRC) --parallel=$(PARALLEL) --repeat=$(REPEAT) @bash ./script/compress.sh .PHONY: test-cov test-cov: .deps.ok .build.cov.ok - @-bash ./test --persist=$(PERSIST) --verbose=$(VERBOSE) \ + @-bash ./hs_test.sh --persist=$(PERSIST) --verbose=$(VERBOSE) \ --unconfigure=$(UNCONFIGURE) --debug=$(DEBUG) --test=$(TEST-HS) --cpus=$(CPUS) \ --vppsrc=$(VPPSRC) @$(MAKE) -C ../.. test-cov-post HS_TEST=1 diff --git a/extras/hs-test/hs_test.sh b/extras/hs-test/hs_test.sh new file mode 100644 index 00000000000..28df3e565fe --- /dev/null +++ b/extras/hs-test/hs_test.sh @@ -0,0 +1,92 @@ +#!/usr/bin/env bash + +source vars + +args= +single_test=0 +persist_set=0 +unconfigure_set=0 +debug_set=0 +ginkgo_args= + +for i in "$@" +do +case "${i}" in + --persist=*) + persist="${i#*=}" + if [ "$persist" = "true" ]; then + args="$args -persist" + persist_set=1 + fi + ;; + --debug=*) + debug="${i#*=}" + if [ "$debug" = "true" ]; then + args="$args -debug" + debug_set=1 + fi + ;; + --verbose=*) + verbose="${i#*=}" + if [ "$verbose" = "true" ]; then + args="$args -verbose" + fi + ;; + --unconfigure=*) + unconfigure="${i#*=}" + if [ "$unconfigure" = "true" ]; then + args="$args -unconfigure" + unconfigure_set=1 + fi + ;; + --cpus=*) + args="$args -cpus ${i#*=}" + ;; + --vppsrc=*) + args="$args -vppsrc ${i#*=}" + ;; + --test=*) + tc_name="${i#*=}" + if [ "$tc_name" != "all" ]; then + single_test=1 + ginkgo_args="$ginkgo_args --focus $tc_name -vv" + args="$args -verbose" + else + ginkgo_args="$ginkgo_args -v" + fi + ;; + --parallel=*) + ginkgo_args="$ginkgo_args -procs=${i#*=}" + ;; + --repeat=*) + ginkgo_args="$ginkgo_args --repeat=${i#*=}" + ;; +esac +done + +if [ $single_test -eq 0 ] && [ $persist_set -eq 1 ]; then + echo "persist flag is not supported while running all tests!" + exit 1 +fi + +if [ $unconfigure_set -eq 1 ] && [ $single_test -eq 0 ]; then + echo "a single test has to be specified when unconfigure is set" + exit 1 +fi + +if [ $persist_set -eq 1 ] && [ $unconfigure_set -eq 1 ]; then + echo "setting persist flag and unconfigure flag is not allowed" + exit 1 +fi + +if [ $single_test -eq 0 ] && [ $debug_set -eq 1 ]; then + echo "VPP debug flag is not supperted while running all tests!" + exit 1 +fi + +mkdir -p summary +# shellcheck disable=SC2086 +sudo -E go run github.com/onsi/ginkgo/v2/ginkgo --no-color --trace --json-report=summary/report.json $ginkgo_args -- $args + +jq -r '.[0] | .SpecReports[] | select((.State == "failed") or (.State == "timedout") or (.State == "panicked")) | select(.Failure != null) | "TestName: \(.LeafNodeText)\nSuite:\n\(.Failure.Location.FileName)\nMessage:\n\(.Failure.Message)\n Full Stack Trace:\n\(.Failure.Location.FullStackTrace)\n"' summary/report.json > summary/failed-summary.log \ + && echo "Summary generated -> summary/failed-summary.log" diff --git a/extras/hs-test/script/build_boringssl.sh b/extras/hs-test/script/build_boringssl.sh index 441878a77ca..cca4e4a31d1 100755 --- a/extras/hs-test/script/build_boringssl.sh +++ b/extras/hs-test/script/build_boringssl.sh @@ -1,4 +1,4 @@ #!/bin/bash -cd boringssl +cd boringssl || exit 1 cmake -GNinja -B build ninja -C build diff --git a/extras/hs-test/script/build_hst.sh b/extras/hs-test/script/build_hst.sh index 3b4bc28e275..f3a8e272207 100755 --- a/extras/hs-test/script/build_hst.sh +++ b/extras/hs-test/script/build_hst.sh @@ -1,17 +1,17 @@ #!/usr/bin/env bash -if [ $(lsb_release -is) != Ubuntu ]; then +if [ "$(lsb_release -is)" != Ubuntu ]; then echo "Host stack test framework is supported only on Ubuntu" exit 1 fi -if [ -z $(which ab) ]; then +if [ -z "$(which ab)" ]; then echo "Host stack test framework requires apache2-utils to be installed" echo "It is recommended to run 'sudo make install-dep'" exit 1 fi -if [ -z $(which wrk) ]; then +if [ -z "$(which wrk)" ]; then echo "Host stack test framework requires wrk to be installed" echo "It is recommended to run 'sudo make install-dep'" exit 1 @@ -28,9 +28,7 @@ else fi echo "Taking build objects from ${VPP_BUILD_ROOT}" -if [ -z "$UBUNTU_VERSION" ] ; then - export UBUNTU_VERSION=$(lsb_release -rs) -fi +export UBUNTU_VERSION=${UBUNTU_VERSION:-"$(lsb_release -rs)"} echo "Ubuntu version is set to ${UBUNTU_VERSION}" export HST_LDPRELOAD=${VPP_BUILD_ROOT}/lib/x86_64-linux-gnu/libvcl_ldpreload.so @@ -57,12 +55,14 @@ fi docker_build () { tag=$1 dockername=$2 + set -x docker build --build-arg UBUNTU_VERSION \ - --build-arg http_proxy=$HTTP_PROXY \ - --build-arg https_proxy=$HTTP_PROXY \ - --build-arg HTTP_PROXY=$HTTP_PROXY \ - --build-arg HTTPS_PROXY=$HTTP_PROXY \ - -t $tag -f docker/Dockerfile.$dockername . + --build-arg http_proxy="$HTTP_PROXY" \ + --build-arg https_proxy="$HTTP_PROXY" \ + --build-arg HTTP_PROXY="$HTTP_PROXY" \ + --build-arg HTTPS_PROXY="$HTTP_PROXY" \ + -t "$tag" -f docker/Dockerfile."$dockername" . + set +x } docker_build hs-test/vpp vpp @@ -77,5 +77,6 @@ fi # cleanup detached images images=$(docker images --filter "dangling=true" -q --no-trunc) if [ "$images" != "" ]; then + # shellcheck disable=SC2086 docker rmi $images fi diff --git a/extras/hs-test/script/build_nginx.sh b/extras/hs-test/script/build_nginx.sh index 69d366aab0e..f21201c4297 100755 --- a/extras/hs-test/script/build_nginx.sh +++ b/extras/hs-test/script/build_nginx.sh @@ -1,5 +1,5 @@ #!/bin/bash -cd nginx +cd nginx || exit 1 ./auto/configure --with-debug --with-http_v3_module --with-cc-opt="-I../boringssl/include" --with-ld-opt="-L../boringssl/build/ssl -L../boringssl/build/crypto" --without-http_rewrite_module --without-http_gzip_module make make install diff --git a/extras/hs-test/script/compress.sh b/extras/hs-test/script/compress.sh old mode 100644 new mode 100755 diff --git a/extras/hs-test/script/nginx_ldp.sh b/extras/hs-test/script/nginx_ldp.sh index a6b0a20e47b..416aa5499af 100755 --- a/extras/hs-test/script/nginx_ldp.sh +++ b/extras/hs-test/script/nginx_ldp.sh @@ -1,3 +1,4 @@ #!/usr/bin/env bash -$1 -v && LD_PRELOAD=$LDP $@ 2>&1 > /proc/1/fd/1 +# shellcheck disable=SC2068 +$1 -v && LD_PRELOAD=$LDP $@ > /proc/1/fd/1 2>&1 diff --git a/extras/hs-test/test b/extras/hs-test/test deleted file mode 100644 index 398e2b39edb..00000000000 --- a/extras/hs-test/test +++ /dev/null @@ -1,94 +0,0 @@ -#!/usr/bin/env bash - -source vars - -args= -single_test=0 -persist_set=0 -unconfigure_set=0 -debug_set=0 -vppsrc= -ginkgo_args= -parallel= - -for i in "$@" -do -case "${i}" in - --persist=*) - persist="${i#*=}" - if [ $persist = "true" ]; then - args="$args -persist" - persist_set=1 - fi - ;; - --debug=*) - debug="${i#*=}" - if [ $debug = "true" ]; then - args="$args -debug" - debug_set=1 - fi - ;; - --verbose=*) - verbose="${i#*=}" - if [ $verbose = "true" ]; then - args="$args -verbose" - fi - ;; - --unconfigure=*) - unconfigure="${i#*=}" - if [ $unconfigure = "true" ]; then - args="$args -unconfigure" - unconfigure_set=1 - fi - ;; - --cpus=*) - args="$args -cpus ${i#*=}" - ;; - --vppsrc=*) - args="$args -vppsrc ${i#*=}" - ;; - --test=*) - tc_name="${i#*=}" - if [ $tc_name != "all" ]; then - single_test=1 - ginkgo_args="$ginkgo_args --focus $tc_name -vv" - args="$args -verbose" - else - ginkgo_args="$ginkgo_args -v" - fi - ;; - --parallel=*) - ginkgo_args="$ginkgo_args -procs=${i#*=}" - ;; - --repeat=*) - ginkgo_args="$ginkgo_args --repeat=${i#*=}" - ;; -esac -done - -if [ $single_test -eq 0 ] && [ $persist_set -eq 1 ]; then - echo "persist flag is not supported while running all tests!" - exit 1 -fi - -if [ $unconfigure_set -eq 1 ] && [ $single_test -eq 0 ]; then - echo "a single test has to be specified when unconfigure is set" - exit 1 -fi - -if [ $persist_set -eq 1 ] && [ $unconfigure_set -eq 1 ]; then - echo "setting persist flag and unconfigure flag is not allowed" - exit 1 -fi - -if [ $single_test -eq 0 ] && [ $debug_set -eq 1 ]; then - echo "VPP debug flag is not supperted while running all tests!" - exit 1 -fi - -mkdir -p summary - -sudo -E go run github.com/onsi/ginkgo/v2/ginkgo --no-color --trace --json-report=summary/report.json $ginkgo_args -- $args - -jq -r '.[0] | .SpecReports[] | select((.State == "failed") or (.State == "timedout") or (.State == "panicked")) | select(.Failure != null) | "TestName: \(.LeafNodeText)\nSuite:\n\(.Failure.Location.FileName)\nMessage:\n\(.Failure.Message)\n Full Stack Trace:\n\(.Failure.Location.FullStackTrace)\n"' summary/report.json > summary/failed-summary.log \ - && echo "Summary generated -> summary/failed-summary.log" \ No newline at end of file -- cgit 1.2.3-korg