From 9992d0d083ad2498b5a95a86593d79bdda91525a Mon Sep 17 00:00:00 2001 From: Jonathan West Date: Thu, 15 Oct 2026 23:36:40 -0400 Subject: [PATCH] chore: remove duplicate sequential tests Signed-off-by: Jonathan West --- .../1-002-validate_backend_service_test.go | 34 +++++ ...lidate_backend_service_permissions_test.go | 64 -------- ...lidate_terminating_namespace_block_test.go | 141 ------------------ ...-111_validate_default_argocd_route_test.go | 99 ------------ 4 files changed, 34 insertions(+), 304 deletions(-) delete mode 100644 test/openshift/e2e/ginkgo/parallel/1-026-validate_backend_service_permissions_test.go delete mode 100644 test/openshift/e2e/ginkgo/sequential/1-074_validate_terminating_namespace_block_test.go delete mode 100644 test/openshift/e2e/ginkgo/sequential/1-111_validate_default_argocd_route_test.go diff --git a/test/openshift/e2e/ginkgo/parallel/1-002-validate_backend_service_test.go b/test/openshift/e2e/ginkgo/parallel/1-002-validate_backend_service_test.go index 21ed1f1de79..eef8d8159db 100644 --- a/test/openshift/e2e/ginkgo/parallel/1-002-validate_backend_service_test.go +++ b/test/openshift/e2e/ginkgo/parallel/1-002-validate_backend_service_test.go @@ -8,6 +8,7 @@ import ( k8sFixture "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture/k8s" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" + rbacv1 "k8s.io/api/rbac/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -29,9 +30,42 @@ var _ = Describe("GitOps Operator Parallel E2E Tests", func() { Eventually(depl).Should(k8sFixture.ExistByName()) Eventually(depl, "60s", "3s").Should(deploymentFixture.HaveReplicas(1)) Eventually(depl, "60s", "3s").Should(deploymentFixture.HaveReadyReplicas(1)) + Expect(depl.Spec.Template.Spec.ServiceAccountName).To(Equal("gitops-service-cluster")) + Expect(depl.Spec.Template.Spec.DeprecatedServiceAccount).To(Equal("gitops-service-cluster")) By("checking Service for cluster exists") Eventually(&corev1.Service{ObjectMeta: metav1.ObjectMeta{Name: "cluster", Namespace: "openshift-gitops"}}, "60s", "5s").Should(k8sFixture.ExistByName()) + + By("checking the cluster ServiceAccount, ClusterRole, and ClusterRoleBinding have the expected values") + Eventually(&corev1.ServiceAccount{ObjectMeta: metav1.ObjectMeta{Name: "gitops-service-cluster", Namespace: "openshift-gitops"}}).Should(k8sFixture.ExistByName()) + + cr := &rbacv1.ClusterRole{ObjectMeta: metav1.ObjectMeta{Name: "gitops-service-cluster"}} + Eventually(cr).Should(k8sFixture.ExistByName()) + Expect(cr.Rules).To(Equal([]rbacv1.PolicyRule{ + { + APIGroups: []string{"argoproj.io"}, + Resources: []string{"applications"}, + Verbs: []string{"get", "list", "watch"}, + }, + { + APIGroups: []string{""}, + Resources: []string{"secrets"}, + Verbs: []string{"get", "list", "watch"}, + }, + })) + + crb := &rbacv1.ClusterRoleBinding{ObjectMeta: metav1.ObjectMeta{Name: "gitops-service-cluster"}} + Eventually(crb).Should(k8sFixture.ExistByName()) + Expect(crb.RoleRef).To(Equal(rbacv1.RoleRef{ + APIGroup: "rbac.authorization.k8s.io", + Kind: "ClusterRole", + Name: "gitops-service-cluster", + })) + Expect(crb.Subjects).To(Equal([]rbacv1.Subject{{ + Kind: "ServiceAccount", + Name: "gitops-service-cluster", + Namespace: "openshift-gitops"}, + })) }) }) }) diff --git a/test/openshift/e2e/ginkgo/parallel/1-026-validate_backend_service_permissions_test.go b/test/openshift/e2e/ginkgo/parallel/1-026-validate_backend_service_permissions_test.go deleted file mode 100644 index 7c9dd825408..00000000000 --- a/test/openshift/e2e/ginkgo/parallel/1-026-validate_backend_service_permissions_test.go +++ /dev/null @@ -1,64 +0,0 @@ -package parallel - -import ( - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture" - k8sFixture "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture/k8s" - appsv1 "k8s.io/api/apps/v1" - corev1 "k8s.io/api/core/v1" - rbacv1 "k8s.io/api/rbac/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -var _ = Describe("GitOps Operator Parallel E2E Tests", func() { - - Context("1-026-validate_backend_service_permissions", func() { - // TODO: check if this test can use a new ArgoCD instance instead of the default openshift-gitops instance - - BeforeEach(func() { - fixture.EnsureParallelCleanSlate() - }) - - It("validates backend service permissions", Label("openshift"), func() { - - By("verifying that various backend-related resources exist and have the expected values") - - depl := &appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{Name: "cluster", Namespace: "openshift-gitops"}} - Eventually(depl).Should(k8sFixture.ExistByName()) - Expect(depl.Spec.Template.Spec.ServiceAccountName).To(Equal("gitops-service-cluster")) - Expect(depl.Spec.Template.Spec.DeprecatedServiceAccount).To(Equal("gitops-service-cluster")) - - Eventually(&corev1.ServiceAccount{ObjectMeta: metav1.ObjectMeta{Name: "gitops-service-cluster", Namespace: "openshift-gitops"}}).Should(k8sFixture.ExistByName()) - - cr := &rbacv1.ClusterRole{ObjectMeta: metav1.ObjectMeta{Name: "gitops-service-cluster"}} - Eventually(cr).Should(k8sFixture.ExistByName()) - Expect(cr.Rules).To(Equal([]rbacv1.PolicyRule{ - { - APIGroups: []string{"argoproj.io"}, - Resources: []string{"applications"}, - Verbs: []string{"get", "list", "watch"}, - }, - { - APIGroups: []string{""}, - Resources: []string{"secrets"}, - Verbs: []string{"get", "list", "watch"}, - }, - })) - - crb := &rbacv1.ClusterRoleBinding{ObjectMeta: metav1.ObjectMeta{Name: "gitops-service-cluster"}} - Eventually(crb).Should(k8sFixture.ExistByName()) - Expect(crb.RoleRef).To(Equal(rbacv1.RoleRef{ - APIGroup: "rbac.authorization.k8s.io", - Kind: "ClusterRole", - Name: "gitops-service-cluster", - })) - Expect(crb.Subjects).To(Equal([]rbacv1.Subject{{ - Kind: "ServiceAccount", - Name: "gitops-service-cluster", - Namespace: "openshift-gitops"}, - })) - - }) - }) -}) diff --git a/test/openshift/e2e/ginkgo/sequential/1-074_validate_terminating_namespace_block_test.go b/test/openshift/e2e/ginkgo/sequential/1-074_validate_terminating_namespace_block_test.go deleted file mode 100644 index 1ac4391f997..00000000000 --- a/test/openshift/e2e/ginkgo/sequential/1-074_validate_terminating_namespace_block_test.go +++ /dev/null @@ -1,141 +0,0 @@ -/* -Copyright 2025. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package sequential - -import ( - "context" - - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - argov1beta1api "github.com/redhat-developer/gitops-operator/argocd-operator/api/v1beta1" - "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture" - argocdFixture "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture/argocd" - configmapFixture "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture/configmap" - k8sFixture "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture/k8s" - fixtureUtils "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture/utils" - corev1 "k8s.io/api/core/v1" - rbacv1 "k8s.io/api/rbac/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "sigs.k8s.io/controller-runtime/pkg/client" -) - -var _ = Describe("GitOps Operator Sequential E2E Tests", func() { - - Context("1-074_validate_terminating_namespace_block", func() { - - var ( - k8sClient client.Client - ctx context.Context - ) - - BeforeEach(func() { - fixture.EnsureSequentialCleanSlate() - k8sClient, _ = fixtureUtils.GetE2ETestKubeClient() - ctx = context.Background() - }) - - It("ensures that if one managed namespace is stuck in deleting state -- due to a finalizer -- it does not block other managed namespaces from being reconciled", func() { - - By("creating an Argo CD instance that will manage other namespaces") - gitops_2242_ns_main, cleanupFunc := fixture.CreateNamespaceWithCleanupFunc("gitops-2242-ns-main") - defer cleanupFunc() - - argoCD := &argov1beta1api.ArgoCD{ - ObjectMeta: metav1.ObjectMeta{ - Name: "gitops-2242-argocd", - Namespace: gitops_2242_ns_main.Name, - Finalizers: []string{"argoproj.io/finalizer"}, - }, - Spec: argov1beta1api.ArgoCDSpec{ - RBAC: argov1beta1api.ArgoCDRBACSpec{ - Policy: new("g, system:authenticated, role:admin"), - Scopes: new("[groups]"), - }, - }, - } - Expect(k8sClient.Create(ctx, argoCD)).To(Succeed()) - - By("waiting for ArgoCD CR to be reconciled and the instance to be ready") - Eventually(argoCD, "5m", "5s").Should(argocdFixture.BeAvailable()) - - // This RoleBinding (ported from kuttl test) appears not to have a point: it grants openshift-gitops argo cd instance to this argo cd. - // I've left it commented out. - // - // nsRoleBinding := &rbacv1.RoleBinding{ - // ObjectMeta: metav1.ObjectMeta{ - // Name: "grant-argocd", - // Namespace: gitops_2242_ns_main.Name, - // }, - // RoleRef: rbacv1.RoleRef{ - // APIGroup: "rbac.authorization.k8s.io", - // Kind: "ClusterRole", - // Name: "admin", - // }, - // Subjects: []rbacv1.Subject{ - // {Kind: "ServiceAccount", Name: "openshift-gitops-argocd-application-controller", Namespace: "openshift-gitops"}}, - // } - // Expect(k8sClient.Create(ctx, nsRoleBinding)).To(Succeed()) - - gitops_2242_ns_first, cleanupFunc := fixture.CreateManagedNamespaceWithCleanupFunc("gitops-2242-ns-first", gitops_2242_ns_main.Name) - defer cleanupFunc() - - By("creating a ConfigMap with a finalizer, so that when the Namespace is deleted, the Namespace cannot finish deleting until the ConfigMap finalizer is removed") - firstConfigMap := &corev1.ConfigMap{ - ObjectMeta: metav1.ObjectMeta{ - Name: "my-config-map-2", - Namespace: gitops_2242_ns_first.Name, - Finalizers: []string{ - "some.random/finalizer", - }, - }, - Data: map[string]string{ - "foo": "bar", - }, - } - Expect(k8sClient.Create(ctx, firstConfigMap)).To(Succeed()) - defer func() { - // At the end of the test, remove the finalizer from the ConfigMap so the NS can be deleted. - configmapFixture.Update(firstConfigMap, func(cm *corev1.ConfigMap) { - cm.Finalizers = nil - }) - }() - - By("starting to delete the Namespace in the background. This puts the Namespace into deletion state, but it cannot finish deletion until the ConfigMap has its finalizer removed, which happens at the end of the test") - go func() { - defer GinkgoRecover() - Expect(k8sClient.Delete(ctx, gitops_2242_ns_first)).To(Succeed()) - }() - - By("creating a second managed namespace, to managed by the Argo CD instance") - gitops_2242_ns_second, cleanupFunc := fixture.CreateManagedNamespaceWithCleanupFunc("gitops-2242-ns-second", "gitops-2242-ns-main") - defer cleanupFunc() - - By("verifying that the operator is successfully able to grant access from the Argo CD instance to the second Namespace. That confirms that, even though the first namespace is in deletion state, that the operator is not blocked on other Namespaces") - argocdServerRoleBindingInGitops_2242_ns_second := &rbacv1.RoleBinding{ - ObjectMeta: metav1.ObjectMeta{Name: "gitops-2242-argocd-argocd-server", Namespace: gitops_2242_ns_second.Name}, - } - Eventually(argocdServerRoleBindingInGitops_2242_ns_second).Should(k8sFixture.ExistByName()) - - argocdApplicationServerRoleBindingInGitops_2242_ns_second := &rbacv1.RoleBinding{ - ObjectMeta: metav1.ObjectMeta{Name: "gitops-2242-argocd-argocd-application-controller", Namespace: gitops_2242_ns_second.Name}, - } - Eventually(argocdApplicationServerRoleBindingInGitops_2242_ns_second).Should(k8sFixture.ExistByName()) - - }) - - }) -}) diff --git a/test/openshift/e2e/ginkgo/sequential/1-111_validate_default_argocd_route_test.go b/test/openshift/e2e/ginkgo/sequential/1-111_validate_default_argocd_route_test.go deleted file mode 100644 index 6ffb695dcd8..00000000000 --- a/test/openshift/e2e/ginkgo/sequential/1-111_validate_default_argocd_route_test.go +++ /dev/null @@ -1,99 +0,0 @@ -package sequential - -import ( - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" - routev1 "github.com/openshift/api/route/v1" - argov1beta1api "github.com/redhat-developer/gitops-operator/argocd-operator/api/v1beta1" - "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture" - argocdFixture "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture/argocd" - k8sFixture "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture/k8s" - routeFixture "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture/route" - corev1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/intstr" -) - -var _ = Describe("GitOps Operator Sequential E2E Tests", func() { - - Context("1-111_validate_default_argocd_route", func() { - - BeforeEach(func() { - - fixture.EnsureSequentialCleanSlate() - }) - - It("ensuring that default openshift-gitops instance has expected default Argo CD server route, and that it is possible to modify the values on that default instance", Label("openshift"), func() { - - By("verifying route of openshift-gitops Argo CD instance has expected values") - openshiftArgoCD, err := argocdFixture.GetOpenShiftGitOpsNSArgoCD() - Expect(err).ToNot(HaveOccurred()) - - Expect(openshiftArgoCD.Spec.Server.Route.Enabled).To(BeTrue()) - Eventually(openshiftArgoCD, "5m", "5s").Should(argocdFixture.BeAvailable()) - - serverRoute := &routev1.Route{ - ObjectMeta: metav1.ObjectMeta{ - Name: "openshift-gitops-server", - Namespace: "openshift-gitops", - }, - } - Eventually(serverRoute).Should(k8sFixture.ExistByName()) - - Expect(serverRoute.Spec.Port).To(Equal(&routev1.RoutePort{ - TargetPort: intstr.FromString("https"), - })) - - Expect(serverRoute.Spec.TLS).To(Equal(&routev1.TLSConfig{ - InsecureEdgeTerminationPolicy: routev1.InsecureEdgeTerminationPolicyRedirect, - Termination: routev1.TLSTerminationReencrypt, - })) - - Expect(serverRoute.Spec.To).Should(Equal(routev1.RouteTargetReference{ - Kind: "Service", - Name: "openshift-gitops-server", - Weight: new(int32(100)), - })) - - By("verifying Route has admitted ingress") - Eventually(serverRoute).Should(routeFixture.HaveAdmittedIngress()) - - By("verifying the argocd-server-tls secret is created by the OpenShift's service CA") - - secret := &corev1.Secret{ - ObjectMeta: metav1.ObjectMeta{ - Name: "argocd-server-tls", - Namespace: "openshift-gitops", - }, - } - Eventually(secret).Should(k8sFixture.ExistByName()) - Expect(secret.Type).Should(Equal(corev1.SecretTypeTLS)) - - By("updating ArgoCD CR server route to TLS passthrough and TLS termination policy of none") - argocdFixture.Update(openshiftArgoCD, func(ac *argov1beta1api.ArgoCD) { - ac.Spec.Server.Route.Enabled = true - ac.Spec.Server.Route.TLS = &routev1.TLSConfig{ - Termination: routev1.TLSTerminationPassthrough, - InsecureEdgeTerminationPolicy: routev1.InsecureEdgeTerminationPolicyNone, - } - }) - - defer argocdFixture.Update(openshiftArgoCD, func(ac *argov1beta1api.ArgoCD) { // Cleanup - ac.Spec.Server.Route.TLS = nil - }) - - By("verifying server Route has changed to the TLS new values from ArgoCD CR") - Eventually(openshiftArgoCD, "5m", "5s").Should(argocdFixture.BeAvailable()) - - Eventually(serverRoute).Should(k8sFixture.ExistByName()) - - Expect(serverRoute.Spec.TLS).To(Equal(&routev1.TLSConfig{ - InsecureEdgeTerminationPolicy: routev1.InsecureEdgeTerminationPolicyNone, - Termination: routev1.TLSTerminationPassthrough, - })) - - }) - - }) - -})