Skip to content

gomega.Eventually ignores default timeout #781

@pohly

Description

@pohly

In a Kubernetes e2e_node test, we have:

gomega.SetDefaultEventuallyTimeout(5 * time.Minute)
...
gomega.Eventually(ctx, listResources).Should(matchNode, "ResourceSlice from kubelet plugin")

But that call doesn't time out. Eventually the entire suite gets killed by the CI, which doesn't give any information about the reason why it didn't stop.

I think I traced it to:

func (assertion *AsyncAssertion) afterTimeout() <-chan time.Time {
if assertion.timeoutInterval >= 0 {
return time.After(assertion.timeoutInterval)
}
if assertion.asyncType == AsyncAssertionTypeConsistently {
return time.After(assertion.g.DurationBundle.ConsistentlyDuration)
} else {
if assertion.ctx == nil {
return time.After(assertion.g.DurationBundle.EventuallyTimeout)
} else {
return nil
}
}
}

assertion.ctx is from Ginkgo and the specific assertion doesn't have a timeout:

(dlv) p assertion.ctx
Sending output to pager...
context.Context(*github.com/onsi/ginkgo/v2/internal.specContext) *{
	Context: context.Context(*context.valueCtx) *{
		Context: context.Context(*context.cancelCtx) ...,
		key: interface {}(string) *(*interface {})(0xc000aa6700),
		val: interface {}(*github.com/onsi/ginkgo/v2/internal.specContext) ...,},
	ProgressReporterManager: *github.com/onsi/ginkgo/v2/internal.ProgressReporterManager {
		lock: *(*sync.Mutex)(0xc000aa44e0),
		progressReporters: map[int]func() string [...],
		prCounter: 1,},
	cancel: context.WithCancelCause.func1 {
		c *context.cancelCtx = *(*context.cancelCtx)(0xc0008141e0)
	},
...

(dlv) p assertion.timeoutInterval
github.com/cenkalti/backoff/v4.Stop (-1)

Therefore the default timeout gets ignored. This seems wrong. gomega.Eventually should stop when the context gets canceled or the gomega.Eventually timeout occurs, whether that was set per call or is the default.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions