From 6c0d2941384ee36323d0170327d9c3ba0e504dd7 Mon Sep 17 00:00:00 2001 From: Paco Xu Date: Wed, 19 Oct 2022 15:33:29 +0800 Subject: [PATCH] kubectl-e2e: the event rendering may have 3 or 4 whitespaces --- test/e2e/kubectl/kubectl.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/e2e/kubectl/kubectl.go b/test/e2e/kubectl/kubectl.go index 25a77a82ecd..7667e00ad00 100644 --- a/test/e2e/kubectl/kubectl.go +++ b/test/e2e/kubectl/kubectl.go @@ -1942,7 +1942,7 @@ metadata: }) ginkgo.Describe("Kubectl events", func() { - ginkgo.It("should show event when pod is created ", func() { + ginkgo.It("should show event when pod is created", func() { podName := "e2e-test-httpd-pod" ginkgo.By("running the image " + httpdImage) e2ekubectl.RunKubectlOrDie(ns, "run", podName, "--image="+httpdImage, podRunningTimeoutArg, "--labels=run="+podName) @@ -1957,7 +1957,9 @@ metadata: ginkgo.By("show started event for this pod") events := e2ekubectl.RunKubectlOrDie(ns, "alpha", "events", "--for=pod/"+podName) - if !strings.Contains(events, fmt.Sprintf("Normal Scheduled Pod/%s", podName)) { + // replace multi spaces into single white space + eventsStr := strings.Join(strings.Fields(strings.TrimSpace(events)), " ") + if !strings.Contains(string(eventsStr), fmt.Sprintf("Normal Scheduled Pod/%s", podName)) { framework.Failf("failed to list expected event") }