Skip to content

Commit

Permalink
tests: k8s: reduce the policy tests output noise
Browse files Browse the repository at this point in the history
Hide some of the kubectl output, to reduce the size and redundancy of
this output.

Fixes: kata-containers#9388

Signed-off-by: Dan Mihai <[email protected]>
  • Loading branch information
danmihai1 committed Apr 22, 2024
1 parent df23eb0 commit ed6412b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
4 changes: 3 additions & 1 deletion tests/integration/kubernetes/k8s-policy-job.bats
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,9 @@ teardown() {
# Debugging information
for pod_name in ${pod_names[@]}; do
info "Pod ${pod_name}:"
kubectl describe pod "${pod_name}"

# Don't print the "Message:" line because it contains a truncated policy log.
kubectl describe pod "${pod_name}" | grep -v "Message:"
done

info "Job ${job_name}:"
Expand Down
8 changes: 5 additions & 3 deletions tests/integration/kubernetes/k8s-policy-pod.bats
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,16 @@ test_pod_policy_error() {

command="kubectl describe pod ${pod_name} | grep FailedPostStartHook"
info "Waiting ${wait_time} seconds for: ${command}"
waitForProcess "${wait_time}" "$sleep_time" "${command}"

# Don't print the "Message:" line because it contains a truncated policy log.
waitForProcess "${wait_time}" "$sleep_time" "${command}" | grep -v "Message:"
}

teardown() {
policy_tests_enabled || skip "Policy tests are disabled."

# Debugging information
kubectl describe pod "${pod_name}"
# Debugging information. Don"t print the "Message:" line because it contains a truncated policy log.
kubectl describe pod "${pod_name}" | grep -v "Message:"

# Clean-up
kubectl delete pod "${pod_name}"
Expand Down
4 changes: 3 additions & 1 deletion tests/integration/kubernetes/k8s-policy-rc.bats
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ teardown() {

for pod_name in ${launched_pods[@]}; do
info "Pod ${pod_name}:"
kubectl describe pod "${pod_name}"

# Don't print the "Message:" line because it contains a truncated policy log.
kubectl describe pod "${pod_name}" | grep -v "Message:"
done

# Clean-up
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/kubernetes/tests_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -314,5 +314,5 @@ wait_for_blocked_request() {

command="kubectl describe pod ${pod} | grep \"${endpoint} is blocked by policy\""
info "Waiting ${wait_time} seconds for: ${command}"
waitForProcess "${wait_time}" "$sleep_time" "${command}" || return 1
waitForProcess "${wait_time}" "$sleep_time" "${command}" >/dev/null 2>/dev/null
}

0 comments on commit ed6412b

Please sign in to comment.