Skip to content

Commit e29a8d7

Browse files
committed
test/e2e: Fix 'resource name may not be empty' failure in catalog templating test case
Update the 'adding catalog template adjusts image used' test case and fix the issue where get requests for the test catalogsource were failing due to the source.GetName() and source.GetNamespace() being empty, and therefore the test catalogsource could never be updated. Updating the test logic to avoid overwriting the `source` variable during every poll by suppressing the variable returned appeared to be the culprit. This was consistently reproducible on a cluster when focusing on this single test and running the e2e suite directly. After making these changes, I wasn't able to reproduce locally anymore. Signed-off-by: timflannagan <[email protected]>
1 parent 6dc9026 commit e29a8d7

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

test/e2e/catalog_e2e_test.go

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,7 +1050,6 @@ var _ = Describe("Catalog represents a store of bundles which OLM can use to ins
10501050
// This test attempts to create a catalog source, and update it with a template annotation
10511051
// and ensure that the image gets changed according to what's in the template as well as
10521052
// check the status conditions are updated accordingly
1053-
10541053
sourceName := genName("catalog-")
10551054
source := &v1alpha1.CatalogSource{
10561055
TypeMeta: metav1.TypeMeta{
@@ -1069,20 +1068,27 @@ var _ = Describe("Catalog represents a store of bundles which OLM can use to ins
10691068
}
10701069

10711070
By("creating a catalog source")
1072-
source, err := crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Create(context.TODO(), source, metav1.CreateOptions{})
1073-
Expect(err).ToNot(HaveOccurred())
1074-
1075-
By("update the catalog source with template annotation")
10761071

1077-
source, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Get(context.TODO(), source.GetName(), metav1.GetOptions{})
1078-
Expect(err).ShouldNot(HaveOccurred(), "error getting catalog source")
1072+
var err error
1073+
Eventually(func() error {
1074+
source, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Create(context.TODO(), source, metav1.CreateOptions{})
1075+
return err
1076+
}).Should(Succeed())
10791077

1080-
// create an annotation using the kube templates
1081-
source.SetAnnotations(map[string]string{catalogsource.CatalogImageTemplateAnnotation: fmt.Sprintf("quay.io/olmtest/catsrc-update-test:%s.%s.%s", catalogsource.TemplKubeMajorV, catalogsource.TemplKubeMinorV, catalogsource.TemplKubePatchV)})
1078+
By("updating the catalog source with template annotation")
10821079

1083-
// Update the catalog image
10841080
Eventually(func() error {
1085-
source, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Update(context.TODO(), source, metav1.UpdateOptions{})
1081+
source, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Get(context.TODO(), source.GetName(), metav1.GetOptions{})
1082+
if err != nil {
1083+
return err
1084+
}
1085+
// create an annotation using the kube templates
1086+
source.SetAnnotations(map[string]string{
1087+
catalogsource.CatalogImageTemplateAnnotation: fmt.Sprintf("quay.io/olmtest/catsrc-update-test:%s.%s.%s", catalogsource.TemplKubeMajorV, catalogsource.TemplKubeMinorV, catalogsource.TemplKubePatchV),
1088+
})
1089+
1090+
// Update the catalog image
1091+
_, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Update(context.TODO(), source, metav1.UpdateOptions{})
10861092
return err
10871093
}).Should(Succeed())
10881094

@@ -1099,7 +1105,7 @@ var _ = Describe("Catalog represents a store of bundles which OLM can use to ins
10991105
}
11001106

11011107
return false, nil
1102-
}, 5*time.Minute, 1*time.Second).Should(BeTrue())
1108+
}).Should(BeTrue())
11031109

11041110
// source should be the latest we got from the eventually block
11051111
Expect(source.Status.Conditions).ToNot(BeNil())

0 commit comments

Comments
 (0)