Skip to content

Commit

Permalink
Dump logs when e2e fails in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
thockin committed Sep 19, 2023
1 parent 0ca8086 commit 7d1e3cd
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ test: $(BUILD_DIRS)
/bin/sh -c " \
./build/test.sh ./... \
"
./test_e2e.sh
VERBOSE=1 ./test_e2e.sh

TEST_TOOLS := $(shell find _test_tools/* -type d -printf "%f ")
test-tools: $(foreach tool, $(TEST_TOOLS), .container-test_tool.$(tool))
Expand Down
43 changes: 30 additions & 13 deletions test_e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3291,21 +3291,17 @@ make container REGISTRY=e2e VERSION="${E2E_TAG}" ALLOW_STALE_APT=1
make test-tools REGISTRY=e2e

function finish() {
r=$?
trap "" INT EXIT ERR
if [[ $r != 0 ]]; then
echo
echo "the directory $DIR was not removed as it contains"\
"log files useful for debugging"
fi
exit $r
r=$?
trap "" INT EXIT ERR
if [[ $r != 0 ]]; then
echo
echo "the directory $DIR was not removed as it contains"\
"log files useful for debugging"
fi
exit $r
}
trap finish INT EXIT ERR

echo
echo "test root is $DIR"
echo

# Run a test function and return its error code. This is needed because POSIX
# dictates that `errexit` does not apply inside a function called in an `if`
# context. But if we don't call it with `if`, then it terminates the whole
Expand Down Expand Up @@ -3345,10 +3341,24 @@ umask 0002
# Mark all repos as safe, to avoid "dubious ownership".
git config --global --add safe.directory '*'

# Iterate over the chosen tests and run them.
FAILS=()
FINAL_RET=0
RUNS="${RUNS:-1}"

echo
echo "test root is $DIR"
if (( "${RUNS}" > 1 )); then
echo " RUNS=$RUNS"
fi
if [[ "${CLEANUP:-}" == 0 ]]; then
echo " CLEANUP disabled"
fi
if [[ -n "${VERBOSE:-}" ]]; then
echo " VERBOSE enabled"
fi
echo

# Iterate over the chosen tests and run them.
for t; do
TEST_RET=0
RUN=0
Expand Down Expand Up @@ -3377,6 +3387,13 @@ for t; do
if [[ "$RUN_RET" != 42 ]]; then
echo "FAIL: unknown error"
fi
if [[ -n "${VERBOSE:-}" ]]; then
echo -ne "\n\n"
echo "LOG ----------------------"
cat "${LOG}.${RUN}"
echo "--------------------------"
echo -ne "\n\n"
fi
fi
remove_containers || true
RUN=$((RUN+1))
Expand Down

0 comments on commit 7d1e3cd

Please sign in to comment.