Skip to content

Commit 92aacef

Browse files
authored
fix: add tests that ensure channel metadata is not included in bundle sorting during resolution (#420)
Signed-off-by: Joe Lanford <[email protected]>
1 parent 06f97d1 commit 92aacef

File tree

3 files changed

+27
-23
lines changed

3 files changed

+27
-23
lines changed

internal/controllers/operator_controller_test.go

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ var _ = Describe("Operator Controller Test", func() {
788788
BeforeEach(func() {
789789
By("initializing cluster state")
790790
pkgName = "prometheus"
791-
pkgChan = "alpha"
791+
pkgChan = "non-existent"
792792
operator = &operatorsv1alpha1.Operator{
793793
ObjectMeta: metav1.ObjectMeta{Name: opKey.Name},
794794
Spec: operatorsv1alpha1.OperatorSpec{
@@ -1048,28 +1048,27 @@ func verifyConditionsInvariants(op *operatorsv1alpha1.Operator) {
10481048
}
10491049
}
10501050

1051-
var betaChannel = catalogmetadata.Channel{Channel: declcfg.Channel{
1052-
Name: "beta",
1053-
Entries: []declcfg.ChannelEntry{
1054-
{
1055-
Name: "operatorhub/prometheus/0.37.0",
1056-
},
1057-
{
1058-
Name: "operatorhub/prometheus/0.47.0",
1059-
Replaces: "operatorhub/prometheus/0.37.0",
1060-
},
1061-
{
1062-
Name: "operatorhub/plain/0.1.0",
1063-
},
1064-
{
1065-
Name: "operatorhub/badmedia/0.1.0",
1066-
},
1067-
},
1068-
}}
1051+
var (
1052+
alphaChannel = catalogmetadata.Channel{Channel: declcfg.Channel{
1053+
Name: "alpha",
1054+
}}
1055+
betaChannel = catalogmetadata.Channel{Channel: declcfg.Channel{
1056+
Name: "beta",
1057+
}}
1058+
)
10691059

10701060
var testBundleList = []*catalogmetadata.Bundle{
10711061
{Bundle: declcfg.Bundle{
1072-
Name: "operatorhub/prometheus/0.37.0",
1062+
Name: "operatorhub/prometheus/alpha/0.37.0",
1063+
Package: "prometheus",
1064+
Image: "quay.io/operatorhubio/prometheus@sha256:3e281e587de3d03011440685fc4fb782672beab044c1ebadc42788ce05a21c35",
1065+
Properties: []property.Property{
1066+
{Type: property.TypePackage, Value: json.RawMessage(`{"packageName":"prometheus","version":"0.37.0"}`)},
1067+
{Type: property.TypeGVK, Value: json.RawMessage(`[]`)},
1068+
},
1069+
}, InChannels: []*catalogmetadata.Channel{&alphaChannel}},
1070+
{Bundle: declcfg.Bundle{
1071+
Name: "operatorhub/prometheus/beta/0.37.0",
10731072
Package: "prometheus",
10741073
Image: "quay.io/operatorhubio/prometheus@sha256:3e281e587de3d03011440685fc4fb782672beab044c1ebadc42788ce05a21c35",
10751074
Properties: []property.Property{
@@ -1078,7 +1077,7 @@ var testBundleList = []*catalogmetadata.Bundle{
10781077
},
10791078
}, InChannels: []*catalogmetadata.Channel{&betaChannel}},
10801079
{Bundle: declcfg.Bundle{
1081-
Name: "operatorhub/prometheus/0.47.0",
1080+
Name: "operatorhub/prometheus/beta/0.47.0",
10821081
Package: "prometheus",
10831082
Image: "quay.io/operatorhubio/prometheus@sha256:5b04c49d8d3eff6a338b56ec90bdf491d501fe301c9cdfb740e5bff6769a21ed",
10841083
Properties: []property.Property{

test/e2e/install_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ var _ = Describe("Operator Install", func() {
5353
BeforeEach(func() {
5454
operator.Spec = operatorv1alpha1.OperatorSpec{
5555
PackageName: "prometheus",
56-
Version: "0.47.0",
5756
}
5857
})
5958
It("resolves the specified package with correct bundle path", func() {
@@ -69,7 +68,7 @@ var _ = Describe("Operator Install", func() {
6968
g.Expect(cond.Status).To(Equal(metav1.ConditionTrue))
7069
g.Expect(cond.Reason).To(Equal(operatorv1alpha1.ReasonSuccess))
7170
g.Expect(cond.Message).To(ContainSubstring("resolved to"))
72-
g.Expect(operator.Status.ResolvedBundleResource).ToNot(BeEmpty())
71+
g.Expect(operator.Status.ResolvedBundleResource).To(Equal("localhost/testdata/bundles/registry-v1/prometheus-operator:v0.65.1"))
7372
}).Should(Succeed())
7473

7574
By("eventually installing the package successfully")

testdata/catalogs/test-catalog/catalog.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ name: prometheus
44
defaultChannel: beta
55
---
66
schema: olm.channel
7+
name: alpha
8+
package: prometheus
9+
entries:
10+
- name: prometheus-operator.0.47.0
11+
---
12+
schema: olm.channel
713
name: beta
814
package: prometheus
915
entries:

0 commit comments

Comments
 (0)