|
| 1 | +/* |
| 2 | +Copyright 2025. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +package parallel |
| 18 | + |
| 19 | +import ( |
| 20 | + "context" |
| 21 | + |
| 22 | + argov1beta1api "github.com/argoproj-labs/argocd-operator/api/v1beta1" |
| 23 | + . "github.com/onsi/ginkgo/v2" |
| 24 | + . "github.com/onsi/gomega" |
| 25 | + "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture" |
| 26 | + argocdFixture "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture/argocd" |
| 27 | + deplFixture "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture/deployment" |
| 28 | + k8sFixture "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture/k8s" |
| 29 | + statefulsetFixture "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture/statefulset" |
| 30 | + fixtureUtils "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture/utils" |
| 31 | + appsv1 "k8s.io/api/apps/v1" |
| 32 | + corev1 "k8s.io/api/core/v1" |
| 33 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 34 | + "sigs.k8s.io/controller-runtime/pkg/client" |
| 35 | +) |
| 36 | + |
| 37 | +var _ = Describe("GitOps Operator Parallel E2E Tests", func() { |
| 38 | + |
| 39 | + Context("1-068_validate_redis_secure_comm_autotls_no_ha", func() { |
| 40 | + |
| 41 | + var ( |
| 42 | + k8sClient client.Client |
| 43 | + ctx context.Context |
| 44 | + ns *corev1.Namespace |
| 45 | + cleanupFunc func() |
| 46 | + ) |
| 47 | + |
| 48 | + BeforeEach(func() { |
| 49 | + fixture.EnsureParallelCleanSlate() |
| 50 | + |
| 51 | + k8sClient, _ = fixtureUtils.GetE2ETestKubeClient() |
| 52 | + ctx = context.Background() |
| 53 | + }) |
| 54 | + |
| 55 | + AfterEach(func() { |
| 56 | + defer cleanupFunc() |
| 57 | + fixture.OutputDebugOnFail(ns) |
| 58 | + }) |
| 59 | + |
| 60 | + It("validates that the operator configures Redis using auto-gen TLS certificates when HA is disabled", func() { |
| 61 | + |
| 62 | + expectComponentsAreRunning := func() { |
| 63 | + |
| 64 | + deploymentsShouldExist := []string{"argocd-redis", "argocd-server", "argocd-repo-server"} |
| 65 | + for _, depl := range deploymentsShouldExist { |
| 66 | + depl := &appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{Name: depl, Namespace: ns.Name}} |
| 67 | + Eventually(depl).Should(k8sFixture.ExistByName()) |
| 68 | + Eventually(depl).Should(deplFixture.HaveReplicas(1)) |
| 69 | + Eventually(depl).Should(deplFixture.HaveReadyReplicas(1)) |
| 70 | + } |
| 71 | + |
| 72 | + statefulSet := &appsv1.StatefulSet{ObjectMeta: metav1.ObjectMeta{Name: "argocd-application-controller", Namespace: ns.Name}} |
| 73 | + Eventually(statefulSet).Should(k8sFixture.ExistByName()) |
| 74 | + Eventually(statefulSet).Should(statefulsetFixture.HaveReplicas(1)) |
| 75 | + Eventually(statefulSet).Should(statefulsetFixture.HaveReadyReplicas(1)) |
| 76 | + } |
| 77 | + |
| 78 | + By("creating simple namespace-scoped Argo CD instance with HA disabled") |
| 79 | + ns, cleanupFunc = fixture.CreateRandomE2ETestNamespaceWithCleanupFunc() |
| 80 | + |
| 81 | + argoCD := &argov1beta1api.ArgoCD{ |
| 82 | + ObjectMeta: metav1.ObjectMeta{Name: "argocd", Namespace: ns.Name}, |
| 83 | + Spec: argov1beta1api.ArgoCDSpec{ |
| 84 | + HA: argov1beta1api.ArgoCDHASpec{ |
| 85 | + Enabled: false, |
| 86 | + }, |
| 87 | + Redis: argov1beta1api.ArgoCDRedisSpec{}, |
| 88 | + }, |
| 89 | + } |
| 90 | + Expect(k8sClient.Create(ctx, argoCD)).To(Succeed()) |
| 91 | + |
| 92 | + By("waiting for initial non-HA instance to be ready") |
| 93 | + Eventually(argoCD, "5m", "5s").Should(argocdFixture.BeAvailable()) |
| 94 | + expectComponentsAreRunning() |
| 95 | + |
| 96 | + By("enabling redis autoTLS for openshift on the non-HA instance") |
| 97 | + argocdFixture.Update(argoCD, func(ac *argov1beta1api.ArgoCD) { |
| 98 | + ac.Spec.Redis.AutoTLS = "openshift" |
| 99 | + }) |
| 100 | + |
| 101 | + By("waiting for components to reconcile and restart with AutoTLS enabled") |
| 102 | + //wait for components |
| 103 | + expectComponentsAreRunning() |
| 104 | + |
| 105 | + By("verifying Redis TLS Secret exists and has data") |
| 106 | + redisTLSSecret := &corev1.Secret{ObjectMeta: metav1.ObjectMeta{Name: "argocd-operator-redis-tls", Namespace: ns.Name}} |
| 107 | + Eventually(redisTLSSecret).Should(k8sFixture.ExistByName()) |
| 108 | + |
| 109 | + redisDepl := &appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{Name: "argocd-redis", Namespace: ns.Name}} |
| 110 | + |
| 111 | + By("expecting redis-server to eventually have desired container process command/arguments (TLS)") |
| 112 | + expectedString := "--save \"\" --appendonly no --requirepass " + "$(REDIS_PASSWORD)" + " --tls-port 6379 --port 0 --tls-cert-file /app/config/redis/tls/tls.crt --tls-key-file /app/config/redis/tls/tls.key --tls-auth-clients no" |
| 113 | + |
| 114 | + if !fixture.IsUpstreamOperatorTests() { |
| 115 | + expectedString = "redis-server --protected-mode no " + expectedString |
| 116 | + } |
| 117 | + //wait for the command to be updated |
| 118 | + Eventually(redisDepl).Should(deplFixture.HaveContainerCommandSubstring(expectedString, 0), |
| 119 | + "TLS .spec.template.spec.containers.args for argocd-redis deployment are wrong") |
| 120 | + |
| 121 | + repoServerDepl := &appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{Name: "argocd-repo-server", Namespace: ns.Name}} |
| 122 | + |
| 123 | + By("expecting repo-server to eventually have desired container process command/arguments (TLS)") |
| 124 | + Eventually(repoServerDepl).Should(deplFixture.HaveContainerCommandSubstring("uid_entrypoint.sh argocd-repo-server --redis argocd-redis."+ns.Name+".svc.cluster.local:6379 --redis-use-tls --redis-ca-certificate /app/config/reposerver/tls/redis/tls.crt --loglevel info --logformat text", 0), |
| 125 | + "TLS .spec.template.spec.containers.command for argocd-repo-server deployment is wrong") |
| 126 | + |
| 127 | + argocdServerDepl := &appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{Name: "argocd-server", Namespace: ns.Name}} |
| 128 | + |
| 129 | + By("expecting argocd-server to eventually have desired container process command/arguments (TLS)") |
| 130 | + Eventually(argocdServerDepl).Should(deplFixture.HaveContainerCommandSubstring("argocd-server --staticassets /shared/app --dex-server https://argocd-dex-server."+ns.Name+".svc.cluster.local:5556 --repo-server argocd-repo-server."+ns.Name+".svc.cluster.local:8081 --redis argocd-redis."+ns.Name+".svc.cluster.local:6379 --redis-use-tls --redis-ca-certificate /app/config/server/tls/redis/tls.crt --loglevel info --logformat text", 0), |
| 131 | + "TLS .spec.template.spec.containers.command for argocd-server deployment is wrong") |
| 132 | + |
| 133 | + applicationControllerSS := &appsv1.StatefulSet{ObjectMeta: metav1.ObjectMeta{Name: "argocd-application-controller", Namespace: ns.Name}} |
| 134 | + |
| 135 | + By("expecting application-controller to eventually have desired container process command/arguments (TLS)") |
| 136 | + Eventually(applicationControllerSS).Should(statefulsetFixture.HaveContainerCommandSubstring("argocd-application-controller --operation-processors 10 --redis argocd-redis."+ns.Name+".svc.cluster.local:6379 --redis-use-tls --redis-ca-certificate /app/config/controller/tls/redis/tls.crt --repo-server argocd-repo-server."+ns.Name+".svc.cluster.local:8081 --status-processors 20 --kubectl-parallelism-limit 10 --loglevel info --logformat text", 0), |
| 137 | + "TLS .spec.template.spec.containers.command for argocd-application-controller statefulsets is wrong") |
| 138 | + }) |
| 139 | + }) |
| 140 | +}) |
0 commit comments