|
| 1 | +package e2e |
| 2 | + |
| 3 | +import ( |
| 4 | + "context" |
| 5 | + "k8s.io/apimachinery/pkg/runtime/schema" |
| 6 | + "k8s.io/client-go/dynamic" |
| 7 | + |
| 8 | + . "github.com/onsi/ginkgo" |
| 9 | + . "github.com/onsi/gomega" |
| 10 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 11 | + |
| 12 | + "github.com/operator-framework/api/pkg/operators/v1alpha1" |
| 13 | + "github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned" |
| 14 | + "github.com/operator-framework/operator-lifecycle-manager/pkg/lib/operatorclient" |
| 15 | + "github.com/operator-framework/operator-lifecycle-manager/test/e2e/ctx" |
| 16 | +) |
| 17 | + |
| 18 | +var _ = Describe("Installing bundles with new object types", func() { |
| 19 | + var ( |
| 20 | + kubeClient operatorclient.ClientInterface |
| 21 | + operatorClient versioned.Interface |
| 22 | + dynamicClient dynamic.Interface |
| 23 | + ) |
| 24 | + |
| 25 | + BeforeEach(func() { |
| 26 | + kubeClient = ctx.Ctx().KubeClient() |
| 27 | + operatorClient = ctx.Ctx().OperatorClient() |
| 28 | + dynamicClient = ctx.Ctx().DynamicClient() |
| 29 | + }) |
| 30 | + |
| 31 | + AfterEach(func() { |
| 32 | + cleaner.NotifyTestComplete(true) |
| 33 | + }) |
| 34 | + |
| 35 | + When("a bundle with a pdb, priorityclass, and VPA object is installed", func() { |
| 36 | + By("including the VPA CRD in the CSV") |
| 37 | + const ( |
| 38 | + packageName = "busybox" |
| 39 | + channelName = "alpha" |
| 40 | + subName = "test-subscription" |
| 41 | + ) |
| 42 | + |
| 43 | + BeforeEach(func() { |
| 44 | + const ( |
| 45 | + sourceName = "test-catalog" |
| 46 | + imageName = "quay.io/olmtest/single-bundle-index:pdb" |
| 47 | + ) |
| 48 | + // create catalog source |
| 49 | + source := &v1alpha1.CatalogSource{ |
| 50 | + TypeMeta: metav1.TypeMeta{ |
| 51 | + Kind: v1alpha1.CatalogSourceKind, |
| 52 | + APIVersion: v1alpha1.CatalogSourceCRDAPIVersion, |
| 53 | + }, |
| 54 | + ObjectMeta: metav1.ObjectMeta{ |
| 55 | + Name: sourceName, |
| 56 | + Namespace: testNamespace, |
| 57 | + Labels: map[string]string{"olm.catalogSource": sourceName}, |
| 58 | + }, |
| 59 | + Spec: v1alpha1.CatalogSourceSpec{ |
| 60 | + SourceType: v1alpha1.SourceTypeGrpc, |
| 61 | + Image: imageName, |
| 62 | + }, |
| 63 | + } |
| 64 | + |
| 65 | + source, err := operatorClient.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Create(context.TODO(), source, metav1.CreateOptions{}) |
| 66 | + Expect(err).ToNot(HaveOccurred(), "could not create catalog source") |
| 67 | + |
| 68 | + // Create a Subscription for package |
| 69 | + _ = createSubscriptionForCatalog(operatorClient, source.GetNamespace(), subName, source.GetName(), packageName, channelName, "", v1alpha1.ApprovalAutomatic) |
| 70 | + |
| 71 | + // Wait for the Subscription to succeed |
| 72 | + Eventually(func() error { |
| 73 | + _, err = fetchSubscription(operatorClient, testNamespace, subName, subscriptionStateAtLatestChecker) |
| 74 | + return err |
| 75 | + }).Should(BeNil()) |
| 76 | + }) |
| 77 | + |
| 78 | + It("should create the additional bundle objects", func() { |
| 79 | + const ( |
| 80 | + vpaGroup = "autoscaling.k8s.io" |
| 81 | + vpaVersion = "v1" |
| 82 | + vpaResource = "verticalpodautoscalers" |
| 83 | + pdbName = "busybox-pdb" |
| 84 | + priorityClassName = "high-priority" |
| 85 | + vpaName = "busybox-vpa" |
| 86 | + ) |
| 87 | + |
| 88 | + var resource = schema.GroupVersionResource{ |
| 89 | + Group: vpaGroup, |
| 90 | + Version: vpaVersion, |
| 91 | + Resource: vpaResource, |
| 92 | + } |
| 93 | + |
| 94 | + // confirm extra bundle objects are installed |
| 95 | + Eventually(func() error { |
| 96 | + _, err := kubeClient.KubernetesInterface().PolicyV1beta1().PodDisruptionBudgets(testNamespace).Get(context.TODO(), pdbName, metav1.GetOptions{}) |
| 97 | + return err |
| 98 | + }).Should(Succeed(), "expected no error getting pdb object associated with CSV") |
| 99 | + |
| 100 | + Eventually(func() error { |
| 101 | + _, err := kubeClient.KubernetesInterface().SchedulingV1().PriorityClasses().Get(context.TODO(), priorityClassName, metav1.GetOptions{}) |
| 102 | + return err |
| 103 | + }).Should(Succeed(), "expected no error getting priorityclass object associated with CSV") |
| 104 | + |
| 105 | + Eventually(func() error { |
| 106 | + _, err := dynamicClient.Resource(resource).Namespace(testNamespace).Get(context.TODO(), vpaName, metav1.GetOptions{}) |
| 107 | + return err |
| 108 | + }).Should(Succeed(), "expected no error finding vpa object associated with csv") |
| 109 | + }) |
| 110 | + }) |
| 111 | +}) |
0 commit comments