From 5622fa16bc7c2201051973f07cab6f41a9a82c4f Mon Sep 17 00:00:00 2001 From: Andrea Panattoni Date: Fri, 3 Nov 2023 16:10:42 +0100 Subject: [PATCH] e2e: Gather `cluster-info` on test failure This is a leftover from - https://github.com/k8snetworkplumbingwg/sriov-network-operator/pull/534 Prior to this commit, `kubectl cluster-info ...` is invoked only if the conformance tests does not fail, which is not that useful. Signed-off-by: Andrea Panattoni --- hack/run-e2e-conformance-virtual-cluster.sh | 8 ++++++++ hack/run-e2e-conformance-virtual-ocp.sh | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/hack/run-e2e-conformance-virtual-cluster.sh b/hack/run-e2e-conformance-virtual-cluster.sh index 66c32f66e..5d78f7a8c 100755 --- a/hack/run-e2e-conformance-virtual-cluster.sh +++ b/hack/run-e2e-conformance-virtual-cluster.sh @@ -426,9 +426,17 @@ if [ -z $SKIP_TEST ]; then export JUNIT_OUTPUT="${root}/${TEST_REPORT_PATH}/conformance-test-report" fi + # Disable exit on error temporarily to gather cluster information + set +e SUITE=./test/conformance hack/run-e2e-conformance.sh + TEST_EXITE_CODE=$? + set -e if [[ -v TEST_REPORT_PATH ]]; then kubectl cluster-info dump --namespaces ${NAMESPACE} --output-directory "${root}/${TEST_REPORT_PATH}/cluster-info" fi + + if [[ $TEST_EXITE_CODE -ne 0 ]]; then + exit $TEST_EXITE_CODE + fi fi diff --git a/hack/run-e2e-conformance-virtual-ocp.sh b/hack/run-e2e-conformance-virtual-ocp.sh index 92e196185..1172baa35 100755 --- a/hack/run-e2e-conformance-virtual-ocp.sh +++ b/hack/run-e2e-conformance-virtual-ocp.sh @@ -293,9 +293,17 @@ if [ -z $SKIP_TEST ]; then export JUNIT_OUTPUT="${root}/${TEST_REPORT_PATH}/conformance-test-report" fi + # Disable exit on error temporarily to gather cluster information + set +e SUITE=./test/conformance hack/run-e2e-conformance.sh + TEST_EXITE_CODE=$? + set -e if [[ -v TEST_REPORT_PATH ]]; then kubectl cluster-info dump --namespaces ${NAMESPACE} --output-directory "${root}/${TEST_REPORT_PATH}/cluster-info" fi + + if [[ $TEST_EXITE_CODE -ne 0 ]]; then + exit $TEST_EXITE_CODE + fi fi