diff --git a/test/e2e/framework/test_context.go b/test/e2e/framework/test_context.go index 970ec152fd4..1b4a19445f4 100644 --- a/test/e2e/framework/test_context.go +++ b/test/e2e/framework/test_context.go @@ -32,6 +32,7 @@ import ( "github.com/onsi/ginkgo/v2" "github.com/onsi/ginkgo/v2/types" + "github.com/onsi/gomega" gomegaformat "github.com/onsi/gomega/format" restclient "k8s.io/client-go/rest" @@ -472,6 +473,15 @@ func AfterReadingAllFlags(t *TestContextType) { os.Exit(0) } + // Reconfigure gomega defaults. The poll interval should be suitable + // for most tests. The timeouts are more subjective and tests may want + // to override them, but these defaults are still better for E2E than the + // ones from Gomega (1s timeout, 10ms interval). + gomega.SetDefaultEventuallyPollingInterval(t.timeouts.Poll) + gomega.SetDefaultConsistentlyPollingInterval(t.timeouts.Poll) + gomega.SetDefaultEventuallyTimeout(t.timeouts.PodStart) + gomega.SetDefaultConsistentlyDuration(t.timeouts.PodStartShort) + // Only set a default host if one won't be supplied via kubeconfig if len(t.Host) == 0 && len(t.KubeConfig) == 0 { // Check if we can use the in-cluster config diff --git a/test/e2e/framework/timeouts.go b/test/e2e/framework/timeouts.go index 99fc8b9adfa..5cfc29edba3 100644 --- a/test/e2e/framework/timeouts.go +++ b/test/e2e/framework/timeouts.go @@ -47,10 +47,12 @@ type TimeoutContext struct { Poll time.Duration // PodStart is how long to wait for the pod to be started. + // This value is the default for gomega.Eventually. PodStart time.Duration // PodStartShort is same as `PodStart`, but shorter. // Use it in a case-by-case basis, mostly when you are sure pod start will not be delayed. + // This value is the default for gomega.Consistently. PodStartShort time.Duration // PodStartSlow is same as `PodStart`, but longer. @@ -118,6 +120,8 @@ func NewTimeoutContext() *TimeoutContext { // PollInterval defines how long to wait between API server queries while // waiting for some condition. +// +// This value is the default for gomega.Eventually and gomega.Consistently. func PollInterval() time.Duration { return TestContext.timeouts.Poll }