hs-test: fixed timed out tests passing in the CI

Type: test

Change-Id: Id05ea56bc5dfd80d42b8600cf11e763e25420bd0
Signed-off-by: Adrian Villin <avillin@cisco.com>
This commit is contained in:
Adrian Villin 2024-05-10 04:19:35 -04:00
parent 595d8cb668
commit 688ac5ae55
3 changed files with 37 additions and 34 deletions

View File

@ -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"

View File

@ -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."
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 "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."
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."
else
echo "Not compressing files in temporary directories from test runs."
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."
else
echo "Not compressing files in temporary directories from test runs."
exit 0
exit 1
fi
exit 1

3
extras/hs-test/test Executable file → Normal file
View File

@ -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"