From aa772d77fbcd1d9c5f1947bf7ed61ebdcf79e2ed Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Wed, 14 Feb 2024 08:57:39 +0100 Subject: [PATCH] e2e pod: dump pod in unexpected phase When stopping polling, the provided messages becomes the complete failure message. This means that the code which calls gomega.StopTrying must include the pod in the message instead of just summarizing the phase. This makes the failure more useful. --- test/e2e/framework/pod/wait.go | 2 +- test/e2e/framework/pod/wait_test.go | 22 ++++++++++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/test/e2e/framework/pod/wait.go b/test/e2e/framework/pod/wait.go index b760edc43a9..546ff133d43 100644 --- a/test/e2e/framework/pod/wait.go +++ b/test/e2e/framework/pod/wait.go @@ -75,7 +75,7 @@ func BeRunningNoRetries() types.GomegaMatcher { gcustom.MakeMatcher(func(pod *v1.Pod) (bool, error) { switch pod.Status.Phase { case v1.PodFailed, v1.PodSucceeded: - return false, gomega.StopTrying(fmt.Sprintf("Expected pod to reach phase %q, got final phase %q instead.", v1.PodRunning, pod.Status.Phase)) + return false, gomega.StopTrying(fmt.Sprintf("Expected pod to reach phase %q, got final phase %q instead:\n%s", v1.PodRunning, pod.Status.Phase, format.Object(pod, 1))) default: return true, nil } diff --git a/test/e2e/framework/pod/wait_test.go b/test/e2e/framework/pod/wait_test.go index 89e0755f28c..30ec0229f9f 100644 --- a/test/e2e/framework/pod/wait_test.go +++ b/test/e2e/framework/pod/wait_test.go @@ -366,7 +366,16 @@ In [It] at: wait_test.go:71