hs-test: fixed timed out tests passing in the CI 29/40729/10
authorAdrian Villin <avillin@cisco.com>
Fri, 10 May 2024 08:19:35 +0000 (04:19 -0400)
committerAdrian Villin <avillin@cisco.com>
Fri, 17 May 2024 16:47:00 +0000 (16:47 +0000)
Type: test

Change-Id: Id05ea56bc5dfd80d42b8600cf11e763e25420bd0
Signed-off-by: Adrian Villin <avillin@cisco.com>
extras/hs-test/Makefile
extras/hs-test/script/compress.sh
extras/hs-test/test [changed mode: 0755->0644]

index 6ee89bc..e247bf4 100644 (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"
index 92a2fbd..1f0205c 100644 (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."
-    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
old mode 100755 (executable)
new mode 100644 (file)
index fd17feb..398e2b3
@@ -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