tests: k8s-env.bats: log exec output

Log the "kubectl exec" ouput, just in case it helps investigate sporadic
test errors like:

https://github.com/kata-containers/kata-containers/actions/runs/13724022494/job/38387329321?pr=10973

not ok 1 Environment variables
(in test file k8s-env.bats, line 37)
 `grep "HOST_IP=\([0-9]\+\(\.\|$\)\)\{4\}"' failed

It appears that the first exec from this test case produced the expected
output:

MY_POD_NAME=test-env

but the second exec produced something else - that will be logged after
this change.

Signed-off-by: Dan Mihai <dmihai@microsoft.com>
This commit is contained in:
Dan Mihai 2025-03-07 19:28:00 +00:00
parent 95d47e4d05
commit 509e6da965

View File

@ -32,14 +32,14 @@ setup() {
kubectl wait --for=condition=Ready --timeout=$timeout pod "$pod_name"
# Print environment variables
kubectl exec $pod_name -- "${exec_command[@]}" | grep "MY_POD_NAME=$pod_name"
kubectl exec $pod_name -- "${exec_command[@]}" | \
grep "HOST_IP=\([0-9]\+\(\.\|$\)\)\{4\}"
grep_pod_exec_output "${pod_name}" "MY_POD_NAME=${pod_name}" "${exec_command[@]}"
grep_pod_exec_output "${pod_name}" "HOST_IP=\([0-9]\+\(\.\|$\)\)\{4\}" "${exec_command[@]}"
# Requested 32Mi of memory
kubectl exec $pod_name -- "${exec_command[@]}" | \
grep "MEMORY_REQUESTS=$((1024 * 1024 * 32))"
grep_pod_exec_output "${pod_name}" "MEMORY_REQUESTS=$((1024 * 1024 * 32))" "${exec_command[@]}"
# Memory limits allocated by the node
kubectl exec $pod_name -- "${exec_command[@]}" | grep "MEMORY_LIMITS=[1-9]\+"
grep_pod_exec_output "${pod_name}" "MEMORY_LIMITS=[1-9]\+" "${exec_command[@]}"
}
teardown() {