From 55ae98eb28cca10db126bf61ce533deb8aa6a968 Mon Sep 17 00:00:00 2001 From: Wainer dos Santos Moschetta Date: Thu, 30 May 2024 16:57:28 -0300 Subject: [PATCH] tests/k8s: print logs on fail only (k8s-confidential-attestation.bats) Use the variable BATS_TEST_COMPLETED which is defined by the bats framework when the test finishes. `BATS_TEST_COMPLETED=` (empty) means the test failed, so the node syslogs will be printed only at that condition. Fixes: #9750 Signed-off-by: Wainer dos Santos Moschetta --- tests/integration/kubernetes/k8s-confidential-attestation.bats | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/kubernetes/k8s-confidential-attestation.bats b/tests/integration/kubernetes/k8s-confidential-attestation.bats index 5ebd649b18..f1b648c58b 100644 --- a/tests/integration/kubernetes/k8s-confidential-attestation.bats +++ b/tests/integration/kubernetes/k8s-confidential-attestation.bats @@ -93,7 +93,7 @@ teardown() { [ -n "${pod_name:-}" ] && kubectl describe "pod/${pod_name}" || true [ -n "${pod_config_dir:-}" ] && kubectl delete -f "${K8S_TEST_YAML}" || true - if [ -n "${node_start_time}:-}" ]; then + if [[ -n "${node_start_time}:-}" && -z "$BATS_TEST_COMPLETED" ]]; then echo "DEBUG: system logs of node '$node' since test start time ($node_start_time)" print_node_journal "$node" "kata" --since "$node_start_time" || true fi