Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-4.6] Bug 1968226: Fix inconsistent dependency candidate order. #2184

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
67 changes: 67 additions & 0 deletions test/e2e/subscription_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2131,6 +2131,73 @@ var _ = Describe("Subscription", func() {
}).ShouldNot(Succeed())
})
})

When("there exists a Subscription to an operator having dependency candidates in both default and nondefault channels", func() {
var (
teardown func()
)

BeforeEach(func() {
teardown = func() {}

packages := []registry.PackageManifest{
{
PackageName: "dependency",
Channels: []registry.PackageChannel{
{Name: "default", CurrentCSVName: "csv-dependency"},
{Name: "nondefault", CurrentCSVName: "csv-dependency"},
},
DefaultChannelName: "default",
},
{
PackageName: "root",
Channels: []registry.PackageChannel{
{Name: "unimportant", CurrentCSVName: "csv-root"},
},
DefaultChannelName: "unimportant",
},
}

crds := []apiextensions.CustomResourceDefinition{newCRD(genName("crd-"))}
csvs := []operatorsv1alpha1.ClusterServiceVersion{
newCSV("csv-dependency", testNamespace, "", semver.MustParse("1.0.0"), crds, nil, nil),
newCSV("csv-root", testNamespace, "", semver.MustParse("1.0.0"), nil, crds, nil),
}

_, teardown = createInternalCatalogSource(ctx.Ctx().KubeClient(), ctx.Ctx().OperatorClient(), "test-catalog", testNamespace, packages, crds, csvs)

createSubscriptionForCatalog(ctx.Ctx().OperatorClient(), testNamespace, "test-subscription", "test-catalog", "root", "unimportant", "", operatorsv1alpha1.ApprovalAutomatic)
})

AfterEach(func() {
teardown()
})

It("should create a Subscription using the candidate's default channel", func() {
Eventually(func() ([]operatorsv1alpha1.Subscription, error) {
var list operatorsv1alpha1.SubscriptionList
if err := ctx.Ctx().Client().List(context.TODO(), &list); err != nil {
return nil, err
}
return list.Items, nil
}).Should(ContainElement(WithTransform(
func(in operatorsv1alpha1.Subscription) operatorsv1alpha1.SubscriptionSpec {
return operatorsv1alpha1.SubscriptionSpec{
CatalogSource: in.Spec.CatalogSource,
CatalogSourceNamespace: in.Spec.CatalogSourceNamespace,
Package: in.Spec.Package,
Channel: in.Spec.Channel,
}
},
Equal(operatorsv1alpha1.SubscriptionSpec{
CatalogSource: "test-catalog",
CatalogSourceNamespace: testNamespace,
Package: "dependency",
Channel: "default",
}),
)))
})
})
})

const (
Expand Down