Skip to content

Commit e1dc613

Browse files
committed
Fix Eventually timeout race condition in parallel test execution
Move SetDefaultEventuallyTimeout from individual Describe blocks to BeforeSuite to fix timeout race condition. Root cause: When tests run in parallel with `-p`, all test files execute in the same process. SetDefaultEventuallyTimeout is global to Gomega, so whichever Describe block runs last overwrites the timeout for all tests. The sequence was: 1. func_deploy_test.go sets timeout to 10 minutes 2. metrics_test.go sets timeout to 2 minutes (120 seconds) 3. All subsequent tests use 2 minutes, causing deployment tests to timeout Solution: Set timeout once globally in BeforeSuite before any Describe blocks execute. This ensures a consistent 10 minute timeout for all tests. Removed redundant timeout settings from: - test/e2e/func_deploy_test.go (10 min) - test/e2e/func_middleware_update_test.go (10 min) - test/e2e/bundle_test.go (5 min) - test/e2e/metrics_test.go (2 min - the culprit)
1 parent 665901d commit e1dc613

5 files changed

Lines changed: 6 additions & 12 deletions

File tree

test/e2e/bundle_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,6 @@ var _ = Describe("Bundle", Label("bundle"), Ordered, func() {
4747
testNamespaces []TestNamespace
4848
)
4949

50-
SetDefaultEventuallyTimeout(5 * time.Minute)
51-
SetDefaultEventuallyPollingInterval(time.Second)
52-
5350
BeforeAll(func() {
5451
bundleImage = os.Getenv("BUNDLE_IMG")
5552
Expect(bundleImage).ToNot(BeEmpty(), "BUNDLE_IMG must be given")

test/e2e/e2e_suite_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"context"
2121
"fmt"
2222
"testing"
23+
"time"
2324

2425
. "github.com/onsi/ginkgo/v2"
2526
. "github.com/onsi/gomega"
@@ -51,6 +52,11 @@ func TestE2E(t *testing.T) {
5152
var _ = BeforeSuite(func() {
5253
ctx = context.Background()
5354

55+
// Set global timeout for Eventually assertions
56+
// Must be set here (not in Describe blocks) to avoid race conditions in parallel execution
57+
SetDefaultEventuallyTimeout(10 * time.Minute)
58+
SetDefaultEventuallyPollingInterval(1 * time.Second)
59+
5460
// Register the Function API scheme
5561
err := functionsdevv1alpha1.AddToScheme(scheme.Scheme)
5662
Expect(err).NotTo(HaveOccurred())

test/e2e/func_deploy_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,9 +126,6 @@ func functionNotDeployed(functionName, functionNamespace string) func(g Gomega)
126126

127127
var _ = Describe("Operator", func() {
128128

129-
SetDefaultEventuallyTimeout(10 * time.Minute)
130-
SetDefaultEventuallyPollingInterval(time.Second)
131-
132129
Context("with a deployed function", func() {
133130
var repoURL string
134131
var repoDir string

test/e2e/func_middleware_update_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ import (
3939

4040
var _ = Describe("Middleware Update", func() {
4141

42-
SetDefaultEventuallyTimeout(10 * time.Minute)
43-
SetDefaultEventuallyPollingInterval(time.Second)
44-
4542
Context("with a function deployed using old func CLI", func() {
4643

4744
var repoURL string

test/e2e/metrics_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,6 @@ var _ = Describe("Manager", func() {
7979
}
8080
})
8181

82-
SetDefaultEventuallyTimeout(2 * time.Minute)
83-
SetDefaultEventuallyPollingInterval(time.Second)
84-
8582
Context("Manager", func() {
8683
// BeforeEach ensures controllerPodName is set before each test runs
8784
BeforeEach(func() {

0 commit comments

Comments
 (0)