From f54d2a8fb71caa164fbdd78f42b2db030d7d5f09 Mon Sep 17 00:00:00 2001 From: Kui Wang Date: Mon, 29 Sep 2025 09:57:33 +0800 Subject: [PATCH] migrate more cases from tests-private --- .../openshift_payload_olmv0.json | 138 ++++++++ tests-extension/Makefile | 58 +++- tests-extension/test/qe/README.md | 21 +- tests-extension/test/qe/specs/olmv0_allns.go | 155 +++++++++ .../qe/specs/{olmv0.go => olmv0_common.go} | 13 +- .../test/qe/specs/olmv0_defaultoption.go | 46 +++ .../test/qe/specs/olmv0_hypershiftmgmt.go | 109 ++++++ .../test/qe/specs/olmv0_microshift.go | 324 ++++++++++++++++++ .../test/qe/specs/olmv0_multins.go | 113 ++++++ .../test/qe/specs/olmv0_nonallns.go | 247 +++++++++++++ .../test/qe/util/filters/filters.go | 4 + tests-extension/test/qe/util/hypeshift.go | 16 +- 12 files changed, 1238 insertions(+), 6 deletions(-) create mode 100644 tests-extension/test/qe/specs/olmv0_allns.go rename tests-extension/test/qe/specs/{olmv0.go => olmv0_common.go} (83%) create mode 100644 tests-extension/test/qe/specs/olmv0_defaultoption.go create mode 100644 tests-extension/test/qe/specs/olmv0_hypershiftmgmt.go create mode 100644 tests-extension/test/qe/specs/olmv0_microshift.go create mode 100644 tests-extension/test/qe/specs/olmv0_multins.go create mode 100644 tests-extension/test/qe/specs/olmv0_nonallns.go diff --git a/tests-extension/.openshift-tests-extension/openshift_payload_olmv0.json b/tests-extension/.openshift-tests-extension/openshift_payload_olmv0.json index 90df92d73a..b861566623 100644 --- a/tests-extension/.openshift-tests-extension/openshift_payload_olmv0.json +++ b/tests-extension/.openshift-tests-extension/openshift_payload_olmv0.json @@ -1,4 +1,19 @@ [ + { + "name": "[sig-operator][Jira:OLM] OLMv0 within all namespace PolarionID:21418-PolarionID:25679-[Skipped:Disconnected]Cluster resource created and deleted correctly [Serial]", + "labels": { + "Extended": {}, + "NonHyperShiftHOST": {} + }, + "resources": { + "isolation": {} + }, + "source": "openshift:payload:olmv0", + "lifecycle": "informing", + "environmentSelector": { + "exclude": "topology==\"External\"" + } + }, { "name": "[sig-operator][Jira:OLM] OLMv0 should pass a trivial sanity check", "labels": { @@ -26,5 +41,128 @@ "environmentSelector": { "exclude": "topology==\"External\"" } + }, + { + "name": "[sig-operator][Jira:OLM] OLMv0 should PolarionID:73695-[Skipped:Disconnected]PO is disable", + "labels": { + "Extended": {} + }, + "resources": { + "isolation": {} + }, + "source": "openshift:payload:olmv0", + "lifecycle": "informing", + "environmentSelector": {} + }, + { + "name": "[sig-operator][Jira:OLM] OLMv0 optional should PolarionID:68679-[Skipped:Disconnected]catalogsource with invalid name is created", + "labels": { + "Extended": {}, + "NonHyperShiftHOST": {} + }, + "resources": { + "isolation": {} + }, + "source": "openshift:payload:olmv0", + "lifecycle": "informing", + "environmentSelector": { + "exclude": "topology==\"External\"" + } + }, + { + "name": "[sig-operator][Jira:OLM] OLMvo on hypershift mgmt ROSA-OSD_CCS-HyperShiftMGMT-ConnectedOnly-Author:kuiwang-Medium-45381-Support custom catalogs in hypershift", + "labels": { + "Extended": {}, + "NonHyperShiftHOST": {} + }, + "resources": { + "isolation": {} + }, + "source": "openshift:payload:olmv0", + "lifecycle": "informing", + "environmentSelector": { + "exclude": "topology==\"External\"" + } + }, + { + "name": "[sig-operator][Jira:OLM] OLMv0 on microshift PolarionID:69867-[Skipped:Disconnected]deployed in microshift and install one operator with single mode.", + "labels": { + "Extended": {}, + "NonHyperShiftHOST": {} + }, + "resources": { + "isolation": {} + }, + "source": "openshift:payload:olmv0", + "lifecycle": "informing", + "environmentSelector": { + "exclude": "topology==\"External\"" + } + }, + { + "name": "[sig-operator][Jira:OLM] OLMv0 on microshift PolarionID:69868-[Skipped:Disconnected]olm microshift install operator with all mode, muilt og error and delete one og to get it installed.", + "labels": { + "Extended": {}, + "NonHyperShiftHOST": {} + }, + "resources": { + "isolation": {} + }, + "source": "openshift:payload:olmv0", + "lifecycle": "informing", + "environmentSelector": { + "exclude": "topology==\"External\"" + } + }, + { + "name": "[sig-operator][Jira:OLM] OLMv0 on microshift PolarionID:83581-[Skipped:Disconnected]olmv0 networkpolicy on microshift.", + "labels": { + "Extended": {}, + "NonHyperShiftHOST": {} + }, + "resources": { + "isolation": {} + }, + "source": "openshift:payload:olmv0", + "lifecycle": "informing", + "environmentSelector": { + "exclude": "topology==\"External\"" + } + }, + { + "name": "[sig-operator][Jira:OLM] OLMv0 with multi ns PolarionID:22226-[Skipped:Disconnected]the csv without support MultiNamespace fails for og with MultiNamespace", + "labels": { + "Extended": {} + }, + "resources": { + "isolation": {} + }, + "source": "openshift:payload:olmv0", + "lifecycle": "informing", + "environmentSelector": {} + }, + { + "name": "[sig-operator][Jira:OLM] OLMv0 within a namespace PolarionID:24870-[Skipped:Disconnected]can not create csv without operator group", + "labels": { + "Extended": {} + }, + "resources": { + "isolation": {} + }, + "source": "openshift:payload:olmv0", + "lifecycle": "informing", + "environmentSelector": {} + }, + { + "name": "[sig-operator][Jira:OLM] OLMv0 within a namespace PolarionID:37263-[Skipped:Disconnected][Skipped:Proxy]Subscription stays in UpgradePending but InstallPlan not installing [Slow]", + "labels": { + "Extended": {} + }, + "resources": { + "isolation": {} + }, + "source": "openshift:payload:olmv0", + "lifecycle": "informing", + "environmentSelector": {} } ] diff --git a/tests-extension/Makefile b/tests-extension/Makefile index 56da8241ba..f98b11f6b5 100644 --- a/tests-extension/Makefile +++ b/tests-extension/Makefile @@ -42,7 +42,53 @@ TOOLS_BIN_DIR := $(CURDIR)/bin #SECTION Development .PHONY: verify #HELP To verify the code -verify: tidy fmt vet lint +verify: + @echo "Running verification checks..." + @errors=0; \ + failed_steps=""; \ + echo "1/4 Running 'make tidy'..."; \ + if ! $(MAKE) tidy; then \ + echo "ERROR: 'make tidy' failed"; \ + errors=$$((errors+1)); \ + failed_steps="$$failed_steps tidy"; \ + else \ + echo "SUCCESS: 'make tidy' passed"; \ + fi; \ + echo ""; \ + echo "2/4 Running 'make fmt'..."; \ + if ! $(MAKE) fmt; then \ + echo "ERROR: 'make fmt' failed"; \ + errors=$$((errors+1)); \ + failed_steps="$$failed_steps fmt"; \ + else \ + echo "SUCCESS: 'make fmt' passed"; \ + fi; \ + echo ""; \ + echo "3/4 Running 'make vet'..."; \ + if ! $(MAKE) vet; then \ + echo "ERROR: 'make vet' failed"; \ + errors=$$((errors+1)); \ + failed_steps="$$failed_steps vet"; \ + else \ + echo "SUCCESS: 'make vet' passed"; \ + fi; \ + echo ""; \ + echo "4/4 Running 'make lint'..."; \ + if ! $(MAKE) lint; then \ + echo "ERROR: 'make lint' failed"; \ + errors=$$((errors+1)); \ + failed_steps="$$failed_steps lint"; \ + else \ + echo "SUCCESS: 'make lint' passed"; \ + fi; \ + echo ""; \ + echo "Verification completed with $$errors error(s)"; \ + if [ $$errors -gt 0 ]; then \ + echo "FAILED: The following verification check(s) failed:$$failed_steps"; \ + exit 1; \ + else \ + echo "SUCCESS: All verification checks passed"; \ + fi .PHONY: tidy #HELP Run go mod tidy. tidy: @@ -50,7 +96,15 @@ tidy: .PHONY: fmt fmt: #HELP Run go fmt against code. - go fmt ./... + @files=$$(find . -name '*.go' -not -path './vendor/*' -not -path './pkg/bindata/qe/*' -exec gofmt -l {} \;); \ + if [ -n "$$files" ]; then \ + echo "Files that need formatting:"; \ + echo "$$files"; \ + echo ""; \ + echo "To fix formatting, run:"; \ + echo " find . -name '*.go' -not -path './vendor/*' -not -path './pkg/bindata/qe/*' -exec gofmt -w {} \\;"; \ + exit 1; \ + fi .PHONY: vet vet: #HELP Run go vet against code. diff --git a/tests-extension/test/qe/README.md b/tests-extension/test/qe/README.md index 266a0e3b70..80407d5950 100644 --- a/tests-extension/test/qe/README.md +++ b/tests-extension/test/qe/README.md @@ -213,7 +213,7 @@ All migrated test case code needs the following changes to run in the new test f 14. **CPaasrunOnly, CPaasrunBoth, StagerunOnly, StagerunBoth, ProdrunOnly, ProdrunBoth**: Deprecated 15. **StressTest**: Use Ginkgo label `g.Label("StressTest")` 16. **NonHyperShiftHOST**: Use Ginkgo label `g.Label("NonHyperShiftHOST")` or use `IsHypershiftHostedCluster` judgment, then skip -17. **HyperShiftMGMT**: Deprecated. For cases needing hypershift mgmt execution, use `g.Label("NonHyperShiftHOST")` and `ValidHypershiftAndGetGuestKubeConf` validation (to be provided when OLMv1 supports hypershift) +17. **HyperShiftMGMT**: Deprecated. For cases needing hypershift mgmt execution, use `g.Label("NonHyperShiftHOST")` and `ValidHypershiftAndGetGuestKubeConf` validation 18. **MicroShiftOnly**: Deprecated. For cases not supporting microshift, use `SkipMicroshift` judgment, then skip 19. **ROSA**: Deprecated. Three ROSA job types: - `rosa-sts-ovn`: equivalent to OCP @@ -366,6 +366,25 @@ Consider these requirements when writing and reviewing code: /payload-aggregate periodic-ci-openshift-release-master-ci--e2e-gcp-ovn-serial 5 ``` +## Test Case Migration Mapping + +The following table shows the mapping between the original g.Describe blocks in `openshift-tests-private/test/extended/operators/olm.go` and the corresponding migrated spec files in this repository: + +| Original g.Describe in olm.go | Mapped Spec File | Line in olm.go | +|-------------------------------|------------------|----------------| +| `[sig-operators] OLM optional` | `olmv0_defaultoption.go` | 34 | +| `[sig-operators] OLM should` | `olmv0_defaultoption.go` | 150 | +| `[sig-operators] OLM for an end user use` | `olmv0_common.go` | 5302 | +| `[sig-operators] OLM for an end user handle common object` | `olmv0_common.go` | 5349 | +| `[sig-operators] OLM for an end user handle within a namespace` | `olmv0_nonallns.go` | 5555 | +| `[sig-operators] OLM for an end user handle to support` | `olmv0_multins.go` | 11544 | +| `[sig-operators] OLM for an end user handle within all namespace` | `olmv0_allns.go` | 12657 | +| `[sig-operators] OLM on hypershift` | `olmv0_hypershiftmgmt.go` | 14814 | + +### Notes: +- Each mapped spec file contains a comment indicating its relationship to the original olm.go g.Describe block +- Some spec files map to multiple g.Describe blocks (e.g., `olmv0_common.go` and `olmv0_defaultoption.go`) + ## How to Keep Test Names Unique OTE requires unique test names. If you want to modify a test name after merging, refer to the [Makefile implementation](https://github.com/openshift/operator-framework-operator-controller/blob/main/openshift/tests-extension/Makefile#L104) for proper modification procedures. diff --git a/tests-extension/test/qe/specs/olmv0_allns.go b/tests-extension/test/qe/specs/olmv0_allns.go new file mode 100644 index 0000000000..303a323528 --- /dev/null +++ b/tests-extension/test/qe/specs/olmv0_allns.go @@ -0,0 +1,155 @@ +package specs + +import ( + "fmt" + "os" + "path/filepath" + "strings" + + g "github.com/onsi/ginkgo/v2" + o "github.com/onsi/gomega" + + exutil "github.com/openshift/operator-framework-olm/tests-extension/test/qe/util" + "github.com/openshift/operator-framework-olm/tests-extension/test/qe/util/architecture" + "github.com/openshift/operator-framework-olm/tests-extension/test/qe/util/olmv0util" +) + +// it is mapping to the Describe "OLM for an end user handle within all namespace" in olm.go +var _ = g.Describe("[sig-operator][Jira:OLM] OLMv0 within all namespace", func() { + defer g.GinkgoRecover() + + var ( + oc = exutil.NewCLI("olm-all-"+exutil.GetRandomString(), exutil.KubeConfigPath()) + + dr = make(olmv0util.DescriberResrouce) + ) + + g.BeforeEach(func() { + exutil.SkipMicroshift(oc) + exutil.SkipNoOLMCore(oc) + itName := g.CurrentSpecReport().FullText() + dr.AddIr(itName) + }) + + g.AfterEach(func() { + itName := g.CurrentSpecReport().FullText() + dr.GetIr(itName).Cleanup() + dr.RmIr(itName) + }) + + g.It("PolarionID:21418-PolarionID:25679-[Skipped:Disconnected]Cluster resource created and deleted correctly [Serial]", g.Label("NonHyperShiftHOST"), func() { + architecture.SkipArchitectures(oc, architecture.PPC64LE, architecture.S390X, architecture.MULTI) + exutil.SkipBaselineCaps(oc, "None") + exutil.SkipNoCapabilities(oc, "marketplace") + exutil.SkipIfDisableDefaultCatalogsource(oc) + infra, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("infrastructures", "cluster", "-o=jsonpath={.status.infrastructureTopology}").Output() + o.Expect(err).NotTo(o.HaveOccurred()) + if infra == "SingleReplica" { + g.Skip("it is not supported") + } + exutil.SkipBaselineCaps(oc, "None") + platform := exutil.CheckPlatform(oc) + proxy, errProxy := oc.AsAdmin().WithoutNamespace().Run("get").Args("proxy", "cluster", "-o=jsonpath={.status.httpProxy}{.status.httpsProxy}").Output() + o.Expect(errProxy).NotTo(o.HaveOccurred()) + if proxy != "" || strings.Contains(platform, "openstack") || strings.Contains(platform, "baremetal") || strings.Contains(platform, "vsphere") || exutil.Is3MasterNoDedicatedWorkerNode(oc) || + os.Getenv("HTTP_PROXY") != "" || os.Getenv("HTTPS_PROXY") != "" || os.Getenv("http_proxy") != "" || os.Getenv("https_proxy") != "" { + g.Skip("it is not supported") + } + var ( + itName = g.CurrentSpecReport().FullText() + buildPruningBaseDir = exutil.FixturePath("testdata", "olm") + ogAllTemplate = filepath.Join(buildPruningBaseDir, "og-allns.yaml") + catsrcImageTemplate = filepath.Join(buildPruningBaseDir, "catalogsource-image.yaml") + subTemplate = filepath.Join(buildPruningBaseDir, "olm-subscription.yaml") + ogAll = olmv0util.OperatorGroupDescription{ + Name: "og-all", + Namespace: "", + Template: ogAllTemplate, + } + catsrc = olmv0util.CatalogSourceDescription{ + Name: "catsrc-operator", + Namespace: "", + DisplayName: "Test Catsrc Operators", + Publisher: "Red Hat", + SourceType: "grpc", + Address: "quay.io/olmqe/nginx-ok-index:vokv25679", + Template: catsrcImageTemplate, + } + sub = olmv0util.SubscriptionDescription{ + SubName: "nginx-ok-v25679", + Namespace: "", + Channel: "alpha", + IpApproval: "Automatic", + OperatorPackage: "nginx-ok-v25679", + CatalogSourceName: catsrc.Name, + CatalogSourceNamespace: "", + StartingCSV: "", + CurrentCSV: "", + InstalledCSV: "", + Template: subTemplate, + SingleNamespace: false, + } + crdName = "okv25679s.cache.example.com" + crName = "Okv25679" + podLabelName = "controller-manager" + cl = olmv0util.CheckList{} + ) + + // OCP-25679, OCP-21418 + g.By("Create og") + ns := oc.Namespace() + ogAll.Namespace = ns + ogAll.Create(oc, itName, dr) + + g.By("create catalog source") + catsrc.Namespace = ns + catsrc.CreateWithCheck(oc, itName, dr) + + g.By("Create operator targeted at all namespace") + sub.Namespace = ns + sub.CatalogSourceNamespace = catsrc.Namespace + sub.Create(oc, itName, dr) + + // OCP-25679, OCP-21418 + g.By("Check the cluster resource rolebinding, role and service account exists") + clusterResources := strings.Fields(olmv0util.GetResource(oc, exutil.AsAdmin, exutil.WithoutNamespace, "clusterrolebinding", + fmt.Sprintf("--selector=olm.owner=%s", sub.InstalledCSV), "-o=jsonpath={.items[0].metadata.name}{\" \"}{.items[0].roleRef.name}{\" \"}{.items[0].subjects[0].name}")) + o.Expect(clusterResources).NotTo(o.BeEmpty()) + cl.Add(olmv0util.NewCheck("present", exutil.AsAdmin, exutil.WithoutNamespace, exutil.Present, "", exutil.Ok, []string{"clusterrole", clusterResources[1]})) + cl.Add(olmv0util.NewCheck("present", exutil.AsAdmin, exutil.WithoutNamespace, exutil.Present, "", exutil.Ok, []string{"sa", clusterResources[2], "-n", sub.Namespace})) + + // OCP-21418 + g.By("Check the pods of the operator is running") + cl.Add(olmv0util.NewCheck("expect", exutil.AsAdmin, exutil.WithoutNamespace, exutil.Contain, "Running", exutil.Ok, []string{"pod", fmt.Sprintf("--selector=control-plane=%s", podLabelName), "-n", sub.Namespace, "-o=jsonpath={.items[*].status.phase}"})) + + // OCP-21418 + g.By("Check no resource of new crd") + cl.Add(olmv0util.NewCheck("present", exutil.AsAdmin, exutil.WithNamespace, exutil.NotPresent, "", exutil.Ok, []string{crName})) + //do check parallelly + cl.Check(oc) + cl.Empty() + + // OCP-25679, OCP-21418 + g.By("Delete the operator") + sub.Delete(itName, dr) + sub.GetCSV().Delete(itName, dr) + + // OCP-25679, OCP-21418 + g.By("Check the cluster resource rolebinding, role and service account do not exist") + cl.Add(olmv0util.NewCheck("present", exutil.AsAdmin, exutil.WithoutNamespace, exutil.NotPresent, "", exutil.Ok, []string{"clusterrolebinding", clusterResources[0]})) + cl.Add(olmv0util.NewCheck("present", exutil.AsAdmin, exutil.WithoutNamespace, exutil.NotPresent, "", exutil.Ok, []string{"clusterrole", clusterResources[1]})) + cl.Add(olmv0util.NewCheck("present", exutil.AsAdmin, exutil.WithoutNamespace, exutil.NotPresent, "", exutil.Ok, []string{"sa", clusterResources[2], "-n", sub.Namespace})) + + // OCP-21418 + g.By("Check the CRD still exists") + cl.Add(olmv0util.NewCheck("present", exutil.AsAdmin, exutil.WithoutNamespace, exutil.Present, "", exutil.Ok, []string{"crd", crdName})) + + // OCP-21418 + g.By("Check the pods of the operator is deleted") + cl.Add(olmv0util.NewCheck("expect", exutil.AsAdmin, exutil.WithoutNamespace, exutil.Compare, "", exutil.Ok, []string{"pod", fmt.Sprintf("--selector=control-plane=%s", podLabelName), "-n", sub.Namespace, "-o=jsonpath={.items[*].status.phase}"})) + + cl.Check(oc) + + }) + +}) diff --git a/tests-extension/test/qe/specs/olmv0.go b/tests-extension/test/qe/specs/olmv0_common.go similarity index 83% rename from tests-extension/test/qe/specs/olmv0.go rename to tests-extension/test/qe/specs/olmv0_common.go index 385b054e47..4ecdbff63f 100644 --- a/tests-extension/test/qe/specs/olmv0.go +++ b/tests-extension/test/qe/specs/olmv0_common.go @@ -2,9 +2,10 @@ package specs import ( "context" + "os/exec" + g "github.com/onsi/ginkgo/v2" o "github.com/onsi/gomega" - "os/exec" exutil "github.com/openshift/operator-framework-olm/tests-extension/test/qe/util" "github.com/openshift/operator-framework-olm/tests-extension/test/qe/util/olmv0util" @@ -16,6 +17,7 @@ var _ = g.Describe("[sig-operator][Jira:OLM] OLMv0", func() { }) }) +// it is mapping to the Describe "OLM for an end user handle common object" and "OLM for an end user use" in olm.go var _ = g.Describe("[sig-operator][Jira:OLM] OLMv0 should", func() { defer g.GinkgoRecover() @@ -58,4 +60,13 @@ var _ = g.Describe("[sig-operator][Jira:OLM] OLMv0 should", func() { "-o=jsonpath={.status.conditions[?(@.type==\"Available\")].status}{.status.conditions[?(@.type==\"Progressing\")].status}{.status.conditions[?(@.type==\"Degraded\")].status}"}).Check(oc) }) + g.It("PolarionID:73695-[Skipped:Disconnected]PO is disable", func() { + + if !exutil.IsTechPreviewNoUpgrade(oc) { + g.Skip("PO is supported in TP only currently, so skip it") + } + _, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("co", "platform-operators-aggregated").Output() + o.Expect(err).To(o.HaveOccurred(), "PO is not disable") + }) + }) diff --git a/tests-extension/test/qe/specs/olmv0_defaultoption.go b/tests-extension/test/qe/specs/olmv0_defaultoption.go new file mode 100644 index 0000000000..a05a387baf --- /dev/null +++ b/tests-extension/test/qe/specs/olmv0_defaultoption.go @@ -0,0 +1,46 @@ +package specs + +import ( + "path/filepath" + + g "github.com/onsi/ginkgo/v2" + + exutil "github.com/openshift/operator-framework-olm/tests-extension/test/qe/util" + "github.com/openshift/operator-framework-olm/tests-extension/test/qe/util/olmv0util" +) + +// it is mapping to the Describe "OLM should" and "OLM optional" in olm.go +var _ = g.Describe("[sig-operator][Jira:OLM] OLMv0 optional should", func() { + defer g.GinkgoRecover() + + var ( + oc = exutil.NewCLI("default-"+exutil.GetRandomString(), exutil.KubeConfigPath()) + ) + + g.BeforeEach(func() { + exutil.SkipMicroshift(oc) + exutil.SkipNoOLMCore(oc) + }) + + g.It("PolarionID:68679-[Skipped:Disconnected]catalogsource with invalid name is created", g.Label("NonHyperShiftHOST"), func() { + dr := make(olmv0util.DescriberResrouce) + itName := g.CurrentSpecReport().FullText() + dr.AddIr(itName) + + buildPruningBaseDir := exutil.FixturePath("testdata", "olm") + csImageTemplate := filepath.Join(buildPruningBaseDir, "catalogsource-opm.yaml") + + cs := olmv0util.CatalogSourceDescription{ + Name: "bug-68679-4.14", // the name contains "." + Namespace: oc.Namespace(), + DisplayName: "QE Operators", + Publisher: "QE", + SourceType: "grpc", + Address: "quay.io/olmqe/nginxolm-operator-index:v1", + Template: csImageTemplate, + } + defer cs.Delete(itName, dr) + cs.CreateWithCheck(oc, itName, dr) + }) + +}) diff --git a/tests-extension/test/qe/specs/olmv0_hypershiftmgmt.go b/tests-extension/test/qe/specs/olmv0_hypershiftmgmt.go new file mode 100644 index 0000000000..169dd4a6ef --- /dev/null +++ b/tests-extension/test/qe/specs/olmv0_hypershiftmgmt.go @@ -0,0 +1,109 @@ +package specs + +import ( + "context" + "path/filepath" + + g "github.com/onsi/ginkgo/v2" + o "github.com/onsi/gomega" + + exutil "github.com/openshift/operator-framework-olm/tests-extension/test/qe/util" + "github.com/openshift/operator-framework-olm/tests-extension/test/qe/util/olmv0util" + e2e "k8s.io/kubernetes/test/e2e/framework" +) + +// it is mapping to the Describe "OLM on hypershift" in olm.go +var _ = g.Describe("[sig-operator][Jira:OLM] OLMvo on hypershift mgmt", g.Label("NonHyperShiftHOST"), func() { + defer g.GinkgoRecover() + + var ( + oc = exutil.NewCLIForKubeOpenShift("hypershiftmgmt-" + exutil.GetRandomString()) + guestClusterName, guestClusterKube, hostedClusterNS string + isAKS bool + errIsAKS error + ) + + g.BeforeEach(func() { + exutil.SkipMicroshift(oc) + isAKS, errIsAKS = exutil.IsAKSCluster(context.TODO(), oc) + if errIsAKS != nil { + g.Skip("can not determine if it is openshift cluster or aks cluster") + } + if !isAKS { + exutil.SkipNoOLMCore(oc) + } + guestClusterName, guestClusterKube, hostedClusterNS = exutil.ValidHypershiftAndGetGuestKubeConf(oc) + e2e.Logf("%s, %s, %s", guestClusterName, guestClusterKube, hostedClusterNS) + oc.SetGuestKubeconf(guestClusterKube) + }) + + g.It("ROSA-OSD_CCS-HyperShiftMGMT-ConnectedOnly-Author:kuiwang-Medium-45381-Support custom catalogs in hypershift", func() { + var ( + itName = g.CurrentSpecReport().FullText() + buildPruningBaseDir = exutil.FixturePath("testdata", "olm") + ogSingleTemplate = filepath.Join(buildPruningBaseDir, "operatorgroup.yaml") + subTemplate = filepath.Join(buildPruningBaseDir, "olm-subscription.yaml") + catsrcImageTemplate = filepath.Join(buildPruningBaseDir, "catalogsource-image.yaml") + og = olmv0util.OperatorGroupDescription{ + Name: "og-singlenamespace", + Namespace: "", + Template: ogSingleTemplate, + } + catsrc = olmv0util.CatalogSourceDescription{ + Name: "catsrc-2378-operator", + Namespace: "", + DisplayName: "Test Catsrc 2378 Operators", + Publisher: "Red Hat", + SourceType: "grpc", + Address: "quay.io/olmqe/olm-index:OLM-2378-Oadp-GoodOne-multi", + Template: catsrcImageTemplate, + } + subOadp = olmv0util.SubscriptionDescription{ + SubName: "oadp-operator", + Namespace: "", + Channel: "alpha", + IpApproval: "Automatic", + OperatorPackage: "oadp-operator", + CatalogSourceName: catsrc.Name, + CatalogSourceNamespace: "", + StartingCSV: "oadp-operator.v0.5.3", + CurrentCSV: "", + InstalledCSV: "", + Template: subTemplate, + SingleNamespace: true, + } + dr = make(olmv0util.DescriberResrouce) + ) + + g.By("init resource") + dr.AddIr(itName) + ns := "guest-cluster-45381" + err := oc.AsGuestKubeconf().Run("create").Args("ns", ns).Execute() + o.Expect(err).NotTo(o.HaveOccurred()) + defer func() { + _ = oc.AsGuestKubeconf().Run("delete").Args("ns", ns).Execute() + }() + og.Namespace = ns + catsrc.Namespace = ns + subOadp.Namespace = ns + subOadp.CatalogSourceNamespace = catsrc.Namespace + + g.By("create catalog source") + defer catsrc.Delete(itName, dr) + catsrc.CreateWithCheck(oc.AsGuestKubeconf(), itName, dr) + + g.By("Create og") + defer og.Delete(itName, dr) + og.Create(oc.AsGuestKubeconf(), itName, dr) + + g.By("install OADP") + defer subOadp.Delete(itName, dr) + subOadp.Create(oc.AsGuestKubeconf(), itName, dr) + defer subOadp.DeleteCSV(itName, dr) + + g.By("Check the oadp-operator.v0.5.3 is installed successfully") + olmv0util.NewCheck("expect", exutil.AsAdmin, exutil.WithoutNamespace, exutil.Compare, "Succeeded", exutil.Ok, []string{"csv", subOadp.InstalledCSV, "-n", subOadp.Namespace, "-o=jsonpath={.status.phase}"}).Check(oc.AsGuestKubeconf()) + + }) + +}) diff --git a/tests-extension/test/qe/specs/olmv0_microshift.go b/tests-extension/test/qe/specs/olmv0_microshift.go new file mode 100644 index 0000000000..5b452b411b --- /dev/null +++ b/tests-extension/test/qe/specs/olmv0_microshift.go @@ -0,0 +1,324 @@ +package specs + +import ( + "context" + "fmt" + "path/filepath" + + g "github.com/onsi/ginkgo/v2" + o "github.com/onsi/gomega" + exutil "github.com/openshift/operator-framework-olm/tests-extension/test/qe/util" + "github.com/openshift/operator-framework-olm/tests-extension/test/qe/util/olmv0util" + + apierrors "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + e2e "k8s.io/kubernetes/test/e2e/framework" +) + +// it is mapping to olm_microshift.go +var _ = g.Describe("[sig-operator][Jira:OLM] OLMv0 on microshift", g.Label("NonHyperShiftHOST"), func() { + defer g.GinkgoRecover() + + var ( + oc = exutil.NewCLIWithoutNamespace("default") + + dr = make(olmv0util.DescriberResrouce) + ) + + g.BeforeEach(func() { + if !exutil.IsMicroshiftCluster(oc) { + g.Skip("it is not microshift, so skip it.") + } + + _, errCheckOlm := oc.AdminKubeClient().CoreV1().Namespaces().Get(context.Background(), + "openshift-operator-lifecycle-manager", metav1.GetOptions{}) + if errCheckOlm != nil { + if apierrors.IsNotFound(errCheckOlm) { + g.Skip("there is no olm installed on microshift, so skip it") + } else { + o.Expect(errCheckOlm).NotTo(o.HaveOccurred()) + } + } + dr.AddIr(g.CurrentSpecReport().FullText()) + + }) + + // author: kuiwang@redhat.com + g.It("PolarionID:69867-[Skipped:Disconnected]deployed in microshift and install one operator with single mode.", func() { + + var ( + itName = g.CurrentSpecReport().FullText() + namespace = "olm-mcroshift-69867" + buildPruningBaseDir = exutil.FixturePath("testdata", "olm", "microshift") + ogSingleTemplate = filepath.Join(buildPruningBaseDir, "og-single.yaml") + catsrcImageTemplate = filepath.Join(buildPruningBaseDir, "catalogsource-image-restricted.yaml") + subTemplate = filepath.Join(buildPruningBaseDir, "olm-subscription.yaml") + + og = olmv0util.OperatorGroupDescription{ + Name: "og-singlenamespace", + Namespace: namespace, + Template: ogSingleTemplate, + ClusterType: "microshift", + } + catsrc = olmv0util.CatalogSourceDescription{ + Name: "catalog", + Namespace: namespace, + DisplayName: "Test Catsrc Operators", + Publisher: "OLM QE", + SourceType: "grpc", + Address: "quay.io/olmqe/nginx-ok-index:v1399-fbc-multi", + Template: catsrcImageTemplate, + ClusterType: "microshift", + } + sub = olmv0util.SubscriptionDescription{ + SubName: "nginx-ok1-1399", + Namespace: namespace, + Channel: "alpha", + IpApproval: "Automatic", + OperatorPackage: "nginx-ok1-1399", + CatalogSourceName: catsrc.Name, + CatalogSourceNamespace: catsrc.Namespace, + StartingCSV: "", + CurrentCSV: "", + InstalledCSV: "", + Template: subTemplate, + SingleNamespace: true, + ClusterType: "microshift", + } + ) + + g.By("check olm related CRD") + output, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("crd").Output() + o.Expect(err).NotTo(o.HaveOccurred()) + o.Expect(output).To(o.And( + o.ContainSubstring("catalogsources.operators.coreos.com"), + o.ContainSubstring("clusterserviceversions.operators.coreos.com"), + o.ContainSubstring("installplans.operators.coreos.com"), + o.ContainSubstring("olmconfigs.operators.coreos.com"), + o.ContainSubstring("operatorconditions.operators.coreos.com"), + o.ContainSubstring("operatorgroups.operators.coreos.com"), + o.ContainSubstring("operators.operators.coreos.com"), + o.ContainSubstring("subscriptions.operators.coreos.com"), + ), "some CRDs do not exist") + + g.By("the olm and catalog pod is running") + output, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("pod", "-n", "openshift-operator-lifecycle-manager", + "-l", "app=olm-operator").Output() + o.Expect(err).NotTo(o.HaveOccurred()) + o.Expect(output).To(o.ContainSubstring("Running"), "olm pod is not running") + output, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("pod", "-n", "openshift-operator-lifecycle-manager", + "-l", "app=catalog-operator").Output() + o.Expect(err).NotTo(o.HaveOccurred()) + o.Expect(output).To(o.ContainSubstring("Running"), "catalog pod is not running") + + g.By("create namespace") + defer func() { + _ = oc.AsAdmin().WithoutNamespace().Run("delete").Args("namespace", namespace, "--ignore-not-found").Execute() + }() + err = oc.AsAdmin().WithoutNamespace().Run("create").Args("namespace", namespace).Execute() + o.Expect(err).NotTo(o.HaveOccurred(), fmt.Sprintf("Failed to create namespace/%s", namespace)) + + g.By("Create opertor group") + defer og.Delete(itName, dr) + og.Create(oc, itName, dr) + + g.By("Create catalog") + defer catsrc.Delete(itName, dr) + catsrc.CreateWithCheck(oc, itName, dr) + + g.By("install operator") + defer sub.DeleteCSV(itName, dr) + defer sub.Delete(itName, dr) + sub.Create(oc, itName, dr) + olmv0util.NewCheck("expect", exutil.AsAdmin, exutil.WithoutNamespace, exutil.Compare, "Succeeded+2+Installing-TIME-WAIT-300s", exutil.Ok, []string{"csv", sub.InstalledCSV, "-n", namespace, "-o=jsonpath={.status.phase}"}).Check(oc) + + g.By("check operator") + output, err = oc.AsAdmin().WithoutNamespace().Run("get").Args("operators.operators.coreos.com", + sub.OperatorPackage+"."+namespace, "-o=jsonpath={.status}").Output() + o.Expect(err).NotTo(o.HaveOccurred()) + o.Expect(output).To(o.And( + o.ContainSubstring("ClusterRole"), + o.ContainSubstring("ClusterRoleBinding"), + o.ContainSubstring("ClusterServiceVersion"), + o.ContainSubstring("CustomResourceDefinition"), + o.ContainSubstring("Deployment"), + o.ContainSubstring("OperatorCondition"), + o.ContainSubstring("Subscription"), + ), "some resources do not exist") + + }) + // author: kuiwang@redhat.com + g.It("PolarionID:69868-[Skipped:Disconnected]olm microshift install operator with all mode, muilt og error and delete one og to get it installed.", func() { + + var ( + itName = g.CurrentSpecReport().FullText() + namespace = "openshift-operators" + buildPruningBaseDir = exutil.FixturePath("testdata", "olm", "microshift") + ogAllTemplate = filepath.Join(buildPruningBaseDir, "og-all.yaml") + catsrcImageTemplate = filepath.Join(buildPruningBaseDir, "catalogsource-image-restricted.yaml") + subTemplate = filepath.Join(buildPruningBaseDir, "olm-subscription.yaml") + + og = olmv0util.OperatorGroupDescription{ + Name: "og-all", + Namespace: namespace, + Template: ogAllTemplate, + ClusterType: "microshift", + } + catsrc = olmv0util.CatalogSourceDescription{ + Name: "catalog-all", + Namespace: "openshift-marketplace", + DisplayName: "Test Catsrc Operators", + Publisher: "OLM QE", + SourceType: "grpc", + Address: "quay.io/olmqe/nginx-ok-index:v1399-fbc-multi", + Template: catsrcImageTemplate, + ClusterType: "microshift", + } + sub = olmv0util.SubscriptionDescription{ + SubName: "nginx-ok2-1399", + Namespace: namespace, + Channel: "alpha", + IpApproval: "Automatic", + OperatorPackage: "nginx-ok2-1399", + CatalogSourceName: catsrc.Name, + CatalogSourceNamespace: catsrc.Namespace, + StartingCSV: "", + CurrentCSV: "", + InstalledCSV: "", + Template: subTemplate, + SingleNamespace: false, + ClusterType: "microshift", + } + ) + + g.By("check og in openshift-operators already") + output, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("og", "global-operators", "-n", namespace).Output() + o.Expect(err).NotTo(o.HaveOccurred()) + e2e.Logf("it is \n: %v", output) + + g.By("Create opertor group") + defer og.Delete(itName, dr) + og.Create(oc, itName, dr) + + g.By("Create catalog") + defer catsrc.Delete(itName, dr) + catsrc.CreateWithCheck(oc, itName, dr) + + g.By("install operator with multi og") + defer sub.DeleteCSV(itName, dr) + defer sub.Delete(itName, dr) + sub.CreateWithoutCheck(oc, itName, dr) + olmv0util.NewCheck("expect", exutil.AsAdmin, exutil.WithoutNamespace, exutil.Compare, "", exutil.Ok, []string{"sub", sub.SubName, "-n", namespace, "-o=jsonpath={.status.installedCSV}"}).Check(oc) + olmv0util.NewCheck("expect", exutil.AsAdmin, exutil.WithoutNamespace, exutil.Contain, "MultipleOperatorGroupsFound", exutil.Ok, []string{"og", og.Name, "-n", namespace, "-o=jsonpath={.status}"}).Check(oc) + + g.By("delete more og") + og.Delete(itName, dr) + + g.By("operator is installed") + sub.FindInstalledCSV(oc, itName, dr) + olmv0util.NewCheck("expect", exutil.AsAdmin, exutil.WithoutNamespace, exutil.Contain, sub.InstalledCSV, exutil.Ok, []string{"csv", "-n", "default"}).Check(oc) + + }) + + // author: kuiwang@redhat.com + g.It("PolarionID:83581-[Skipped:Disconnected]olmv0 networkpolicy on microshift.", func() { + + policies := []olmv0util.NpExpecter{ + { + Name: "catalog-operator", + Namespace: "openshift-operator-lifecycle-manager", + ExpectIngress: []olmv0util.IngressRule{ + { + Ports: []olmv0util.Port{{Port: "metrics", Protocol: "TCP"}}, + Selectors: nil, + }, + }, + ExpectEgress: []olmv0util.EgressRule{ + { + Ports: []olmv0util.Port{{Port: 6443, Protocol: "TCP"}}, + Selectors: nil, + }, + { + Ports: []olmv0util.Port{{Port: "dns-tcp", Protocol: "TCP"}, {Port: "dns", Protocol: "UDP"}}, + Selectors: []olmv0util.Selector{ + {NamespaceLabels: map[string]string{"kubernetes.io/metadata.name": "openshift-dns"}}, + }, + }, + { + Ports: []olmv0util.Port{{Port: 50051, Protocol: "TCP"}}, + Selectors: nil, + }, + }, + ExpectSelector: map[string]string{"app": "catalog-operator"}, + ExpectPolicyTypes: []string{"Ingress", "Egress"}, + }, + { + Name: "default-deny-all-traffic", + Namespace: "openshift-operator-lifecycle-manager", + ExpectIngress: nil, + ExpectEgress: nil, + ExpectSelector: map[string]string{}, + ExpectPolicyTypes: []string{"Ingress", "Egress"}, + }, + { + Name: "olm-operator", + Namespace: "openshift-operator-lifecycle-manager", + ExpectIngress: []olmv0util.IngressRule{ + { + Ports: []olmv0util.Port{{Port: "metrics", Protocol: "TCP"}}, + Selectors: nil, + }, + }, + ExpectEgress: []olmv0util.EgressRule{ + { + Ports: []olmv0util.Port{{Port: 6443, Protocol: "TCP"}}, + Selectors: nil, + }, + { + Ports: []olmv0util.Port{{Port: "dns-tcp", Protocol: "TCP"}, {Port: "dns", Protocol: "UDP"}}, + Selectors: []olmv0util.Selector{ + {NamespaceLabels: map[string]string{"kubernetes.io/metadata.name": "openshift-dns"}}, + }, + }, + }, + ExpectSelector: map[string]string{"app": "olm-operator"}, + ExpectPolicyTypes: []string{"Ingress", "Egress"}, + }, + { + Name: "default-allow-all", + Namespace: "openshift-operators", + ExpectIngress: []olmv0util.IngressRule{ + { + Ports: []olmv0util.Port{{Port: nil, Protocol: ""}}, + Selectors: nil, + }, + }, + ExpectEgress: []olmv0util.EgressRule{ + { + Ports: []olmv0util.Port{{Port: nil, Protocol: ""}}, + Selectors: nil, + }, + }, + ExpectSelector: map[string]string{}, + ExpectPolicyTypes: []string{"Ingress", "Egress"}, + }, + // after https://issues.redhat.com/browse/OCPBUGS-59566 is fixed, more checkers are added here + } + + for _, policy := range policies { + + g.By(fmt.Sprintf("Checking NP %s in %s", policy.Name, policy.Namespace)) + specs, err := oc.AsAdmin().WithoutNamespace(). + Run("get").Args("networkpolicy", policy.Name, "-n", policy.Namespace, "-o=jsonpath={.spec}").Output() + o.Expect(err).NotTo(o.HaveOccurred()) + o.Expect(specs).NotTo(o.BeEmpty()) + e2e.Logf("specs: %v", specs) + + olmv0util.VerifySelector(specs, policy.ExpectSelector, policy.Name) + olmv0util.VerifyPolicyTypes(specs, policy.ExpectPolicyTypes, policy.Name) + olmv0util.VerifyIngress(specs, policy.ExpectIngress, policy.Name) + olmv0util.VerifyEgress(specs, policy.ExpectEgress, policy.Name) + } + + }) +}) diff --git a/tests-extension/test/qe/specs/olmv0_multins.go b/tests-extension/test/qe/specs/olmv0_multins.go new file mode 100644 index 0000000000..ccf2ee4538 --- /dev/null +++ b/tests-extension/test/qe/specs/olmv0_multins.go @@ -0,0 +1,113 @@ +package specs + +import ( + "path/filepath" + + g "github.com/onsi/ginkgo/v2" + + exutil "github.com/openshift/operator-framework-olm/tests-extension/test/qe/util" + "github.com/openshift/operator-framework-olm/tests-extension/test/qe/util/olmv0util" +) + +// it is mapping to the Describe "OLM for an end user handle to support" in olm.go +var _ = g.Describe("[sig-operator][Jira:OLM] OLMv0 with multi ns", func() { + defer g.GinkgoRecover() + + var ( + oc = exutil.NewCLI("olm-multi-"+exutil.GetRandomString(), exutil.KubeConfigPath()) + + dr = make(olmv0util.DescriberResrouce) + ) + + g.BeforeEach(func() { + exutil.SkipMicroshift(oc) + + exutil.SkipNoOLMCore(oc) + itName := g.CurrentSpecReport().FullText() + dr.AddIr(itName) + }) + + g.AfterEach(func() {}) + + g.It("PolarionID:22226-[Skipped:Disconnected]the csv without support MultiNamespace fails for og with MultiNamespace", func() { + var ( + buildPruningBaseDir = exutil.FixturePath("testdata", "olm") + cmNcTemplate = filepath.Join(buildPruningBaseDir, "cm-namespaceconfig.yaml") + catsrcCmTemplate = filepath.Join(buildPruningBaseDir, "catalogsource-configmap.yaml") + ogMultiTemplate = filepath.Join(buildPruningBaseDir, "og-multins.yaml") + subTemplate = filepath.Join(buildPruningBaseDir, "olm-subscription.yaml") + itName = g.CurrentSpecReport().FullText() + og = olmv0util.OperatorGroupDescription{ + Name: "og-multinamespace", + Namespace: "", + Multinslabel: "olmtestmultins", + Template: ogMultiTemplate, + } + cm = olmv0util.ConfigMapDescription{ + Name: "cm-community-namespaceconfig-operators", + Namespace: "", //must be set in iT + Template: cmNcTemplate, + } + catsrc = olmv0util.CatalogSourceDescription{ + Name: "catsrc-community-namespaceconfig-operators", + Namespace: "", //must be set in iT + DisplayName: "Community namespaceconfig Operators", + Publisher: "Community", + SourceType: "configmap", + Address: "cm-community-namespaceconfig-operators", + Template: catsrcCmTemplate, + } + sub = olmv0util.SubscriptionDescription{ + SubName: "namespace-configuration-operator", + Namespace: "", //must be set in iT + Channel: "alpha", + IpApproval: "Automatic", + OperatorPackage: "namespace-configuration-operator", + CatalogSourceName: "catsrc-community-namespaceconfig-operators", + CatalogSourceNamespace: "", //must be set in iT + StartingCSV: "", + CurrentCSV: "namespace-configuration-operator.v0.1.0", //it matches to that in cm, so set it. + InstalledCSV: "", + Template: subTemplate, + SingleNamespace: true, + } + p1 = olmv0util.ProjectDescription{ + Name: "olm-enduser-multins-csv-1-fail", + TargetNamespace: "", + } + p2 = olmv0util.ProjectDescription{ + Name: "olm-enduser-multins-csv-2-fail", + TargetNamespace: "", + } + ) + + defer p1.Delete(oc) + defer p2.Delete(oc) + cm.Namespace = oc.Namespace() + catsrc.Namespace = oc.Namespace() + sub.Namespace = oc.Namespace() + sub.CatalogSourceNamespace = catsrc.Namespace + og.Namespace = oc.Namespace() + p1.TargetNamespace = oc.Namespace() + p2.TargetNamespace = oc.Namespace() + g.By("Create new project") + p1.Create(oc, itName, dr) + p1.Label(oc, "olmtestmultins") + p2.Create(oc, itName, dr) + p2.Label(oc, "olmtestmultins") + + g.By("Create cm") + cm.Create(oc, itName, dr) + + g.By("Create catalog source") + catsrc.Create(oc, itName, dr) + + g.By("Create og") + og.Create(oc, itName, dr) + + g.By("Create sub") + sub.Create(oc, itName, dr) + olmv0util.NewCheck("expect", exutil.AsAdmin, exutil.WithoutNamespace, exutil.Contain, "MultiNamespace InstallModeType not supported", exutil.Ok, []string{"csv", sub.InstalledCSV, "-n", sub.Namespace, "-o=jsonpath={.status.message}"}).Check(oc) + }) + +}) diff --git a/tests-extension/test/qe/specs/olmv0_nonallns.go b/tests-extension/test/qe/specs/olmv0_nonallns.go new file mode 100644 index 0000000000..869f8d65eb --- /dev/null +++ b/tests-extension/test/qe/specs/olmv0_nonallns.go @@ -0,0 +1,247 @@ +package specs + +import ( + "path/filepath" + "strings" + + g "github.com/onsi/ginkgo/v2" + o "github.com/onsi/gomega" + + exutil "github.com/openshift/operator-framework-olm/tests-extension/test/qe/util" + "github.com/openshift/operator-framework-olm/tests-extension/test/qe/util/architecture" + "github.com/openshift/operator-framework-olm/tests-extension/test/qe/util/olmv0util" +) + +// it is mapping to the Describe "OLM for an end user handle within a namespace" in olm.go +var _ = g.Describe("[sig-operator][Jira:OLM] OLMv0 within a namespace", func() { + defer g.GinkgoRecover() + + var ( + oc = exutil.NewCLI("olm-a-"+exutil.GetRandomString(), exutil.KubeConfigPath()) + + dr = make(olmv0util.DescriberResrouce) + ) + + g.BeforeEach(func() { + exutil.SkipMicroshift(oc) + exutil.SkipNoOLMCore(oc) + itName := g.CurrentSpecReport().FullText() + dr.AddIr(itName) + }) + + g.AfterEach(func() { + itName := g.CurrentSpecReport().FullText() + dr.GetIr(itName).Cleanup() + dr.RmIr(itName) + }) + + g.It("PolarionID:24870-[Skipped:Disconnected]can not create csv without operator group", func() { + architecture.SkipNonAmd64SingleArch(oc) + var ( + itName = g.CurrentSpecReport().FullText() + buildPruningBaseDir = exutil.FixturePath("testdata", "olm") + ogSingleTemplate = filepath.Join(buildPruningBaseDir, "operatorgroup.yaml") + catsrcImageTemplate = filepath.Join(buildPruningBaseDir, "catalogsource-image.yaml") + subTemplate = filepath.Join(buildPruningBaseDir, "olm-subscription.yaml") + + og = olmv0util.OperatorGroupDescription{ + Name: "og-singlenamespace", + Namespace: "", + Template: ogSingleTemplate, + } + catsrc = olmv0util.CatalogSourceDescription{ + Name: "catsrc-operator", + Namespace: "", + DisplayName: "Test Catsrc Operators", + Publisher: "Red Hat", + SourceType: "grpc", + Address: "quay.io/olmqe/olm-index:OLM-2378-Oadp-GoodOne-withCache", + Template: catsrcImageTemplate, + } + sub = olmv0util.SubscriptionDescription{ + SubName: "oadp-operator", + Namespace: "", + Channel: "alpha", + IpApproval: "Automatic", + OperatorPackage: "oadp-operator", + CatalogSourceName: catsrc.Name, + CatalogSourceNamespace: "", + StartingCSV: "", + CurrentCSV: "", + InstalledCSV: "", + Template: subTemplate, + SingleNamespace: true, + } + ) + og.Namespace = oc.Namespace() + sub.Namespace = oc.Namespace() + catsrc.Namespace = oc.Namespace() + sub.CatalogSourceNamespace = catsrc.Namespace + + g.By("create catalog source") + catsrc.CreateWithCheck(oc, itName, dr) + + g.By("Create csv with failure because of no operator group") + sub.CurrentCSV = "oadp-operator.v0.5.3" + sub.CreateWithoutCheck(oc, itName, dr) + olmv0util.NewCheck("present", exutil.AsUser, exutil.WithNamespace, exutil.NotPresent, "", exutil.Ok, []string{"csv", sub.CurrentCSV}).Check(oc) + sub.Delete(itName, dr) + + g.By("Create opertor group and then csv is created with success") + og.Create(oc, itName, dr) + sub.Create(oc, itName, dr) + olmv0util.NewCheck("expect", exutil.AsUser, exutil.WithNamespace, exutil.Compare, "Succeeded"+"InstallSucceeded", exutil.Ok, []string{"csv", sub.InstalledCSV, "-o=jsonpath={.status.phase}{.status.reason}"}).Check(oc) + }) + + g.It("PolarionID:37263-[Skipped:Disconnected][Skipped:Proxy]Subscription stays in UpgradePending but InstallPlan not installing [Slow]", func() { + architecture.SkipNonAmd64SingleArch(oc) + exutil.SkipBaselineCaps(oc, "None") + exutil.SkipForSNOCluster(oc) + platform := exutil.CheckPlatform(oc) + if strings.Contains(platform, "openstack") || strings.Contains(platform, "baremetal") || strings.Contains(platform, "vsphere") || strings.Contains(platform, "none") || exutil.Is3MasterNoDedicatedWorkerNode(oc) { + g.Skip("it is not supported") + } + var ( + itName = g.CurrentSpecReport().FullText() + buildPruningBaseDir = exutil.FixturePath("testdata", "olm") + ogSingleTemplate = filepath.Join(buildPruningBaseDir, "operatorgroup.yaml") + catsrcImageTemplate = filepath.Join(buildPruningBaseDir, "catalogsource-image-extract.yaml") + subTemplate = filepath.Join(buildPruningBaseDir, "olm-subscription.yaml") + og = olmv0util.OperatorGroupDescription{ + Name: "og-singlenamespace", + Namespace: "", + Template: ogSingleTemplate, + } + catsrc = olmv0util.CatalogSourceDescription{ + Name: "olm-1860185-catalog", + Namespace: "", + DisplayName: "OLM 1860185 Catalog", + Publisher: "QE", + SourceType: "grpc", + Address: "quay.io/olmqe/nginx-ok-index:vokv37263", + Template: catsrcImageTemplate, + } + catsrc1 = olmv0util.CatalogSourceDescription{ + Name: "catsrc-operator", + Namespace: "", + DisplayName: "Test Catsrc Operators", + Publisher: "Red Hat", + SourceType: "grpc", + Address: "quay.io/olmqe/olm-index:OLM-2378-Oadp-GoodOne-withCache", + Template: catsrcImageTemplate, + } + catsrc2 = olmv0util.CatalogSourceDescription{ + Name: "catsrc-nginx-operator", + Namespace: "", + DisplayName: "Test Catsrc Operators", + Publisher: "Red Hat", + SourceType: "grpc", + Address: "quay.io/olmqe/nginx-ok-index:v1399-fbc", + Template: catsrcImageTemplate, + } + subStrimzi = olmv0util.SubscriptionDescription{ + SubName: "nginx-ok-v37263", + Namespace: "", + Channel: "alpha", + IpApproval: "Automatic", + OperatorPackage: "nginx-ok-v37263", + CatalogSourceName: catsrc.Name, + CatalogSourceNamespace: "", + StartingCSV: "", + CurrentCSV: "", + InstalledCSV: "", + Template: subTemplate, + SingleNamespace: true, + } + subBuildv2 = olmv0util.SubscriptionDescription{ + SubName: "nginx-ok1-1399", + Namespace: "", + Channel: "alpha", + IpApproval: "Automatic", + OperatorPackage: "nginx-ok1-1399", + CatalogSourceName: catsrc2.Name, + CatalogSourceNamespace: "", + StartingCSV: "nginx-ok1-1399.v0.0.4", + CurrentCSV: "", + InstalledCSV: "", + Template: subTemplate, + SingleNamespace: true, + } + subMta = olmv0util.SubscriptionDescription{ + SubName: "oadp-operator", + Namespace: "", + Channel: "alpha", + IpApproval: "Automatic", + OperatorPackage: "oadp-operator", + CatalogSourceName: catsrc1.Name, + CatalogSourceNamespace: "", + StartingCSV: "", + CurrentCSV: "", + InstalledCSV: "", + Template: subTemplate, + SingleNamespace: true, + } + ) + oc.SetupProject() // project and its resource are deleted automatically when out of It, so no need derfer or AfterEach + og.Namespace = oc.Namespace() + catsrc.Namespace = oc.Namespace() + catsrc1.Namespace = oc.Namespace() + catsrc2.Namespace = oc.Namespace() + subStrimzi.Namespace = oc.Namespace() + subStrimzi.CatalogSourceNamespace = catsrc.Namespace + subBuildv2.Namespace = oc.Namespace() + subBuildv2.CatalogSourceNamespace = catsrc2.Namespace + subMta.Namespace = oc.Namespace() + subMta.CatalogSourceNamespace = catsrc1.Namespace + + g.By("create catalog source") + catsrc.CreateWithCheck(oc, itName, dr) + catsrc1.CreateWithCheck(oc, itName, dr) + catsrc2.CreateWithCheck(oc, itName, dr) + + g.By("Create og") + og.Create(oc, itName, dr) + + g.By("install Strimzi") + subStrimzi.Create(oc, itName, dr) + + g.By("check if Strimzi is installed") + olmv0util.NewCheck("expect", exutil.AsAdmin, exutil.WithoutNamespace, exutil.Compare, "Succeeded", exutil.Ok, []string{"csv", subStrimzi.InstalledCSV, "-n", subStrimzi.Namespace, "-o=jsonpath={.status.phase}"}).Check(oc) + + g.By("install Portworx") + subMta.Create(oc, itName, dr) + + g.By("check if Portworx is installed") + olmv0util.NewCheck("expect", exutil.AsAdmin, exutil.WithoutNamespace, exutil.Compare, "Succeeded", exutil.Ok, []string{"csv", subMta.InstalledCSV, "-n", subMta.Namespace, "-o=jsonpath={.status.phase}"}).Check(oc) + + g.By("get IP of Portworx") + mtaIP := subMta.GetIP(oc) + + g.By("Delete Portworx sub") + subMta.Delete(itName, dr) + + g.By("check if Portworx sub is Deleted") + olmv0util.NewCheck("present", exutil.AsAdmin, exutil.WithoutNamespace, exutil.NotPresent, "", exutil.Ok, []string{"sub", subMta.SubName, "-n", subMta.Namespace}).Check(oc) + + g.By("Delete Portworx csv") + csvPortworx := olmv0util.CsvDescription{ + Name: subMta.InstalledCSV, + Namespace: subMta.Namespace, + } + csvPortworx.Delete(itName, dr) + + g.By("check if Portworx csv is Deleted") + olmv0util.NewCheck("present", exutil.AsAdmin, exutil.WithoutNamespace, exutil.NotPresent, "", exutil.Ok, []string{"csv", subMta.InstalledCSV, "-n", subMta.Namespace}).Check(oc) + + g.By("install Couchbase") + subBuildv2.Create(oc, itName, dr) + + g.By("get IP of Couchbase") + couchbaseIP := subBuildv2.GetIP(oc) + + g.By("it takes different IP") + o.Expect(couchbaseIP).NotTo(o.Equal(mtaIP)) + + }) + +}) diff --git a/tests-extension/test/qe/util/filters/filters.go b/tests-extension/test/qe/util/filters/filters.go index 5a29c5bdf4..238de63ae1 100644 --- a/tests-extension/test/qe/util/filters/filters.go +++ b/tests-extension/test/qe/util/filters/filters.go @@ -30,6 +30,7 @@ func BasedStandardTests(filter string) string { standardFilter := `(!labels.exists(l, l=="Extended")) || (labels.exists(l, l=="Extended") && labels.exists(l, l=="ReleaseGate"))` return buildFilter(standardFilter, filter) } + // BasedExtendedTests generates a qualifier for all extended tests. // Includes: all tests marked with "Extended" label. // Additional filter can be applied to further narrow the selection. @@ -37,6 +38,7 @@ func BasedExtendedTests(filter string) string { extendedFilter := `labels.exists(l, l=="Extended")` return buildFilter(extendedFilter, filter) } + // BasedExtendedReleaseGateTests generates a qualifier for extended release gate tests. // Includes: Extended tests that are also marked as ReleaseGate. // Additional filter can be applied to further narrow the selection. @@ -44,6 +46,7 @@ func BasedExtendedReleaseGateTests(filter string) string { extendedReleaseGateFilter := `labels.exists(l, l=="Extended") && labels.exists(l, l=="ReleaseGate")` return buildFilter(extendedReleaseGateFilter, filter) } + // BasedExtendedCandidateTests generates a qualifier for extended candidate tests. // Includes: Extended tests that are NOT marked as ReleaseGate. // Additional filter can be applied to further narrow the selection. @@ -51,6 +54,7 @@ func BasedExtendedCandidateTests(filter string) string { extendedCandidateFilter := `labels.exists(l, l=="Extended") && !labels.exists(l, l=="ReleaseGate")` return buildFilter(extendedCandidateFilter, filter) } + // BasedExtendedCandidateFuncTests generates a qualifier for extended candidate functional tests. // Includes: Extended tests that are NOT ReleaseGate and NOT StressTest. // Additional filter can be applied to further narrow the selection. diff --git a/tests-extension/test/qe/util/hypeshift.go b/tests-extension/test/qe/util/hypeshift.go index 0110a19d77..ba0ff39f90 100644 --- a/tests-extension/test/qe/util/hypeshift.go +++ b/tests-extension/test/qe/util/hypeshift.go @@ -48,12 +48,12 @@ const ( func ValidHypershiftAndGetGuestKubeConf(oc *CLI) (string, string, string) { operatorNS := GetHyperShiftOperatorNameSpace(oc) if len(operatorNS) <= 0 { - g.Skip("there is no hypershift operator on host cluster, skip test run") + g.Skip("there is no hypershift operator on host cluster, so it is not hypershift mgmt cluster and skip test run") } hostedclusterNS := GetHyperShiftHostedClusterNameSpace(oc) if len(hostedclusterNS) <= 0 { - g.Skip("there is no hosted cluster NS in mgmt cluster, skip test run") + g.Skip("there is no hosted cluster NS in mgmt cluster, so it is not hypershift mgmt cluster and skip test run") } clusterNames, err := oc.AsAdmin().WithoutNamespace().Run("get").Args( @@ -79,6 +79,12 @@ func ValidHypershiftAndGetGuestKubeConf(oc *CLI) (string, string, string) { hostedClusterKubeconfigFile = os.Getenv("GUEST_KUBECONFIG") e2e.Logf("use a known hosted cluster kubeconfig: %v", hostedClusterKubeconfigFile) } else { + // Check if hypershift command is available + _, err := exec.LookPath("hypershift") + if err != nil { + g.Skip("hypershift command not found in PATH, cannot create kubeconfig for hosted cluster") + } + hostedClusterKubeconfigFile = "/tmp/guestcluster-kubeconfig-" + clusterName + "-" + GetRandomString() output, err := exec.Command("bash", "-c", fmt.Sprintf("hypershift create kubeconfig --name %s --namespace %s > %s", clusterName, hostedclusterNS, hostedClusterKubeconfigFile)).Output() @@ -129,6 +135,12 @@ func ValidHypershiftAndGetGuestKubeConfWithNoSkip(oc *CLI) (string, string, stri hostedClusterKubeconfigFile = os.Getenv("GUEST_KUBECONFIG") e2e.Logf("use a known hosted cluster kubeconfig: %v", hostedClusterKubeconfigFile) } else { + // Check if hypershift command is available + _, err := exec.LookPath("hypershift") + if err != nil { + return "", "", "" + } + hostedClusterKubeconfigFile = "/tmp/guestcluster-kubeconfig-" + clusterName + "-" + GetRandomString() output, err := exec.Command("bash", "-c", fmt.Sprintf("hypershift create kubeconfig --name %s --namespace %s > %s", clusterName, hostedclusterNS, hostedClusterKubeconfigFile)).Output()