From 69d20a0060d61fd24f7285406958ab08010c3850 Mon Sep 17 00:00:00 2001 From: Andrea Panattoni Date: Wed, 11 Dec 2024 15:26:52 +0100 Subject: [PATCH] ci: Save kind logs after each failed test Some e2e test restart the multi-networkpolicy daemon, making the logs gathering at the end of the CI job useless. Create a script to loop over all the test files and collect logs every time a test fails. Signed-off-by: Andrea Panattoni --- .github/workflows/kind-e2e.yml | 9 ++------- e2e/run_all_tests.sh | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 7 deletions(-) create mode 100755 e2e/run_all_tests.sh diff --git a/.github/workflows/kind-e2e.yml b/.github/workflows/kind-e2e.yml index 1724baca..4caeb5f4 100644 --- a/.github/workflows/kind-e2e.yml +++ b/.github/workflows/kind-e2e.yml @@ -31,16 +31,11 @@ jobs: # enable ip6_tables sudo modprobe ip6_tables - bats ./tests/*.bats - - - name: Export kind logs - if: ${{ failure() }} - run: - ./e2e/bin/kind export logs /tmp/kind-logs + ./run_all_tests.sh - name: Upload logs uses: actions/upload-artifact@v4 if: ${{ failure() }} with: name: kind-logs-e2e - path: /tmp/kind-logs/ + path: ./e2e/artifacts/ diff --git a/e2e/run_all_tests.sh b/e2e/run_all_tests.sh new file mode 100755 index 00000000..e7cb9069 --- /dev/null +++ b/e2e/run_all_tests.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +E2E="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" + +pushd ${E2E} + +suite_failed=0 + +for f in ./tests/*.bats; do + bats $f + retval=$? + if [ $retval -ne 0 ]; then + suite_failed=1 + ./bin/kind export logs ./artifacts/`basename $f`.test/kind-logs + fi +done + +exit $suite_failed