mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-20 02:11:09 +00:00
e2e framework: configure poll interval+duration for gomega
Primarily this protects against accidentally polling with the default interval of 10ms. Setting these defaults may also make some tests simpler because they don't need to override the defaults.
This commit is contained in:
parent
16a6f70e11
commit
0f9a8d38be
@ -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
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user