Skip to content

Commit

Permalink
ci: Save kind logs after each failed test
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
zeeke committed Dec 11, 2024
1 parent 63e7565 commit 69d20a0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
9 changes: 2 additions & 7 deletions .github/workflows/kind-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/
18 changes: 18 additions & 0 deletions e2e/run_all_tests.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 69d20a0

Please sign in to comment.