Skip to content

Commit 244cafc

Browse files
author
Per Goncalves da Silva
committed
Improve catalog source e2e
Signed-off-by: Per Goncalves da Silva <[email protected]>
1 parent f8d7f78 commit 244cafc

File tree

1 file changed

+65
-38
lines changed

1 file changed

+65
-38
lines changed

Diff for: test/e2e/catalog_e2e_test.go

+65-38
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,17 @@ var _ = Describe("Starting CatalogSource e2e tests", func() {
201201

202202
installPlanName := subscription.Status.Install.Name
203203
requiresApprovalChecker := buildInstallPlanPhaseCheckFunc(v1alpha1.InstallPlanPhaseRequiresApproval)
204-
fetchedInstallPlan, err := fetchInstallPlanWithNamespace(GinkgoT(), crc, installPlanName, ns.GetName(), requiresApprovalChecker)
205-
Expect(err).ShouldNot(HaveOccurred())
206204

207-
fetchedInstallPlan.Spec.Approved = true
208-
_, err = crc.OperatorsV1alpha1().InstallPlans(ns.GetName()).Update(context.Background(), fetchedInstallPlan, metav1.UpdateOptions{})
209-
Expect(err).ShouldNot(HaveOccurred())
205+
Eventually(func() error {
206+
fetchedInstallPlan, err := fetchInstallPlanWithNamespace(GinkgoT(), crc, installPlanName, ns.GetName(), requiresApprovalChecker)
207+
if err != nil {
208+
return err
209+
}
210+
211+
fetchedInstallPlan.Spec.Approved = true
212+
_, err = crc.OperatorsV1alpha1().InstallPlans(ns.GetName()).Update(context.Background(), fetchedInstallPlan, metav1.UpdateOptions{})
213+
return err
214+
}).Should(Succeed())
210215

211216
_, err = awaitCSV(crc, ns.GetName(), mainCSV.GetName(), csvSucceededChecker)
212217
Expect(err).ShouldNot(HaveOccurred())
@@ -592,11 +597,16 @@ var _ = Describe("Starting CatalogSource e2e tests", func() {
592597
Expect(err).ShouldNot(HaveOccurred())
593598

594599
// Update the catalog's address to point at the other registry pod's cluster ip
595-
addressSource, err = crc.OperatorsV1alpha1().CatalogSources(ns.GetName()).Get(context.Background(), addressSourceName, metav1.GetOptions{})
596-
Expect(err).ShouldNot(HaveOccurred())
597-
addressSource.Spec.Address = net.JoinHostPort(replacementCopy.Status.PodIP, "50051")
598-
_, err = crc.OperatorsV1alpha1().CatalogSources(ns.GetName()).Update(context.Background(), addressSource, metav1.UpdateOptions{})
599-
Expect(err).ShouldNot(HaveOccurred())
600+
Eventually(func() error {
601+
addressSource, err = crc.OperatorsV1alpha1().CatalogSources(ns.GetName()).Get(context.Background(), addressSourceName, metav1.GetOptions{})
602+
if err != nil {
603+
return err
604+
}
605+
606+
addressSource.Spec.Address = net.JoinHostPort(replacementCopy.Status.PodIP, "50051")
607+
_, err = crc.OperatorsV1alpha1().CatalogSources(ns.GetName()).Update(context.Background(), addressSource, metav1.UpdateOptions{})
608+
return err
609+
}).Should(Succeed())
600610

601611
// Wait for the replacement CSV to be installed
602612
_, err = awaitCSV(crc, ns.GetName(), replacementCSV.GetName(), csvSucceededChecker)
@@ -892,12 +902,17 @@ var _ = Describe("Starting CatalogSource e2e tests", func() {
892902
}
893903

894904
// update catalog source with annotation (to kick resync)
895-
source, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Get(context.Background(), source.GetName(), metav1.GetOptions{})
896-
Expect(err).ShouldNot(HaveOccurred(), "error awaiting registry pod")
897-
source.Annotations = make(map[string]string)
898-
source.Annotations["testKey"] = "testValue"
899-
_, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Update(context.Background(), source, metav1.UpdateOptions{})
900-
Expect(err).ShouldNot(HaveOccurred(), "error awaiting registry pod")
905+
Eventually(func() error {
906+
source, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Get(context.Background(), source.GetName(), metav1.GetOptions{})
907+
if err != nil {
908+
return nil
909+
}
910+
911+
source.Annotations = make(map[string]string)
912+
source.Annotations["testKey"] = "testValue"
913+
_, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Update(context.Background(), source, metav1.UpdateOptions{})
914+
return err
915+
}).Should(Succeed())
901916

902917
time.Sleep(11 * time.Second)
903918

@@ -916,11 +931,17 @@ var _ = Describe("Starting CatalogSource e2e tests", func() {
916931
}
917932
}
918933
// update catalog source with annotation (to kick resync)
919-
source, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Get(context.Background(), source.GetName(), metav1.GetOptions{})
920-
Expect(err).ShouldNot(HaveOccurred(), "error getting catalog source pod")
921-
source.Annotations["testKey"] = genName("newValue")
922-
_, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Update(context.Background(), source, metav1.UpdateOptions{})
923-
Expect(err).ShouldNot(HaveOccurred(), "error updating catalog source pod with test annotation")
934+
Eventually(func() error {
935+
source, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Get(context.Background(), source.GetName(), metav1.GetOptions{})
936+
if err != nil {
937+
return err
938+
}
939+
940+
source.Annotations["testKey"] = genName("newValue")
941+
_, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Update(context.Background(), source, metav1.UpdateOptions{})
942+
return err
943+
}).Should(Succeed())
944+
924945
return false
925946
}
926947
// await new catalog source and ensure old one was deleted
@@ -930,11 +951,16 @@ var _ = Describe("Starting CatalogSource e2e tests", func() {
930951
Expect(registryPods.Items).To(HaveLen(1), "unexpected number of registry pods found")
931952

932953
// update catalog source with annotation (to kick resync)
933-
source, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Get(context.Background(), source.GetName(), metav1.GetOptions{})
934-
Expect(err).ShouldNot(HaveOccurred(), "error awaiting registry pod")
935-
source.Annotations["testKey"] = "newValue"
936-
_, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Update(context.Background(), source, metav1.UpdateOptions{})
937-
Expect(err).ShouldNot(HaveOccurred(), "error awaiting registry pod")
954+
Eventually(func() error {
955+
source, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Get(context.Background(), source.GetName(), metav1.GetOptions{})
956+
if err != nil {
957+
return err
958+
}
959+
960+
source.Annotations["testKey"] = "newValue"
961+
_, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Update(context.Background(), source, metav1.UpdateOptions{})
962+
return err
963+
}).Should(Succeed())
938964

939965
subChecker := func(sub *v1alpha1.Subscription) bool {
940966
return sub.Status.InstalledCSV == "busybox.v2.0.0"
@@ -1030,19 +1056,16 @@ var _ = Describe("Starting CatalogSource e2e tests", func() {
10301056
Expect(subscription.Status.InstalledCSV).To(Equal("busybox-dependency.v1.0.0"))
10311057

10321058
// Update the catalog image
1033-
Eventually(func() (bool, error) {
1059+
Eventually(func() error {
10341060
existingSource, err := crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Get(context.Background(), sourceName, metav1.GetOptions{})
10351061
if err != nil {
1036-
return false, err
1062+
return err
10371063
}
10381064
existingSource.Spec.Image = catSrcImage + ":2.0.0-with-ListBundles-method"
10391065

10401066
source, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Update(context.Background(), existingSource, metav1.UpdateOptions{})
1041-
if err == nil {
1042-
return true, nil
1043-
}
1044-
return false, nil
1045-
}).Should(BeTrue())
1067+
return err
1068+
}).Should(Succeed())
10461069

10471070
// Wait for the CatalogSource to be ready
10481071
_, err = fetchCatalogSourceOnStatus(crc, source.GetName(), source.GetNamespace(), catalogSourceRegistryPodSynced)
@@ -1201,11 +1224,15 @@ var _ = Describe("Starting CatalogSource e2e tests", func() {
12011224
})
12021225
When("the catalogsource is updated with a valid polling interval", func() {
12031226
BeforeEach(func() {
1204-
catsrc, err := crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Get(context.TODO(), source.GetName(), metav1.GetOptions{})
1205-
Expect(err).ToNot(HaveOccurred())
1206-
catsrc.Spec.UpdateStrategy.RegistryPoll.RawInterval = correctInterval
1207-
_, err = crc.OperatorsV1alpha1().CatalogSources(catsrc.GetNamespace()).Update(context.TODO(), catsrc, metav1.UpdateOptions{})
1208-
Expect(err).ToNot(HaveOccurred())
1227+
Eventually(func() error {
1228+
catsrc, err := crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Get(context.TODO(), source.GetName(), metav1.GetOptions{})
1229+
if err != nil {
1230+
return err
1231+
}
1232+
catsrc.Spec.UpdateStrategy.RegistryPoll.RawInterval = correctInterval
1233+
_, err = crc.OperatorsV1alpha1().CatalogSources(catsrc.GetNamespace()).Update(context.TODO(), catsrc, metav1.UpdateOptions{})
1234+
return err
1235+
}).Should(Succeed())
12091236
})
12101237
It("the catalogsource spec shows the updated polling interval, and the error message in the status is cleared", func() {
12111238
Eventually(func() error {

0 commit comments

Comments
 (0)