From 005a9da0ccb4aca87026f055e44e5d8b4a62e351 Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Mon, 24 Oct 2022 08:24:55 +0200 Subject: [PATCH] e2e framework: implement pod polling with gomega.Eventually gomega.Eventually provides better progress reports: instead of filling up the log with rather useless one-line messages that are not enough to to understand the current state, it integrates with Gingko's progress reporting (SIGUSR1, --poll-progress-after) and then dumps the same complete failure message as after a timeout. That makes it possible to understand why progress isn't getting made without having to wait for the timeout. The other advantage is that the failure message for some unexpected pod state becomes more readable: instead of encapsulating it as "observed object" inside an error, it directly gets rendered by gomega. --- test/e2e/framework/internal/output/output.go | 4 + test/e2e/framework/pod/wait.go | 16 +- test/e2e/framework/pod/wait_test.go | 377 +++++++++++-------- 3 files changed, 230 insertions(+), 167 deletions(-) diff --git a/test/e2e/framework/internal/output/output.go b/test/e2e/framework/internal/output/output.go index cc26c079677..053c36012a7 100644 --- a/test/e2e/framework/internal/output/output.go +++ b/test/e2e/framework/internal/output/output.go @@ -122,6 +122,9 @@ var timePrefix = regexp.MustCompile(`(?m)^[[:alpha:]]{3} +[[:digit:]]{1,2} +[[:d // elapsedSuffix matches "Elapsed: 16.189µs" var elapsedSuffix = regexp.MustCompile(`Elapsed: [[:digit:]]+(\.[[:digit:]]+)?(µs|ns|ms|s|m)`) +// afterSuffix matches "after 5.001s." +var afterSuffix = regexp.MustCompile(`after [[:digit:]]+(\.[[:digit:]]+)?(µs|ns|ms|s|m).`) + // timeSuffix matches "@ 09/06/22 15:36:43.44 (5.001s)" as printed by Ginkgo v2 for log output, with the duration being optional. var timeSuffix = regexp.MustCompile(`(?m)@[[:space:]][[:digit:]]{2}/[[:digit:]]{2}/[[:digit:]]{2} [[:digit:]]{2}:[[:digit:]]{2}:[[:digit:]]{2}(\.[[:digit:]]{1,3})?( \([[:digit:]]+(\.[[:digit:]]+)?(µs|ns|ms|s|m)\))?$`) @@ -129,6 +132,7 @@ func stripTimes(in string) string { out := timePrefix.ReplaceAllString(in, "") out = elapsedSuffix.ReplaceAllString(out, "Elapsed: ") out = timeSuffix.ReplaceAllString(out, "