Skip to content

Commit 171bd7e

Browse files
Merge pull request #1641 from exdx/fix/crd-e2e-test
fix: use server-side apply in crd e2e test
2 parents c29a8cc + 73e28c9 commit 171bd7e

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

test/e2e/crd_e2e_test.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import (
1010
. "github.com/onsi/gomega"
1111
operatorsv1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1"
1212
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry"
13+
"github.com/operator-framework/operator-lifecycle-manager/test/e2e/ctx"
14+
1315
"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions"
1416
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
1517
apiextensionsv1beta1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1beta1"
@@ -299,13 +301,12 @@ var _ = Describe("CRD Versions", func() {
299301

300302
// old CRD has been installed onto the cluster - now upgrade the subscription to point to the channel with the new CRD
301303
// installing the new CSV should fail with a warning about data loss, since a storage version is missing in the new CRD
302-
sub, err := crc.OperatorsV1alpha1().Subscriptions(testNamespace).Get(context.TODO(), subscription.GetName(), metav1.GetOptions{})
303-
Expect(err).ToNot(HaveOccurred(), "could not get subscription")
304-
305-
// update channel on sub
306-
sub.Spec.Channel = alphaChannel
307-
_, err = crc.OperatorsV1alpha1().Subscriptions(testNamespace).Update(context.TODO(), sub, metav1.UpdateOptions{})
308-
Expect(err).ToNot(HaveOccurred(), "could not update subscription")
304+
// use server-side apply to apply the update to the subscription point to the alpha channel
305+
Eventually(Apply(subscription, func(s *operatorsv1alpha1.Subscription) error {
306+
s.Spec.Channel = alphaChannel
307+
return nil
308+
})).Should(Succeed())
309+
ctx.Ctx().Logf("updated subscription to point to alpha channel")
309310

310311
subscriptionAtLatestWithDifferentInstallPlan := func(v *operatorsv1alpha1.Subscription) bool {
311312
return subscriptionStateAtLatestChecker(v) && v.Status.InstallPlanRef != nil && v.Status.InstallPlanRef.Name != fetchedInstallPlan.Name

0 commit comments

Comments
 (0)