Skip to content

Commit 447f30e

Browse files
committed
Add eventually to e2e test crud operations
1 parent e7199d1 commit 447f30e

File tree

1 file changed

+28
-8
lines changed

1 file changed

+28
-8
lines changed

test/e2e/installplan_e2e_test.go

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3009,7 +3009,9 @@ var _ = Describe("Install Plan", func() {
30093009
BeforeEach(func() {
30103010
ns = &corev1.Namespace{}
30113011
ns.SetName(genName("ns-"))
3012-
Expect(ctx.Ctx().Client().Create(context.Background(), ns)).To(Succeed())
3012+
Eventually(func() error {
3013+
return ctx.Ctx().Client().Create(context.Background(), ns)
3014+
}, timeout, interval).Should(Succeed(), "could not create Namespace")
30133015

30143016
// Create a dummy CatalogSource to bypass the bundle unpacker's check for a CatalogSource
30153017
catsrc := &operatorsv1alpha1.CatalogSource{
@@ -3022,7 +3024,9 @@ var _ = Describe("Install Plan", func() {
30223024
SourceType: operatorsv1alpha1.SourceTypeGrpc,
30233025
},
30243026
}
3025-
Expect(ctx.Ctx().Client().Create(context.Background(), catsrc)).To(Succeed())
3027+
Eventually(func() error {
3028+
return ctx.Ctx().Client().Create(context.Background(), catsrc)
3029+
}, timeout, interval).Should(Succeed(), "could not create CatalogSource")
30263030

30273031
catsrcName = catsrc.GetName()
30283032

@@ -3036,7 +3040,9 @@ var _ = Describe("Install Plan", func() {
30363040
TargetNamespaces: []string{ns.GetName()},
30373041
},
30383042
}
3039-
Expect(ctx.Ctx().Client().Create(context.Background(), og)).To(Succeed())
3043+
Eventually(func() error {
3044+
return ctx.Ctx().Client().Create(context.Background(), og)
3045+
}, timeout, interval).Should(Succeed(), "could not create OperatorGroup")
30403046

30413047
// Wait for the OperatorGroup to be synced so the InstallPlan doesn't fail due to an invalid OperatorGroup
30423048
Eventually(
@@ -3046,6 +3052,7 @@ var _ = Describe("Install Plan", func() {
30463052
return og.Status.Namespaces, err
30473053
},
30483054
1*time.Minute,
3055+
interval,
30493056
).Should(ContainElement(ns.GetName()))
30503057

30513058
now := metav1.Now()
@@ -3085,7 +3092,9 @@ var _ = Describe("Install Plan", func() {
30853092
})
30863093

30873094
AfterEach(func() {
3088-
Expect(ctx.Ctx().Client().Delete(context.Background(), ns)).To(Succeed())
3095+
Eventually(func() error {
3096+
return ctx.Ctx().Client().Delete(context.Background(), ns)
3097+
}, timeout, interval).Should(Succeed(), "could not delete Namespace")
30893098
})
30903099

30913100
It("should show an error on the bundlelookup condition for a non-existent bundle image", func() {
@@ -3100,11 +3109,15 @@ var _ = Describe("Install Plan", func() {
31003109
ip.SetAnnotations(annotations)
31013110
waitFor := 1*time.Minute + 30*time.Second
31023111

3103-
Expect(ctx.Ctx().Client().Create(context.Background(), ip)).To(Succeed())
3112+
Eventually(func() error {
3113+
return ctx.Ctx().Client().Create(context.Background(), ip)
3114+
}, timeout, interval).Should(Succeed(), "could not create InstallPlan")
31043115

31053116
// The status gets ignored on create so we need to update it else the InstallPlan sync ignores
31063117
// InstallPlans without any steps or bundle lookups
3107-
Expect(ctx.Ctx().Client().Status().Update(context.Background(), ip)).To(Succeed())
3118+
Eventually(func() error {
3119+
return ctx.Ctx().Client().Status().Update(context.Background(), ip)
3120+
}, timeout, interval).Should(Succeed(), "could not update InstallPlan status")
31083121

31093122
// The InstallPlan's status.bundleLookup.conditions should have a BundleLookupPending condition
31103123
// with the container status from unpack pod that mentions an image pull failure for the non-existent
@@ -3126,6 +3139,7 @@ var _ = Describe("Install Plan", func() {
31263139
return "", fmt.Errorf("%s condition not found", operatorsv1alpha1.BundleLookupPending)
31273140
},
31283141
1*time.Minute,
3142+
interval,
31293143
).Should(ContainSubstring("ErrImagePull"))
31303144

31313145
// The InstallPlan should eventually fail due to the ActiveDeadlineSeconds limit
@@ -3135,18 +3149,23 @@ var _ = Describe("Install Plan", func() {
31353149
return ip, err
31363150
},
31373151
waitFor,
3152+
interval,
31383153
).Should(HavePhase(operatorsv1alpha1.InstallPlanPhaseFailed))
31393154
})
31403155

31413156
It("should timeout and fail the InstallPlan for an invalid bundle image", func() {
31423157
// Create an InstallPlan status.bundleLookups.Path specified for an invalid bundle image
31433158
ip.Status.BundleLookups[0].Path = "alpine:3.13"
31443159

3145-
Expect(ctx.Ctx().Client().Create(context.Background(), ip)).To(Succeed())
3160+
Eventually(func() error {
3161+
return ctx.Ctx().Client().Create(context.Background(), ip)
3162+
}, timeout, interval).Should(Succeed(), "could not create InstallPlan")
31463163

31473164
// The status gets ignored on create so we need to update it else the InstallPlan sync ignores
31483165
// InstallPlans without any steps or bundle lookups
3149-
Expect(ctx.Ctx().Client().Status().Update(context.Background(), ip)).To(Succeed())
3166+
Eventually(func() error {
3167+
return ctx.Ctx().Client().Status().Update(context.Background(), ip)
3168+
}, timeout, interval).Should(Succeed(), "could not update InstallPlan status")
31503169

31513170
// The InstallPlan should fail after the unpack pod keeps failing and exceeds the job's
31523171
// BackoffLimit(set to 3), which for 4 failures is an exponential backoff (10s + 20s + 40s + 80s)= 2m30s
@@ -3157,6 +3176,7 @@ var _ = Describe("Install Plan", func() {
31573176
return ip, err
31583177
},
31593178
5*time.Minute,
3179+
interval,
31603180
).Should(HavePhase(operatorsv1alpha1.InstallPlanPhaseFailed))
31613181
})
31623182

0 commit comments

Comments
 (0)