Skip to content

Commit a2ec578

Browse files
author
Mikalai Radchuk
committed
Updates E2E tests
Signed-off-by: Mikalai Radchuk <[email protected]>
1 parent 3e79f09 commit a2ec578

File tree

4 files changed

+186
-351
lines changed

4 files changed

+186
-351
lines changed

test/e2e/catalog_e2e_test.go

+21-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,16 @@ 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
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) error {
1407+
fetchedSubscription, err := crc.OperatorsV1alpha1().Subscriptions(ns.GetName()).Get(context.Background(), subscription.GetName(), metav1.GetOptions{})
1408+
g.Expect(err).NotTo(HaveOccurred())
14111409

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())
1417-
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+
g.Expect(failingCondition.Message).To(ContainSubstring("missing APIVersion"))
1413+
return nil
1414+
}).Should(BeNil())
14211415
})
14221416
})
14231417
})

test/e2e/fail_forward_e2e_test.go

+7-26
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,6 @@ var _ = Describe("Fail Forward Upgrades", func() {
9090
subscription, err := fetchSubscription(crclient, subscription.GetNamespace(), subscription.GetName(), subscriptionHasInstallPlanChecker)
9191
Expect(err).Should(BeNil())
9292

93-
originalInstallPlanRef := subscription.Status.InstallPlanRef
94-
9593
By("waiting for the v0.1.0 CSV to report a succeeded phase")
9694
_, err = fetchCSV(crclient, subscription.Status.CurrentCSV, ns.GetName(), buildCSVConditionChecker(operatorsv1alpha1.CSVPhaseSucceeded))
9795
Expect(err).ShouldNot(HaveOccurred())
@@ -102,18 +100,11 @@ var _ = Describe("Fail Forward Upgrades", func() {
102100
By("updating the catalog with a broken v0.2.0 bundle image")
103101
brokenProvider, err := NewFileBasedFiledBasedCatalogProvider(filepath.Join(testdataDir, failForwardTestDataBaseDir, "example-operator.v0.2.0.yaml"))
104102
Expect(err).To(BeNil())
105-
106103
err = magicCatalog.UpdateCatalog(context.Background(), brokenProvider)
107104
Expect(err).To(BeNil())
108105

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())
106+
By("verifying that the subscription is still on v0.1.0")
107+
Consistently(subscriptionCurrentCSVGetter(crclient, subscription.GetNamespace(), subscription.GetName())).Should(Equal("example-operator.v0.1.0"))
117108

118109
})
119110
AfterEach(func() {
@@ -124,18 +115,14 @@ var _ = Describe("Fail Forward Upgrades", func() {
124115
By("patching the catalog with another bad bundle version")
125116
badProvider, err := NewFileBasedFiledBasedCatalogProvider(filepath.Join(testdataDir, "fail-forward/multiple-bad-versions", "example-operator.v0.2.1.yaml"))
126117
Expect(err).To(BeNil())
127-
128118
err = magicCatalog.UpdateCatalog(context.Background(), badProvider)
129119
Expect(err).To(BeNil())
130120

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())
121+
By("verifying that the subscription is still on v0.1.0")
122+
Consistently(subscriptionCurrentCSVGetter(crclient, subscription.GetNamespace(), subscription.GetName())).Should(Equal("example-operator.v0.1.0"))
134123

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())
124+
By("patching the OperatorGroup to increase the bundle unpacking timeout")
125+
addBundleUnpackTimeoutOGAnnotation(context.Background(), c, types.NamespacedName{Name: ogName, Namespace: ns.GetName()}, "5m")
139126

140127
By("patching the OperatorGroup to increase the bundle unpacking timeout")
141128
addBundleUnpackTimeoutOGAnnotation(context.Background(), c, types.NamespacedName{Name: ogName, Namespace: ns.GetName()}, "5m")
@@ -190,13 +177,7 @@ var _ = Describe("Fail Forward Upgrades", func() {
190177
Expect(err).To(BeNil())
191178

192179
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"))
180+
Consistently(subscriptionCurrentCSVGetter(crclient, subscription.GetNamespace(), subscription.GetName())).Should(Equal("example-operator.v0.1.0"))
200181
})
201182
})
202183
When("a CSV resource is in a failed state", func() {

0 commit comments

Comments
 (0)