Skip to content

Commit 08ecdc2

Browse files
Merge pull request openshift#535 from camilamacedo86/increase-timeouts
OCPBUGS-63347: Define Default timeouts and apply their usage accross to avoid flakes
2 parents bf97f12 + 604f94b commit 08ecdc2

File tree

11 files changed

+48
-37
lines changed

11 files changed

+48
-37
lines changed

openshift/tests-extension/pkg/helpers/catalogs.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package helpers
33
import (
44
"context"
55
"fmt"
6-
"time"
76

87
//nolint:staticcheck // ST1001: dot-imports for readability
98
. "github.com/onsi/gomega"
@@ -48,5 +47,5 @@ func ExpectCatalogToBeServing(ctx context.Context, name string) {
4847

4948
g.Expect(meta.IsStatusConditionPresentAndEqual(conditions, olmv1.TypeServing, metav1.ConditionTrue)).
5049
To(BeTrue(), fmt.Sprintf("catalog %q is not serving", name))
51-
}).WithTimeout(5 * time.Minute).WithPolling(5 * time.Second).Should(Succeed())
50+
}).WithTimeout(DefaultTimeout).WithPolling(DefaultPolling).Should(Succeed())
5251
}

openshift/tests-extension/pkg/helpers/cluster_catalog.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package helpers
33
import (
44
"context"
55
"fmt"
6-
"time"
76

87
//nolint:staticcheck // ST1001: dot-imports for readability
98
. "github.com/onsi/ginkgo/v2"
@@ -72,6 +71,6 @@ func EnsureCleanupClusterCatalog(ctx context.Context, name string) {
7271
Eventually(func() bool {
7372
err := k8s.Get(ctx, key, &olmv1.ClusterCatalog{})
7473
return errors.IsNotFound(err)
75-
}).WithTimeout(3*time.Minute).WithPolling(2*time.Second).
74+
}).WithTimeout(DefaultTimeout).WithPolling(DefaultPolling).
7675
Should(BeTrue(), "ClusterCatalog %q failed to delete", name)
7776
}

openshift/tests-extension/pkg/helpers/cluster_extension.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ func ExpectClusterExtensionToBeInstalled(ctx context.Context, name string) {
159159
installed := meta.FindStatusCondition(conditions, string(olmv1.TypeInstalled))
160160
g.Expect(installed).ToNot(BeNil(), "Installed condition not found")
161161
g.Expect(installed.Status).To(Equal(metav1.ConditionTrue), "Installed should be True")
162-
}).WithTimeout(5 * time.Minute).WithPolling(1 * time.Second).Should(Succeed())
162+
}).WithTimeout(DefaultTimeout).WithPolling(DefaultPolling).Should(Succeed())
163163
}
164164

165165
// EnsureCleanupClusterExtension attempts to delete any ClusterExtension and a specified CRD
@@ -182,7 +182,7 @@ func EnsureCleanupClusterExtension(ctx context.Context, packageName, crdName str
182182
Eventually(func() bool {
183183
err := k8sClient.Get(ctx, client.ObjectKey{Name: ce.Name}, &olmv1.ClusterExtension{})
184184
return errors.IsNotFound(err)
185-
}).WithTimeout(1*time.Minute).WithPolling(2*time.Second).Should(BeTrue(), "Cleanup ClusterExtension %s failed to delete", ce.Name)
185+
}).WithTimeout(DefaultTimeout).WithPolling(DefaultPolling).Should(BeTrue(), "Cleanup ClusterExtension %s failed to delete", ce.Name)
186186
}
187187
}
188188
} else if !errors.IsNotFound(err) {
@@ -200,7 +200,7 @@ func EnsureCleanupClusterExtension(ctx context.Context, packageName, crdName str
200200
Eventually(func() bool {
201201
err := k8sClient.Get(ctx, client.ObjectKey{Name: crdName}, &apiextensionsv1.CustomResourceDefinition{})
202202
return errors.IsNotFound(err)
203-
}).WithTimeout(1*time.Minute).WithPolling(2*time.Second).Should(BeTrue(), "Lingering CRD %s failed to delete", crdName)
203+
}).WithTimeout(DefaultTimeout).WithPolling(DefaultPolling).Should(BeTrue(), "Lingering CRD %s failed to delete", crdName)
204204
} else if !errors.IsNotFound(err) {
205205
fmt.Fprintf(GinkgoWriter, "Warning: Failed to get CRD %s during cleanup: %v\n", crdName, err)
206206
}
@@ -214,7 +214,7 @@ func ExpectServiceAccountExists(ctx context.Context, name, namespace string) {
214214
Eventually(func(g Gomega) {
215215
err := k8sClient.Get(ctx, client.ObjectKey{Name: name, Namespace: namespace}, sa)
216216
g.Expect(err).ToNot(HaveOccurred(), fmt.Sprintf("failed to get ServiceAccount %q/%q: %v", namespace, name, err))
217-
}).WithTimeout(5*time.Minute).WithPolling(3*time.Second).Should(Succeed(), "ServiceAccount %q/%q did not become visible within timeout", namespace, name)
217+
}).WithTimeout(DefaultTimeout).WithPolling(DefaultPolling).Should(Succeed(), "ServiceAccount %q/%q did not become visible within timeout", namespace, name)
218218
}
219219

220220
// ExpectClusterRoleBindingExists waits for a ClusterRoleBinding to be available and visible to the client.
@@ -224,5 +224,5 @@ func ExpectClusterRoleBindingExists(ctx context.Context, name string) {
224224
Eventually(func(g Gomega) {
225225
err := k8sClient.Get(ctx, client.ObjectKey{Name: name}, crb)
226226
g.Expect(err).ToNot(HaveOccurred(), fmt.Sprintf("failed to get ClusterRoleBinding %q: %v", name, err))
227-
}).WithTimeout(10*time.Second).WithPolling(1*time.Second).Should(Succeed(), "ClusterRoleBinding %q did not become visible within timeout", name)
227+
}).WithTimeout(2*time.Minute).WithPolling(DefaultPolling).Should(Succeed(), "ClusterRoleBinding %q did not become visible within timeout", name)
228228
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package helpers
2+
3+
import "time"
4+
5+
// Default settings for tests that use Eventually.
6+
//
7+
// The timeout is long enough so slow CI systems don’t cause false failures.
8+
// This helps prevent sending wrong signals to Sippy and stops blocking
9+
// pull requests from merging in the whole OCP org.
10+
//
11+
// The polling interval controls how often we check again.
12+
// It’s set to a reasonable value to avoid too many API calls.
13+
const (
14+
// DefaultTimeout is how long we wait before giving up on an Eventually check.
15+
DefaultTimeout = 5 * time.Minute
16+
17+
// DefaultPolling is how often we check again during an Eventually test.
18+
DefaultPolling = 3 * time.Second
19+
)

openshift/tests-extension/pkg/helpers/in_cluster_bundles.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"fmt"
1010
"os"
1111
"os/exec"
12-
"time"
1312

1413
//nolint:staticcheck // ST1001: dot-imports for readability
1514
. "github.com/onsi/ginkgo/v2"
@@ -316,7 +315,7 @@ func waitForBuildToFinish(ctx SpecContext, name, namespace string) {
316315
}
317316
g.Expect(cond).ToNot(BeNil())
318317
g.Expect(cond.Status).To(Equal(corev1.ConditionTrue))
319-
}).WithTimeout(5 * time.Minute).WithPolling(1 * time.Second).Should(Succeed())
318+
}).WithTimeout(DefaultTimeout).WithPolling(DefaultPolling).Should(Succeed())
320319

321320
DeferCleanup(func() {
322321
if CurrentSpecReport().Failed() {
@@ -338,7 +337,7 @@ func waitForClusterCatalogServing(ctx context.Context, name string) {
338337
serving := meta.FindStatusCondition(cc.Status.Conditions, olmv1.TypeServing)
339338
g.Expect(serving).ToNot(BeNil())
340339
g.Expect(serving.Status).To(Equal(metav1.ConditionTrue))
341-
}).WithTimeout(5 * time.Minute).WithPolling(1 * time.Second).Should(Succeed())
340+
}).WithTimeout(DefaultTimeout).WithPolling(DefaultPolling).Should(Succeed())
342341
}
343342

344343
func startBuild(args ...string) *buildv1.Build {

openshift/tests-extension/test/olmv1-catalog.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package test
33
import (
44
"fmt"
55
"strings"
6-
"time"
76

87
//nolint:staticcheck // ST1001: dot-imports for readability
98
. "github.com/onsi/ginkgo/v2"
@@ -99,7 +98,7 @@ func verifyCatalogEndpoint(ctx SpecContext, catalog, endpoint, query string) {
9998
Fail(fmt.Sprintf("Job failed: %s", c.Message))
10099
}
101100
}
102-
}).WithTimeout(2 * time.Minute).WithPolling(5 * time.Second).Should(Succeed())
101+
}).WithTimeout(helpers.DefaultTimeout).WithPolling(helpers.DefaultPolling).Should(Succeed())
103102
}
104103

105104
var _ = Describe("[sig-olmv1][OCPFeatureGate:NewOLM][Skipped:Disconnected] OLMv1 openshift-community-operators Catalog", func() {
@@ -225,7 +224,7 @@ var _ = Describe("[sig-olmv1][OCPFeatureGate:NewOLM][Skipped:Disconnected] OLMv1
225224
g.Expect(c.Status).To(Equal(metav1.ConditionTrue), "expected Progressing=True")
226225
g.Expect(c.Reason).To(Equal("Retrying"), "expected reason to be 'Retrying'")
227226
g.Expect(c.Message).To(ContainSubstring("error creating image source"), "expected image source error")
228-
}).WithTimeout(5 * time.Minute).WithPolling(1 * time.Second).Should(Succeed())
227+
}).WithTimeout(helpers.DefaultTimeout).WithPolling(helpers.DefaultPolling).Should(Succeed())
229228
})
230229
})
231230

openshift/tests-extension/test/olmv1-incompatible.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package test
22

33
import (
44
"context"
5-
"time"
65

76
//nolint:staticcheck // ST1001: dot-imports for readability
87
. "github.com/onsi/ginkgo/v2"
@@ -92,7 +91,7 @@ func waitForOlmUpgradeStatus(ctx SpecContext, status operatorv1.ConditionStatus,
9291
g.Expect(cond.Reason).To(Equal(reasonIncompatibleOperatorsInstalled))
9392
g.Expect(cond.Message).To(ContainSubstring(name))
9493
}
95-
}).WithTimeout(5 * time.Minute).WithPolling(1 * time.Second).Should(Succeed())
94+
}).WithTimeout(helpers.DefaultTimeout).WithPolling(helpers.DefaultPolling).Should(Succeed())
9695
}
9796

9897
func waitForClusterOperatorUpgradable(ctx SpecContext, name string) {
@@ -116,5 +115,5 @@ func waitForClusterOperatorUpgradable(ctx SpecContext, name string) {
116115
g.Expect(cond.Status).To(Equal(configv1.ConditionFalse))
117116
g.Expect(cond.Reason).To(Equal(reasonIncompatibleOperatorsInstalled))
118117
g.Expect(cond.Message).To(ContainSubstring(name))
119-
}).WithTimeout(5 * time.Minute).WithPolling(1 * time.Second).Should(Succeed())
118+
}).WithTimeout(helpers.DefaultTimeout).WithPolling(helpers.DefaultPolling).Should(Succeed())
120119
}

openshift/tests-extension/test/olmv1-preflight.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package test
33
import (
44
"context"
55
"fmt"
6-
"time"
76

87
//nolint:staticcheck // ST1001: dot-imports for readability
98
. "github.com/onsi/ginkgo/v2"
@@ -125,7 +124,7 @@ func runNegativePreflightTest(ctx context.Context, scenario int, namespace strin
125124
c = meta.FindStatusCondition(latest.Status.Conditions, "Installed")
126125
g.Expect(c).NotTo(BeNil())
127126
g.Expect(c.Status).To(Equal(metav1.ConditionFalse))
128-
}).WithTimeout(5 * time.Minute).WithPolling(5 * time.Second).Should(Succeed())
127+
}).WithTimeout(helpers.DefaultTimeout).WithPolling(helpers.DefaultPolling).Should(Succeed())
129128
}
130129

131130
// createDeficientClusterRole returns a modified ClusterRole according to the test scenario.

openshift/tests-extension/test/olmv1-singleownnamespace.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package test
33
import (
44
"context"
55
"fmt"
6-
"time"
76

87
//nolint:staticcheck // ST1001: dot-imports for readability
98
. "github.com/onsi/ginkgo/v2"
@@ -458,7 +457,7 @@ var _ = Describe("[sig-olmv1][OCPFeatureGate:NewOLMOwnSingleNamespace] OLMv1 ope
458457
}
459458
}
460459
g.Expect(found).To(BeTrue(), "failed to find deployment with olm.targetNamespaces annotation")
461-
}).WithTimeout(5 * time.Minute).WithPolling(3 * time.Second).Should(Succeed())
460+
}).WithTimeout(helpers.DefaultTimeout).WithPolling(helpers.DefaultPolling).Should(Succeed())
462461

463462
By(fmt.Sprintf("cleaning up resources created for %s scenario to allow next scenario", sc.label))
464463
deletePolicy := metav1.DeletePropagationForeground
@@ -602,7 +601,7 @@ var _ = Describe("[sig-olmv1][OCPFeatureGate:NewOLMOwnSingleNamespace][Serial] O
602601
g.Expect(installed).ToNot(BeNil(), "Installed condition not found")
603602
g.Expect(installed.Status).To(Equal(metav1.ConditionFalse), "Installed should be False")
604603
g.Expect(installed.Reason).To(Equal("Failed"))
605-
}).WithTimeout(5 * time.Minute).WithPolling(1 * time.Second).Should(Succeed())
604+
}).WithTimeout(helpers.DefaultTimeout).WithPolling(helpers.DefaultPolling).Should(Succeed())
606605
})
607606
})
608607

@@ -742,6 +741,6 @@ var _ = Describe("[sig-olmv1][OCPFeatureGate:NewOLMOwnSingleNamespace] OLMv1 ope
742741
g.Expect(installed.Status).To(Equal(metav1.ConditionFalse), "Installed should be False")
743742
g.Expect(installed.Reason).To(Equal(olmv1.ReasonFailed))
744743
g.Expect(installed.Message).ToNot(BeEmpty())
745-
}).WithTimeout(5 * time.Minute).WithPolling(3 * time.Second).Should(Succeed())
744+
}).WithTimeout(helpers.DefaultTimeout).WithPolling(helpers.DefaultPolling).Should(Succeed())
746745
})
747746
})

openshift/tests-extension/test/olmv1.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package test
33
import (
44
"context"
55
"fmt"
6-
"time"
76

87
//nolint:staticcheck // ST1001: dot-imports for readability
98
. "github.com/onsi/ginkgo/v2"
@@ -185,7 +184,7 @@ var _ = Describe("[sig-olmv1][OCPFeatureGate:NewOLM] OLMv1 operator installation
185184
ce := &olmv1.ClusterExtension{}
186185
Eventually(func() error {
187186
return env.Get().K8sClient.Get(ctx, client.ObjectKey{Name: name}, ce)
188-
}).WithTimeout(5 * time.Minute).WithPolling(5 * time.Second).Should(Succeed())
187+
}).WithTimeout(helpers.DefaultTimeout).WithPolling(helpers.DefaultPolling).Should(Succeed())
189188

190189
By("waiting up to 2 minutes for ClusterExtension to report failure")
191190
Eventually(func(g Gomega) {
@@ -204,6 +203,6 @@ var _ = Describe("[sig-olmv1][OCPFeatureGate:NewOLM] OLMv1 operator installation
204203
g.Expect(installed.Status).To(Equal(metav1.ConditionFalse))
205204
g.Expect(installed.Reason).To(Equal("Failed"))
206205
g.Expect(installed.Message).To(Equal("No bundle installed"))
207-
}).WithTimeout(5 * time.Minute).WithPolling(5 * time.Second).Should(Succeed())
206+
}).WithTimeout(helpers.DefaultTimeout).WithPolling(helpers.DefaultPolling).Should(Succeed())
208207
})
209208
})

0 commit comments

Comments
 (0)