Add logging to show which unexpected events were received in kubectl events e2e test

Co-authored-by: Antonio Ojea <antonio.ojea.garcia@gmail.com>
This commit is contained in:
Brian Pursley 2024-05-23 17:35:10 -04:00
parent 8339711e1f
commit 39d24b0877

View File

@ -2008,13 +2008,13 @@ metadata:
// 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")
framework.Failf("failed to list expected event with pod name: %s, got: %s", podName, events)
}
ginkgo.By("expect not showing any WARNING message except timeouts")
events = e2ekubectl.RunKubectlOrDie(ns, "events", "--types=WARNING", "--for=pod/"+podName)
if events != "" && !strings.Contains(events, "timed out") {
framework.Failf("unexpected WARNING event fired")
framework.Failf("unexpected non-timeout WARNING event fired, got: %s ", events)
}
})
})