|
| 1 | +package parallel |
| 2 | + |
| 3 | +import ( |
| 4 | + "context" |
| 5 | + |
| 6 | + argov1beta1api "github.com/argoproj-labs/argocd-operator/api/v1beta1" |
| 7 | + . "github.com/onsi/ginkgo/v2" |
| 8 | + . "github.com/onsi/gomega" |
| 9 | + "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture" |
| 10 | + argocdFixture "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture/argocd" |
| 11 | + deplFixture "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture/deployment" |
| 12 | + k8sFixture "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture/k8s" |
| 13 | + fixtureUtils "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture/utils" |
| 14 | + appsv1 "k8s.io/api/apps/v1" |
| 15 | + corev1 "k8s.io/api/core/v1" |
| 16 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 17 | + "sigs.k8s.io/controller-runtime/pkg/client" |
| 18 | +) |
| 19 | + |
| 20 | +var _ = Describe("GitOps Operator Parallel E2E Tests", func() { |
| 21 | + |
| 22 | + Context("1-086_validate_applicationset_extra_command_args", func() { |
| 23 | + |
| 24 | + var ( |
| 25 | + k8sClient client.Client |
| 26 | + ctx context.Context |
| 27 | + ns *corev1.Namespace |
| 28 | + cleanupFunc func() |
| 29 | + argoCD *argov1beta1api.ArgoCD |
| 30 | + ) |
| 31 | + |
| 32 | + BeforeEach(func() { |
| 33 | + fixture.EnsureParallelCleanSlate() |
| 34 | + k8sClient, _ = fixtureUtils.GetE2ETestKubeClient() |
| 35 | + ctx = context.Background() |
| 36 | + }) |
| 37 | + |
| 38 | + AfterEach(func() { |
| 39 | + defer cleanupFunc() |
| 40 | + fixture.OutputDebugOnFail(ns) |
| 41 | + }) |
| 42 | + |
| 43 | + It("validates that extra command arguments are added to the ApplicationSet controller deployment", func() { |
| 44 | + |
| 45 | + expectAppSetIsReady := func() { |
| 46 | + Eventually(argoCD, "5m", "5s").Should(argocdFixture.BeAvailable()) |
| 47 | + |
| 48 | + appSetDepl := &appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{Name: "argocd-applicationset-controller", Namespace: ns.Name}} |
| 49 | + |
| 50 | + Eventually(appSetDepl).Should(k8sFixture.ExistByName()) |
| 51 | + Eventually(appSetDepl).Should(deplFixture.HaveReplicas(1)) |
| 52 | + Eventually(appSetDepl).Should(deplFixture.HaveReadyReplicas(1)) |
| 53 | + } |
| 54 | + |
| 55 | + By("creating simple namespace-scoped Argo CD instance with ApplicationSet enabled") |
| 56 | + ns, cleanupFunc = fixture.CreateRandomE2ETestNamespaceWithCleanupFunc() |
| 57 | + |
| 58 | + argoCD = &argov1beta1api.ArgoCD{ |
| 59 | + ObjectMeta: metav1.ObjectMeta{Name: "argocd", Namespace: ns.Name}, |
| 60 | + Spec: argov1beta1api.ArgoCDSpec{ |
| 61 | + ApplicationSet: &argov1beta1api.ArgoCDApplicationSet{}, |
| 62 | + }, |
| 63 | + } |
| 64 | + Expect(k8sClient.Create(ctx, argoCD)).To(Succeed()) |
| 65 | + |
| 66 | + By("waiting for initial ApplicationSet controller instance to be ready") |
| 67 | + expectAppSetIsReady() |
| 68 | + |
| 69 | + By("patching ArgoCD CR to add the extraCommandArgs") |
| 70 | + argocdFixture.Update(argoCD, func(ac *argov1beta1api.ArgoCD) { |
| 71 | + ac.Spec.ApplicationSet.ExtraCommandArgs = []string{"--enable-progressive-syncs"} |
| 72 | + }) |
| 73 | + |
| 74 | + By("waiting for the ApplicationSet controller to reconcile and adopt the new arguments") |
| 75 | + expectAppSetIsReady() |
| 76 | + |
| 77 | + //last Assertion |
| 78 | + By("verifying the new command arguments are present in the Deployment spec") |
| 79 | + appSetDepl := &appsv1.Deployment{ObjectMeta: metav1.ObjectMeta{Name: "argocd-applicationset-controller", Namespace: ns.Name}} |
| 80 | + |
| 81 | + expectedArg := "--enable-progressive-syncs" |
| 82 | + |
| 83 | + //command substring exists |
| 84 | + Eventually(appSetDepl).Should(deplFixture.HaveContainerCommandSubstring(expectedArg, 0), |
| 85 | + "Expected the applicationset-controller command to include the extra argument: %s", expectedArg) |
| 86 | + }) |
| 87 | + }) |
| 88 | +}) |
0 commit comments