From c45fb330b83707f2704905d5265da7f1ee8db60b Mon Sep 17 00:00:00 2001 From: Joe Lanford Date: Thu, 21 Sep 2023 08:43:33 -0400 Subject: [PATCH] fix: add tests that ensure channel metadata is not included in bundle sorting during resolution Signed-off-by: Joe Lanford --- .../controllers/operator_controller_test.go | 41 +++++++++---------- test/e2e/install_test.go | 3 +- testdata/catalogs/test-catalog/catalog.yaml | 6 +++ 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/internal/controllers/operator_controller_test.go b/internal/controllers/operator_controller_test.go index db35d8599..1f75c0518 100644 --- a/internal/controllers/operator_controller_test.go +++ b/internal/controllers/operator_controller_test.go @@ -788,7 +788,7 @@ var _ = Describe("Operator Controller Test", func() { BeforeEach(func() { By("initializing cluster state") pkgName = "prometheus" - pkgChan = "alpha" + pkgChan = "non-existent" operator = &operatorsv1alpha1.Operator{ ObjectMeta: metav1.ObjectMeta{Name: opKey.Name}, Spec: operatorsv1alpha1.OperatorSpec{ @@ -1048,28 +1048,27 @@ func verifyConditionsInvariants(op *operatorsv1alpha1.Operator) { } } -var betaChannel = catalogmetadata.Channel{Channel: declcfg.Channel{ - Name: "beta", - Entries: []declcfg.ChannelEntry{ - { - Name: "operatorhub/prometheus/0.37.0", - }, - { - Name: "operatorhub/prometheus/0.47.0", - Replaces: "operatorhub/prometheus/0.37.0", - }, - { - Name: "operatorhub/plain/0.1.0", - }, - { - Name: "operatorhub/badmedia/0.1.0", - }, - }, -}} +var ( + alphaChannel = catalogmetadata.Channel{Channel: declcfg.Channel{ + Name: "alpha", + }} + betaChannel = catalogmetadata.Channel{Channel: declcfg.Channel{ + Name: "beta", + }} +) var testBundleList = []*catalogmetadata.Bundle{ {Bundle: declcfg.Bundle{ - Name: "operatorhub/prometheus/0.37.0", + Name: "operatorhub/prometheus/alpha/0.37.0", + Package: "prometheus", + Image: "quay.io/operatorhubio/prometheus@sha256:3e281e587de3d03011440685fc4fb782672beab044c1ebadc42788ce05a21c35", + Properties: []property.Property{ + {Type: property.TypePackage, Value: json.RawMessage(`{"packageName":"prometheus","version":"0.37.0"}`)}, + {Type: property.TypeGVK, Value: json.RawMessage(`[]`)}, + }, + }, InChannels: []*catalogmetadata.Channel{&alphaChannel}}, + {Bundle: declcfg.Bundle{ + Name: "operatorhub/prometheus/beta/0.37.0", Package: "prometheus", Image: "quay.io/operatorhubio/prometheus@sha256:3e281e587de3d03011440685fc4fb782672beab044c1ebadc42788ce05a21c35", Properties: []property.Property{ @@ -1078,7 +1077,7 @@ var testBundleList = []*catalogmetadata.Bundle{ }, }, InChannels: []*catalogmetadata.Channel{&betaChannel}}, {Bundle: declcfg.Bundle{ - Name: "operatorhub/prometheus/0.47.0", + Name: "operatorhub/prometheus/beta/0.47.0", Package: "prometheus", Image: "quay.io/operatorhubio/prometheus@sha256:5b04c49d8d3eff6a338b56ec90bdf491d501fe301c9cdfb740e5bff6769a21ed", Properties: []property.Property{ diff --git a/test/e2e/install_test.go b/test/e2e/install_test.go index 1905cfb7a..3519f76db 100644 --- a/test/e2e/install_test.go +++ b/test/e2e/install_test.go @@ -53,7 +53,6 @@ var _ = Describe("Operator Install", func() { BeforeEach(func() { operator.Spec = operatorv1alpha1.OperatorSpec{ PackageName: "prometheus", - Version: "0.47.0", } }) It("resolves the specified package with correct bundle path", func() { @@ -69,7 +68,7 @@ var _ = Describe("Operator Install", func() { g.Expect(cond.Status).To(Equal(metav1.ConditionTrue)) g.Expect(cond.Reason).To(Equal(operatorv1alpha1.ReasonSuccess)) g.Expect(cond.Message).To(ContainSubstring("resolved to")) - g.Expect(operator.Status.ResolvedBundleResource).ToNot(BeEmpty()) + g.Expect(operator.Status.ResolvedBundleResource).To(Equal("localhost/testdata/bundles/registry-v1/prometheus-operator:v0.65.1")) }).Should(Succeed()) By("eventually installing the package successfully") diff --git a/testdata/catalogs/test-catalog/catalog.yaml b/testdata/catalogs/test-catalog/catalog.yaml index 1870f3e72..c82489b03 100644 --- a/testdata/catalogs/test-catalog/catalog.yaml +++ b/testdata/catalogs/test-catalog/catalog.yaml @@ -4,6 +4,12 @@ name: prometheus defaultChannel: beta --- schema: olm.channel +name: alpha +package: prometheus +entries: + - name: prometheus-operator.0.47.0 +--- +schema: olm.channel name: beta package: prometheus entries: