From 688ac5ae5513e5ed45be5cc4376bb4c1dd51258b Mon Sep 17 00:00:00 2001 From: Adrian Villin Date: Fri, 10 May 2024 04:19:35 -0400 Subject: hs-test: fixed timed out tests passing in the CI Type: test Change-Id: Id05ea56bc5dfd80d42b8600cf11e763e25420bd0 Signed-off-by: Adrian Villin --- extras/hs-test/Makefile | 13 +++++----- extras/hs-test/script/compress.sh | 53 +++++++++++++++++++-------------------- extras/hs-test/test | 3 +++ 3 files changed, 36 insertions(+), 33 deletions(-) mode change 100755 => 100644 extras/hs-test/test diff --git a/extras/hs-test/Makefile b/extras/hs-test/Makefile index 6ee89bc2770..e247bf44160 100644 --- a/extras/hs-test/Makefile +++ b/extras/hs-test/Makefile @@ -1,3 +1,4 @@ +export HS_ROOT=$(CURDIR) ifeq ($(VERBOSE),) VERBOSE=false @@ -95,17 +96,21 @@ build-vpp-debug: .PHONY: test 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) \ --unconfigure=$(UNCONFIGURE) --debug=$(DEBUG) --test=$(TEST) --cpus=$(CPUS) \ --vppsrc=$(VPPSRC) --parallel=$(PARALLEL) --repeat=$(REPEAT) - $(call jq-summary) @bash ./script/compress.sh .PHONY: test-debug test-debug: .deps.ok .build_debug.ok - @bash ./test --persist=$(PERSIST) --verbose=$(VERBOSE) \ + # '-' 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) \ --unconfigure=$(UNCONFIGURE) --debug=$(DEBUG) --test=$(TEST) --cpus=$(CPUS) \ --vppsrc=$(VPPSRC) --parallel=$(PARALLEL) --repeat=$(REPEAT) + @bash ./script/compress.sh .PHONY: build-go build-go: @@ -144,7 +149,3 @@ install-deps: fixstyle: @gofmt -w . @go mod tidy - -# splitting this into multiple lines breaks the command -jq-summary = @jq -r '.[0] | .SpecReports[] | select(.State == "failed") | select(.Failure != null) | "TestName: \(.LeafNodeText)\nMessage:\n\(.Failure.Message)\n Full Stack Trace:\n\(.Failure.Location.FullStackTrace)\n"' summary/report.json > summary/failed-summary.log \ - && echo "Summary generated -> failed-summary.log" diff --git a/extras/hs-test/script/compress.sh b/extras/hs-test/script/compress.sh index 92a2fbd6789..1f0205c1efb 100644 --- a/extras/hs-test/script/compress.sh +++ b/extras/hs-test/script/compress.sh @@ -1,34 +1,33 @@ #!/usr/bin/env bash -if [ "${COMPRESS_FAILED_TEST_LOGS}" == "yes" -a -s "${HS_SUMMARY}/failed-summary.log" ] +# if failed-summary.log is not empty, exit status = 1 +if [ -s "${HS_ROOT}/summary/failed-summary.log" ] then - echo -n "Copying docker logs..." - dirs=$(jq -r '.[0] | .SpecReports[] | select(.State == "failed") | .LeafNodeText' ${HS_SUMMARY}/report.json) - for dirName in $dirs; do - logDir=/tmp/hs-test/$dirName - if [ -d "$logDir" ]; then - mkdir -p $WORKSPACE/archives/summary - cp -r $logDir $WORKSPACE/archives/summary/ - fi - done - echo "Done." - - if [ -n "$WORKSPACE" ] + if [ -n "${WORKSPACE}" ] then - echo -n "Copying failed test logs into build log archive directory ($WORKSPACE/archives)... " - mkdir -p $WORKSPACE/archives/summary - cp -a ${HS_SUMMARY}/* $WORKSPACE/archives/summary - echo "Done." - fi + echo -n "Copying docker logs..." + dirs=$(jq -r '.[0] | .SpecReports[] | select(.State == "failed") | .LeafNodeText' ${HS_ROOT}/summary/report.json) + for dirName in $dirs; do + logDir=/tmp/hs-test/$dirName + if [ -d "$logDir" ]; then + mkdir -p ${WORKSPACE}/archives/summary + cp -r $logDir ${WORKSPACE}/archives/summary/ + fi + done + echo "Done." - echo -n "Compressing files in $WORKSPACE/archives from test runs... " - cd $WORKSPACE/archives - find . -type f \( -name "*.json" -o -name "*.log" \) -exec gzip {} \; - echo "Done." + echo -n "Copying failed test logs into build log archive directory (${WORKSPACE}/archives)... " + mkdir -p ${WORKSPACE}/archives/summary + cp -a ${HS_ROOT}/summary/* ${WORKSPACE}/archives/summary + echo "Done." -else - echo "Not compressing files in temporary directories from test runs." - exit 0 -fi + echo -n "Compressing files in ${WORKSPACE}/archives from test runs... " + cd ${WORKSPACE}/archives + find . -type f \( -name "*.json" -o -name "*.log" \) -exec gzip {} \; + echo "Done." -exit 1 \ No newline at end of file + else + echo "Not compressing files in temporary directories from test runs." + fi + exit 1 +fi diff --git a/extras/hs-test/test b/extras/hs-test/test old mode 100755 new mode 100644 index fd17feb2c50..398e2b39edb --- a/extras/hs-test/test +++ b/extras/hs-test/test @@ -89,3 +89,6 @@ 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