Skip to content

Commit 5a3b64d

Browse files
committed
installplan e2e test fixes
- Remove dependence on catalogsource registry image - Remove redundant clones - Wait for OperatorGroup to be synced to reduce flakes
1 parent 06c8bfd commit 5a3b64d

File tree

1 file changed

+24
-27
lines changed

1 file changed

+24
-27
lines changed

test/e2e/installplan_e2e_test.go

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3004,33 +3004,26 @@ var _ = Describe("Install Plan", func() {
30043004
var (
30053005
ns *corev1.Namespace
30063006
catsrcName string
3007-
crc versioned.Interface
30083007
ip *operatorsv1alpha1.InstallPlan
30093008
)
30103009
BeforeEach(func() {
3011-
crc = newCRClient()
30123010
ns = &corev1.Namespace{}
30133011
ns.SetName(genName("ns-"))
30143012
Expect(ctx.Ctx().Client().Create(context.Background(), ns)).To(Succeed())
30153013

3016-
// Create the single (kiali) bundle catalog source
3014+
// Create a dummy CatalogSource to bypass the bundle unpacker's check for a CatalogSource
30173015
catsrc := &operatorsv1alpha1.CatalogSource{
30183016
ObjectMeta: metav1.ObjectMeta{
3019-
Name: genName("kiali-"),
3017+
Name: genName("dummy-catsrc-"),
30203018
Namespace: ns.GetName(),
3021-
Labels: map[string]string{"olm.catalogSource": "kaili-catalog"},
30223019
},
30233020
Spec: operatorsv1alpha1.CatalogSourceSpec{
3024-
Image: "quay.io/olmtest/single-bundle-index:1.0.0",
3021+
Image: "localhost:0/not/exist:catsrc",
30253022
SourceType: operatorsv1alpha1.SourceTypeGrpc,
30263023
},
30273024
}
30283025
Expect(ctx.Ctx().Client().Create(context.Background(), catsrc)).To(Succeed())
30293026

3030-
// Wait for the CatalogSource to be ready
3031-
catsrc, err := fetchCatalogSourceOnStatus(crc, catsrc.GetName(), catsrc.GetNamespace(), catalogSourceRegistryPodSynced)
3032-
Expect(err).ToNot(HaveOccurred())
3033-
30343027
catsrcName = catsrc.GetName()
30353028

30363029
// Create the OperatorGroup
@@ -3045,6 +3038,16 @@ var _ = Describe("Install Plan", func() {
30453038
}
30463039
Expect(ctx.Ctx().Client().Create(context.Background(), og)).To(Succeed())
30473040

3041+
// Wait for the OperatorGroup to be synced so the InstallPlan doesn't fail due to an invalid OperatorGroup
3042+
Eventually(
3043+
func() ([]string, error) {
3044+
err := ctx.Ctx().Client().Get(context.Background(), client.ObjectKeyFromObject(og), og)
3045+
ctx.Ctx().Logf("Waiting for OperatorGroup(%v) to be synced with status.namespaces: %v", og.Name, og.Status.Namespaces)
3046+
return og.Status.Namespaces, err
3047+
},
3048+
1*time.Minute,
3049+
).Should(ContainElement(ns.GetName()))
3050+
30483051
now := metav1.Now()
30493052
ip = &operatorsv1alpha1.InstallPlan{
30503053
ObjectMeta: metav1.ObjectMeta{
@@ -3087,7 +3090,7 @@ var _ = Describe("Install Plan", func() {
30873090

30883091
It("should show an error on the bundlelookup condition for a non-existent bundle image", func() {
30893092
// Create an InstallPlan status.bundleLookups.Path specified for a non-existent bundle image
3090-
ip.Status.BundleLookups[0].Path = "quay.io/foo/bar:v0.0.1"
3093+
ip.Status.BundleLookups[0].Path = "localhost:0/not/exist:v0.0.1"
30913094

30923095
// We wait for some time over the bundle unpack timeout (i.e ActiveDeadlineSeconds) so that the Job can eventually fail
30933096
// Since the default --bundle-unpack-timeout=10m, we override with a shorter timeout via the
@@ -3097,25 +3100,22 @@ var _ = Describe("Install Plan", func() {
30973100
ip.SetAnnotations(annotations)
30983101
waitFor := 1*time.Minute + 30*time.Second
30993102

3100-
outIP := ip.DeepCopy()
3101-
3102-
Expect(ctx.Ctx().Client().Create(context.Background(), outIP)).To(Succeed())
3103+
Expect(ctx.Ctx().Client().Create(context.Background(), ip)).To(Succeed())
31033104

31043105
// The status gets ignored on create so we need to update it else the InstallPlan sync ignores
31053106
// InstallPlans without any steps or bundle lookups
3106-
outIP.Status = ip.Status
3107-
Expect(ctx.Ctx().Client().Status().Update(context.Background(), outIP)).To(Succeed())
3107+
Expect(ctx.Ctx().Client().Status().Update(context.Background(), ip)).To(Succeed())
31083108

31093109
// The InstallPlan's status.bundleLookup.conditions should have a BundleLookupPending condition
31103110
// with the container status from unpack pod that mentions an image pull failure for the non-existent
31113111
// image, e.g ErrImagePull or ImagePullBackOff
31123112
Eventually(
31133113
func() (string, error) {
3114-
err := ctx.Ctx().Client().Get(context.Background(), client.ObjectKeyFromObject(outIP), outIP)
3114+
err := ctx.Ctx().Client().Get(context.Background(), client.ObjectKeyFromObject(ip), ip)
31153115
if err != nil {
31163116
return "", err
31173117
}
3118-
for _, bl := range outIP.Status.BundleLookups {
3118+
for _, bl := range ip.Status.BundleLookups {
31193119
for _, cond := range bl.Conditions {
31203120
if cond.Type != operatorsv1alpha1.BundleLookupPending {
31213121
continue
@@ -3131,8 +3131,8 @@ var _ = Describe("Install Plan", func() {
31313131
// The InstallPlan should eventually fail due to the ActiveDeadlineSeconds limit
31323132
Eventually(
31333133
func() (*operatorsv1alpha1.InstallPlan, error) {
3134-
err := ctx.Ctx().Client().Get(context.Background(), client.ObjectKeyFromObject(outIP), outIP)
3135-
return outIP, err
3134+
err := ctx.Ctx().Client().Get(context.Background(), client.ObjectKeyFromObject(ip), ip)
3135+
return ip, err
31363136
},
31373137
waitFor,
31383138
).Should(HavePhase(operatorsv1alpha1.InstallPlanPhaseFailed))
@@ -3142,22 +3142,19 @@ var _ = Describe("Install Plan", func() {
31423142
// Create an InstallPlan status.bundleLookups.Path specified for an invalid bundle image
31433143
ip.Status.BundleLookups[0].Path = "alpine:3.13"
31443144

3145-
outIP := ip.DeepCopy()
3146-
3147-
Expect(ctx.Ctx().Client().Create(context.Background(), outIP)).To(Succeed())
3145+
Expect(ctx.Ctx().Client().Create(context.Background(), ip)).To(Succeed())
31483146

31493147
// The status gets ignored on create so we need to update it else the InstallPlan sync ignores
31503148
// InstallPlans without any steps or bundle lookups
3151-
outIP.Status = ip.Status
3152-
Expect(ctx.Ctx().Client().Status().Update(context.Background(), outIP)).To(Succeed())
3149+
Expect(ctx.Ctx().Client().Status().Update(context.Background(), ip)).To(Succeed())
31533150

31543151
// The InstallPlan should fail after the unpack pod keeps failing and exceeds the job's
31553152
// BackoffLimit(set to 3), which with an exponential backoff (10s + 20s + 40s)= 1m10s
31563153
// so we wait a little over that.
31573154
Eventually(
31583155
func() (*operatorsv1alpha1.InstallPlan, error) {
3159-
err := ctx.Ctx().Client().Get(context.Background(), client.ObjectKeyFromObject(outIP), outIP)
3160-
return outIP, err
3156+
err := ctx.Ctx().Client().Get(context.Background(), client.ObjectKeyFromObject(ip), ip)
3157+
return ip, err
31613158
},
31623159
2*time.Minute,
31633160
).Should(HavePhase(operatorsv1alpha1.InstallPlanPhaseFailed))

0 commit comments

Comments
 (0)