mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-27 11:31:05 +00:00
tests: k8s: add function to log exec output
grep_pod_exec_output invokes "kubectl exec", logs its output, and checks that a grep pattern is present in the output. Signed-off-by: Dan Mihai <dmihai@microsoft.com>
This commit is contained in:
parent
014ff8476a
commit
caee12c796
@ -378,3 +378,21 @@ teardown_common() {
|
||||
exec_host "${node}" journalctl -x -t "kata" --since '"'$node_start_time'"' || true
|
||||
fi
|
||||
}
|
||||
|
||||
# Invoke "kubectl exec", log its output, and check that a grep pattern is present in the output.
|
||||
#
|
||||
# Parameters:
|
||||
# $1 - pod name
|
||||
# $2 - the grep pattern
|
||||
# $3+ - the command to execute using "kubectl exec"
|
||||
#
|
||||
grep_pod_exec_output() {
|
||||
local -r pod_name="$1"
|
||||
shift
|
||||
local -r grep_arg="$1"
|
||||
shift
|
||||
|
||||
local -r pod_env=$(kubectl exec "${pod_name}" -- "$@")
|
||||
info "pod_env: ${pod_env}"
|
||||
echo "${pod_env}" | grep "${grep_arg}"
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user