Skip to content

Commit f05ea07

Browse files
Merge pull request #2149 from benluddy/bz-1945702
[release-4.7] Bug 1945702: Fix inconsistent dependency candidate order.
2 parents aa9d705 + f598cc8 commit f05ea07

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

test/e2e/subscription_e2e_test.go

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2134,6 +2134,73 @@ var _ = Describe("Subscription", func() {
21342134
}).ShouldNot(Succeed())
21352135
})
21362136
})
2137+
2138+
When("there exists a Subscription to an operator having dependency candidates in both default and nondefault channels", func() {
2139+
var (
2140+
teardown func()
2141+
)
2142+
2143+
BeforeEach(func() {
2144+
teardown = func() {}
2145+
2146+
packages := []registry.PackageManifest{
2147+
{
2148+
PackageName: "dependency",
2149+
Channels: []registry.PackageChannel{
2150+
{Name: "default", CurrentCSVName: "csv-dependency"},
2151+
{Name: "nondefault", CurrentCSVName: "csv-dependency"},
2152+
},
2153+
DefaultChannelName: "default",
2154+
},
2155+
{
2156+
PackageName: "root",
2157+
Channels: []registry.PackageChannel{
2158+
{Name: "unimportant", CurrentCSVName: "csv-root"},
2159+
},
2160+
DefaultChannelName: "unimportant",
2161+
},
2162+
}
2163+
2164+
crds := []apiextensions.CustomResourceDefinition{newCRD(genName("crd-"))}
2165+
csvs := []operatorsv1alpha1.ClusterServiceVersion{
2166+
newCSV("csv-dependency", testNamespace, "", semver.MustParse("1.0.0"), crds, nil, nil),
2167+
newCSV("csv-root", testNamespace, "", semver.MustParse("1.0.0"), nil, crds, nil),
2168+
}
2169+
2170+
_, teardown = createInternalCatalogSource(ctx.Ctx().KubeClient(), ctx.Ctx().OperatorClient(), "test-catalog", testNamespace, packages, crds, csvs)
2171+
2172+
createSubscriptionForCatalog(ctx.Ctx().OperatorClient(), testNamespace, "test-subscription", "test-catalog", "root", "unimportant", "", operatorsv1alpha1.ApprovalAutomatic)
2173+
})
2174+
2175+
AfterEach(func() {
2176+
teardown()
2177+
})
2178+
2179+
It("should create a Subscription using the candidate's default channel", func() {
2180+
Eventually(func() ([]operatorsv1alpha1.Subscription, error) {
2181+
var list operatorsv1alpha1.SubscriptionList
2182+
if err := ctx.Ctx().Client().List(context.TODO(), &list); err != nil {
2183+
return nil, err
2184+
}
2185+
return list.Items, nil
2186+
}).Should(ContainElement(WithTransform(
2187+
func(in operatorsv1alpha1.Subscription) operatorsv1alpha1.SubscriptionSpec {
2188+
return operatorsv1alpha1.SubscriptionSpec{
2189+
CatalogSource: in.Spec.CatalogSource,
2190+
CatalogSourceNamespace: in.Spec.CatalogSourceNamespace,
2191+
Package: in.Spec.Package,
2192+
Channel: in.Spec.Channel,
2193+
}
2194+
},
2195+
Equal(operatorsv1alpha1.SubscriptionSpec{
2196+
CatalogSource: "test-catalog",
2197+
CatalogSourceNamespace: testNamespace,
2198+
Package: "dependency",
2199+
Channel: "default",
2200+
}),
2201+
)))
2202+
})
2203+
})
21372204
})
21382205

21392206
const (

0 commit comments

Comments
 (0)