Skip to content

Commit 67b8fc6

Browse files
Mikalai Radchukperdasilva
Mikalai Radchuk
authored andcommitted
Updates E2E tests
Changes required to account for a new flow where we prevent `InstallPlan` from being created when unpack job fails Signed-off-by: Mikalai Radchuk <[email protected]>
1 parent c96f4d8 commit 67b8fc6

File tree

4 files changed

+236
-369
lines changed

4 files changed

+236
-369
lines changed

test/e2e/catalog_e2e_test.go

+20-27
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,7 @@ var _ = Describe("Starting CatalogSource e2e tests", func() {
10101010

10111011
catSrcImage := "quay.io/olmtest/busybox-dependencies-index"
10121012

1013-
// Create gRPC CatalogSource
1013+
By("creating gRPC CatalogSource")
10141014
source := &v1alpha1.CatalogSource{
10151015
TypeMeta: metav1.TypeMeta{
10161016
Kind: v1alpha1.CatalogSourceKind,
@@ -1028,30 +1028,29 @@ var _ = Describe("Starting CatalogSource e2e tests", func() {
10281028
},
10291029
},
10301030
}
1031-
10321031
source, err := crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Create(context.Background(), source, metav1.CreateOptions{})
10331032
Expect(err).ShouldNot(HaveOccurred())
10341033
defer func() {
10351034
err := crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Delete(context.Background(), source.GetName(), metav1.DeleteOptions{})
10361035
Expect(err).ShouldNot(HaveOccurred())
10371036
}()
10381037

1039-
// Wait for the CatalogSource to be ready
1038+
By("waiting for the CatalogSource to be ready")
10401039
_, err = fetchCatalogSourceOnStatus(crc, source.GetName(), source.GetNamespace(), catalogSourceRegistryPodSynced)
10411040
Expect(err).ToNot(HaveOccurred(), "catalog source did not become ready")
10421041

1043-
// Create a Subscription for busybox
1042+
By("creating a Subscription for busybox")
10441043
subscriptionName := genName("sub-")
10451044
cleanupSubscription := createSubscriptionForCatalog(crc, source.GetNamespace(), subscriptionName, source.GetName(), packageName, channelName, "", v1alpha1.ApprovalAutomatic)
10461045
defer cleanupSubscription()
10471046

1048-
// Wait for the Subscription to succeed
1047+
By("waiting for the Subscription to succeed")
10491048
subscription, err := fetchSubscription(crc, ns.GetName(), subscriptionName, subscriptionStateAtLatestChecker)
10501049
Expect(err).ShouldNot(HaveOccurred())
10511050
Expect(subscription).ShouldNot(BeNil())
10521051
Expect(subscription.Status.InstalledCSV).To(Equal("busybox.v1.0.0"))
10531052

1054-
// Confirm that a subscription was created for busybox-dependency
1053+
By("confirming that a subscription was created for busybox-dependency")
10551054
subscriptionList, err := crc.OperatorsV1alpha1().Subscriptions(source.GetNamespace()).List(context.Background(), metav1.ListOptions{})
10561055
Expect(err).ShouldNot(HaveOccurred())
10571056
dependencySubscriptionName := ""
@@ -1062,13 +1061,13 @@ var _ = Describe("Starting CatalogSource e2e tests", func() {
10621061
}
10631062
Expect(dependencySubscriptionName).ToNot(BeEmpty())
10641063

1065-
// Wait for the Subscription to succeed
1064+
By("waiting for the Subscription to succeed")
10661065
subscription, err = fetchSubscription(crc, ns.GetName(), dependencySubscriptionName, subscriptionStateAtLatestChecker)
10671066
Expect(err).ShouldNot(HaveOccurred())
10681067
Expect(subscription).ShouldNot(BeNil())
10691068
Expect(subscription.Status.InstalledCSV).To(Equal("busybox-dependency.v1.0.0"))
10701069

1071-
// Update the catalog image
1070+
By("updating the catalog image")
10721071
Eventually(func() error {
10731072
existingSource, err := crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Get(context.Background(), sourceName, metav1.GetOptions{})
10741073
if err != nil {
@@ -1080,32 +1079,32 @@ var _ = Describe("Starting CatalogSource e2e tests", func() {
10801079
return err
10811080
}).Should(Succeed())
10821081

1083-
// Wait for the CatalogSource to be ready
1082+
By("waiting for the CatalogSource to be ready")
10841083
_, err = fetchCatalogSourceOnStatus(crc, source.GetName(), source.GetNamespace(), catalogSourceRegistryPodSynced)
10851084
Expect(err).ToNot(HaveOccurred(), "catalog source did not become ready")
10861085

1087-
// Wait for the busybox v2 Subscription to succeed
1086+
By("waiting for the busybox v2 Subscription to succeed")
10881087
subChecker := func(sub *v1alpha1.Subscription) bool {
10891088
return sub.Status.InstalledCSV == "busybox.v2.0.0"
10901089
}
10911090
subscription, err = fetchSubscription(crc, ns.GetName(), subscriptionName, subChecker)
10921091
Expect(err).ShouldNot(HaveOccurred())
10931092
Expect(subscription).ShouldNot(BeNil())
10941093

1095-
// Wait for busybox v2 csv to succeed and check the replaces field
1094+
By("waiting for busybox v2 csv to succeed and check the replaces field")
10961095
csv, err := fetchCSV(crc, subscription.Status.CurrentCSV, subscription.GetNamespace(), csvSucceededChecker)
10971096
Expect(err).ShouldNot(HaveOccurred())
10981097
Expect(csv.Spec.Replaces).To(Equal("busybox.v1.0.0"))
10991098

1100-
// Wait for the busybox-dependency v2 Subscription to succeed
1099+
By("waiting for the busybox-dependency v2 Subscription to succeed")
11011100
subChecker = func(sub *v1alpha1.Subscription) bool {
11021101
return sub.Status.InstalledCSV == "busybox-dependency.v2.0.0"
11031102
}
11041103
subscription, err = fetchSubscription(crc, ns.GetName(), dependencySubscriptionName, subChecker)
11051104
Expect(err).ShouldNot(HaveOccurred())
11061105
Expect(subscription).ShouldNot(BeNil())
11071106

1108-
// Wait for busybox-dependency v2 csv to succeed and check the replaces field
1107+
By("waiting for busybox-dependency v2 csv to succeed and check the replaces field")
11091108
csv, err = fetchCSV(crc, subscription.Status.CurrentCSV, subscription.GetNamespace(), csvSucceededChecker)
11101109
Expect(err).ShouldNot(HaveOccurred())
11111110
Expect(csv.Spec.Replaces).To(Equal("busybox-dependency.v1.0.0"))
@@ -1403,21 +1402,15 @@ var _ = Describe("Starting CatalogSource e2e tests", func() {
14031402
Expect(c.Create(context.Background(), subscription)).To(BeNil())
14041403
})
14051404

1406-
It("fails with a ResolutionFailed error condition, and a message that highlights the missing field in the CSV", func() {
1407-
1408-
subscription, err := fetchSubscription(crc, subscription.GetNamespace(), subscription.GetName(), subscriptionHasInstallPlanChecker)
1409-
Expect(err).Should(BeNil())
1410-
installPlanName := subscription.Status.Install.Name
1411-
1412-
// ensure we wait for the installPlan to fail before moving forward then fetch the subscription again
1413-
_, err = fetchInstallPlan(GinkgoT(), crc, installPlanName, subscription.GetNamespace(), buildInstallPlanPhaseCheckFunc(operatorsv1alpha1.InstallPlanPhaseFailed))
1414-
Expect(err).To(BeNil())
1415-
subscription, err = fetchSubscription(crc, subscription.GetNamespace(), subscription.GetName(), subscriptionHasInstallPlanChecker)
1416-
Expect(err).To(BeNil())
1405+
It("fails with a BundleUnpackFailed error condition, and a message that highlights the missing field in the CSV", func() {
1406+
Eventually(func(g Gomega) string {
1407+
fetchedSubscription, err := crc.OperatorsV1alpha1().Subscriptions(ns.GetName()).Get(context.Background(), subscription.GetName(), metav1.GetOptions{})
1408+
g.Expect(err).NotTo(HaveOccurred())
14171409

1418-
// expect the message that API missing
1419-
failingCondition := subscription.Status.GetCondition(operatorsv1alpha1.SubscriptionInstallPlanFailed)
1420-
Expect(failingCondition.Message).To(ContainSubstring("missing APIVersion"))
1410+
// expect the message that API missing
1411+
failingCondition := fetchedSubscription.Status.GetCondition(v1alpha1.SubscriptionBundleUnpackFailed)
1412+
return failingCondition.Message
1413+
}).Should(ContainSubstring("missing APIVersion"))
14211414
})
14221415
})
14231416
})

test/e2e/fail_forward_e2e_test.go

+61-44
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,13 @@ var _ = Describe("Fail Forward Upgrades", func() {
5555
TeardownNamespace(ns.GetName())
5656
})
5757

58-
When("an InstallPlan is reporting a failed state", func() {
58+
When("InstallPlan is not being created due to failed upgrade", func() {
5959

6060
var (
61-
magicCatalog *MagicCatalog
62-
catalogSourceName string
63-
subscription *operatorsv1alpha1.Subscription
61+
magicCatalog *MagicCatalog
62+
catalogSourceName string
63+
subscription *operatorsv1alpha1.Subscription
64+
originalInstallPlanRef *corev1.ObjectReference
6465
)
6566

6667
BeforeEach(func() {
@@ -90,7 +91,7 @@ var _ = Describe("Fail Forward Upgrades", func() {
9091
subscription, err := fetchSubscription(crclient, subscription.GetNamespace(), subscription.GetName(), subscriptionHasInstallPlanChecker)
9192
Expect(err).Should(BeNil())
9293

93-
originalInstallPlanRef := subscription.Status.InstallPlanRef
94+
originalInstallPlanRef = subscription.Status.InstallPlanRef
9495

9596
By("waiting for the v0.1.0 CSV to report a succeeded phase")
9697
_, err = fetchCSV(crclient, subscription.Status.CurrentCSV, ns.GetName(), buildCSVConditionChecker(operatorsv1alpha1.CSVPhaseSucceeded))
@@ -102,40 +103,30 @@ var _ = Describe("Fail Forward Upgrades", func() {
102103
By("updating the catalog with a broken v0.2.0 bundle image")
103104
brokenProvider, err := NewFileBasedFiledBasedCatalogProvider(filepath.Join(testdataDir, failForwardTestDataBaseDir, "example-operator.v0.2.0.yaml"))
104105
Expect(err).To(BeNil())
105-
106106
err = magicCatalog.UpdateCatalog(context.Background(), brokenProvider)
107107
Expect(err).To(BeNil())
108108

109-
By("verifying the subscription is referencing a new installplan")
110-
subscription, err = fetchSubscription(crclient, subscription.GetNamespace(), subscription.GetName(), subscriptionHasInstallPlanDifferentChecker(originalInstallPlanRef.Name))
111-
Expect(err).Should(BeNil())
112-
113-
By("waiting for the bad InstallPlan to report a failed installation state")
114-
ref := subscription.Status.InstallPlanRef
115-
_, err = fetchInstallPlan(GinkgoT(), crclient, ref.Name, ref.Namespace, buildInstallPlanPhaseCheckFunc(operatorsv1alpha1.InstallPlanPhaseFailed))
116-
Expect(err).To(BeNil())
109+
By("waiting for the subscription to maintain the example-operator.v0.1.0 status.currentCSV")
110+
Consistently(subscriptionCurrentCSVGetter(crclient, subscription.GetNamespace(), subscription.GetName())).Should(Equal("example-operator.v0.1.0"))
117111

112+
By("verifying the subscription is referencing the same InstallPlan")
113+
subscription, err = fetchSubscription(crclient, subscription.GetNamespace(), subscription.GetName(), subscriptionHasInstallPlanChecker)
114+
Expect(err).Should(BeNil())
115+
Expect(subscription.Status.InstallPlanRef.Name).To(Equal(originalInstallPlanRef.Name))
118116
})
119117
AfterEach(func() {
120118
By("removing the testing catalog resources")
121119
Expect(magicCatalog.UndeployCatalog(context.Background())).To(BeNil())
122120
})
123-
It("eventually reports a successful state when multiple bad versions are rolled forward", func() {
121+
It("eventually gets created and reports a successful state when multiple bad versions are rolled forward", func() {
124122
By("patching the catalog with another bad bundle version")
125123
badProvider, err := NewFileBasedFiledBasedCatalogProvider(filepath.Join(testdataDir, "fail-forward/multiple-bad-versions", "example-operator.v0.2.1.yaml"))
126124
Expect(err).To(BeNil())
127-
128125
err = magicCatalog.UpdateCatalog(context.Background(), badProvider)
129126
Expect(err).To(BeNil())
130127

131-
By("waiting for the subscription to have the example-operator.v0.2.1 status.updatedCSV")
132-
subscription, err = fetchSubscription(crclient, subscription.GetNamespace(), subscription.GetName(), subscriptionHasCurrentCSV("example-operator.v0.2.1"))
133-
Expect(err).Should(BeNil())
134-
135-
By("waiting for the bad v0.2.1 InstallPlan to report a failed installation state")
136-
ref := subscription.Status.InstallPlanRef
137-
_, err = fetchInstallPlan(GinkgoT(), crclient, ref.Name, ref.Namespace, buildInstallPlanPhaseCheckFunc(operatorsv1alpha1.InstallPlanPhaseFailed))
138-
Expect(err).To(BeNil())
128+
By("waiting for the subscription to maintain the example-operator.v0.1.0 status.currentCSV")
129+
Consistently(subscriptionCurrentCSVGetter(crclient, subscription.GetNamespace(), subscription.GetName())).Should(Equal("example-operator.v0.1.0"))
139130

140131
By("patching the OperatorGroup to increase the bundle unpacking timeout")
141132
addBundleUnpackTimeoutOGAnnotation(context.Background(), c, types.NamespacedName{Name: ogName, Namespace: ns.GetName()}, "5m")
@@ -146,12 +137,21 @@ var _ = Describe("Fail Forward Upgrades", func() {
146137
err = magicCatalog.UpdateCatalog(context.Background(), fixedProvider)
147138
Expect(err).To(BeNil())
148139

149-
By("waiting for the subscription to have the example-operator.v0.3.0 status.updatedCSV")
150-
subscription, err = fetchSubscription(crclient, subscription.GetNamespace(), subscription.GetName(), subscriptionHasCurrentCSV("example-operator.v0.3.0"))
140+
By("waiting for the subscription to have the example-operator.v0.3.0 status.currentCSV")
141+
_, err = fetchSubscription(crclient, subscription.GetNamespace(), subscription.GetName(), subscriptionHasCurrentCSV("example-operator.v0.3.0"))
151142
Expect(err).Should(BeNil())
143+
144+
By("verifying the subscription is referencing a new InstallPlan")
145+
subscription, err = fetchSubscription(crclient, subscription.GetNamespace(), subscription.GetName(), subscriptionHasInstallPlanDifferentChecker(originalInstallPlanRef.Name))
146+
Expect(err).Should(BeNil())
147+
148+
By("waiting for the fixed v0.3.0 InstallPlan to report a successful state")
149+
ref := subscription.Status.InstallPlanRef
150+
_, err = fetchInstallPlan(GinkgoT(), crclient, ref.Name, ref.Namespace, buildInstallPlanPhaseCheckFunc(operatorsv1alpha1.InstallPlanPhaseComplete))
151+
Expect(err).To(BeNil())
152152
})
153153

154-
It("eventually reports a successful state when using skip ranges", func() {
154+
It("eventually gets created and reports a successful state when using skip ranges", func() {
155155
By("patching the OperatorGroup to increase the bundle unpacking timeout")
156156
addBundleUnpackTimeoutOGAnnotation(context.Background(), c, types.NamespacedName{Name: ogName, Namespace: ns.GetName()}, "5m")
157157

@@ -161,11 +161,20 @@ var _ = Describe("Fail Forward Upgrades", func() {
161161
err = magicCatalog.UpdateCatalog(context.Background(), fixedProvider)
162162
Expect(err).To(BeNil())
163163

164-
By("waiting for the subscription to have the example-operator.v0.3.0 status.updatedCSV")
165-
subscription, err = fetchSubscription(crclient, subscription.GetNamespace(), subscription.GetName(), subscriptionHasCurrentCSV("example-operator.v0.3.0"))
164+
By("waiting for the subscription to have the example-operator.v0.3.0 status.currentCSV")
165+
_, err = fetchSubscription(crclient, subscription.GetNamespace(), subscription.GetName(), subscriptionHasCurrentCSV("example-operator.v0.3.0"))
166+
Expect(err).Should(BeNil())
167+
168+
By("verifying the subscription is referencing a new InstallPlan")
169+
subscription, err = fetchSubscription(crclient, subscription.GetNamespace(), subscription.GetName(), subscriptionHasInstallPlanDifferentChecker(originalInstallPlanRef.Name))
166170
Expect(err).Should(BeNil())
171+
172+
By("waiting for the fixed v0.3.0 InstallPlan to report a successful state")
173+
ref := subscription.Status.InstallPlanRef
174+
_, err = fetchInstallPlan(GinkgoT(), crclient, ref.Name, ref.Namespace, buildInstallPlanPhaseCheckFunc(operatorsv1alpha1.InstallPlanPhaseComplete))
175+
Expect(err).To(BeNil())
167176
})
168-
It("eventually reports a successful state when using skips", func() {
177+
It("eventually gets created and reports a successful state when using skips", func() {
169178
By("patching the OperatorGroup to increase the bundle unpacking timeout")
170179
addBundleUnpackTimeoutOGAnnotation(context.Background(), c, types.NamespacedName{Name: ogName, Namespace: ns.GetName()}, "5m")
171180

@@ -175,11 +184,20 @@ var _ = Describe("Fail Forward Upgrades", func() {
175184
err = magicCatalog.UpdateCatalog(context.Background(), fixedProvider)
176185
Expect(err).To(BeNil())
177186

178-
By("waiting for the subscription to have the example-operator.v0.3.0 status.updatedCSV")
179-
subscription, err = fetchSubscription(crclient, subscription.GetNamespace(), subscription.GetName(), subscriptionHasCurrentCSV("example-operator.v0.3.0"))
187+
By("waiting for the subscription to have the example-operator.v0.3.0 status.currentCSV")
188+
_, err = fetchSubscription(crclient, subscription.GetNamespace(), subscription.GetName(), subscriptionHasCurrentCSV("example-operator.v0.3.0"))
189+
Expect(err).Should(BeNil())
190+
191+
By("verifying the subscription is referencing a new InstallPlan")
192+
subscription, err = fetchSubscription(crclient, subscription.GetNamespace(), subscription.GetName(), subscriptionHasInstallPlanDifferentChecker(originalInstallPlanRef.Name))
180193
Expect(err).Should(BeNil())
194+
195+
By("waiting for the fixed v0.3.0 InstallPlan to report a successful state")
196+
ref := subscription.Status.InstallPlanRef
197+
_, err = fetchInstallPlan(GinkgoT(), crclient, ref.Name, ref.Namespace, buildInstallPlanPhaseCheckFunc(operatorsv1alpha1.InstallPlanPhaseComplete))
198+
Expect(err).To(BeNil())
181199
})
182-
It("eventually reports a failed state when using replaces", func() {
200+
It("never gets created when using replaces", func() {
183201
By("patching the OperatorGroup to increase the bundle unpacking timeout")
184202
addBundleUnpackTimeoutOGAnnotation(context.Background(), c, types.NamespacedName{Name: ogName, Namespace: ns.GetName()}, "5m")
185203

@@ -189,14 +207,13 @@ var _ = Describe("Fail Forward Upgrades", func() {
189207
err = magicCatalog.UpdateCatalog(context.Background(), fixedProvider)
190208
Expect(err).To(BeNil())
191209

192-
By("waiting for the subscription to maintain the example-operator.v0.2.0 status.updatedCSV")
193-
Consistently(func() string {
194-
subscription, err := crclient.OperatorsV1alpha1().Subscriptions(subscription.GetNamespace()).Get(context.Background(), subscription.GetName(), metav1.GetOptions{})
195-
if err != nil || subscription == nil {
196-
return ""
197-
}
198-
return subscription.Status.CurrentCSV
199-
}).Should(Equal("example-operator.v0.2.0"))
210+
By("waiting for the subscription to maintain the example-operator.v0.2.0 status.currentCSV")
211+
Consistently(subscriptionCurrentCSVGetter(crclient, subscription.GetNamespace(), subscription.GetName())).Should(Equal("example-operator.v0.1.0"))
212+
213+
By("verifying the subscription is referencing the same InstallPlan")
214+
subscription, err = fetchSubscription(crclient, subscription.GetNamespace(), subscription.GetName(), subscriptionHasInstallPlanChecker)
215+
Expect(err).Should(BeNil())
216+
Expect(subscription.Status.InstallPlanRef.Name).To(Equal(originalInstallPlanRef.Name))
200217
})
201218
})
202219
When("a CSV resource is in a failed state", func() {
@@ -269,7 +286,7 @@ var _ = Describe("Fail Forward Upgrades", func() {
269286
err = magicCatalog.UpdateCatalog(context.Background(), fixedProvider)
270287
Expect(err).To(BeNil())
271288

272-
By("waiting for the subscription to have the example-operator.v0.3.0 status.updatedCSV")
289+
By("waiting for the subscription to have the example-operator.v0.3.0 status.currentCSV")
273290
subscription, err = fetchSubscription(crclient, subscription.GetNamespace(), subscription.GetName(), subscriptionHasCurrentCSV("example-operator.v0.3.0"))
274291
Expect(err).Should(BeNil())
275292
})
@@ -282,7 +299,7 @@ var _ = Describe("Fail Forward Upgrades", func() {
282299
err = magicCatalog.UpdateCatalog(context.Background(), fixedProvider)
283300
Expect(err).To(BeNil())
284301

285-
By("waiting for the subscription to have the example-operator.v0.3.0 status.updatedCSV")
302+
By("waiting for the subscription to have the example-operator.v0.3.0 status.currentCSV")
286303
subscription, err = fetchSubscription(crclient, subscription.GetNamespace(), subscription.GetName(), subscriptionHasCurrentCSV("example-operator.v0.3.0"))
287304
Expect(err).Should(BeNil())
288305
})
@@ -295,7 +312,7 @@ var _ = Describe("Fail Forward Upgrades", func() {
295312
err = magicCatalog.UpdateCatalog(context.Background(), fixedProvider)
296313
Expect(err).To(BeNil())
297314

298-
By("waiting for the subscription to have the example-operator.v0.3.0 status.updatedCSV")
315+
By("waiting for the subscription to have the example-operator.v0.3.0 status.currentCSV")
299316
subscription, err = fetchSubscription(crclient, subscription.GetNamespace(), subscription.GetName(), subscriptionHasCurrentCSV("example-operator.v0.3.0"))
300317
Expect(err).Should(BeNil())
301318
})

0 commit comments

Comments
 (0)