From 111af4c976bfa8fd475aaa80cd6d3b2cb5c29c9a 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 985dfd71a..c62d4ccfb 100755 --- a/hack/run-e2e-conformance-virtual-cluster.sh +++ b/hack/run-e2e-conformance-virtual-cluster.sh @@ -409,9 +409,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 b55356362..fc8b26cfb 100755 --- a/hack/run-e2e-conformance-virtual-ocp.sh +++ b/hack/run-e2e-conformance-virtual-ocp.sh @@ -274,9 +274,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