From 6474902f0e8c6715c9522c875784cd031fa19a7f Mon Sep 17 00:00:00 2001 From: Todd Short Date: Tue, 12 Nov 2024 16:13:48 -0500 Subject: [PATCH] Add Capability and FeatureGate check to OLMv1 tests Remove OLMv1 TechPreview check in favor of feature gate Use hard-coded capability for now Signed-off-by: Todd Short --- test/extended/olm/olmv1.go | 61 ++++++++----------- test/extended/testdata/bindata.go | 15 +++-- .../testdata/olmv1/install-operator.yaml | 15 +++-- .../generated/zz_generated.annotations.go | 8 +-- zz_generated.manifests/test-reporting.yaml | 8 +++ 5 files changed, 51 insertions(+), 56 deletions(-) diff --git a/test/extended/olm/olmv1.go b/test/extended/olm/olmv1.go index 3394157c6b57..3e31254b65ed 100644 --- a/test/extended/olm/olmv1.go +++ b/test/extended/olm/olmv1.go @@ -23,31 +23,26 @@ const ( typeIncompatibelOperatorsUpgradeable = "InstalledOLMOperatorsUpgradeable" ) -var _ = g.Describe("[sig-olmv1] OLMv1 CRDs", func() { +var _ = g.Describe("[sig-olmv1][OCPFeatureGate:NewOLM] OLMv1 CRDs", func() { defer g.GinkgoRecover() oc := exutil.NewCLIWithoutNamespace("default") g.It("should be installed", func(ctx g.SpecContext) { - g.Skip("Test is temporarily disabled while we make anticipated, breaking changes.") - // Check for tech preview, if this is not tech preview, bail - if !exutil.IsTechPreviewNoUpgrade(ctx, oc.AdminConfigClient()) { - g.Skip("Test only runs in tech-preview") - } + checkFeatureCapability(ctx, oc) - // supports multiple versions during transision providedAPIs := []struct { group string - version []string + version string plural string }{ { group: olmv1GroupName, - version: []string{"v1alpha1", "v1"}, + version: "v1", plural: "clusterextensions", }, { group: olmv1GroupName, - version: []string{"v1alpha1", "v1"}, + version: "v1", plural: "clustercatalogs", }, } @@ -55,14 +50,7 @@ var _ = g.Describe("[sig-olmv1] OLMv1 CRDs", func() { for _, api := range providedAPIs { g.By(fmt.Sprintf("checking %s at version %s [apigroup:%s]", api.plural, api.version, api.group)) // Ensure expected version exists in spec.versions and is both served and stored - var err error - var raw string - for _, ver := range api.version { - raw, err = oc.AsAdmin().Run("get").Args("crds", fmt.Sprintf("%s.%s", api.plural, api.group), fmt.Sprintf("-o=jsonpath={.spec.versions[?(@.name==%q)]}", ver)).Output() - if err == nil { - break - } - } + raw, err := oc.AsAdmin().Run("get").Args("crds", fmt.Sprintf("%s.%s", api.plural, api.group), fmt.Sprintf("-o=jsonpath={.spec.versions[?(@.name==%q)]}", api.version)).Output() o.Expect(err).NotTo(o.HaveOccurred()) o.Expect(raw).To(o.MatchRegexp(`served.?:true`)) o.Expect(raw).To(o.MatchRegexp(`storage.?:true`)) @@ -70,16 +58,12 @@ var _ = g.Describe("[sig-olmv1] OLMv1 CRDs", func() { }) }) -var _ = g.Describe("[sig-olmv1] OLMv1 Catalogs", func() { +var _ = g.Describe("[sig-olmv1][OCPFeatureGate:NewOLM] OLMv1 Catalogs", func() { defer g.GinkgoRecover() oc := exutil.NewCLIWithoutNamespace("default") g.It("should be installed", func(ctx g.SpecContext) { - g.Skip("Test is temporarily disabled while we make anticipated, breaking changes.") - // Check for tech preview, if this is not tech preview, bail - if !exutil.IsTechPreviewNoUpgrade(ctx, oc.AdminConfigClient()) { - g.Skip("Test only runs in tech-preview") - } + checkFeatureCapability(ctx, oc) providedCatalogs := []string{ "openshift-certified-operators", @@ -102,7 +86,7 @@ var _ = g.Describe("[sig-olmv1] OLMv1 Catalogs", func() { }) }) -var _ = g.Describe("[sig-olmv1][Serial] OLMv1 operator installation", func() { +var _ = g.Describe("[sig-olmv1][OCPFeatureGate:NewOLM][Serial] OLMv1 operator installation", func() { defer g.GinkgoRecover() var ( @@ -125,15 +109,12 @@ var _ = g.Describe("[sig-olmv1][Serial] OLMv1 operator installation", func() { }) g.It("should install a cluster extension", func(ctx g.SpecContext) { - g.Skip("Test is temporarily disabled while we make anticipated, breaking changes.") + checkFeatureCapability(ctx, oc) + const ( packageName = "quay-operator" version = "3.13.0" ) - // Check for tech preview, if this is not tech preview, bail - if !exutil.IsTechPreviewNoUpgrade(ctx, oc.AdminConfigClient()) { - g.Skip("Test only runs in tech-preview") - } ns := oc.Namespace() g.By(fmt.Sprintf("Updating the namespace to: %q", ns)) @@ -164,15 +145,12 @@ var _ = g.Describe("[sig-olmv1][Serial] OLMv1 operator installation", func() { }) g.It("should block cluster upgrades if an incompatible operator is installed", func(ctx g.SpecContext) { - g.Skip("Test is temporarily disabled while we make anticipated, breaking changes.") + checkFeatureCapability(ctx, oc) + const ( packageName = "elasticsearch-operator" version = "5.8.13" ) - // Check for tech preview, if this is not tech preview, bail - if !exutil.IsTechPreviewNoUpgrade(ctx, oc.AdminConfigClient()) { - g.Skip("Test only runs in tech-preview") - } ns := oc.Namespace() g.By(fmt.Sprintf("Updating the namespace to: %q", ns)) @@ -205,7 +183,7 @@ var _ = g.Describe("[sig-olmv1][Serial] OLMv1 operator installation", func() { func updateCe(b []byte, args ...string) string { s := string(b) - s = strings.ReplaceAll(s, "{REPLACE}", args[0]) + s = strings.ReplaceAll(s, "{NAMESPACE}", args[0]) s = strings.ReplaceAll(s, "{PACKAGENAME}", args[1]) s = strings.ReplaceAll(s, "{VERSION}", args[2]) return s @@ -253,3 +231,14 @@ func WaitForCondition(oc *exutil.CLI, status bool) (done bool, err error) { } return true, nil } + +func checkFeatureCapability(ctx context.Context, oc *exutil.CLI) { + // Hardcoded until openshift/api is updated: + // import ( configv1 "github.com/openshift/api/config/v1" ) + // configv1.ClusterVersionCapabilityOperatorLifecycleManagerV1 + cap, err := exutil.IsCapabilityEnabled(oc, "OperatorLifecycleManagerV1") + o.Expect(err).NotTo(o.HaveOccurred()) + if !cap { + g.Skip("Test only runs with OperatorLifecycleManagerV1 capability") + } +} diff --git a/test/extended/testdata/bindata.go b/test/extended/testdata/bindata.go index a346ebb63dd9..ca3b89116529 100644 --- a/test/extended/testdata/bindata.go +++ b/test/extended/testdata/bindata.go @@ -50056,12 +50056,12 @@ var _testExtendedTestdataOlmv1InstallOperatorYaml = []byte(`apiVersion: v1 kind: ServiceAccount metadata: name: install-test-sa - namespace: {REPLACE} + namespace: {NAMESPACE} --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: - name: crb-{REPLACE} + name: crb-{NAMESPACE} roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole @@ -50069,17 +50069,16 @@ roleRef: subjects: - kind: ServiceAccount name: install-test-sa - namespace: {REPLACE} + namespace: {NAMESPACE} --- -apiVersion: olm.operatorframework.io/v1alpha1 +apiVersion: olm.operatorframework.io/v1 kind: ClusterExtension metadata: name: install-test-ce spec: - install: - namespace: {REPLACE} - serviceAccount: - name: install-test-sa + namespace: {NAMESPACE} + serviceAccount: + name: install-test-sa source: catalog: packageName: {PACKAGENAME} diff --git a/test/extended/testdata/olmv1/install-operator.yaml b/test/extended/testdata/olmv1/install-operator.yaml index c07d113f2194..8c329e81ba14 100644 --- a/test/extended/testdata/olmv1/install-operator.yaml +++ b/test/extended/testdata/olmv1/install-operator.yaml @@ -2,12 +2,12 @@ apiVersion: v1 kind: ServiceAccount metadata: name: install-test-sa - namespace: {REPLACE} + namespace: {NAMESPACE} --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: - name: crb-{REPLACE} + name: crb-{NAMESPACE} roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole @@ -15,17 +15,16 @@ roleRef: subjects: - kind: ServiceAccount name: install-test-sa - namespace: {REPLACE} + namespace: {NAMESPACE} --- -apiVersion: olm.operatorframework.io/v1alpha1 +apiVersion: olm.operatorframework.io/v1 kind: ClusterExtension metadata: name: install-test-ce spec: - install: - namespace: {REPLACE} - serviceAccount: - name: install-test-sa + namespace: {NAMESPACE} + serviceAccount: + name: install-test-sa source: catalog: packageName: {PACKAGENAME} diff --git a/test/extended/util/annotate/generated/zz_generated.annotations.go b/test/extended/util/annotate/generated/zz_generated.annotations.go index 32423807ea65..50902728bf3d 100644 --- a/test/extended/util/annotate/generated/zz_generated.annotations.go +++ b/test/extended/util/annotate/generated/zz_generated.annotations.go @@ -1703,13 +1703,13 @@ var Annotations = map[string]string{ "[sig-node][apigroup:config.openshift.io] CPU Partitioning node validation should have correct cpuset and cpushare set in crio containers": " [Suite:openshift/conformance/parallel]", - "[sig-olmv1] OLMv1 CRDs should be installed": " [Suite:openshift/conformance/parallel]", + "[sig-olmv1][OCPFeatureGate:NewOLM] OLMv1 CRDs should be installed": " [Suite:openshift/conformance/parallel]", - "[sig-olmv1] OLMv1 Catalogs should be installed": " [Suite:openshift/conformance/parallel]", + "[sig-olmv1][OCPFeatureGate:NewOLM] OLMv1 Catalogs should be installed": " [Suite:openshift/conformance/parallel]", - "[sig-olmv1][Serial] OLMv1 operator installation should block cluster upgrades if an incompatible operator is installed": " [Suite:openshift/conformance/serial]", + "[sig-olmv1][OCPFeatureGate:NewOLM][Serial] OLMv1 operator installation should block cluster upgrades if an incompatible operator is installed": " [Suite:openshift/conformance/serial]", - "[sig-olmv1][Serial] OLMv1 operator installation should install a cluster extension": " [Suite:openshift/conformance/serial]", + "[sig-olmv1][OCPFeatureGate:NewOLM][Serial] OLMv1 operator installation should install a cluster extension": " [Suite:openshift/conformance/serial]", "[sig-operator] OLM should Implement packages API server and list packagemanifest info with namespace not NULL [apigroup:packages.operators.coreos.com]": " [Skipped:NoOptionalCapabilities] [Suite:openshift/conformance/parallel]", diff --git a/zz_generated.manifests/test-reporting.yaml b/zz_generated.manifests/test-reporting.yaml index a0becec6225c..fd46a35d8157 100644 --- a/zz_generated.manifests/test-reporting.yaml +++ b/zz_generated.manifests/test-reporting.yaml @@ -244,6 +244,14 @@ spec: - testName: '[sig-network][OCPFeatureGate:NetworkSegmentation][Feature:UserDefinedPrimaryNetworks] when using openshift ovn-kubernetes when primary network exist, UserDefinedNetwork status should report not-ready' + - featureGate: NewOLM + tests: + - testName: '[sig-olmv1][OCPFeatureGate:NewOLM] OLMv1 CRDs should be installed' + - testName: '[sig-olmv1][OCPFeatureGate:NewOLM] OLMv1 Catalogs should be installed' + - testName: '[sig-olmv1][OCPFeatureGate:NewOLM][Serial] OLMv1 operator installation + should block cluster upgrades if an incompatible operator is installed' + - testName: '[sig-olmv1][OCPFeatureGate:NewOLM][Serial] OLMv1 operator installation + should install a cluster extension' - featureGate: PersistentIPsForVirtualization tests: - testName: '[sig-network][OCPFeatureGate:PersistentIPsForVirtualization][Feature:Layer2LiveMigration]