Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.25.0

require (
github.com/argoproj-labs/argo-rollouts-manager v0.0.7-0.20251105123110-0c547c7a7765
github.com/argoproj-labs/argocd-image-updater v1.0.0
github.com/argoproj-labs/argocd-operator v0.17.0-rc1.0.20260109095501-c05ab1dd9a27
github.com/argoproj/argo-cd/v3 v3.2.3
github.com/argoproj/gitops-engine v0.7.1-0.20251217140045-5baed5604d2d
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be h1:9AeTilPcZAjCFI
github.com/anmitsu/go-shlex v0.0.0-20200514113438-38f4b401e2be/go.mod h1:ySMOLuWl6zY27l47sB3qLNK6tF2fkHG55UZxx8oIVo4=
github.com/argoproj-labs/argo-rollouts-manager v0.0.7-0.20251105123110-0c547c7a7765 h1:zVN+W/nQrRB/kB63YcvcCseuiE//sEzNw6Oa8rqiFOs=
github.com/argoproj-labs/argo-rollouts-manager v0.0.7-0.20251105123110-0c547c7a7765/go.mod h1:WPyZkNHZjir/OTt8mrRwcUZKe1euHrHPJsRv1Wp/F/0=
github.com/argoproj-labs/argocd-image-updater v1.0.0 h1:43+lBl3RGiwLAastRXZlDvPT5WOKoA3TOb6SIZstGGI=
github.com/argoproj-labs/argocd-image-updater v1.0.0/go.mod h1:PJ+Pb3faVqSzNNs35INUZYtzlaqKvBE2ZgZGdDabJQM=
github.com/argoproj-labs/argocd-operator v0.17.0-rc1.0.20260109095501-c05ab1dd9a27 h1:cYVxJYI0icUiQNJWU8DmTbhCvTuKpt2qq5WDv4tNupM=
github.com/argoproj-labs/argocd-operator v0.17.0-rc1.0.20260109095501-c05ab1dd9a27/go.mod h1:mYgUph18vdAsTAXZ0+APJQP7C2Ot81cKUqLfYm89msI=
github.com/argoproj/argo-cd/v3 v3.2.3 h1:7PLQOVhrs/+C2S9+LfDygibOHyZIytB7oMPdlFt8fio=
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,320 @@
/*
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 parallel

import (
"context"

argocdv1alpha1 "github.com/argoproj/argo-cd/v3/pkg/apis/application/v1alpha1"
"github.com/argoproj/gitops-engine/pkg/health"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
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"
"sigs.k8s.io/controller-runtime/pkg/client"

argov1beta1api "github.com/argoproj-labs/argocd-operator/api/v1beta1"
"github.com/argoproj-labs/argocd-operator/tests/ginkgo/fixture"
"github.com/argoproj-labs/argocd-operator/tests/ginkgo/fixture/application"
argocdFixture "github.com/argoproj-labs/argocd-operator/tests/ginkgo/fixture/argocd"
configmapFixture "github.com/argoproj-labs/argocd-operator/tests/ginkgo/fixture/configmap"
k8sFixture "github.com/argoproj-labs/argocd-operator/tests/ginkgo/fixture/k8s"
"github.com/argoproj-labs/argocd-operator/tests/ginkgo/fixture/namespace"
fixtureUtils "github.com/argoproj-labs/argocd-operator/tests/ginkgo/fixture/utils"
)

var _ = Describe("GitOps Operator Parallel E2E Tests", func() {

Context("1-046_validate_application_tracking", func() {

var (
k8sClient client.Client
ctx context.Context
)

BeforeEach(func() {
fixture.EnsureParallelCleanSlate()

k8sClient, _ = fixtureUtils.GetE2ETestKubeClient()
ctx = context.Background()

})

It("verifies that when .spec.installationID is set, that value is set on Argo CD ConfigMap, and that installationID is also set on resources deployed by that Argo CD instance, and that .spec.resourceTrackingMethod is defined on that Argo CD instance", func() {

By("creating namespaces which will contain Argo CD instances and which will be deployed to by Argo CD ")
test_1_046_argocd_1_NS, cleanupFunc := fixture.CreateNamespaceWithCleanupFunc("test-1-046-argocd-1")
defer cleanupFunc()

test_1_046_argocd_2_NS, cleanupFunc := fixture.CreateNamespaceWithCleanupFunc("test-1-046-argocd-2")
defer cleanupFunc()

test_1_046_argocd_3_NS, cleanupFunc := fixture.CreateNamespaceWithCleanupFunc("test-1-046-argocd-3")
defer cleanupFunc()

source_ns_1_NS, cleanupFunc := fixture.CreateNamespaceWithCleanupFunc("source-ns-1")
defer cleanupFunc()

source_ns_2_NS, cleanupFunc := fixture.CreateNamespaceWithCleanupFunc("source-ns-2")
defer cleanupFunc()

source_ns_3_NS, cleanupFunc := fixture.CreateNamespaceWithCleanupFunc("source-ns-3")
defer cleanupFunc()

By("creating first Argo CD instance, with installationID 'instance-1', and annotation+label tracking")
argocd_1 := &argov1beta1api.ArgoCD{
ObjectMeta: metav1.ObjectMeta{
Name: "argocd-1",
Namespace: test_1_046_argocd_1_NS.Name,
},
Spec: argov1beta1api.ArgoCDSpec{
InstallationID: "instance-1",
ResourceTrackingMethod: "annotation+label",
},
}
Expect(k8sClient.Create(ctx, argocd_1)).Should(Succeed())

By("creating second Argo CD instance, with instance-2 ID, and annotation+label tracking")
argocd_2 := &argov1beta1api.ArgoCD{
ObjectMeta: metav1.ObjectMeta{
Name: "argocd-2",
Namespace: test_1_046_argocd_2_NS.Name,
},
Spec: argov1beta1api.ArgoCDSpec{
InstallationID: "instance-2",
ResourceTrackingMethod: "annotation+label",
},
}
Expect(k8sClient.Create(ctx, argocd_2)).Should(Succeed())
By("creating second Argo CD instance, with instance-3 ID, and annotation tracking (by default it is annotation")
argocd_3 := &argov1beta1api.ArgoCD{
ObjectMeta: metav1.ObjectMeta{
Name: "argocd-3",
Namespace: test_1_046_argocd_3_NS.Name,
},
Spec: argov1beta1api.ArgoCDSpec{
InstallationID: "instance-3",
},
}
Expect(k8sClient.Create(ctx, argocd_3)).Should(Succeed())

Eventually(argocd_1, "5m", "5s").Should(argocdFixture.BeAvailable())
Eventually(argocd_2, "5m", "5s").Should(argocdFixture.BeAvailable())
Eventually(argocd_3, "5m", "5s").Should(argocdFixture.BeAvailable())

By("verifying argocd-cm for Argo CD instances contain the values defined in ArgoCD CR .spec field")
configMap_test_1_046_argocd_1 := &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: "argocd-cm",
Namespace: "test-1-046-argocd-1",
},
}
Eventually(configMap_test_1_046_argocd_1).Should(k8sFixture.ExistByName())
Expect(configMap_test_1_046_argocd_1).Should(configmapFixture.HaveStringDataKeyValue("installationID", "instance-1"))
Expect(configMap_test_1_046_argocd_1).Should(configmapFixture.HaveStringDataKeyValue("application.resourceTrackingMethod", "annotation+label"))

configMap_test_1_046_argocd_2 := &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: "argocd-cm",
Namespace: "test-1-046-argocd-2",
},
}

Eventually(configMap_test_1_046_argocd_2).Should(k8sFixture.ExistByName())
Expect(configMap_test_1_046_argocd_2).Should(configmapFixture.HaveStringDataKeyValue("installationID", "instance-2"))
Expect(configMap_test_1_046_argocd_2).Should(configmapFixture.HaveStringDataKeyValue("application.resourceTrackingMethod", "annotation+label"))

configMap_test_1_046_argocd_3 := &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: "argocd-cm",
Namespace: "test-1-046-argocd-3",
},
}

Eventually(configMap_test_1_046_argocd_2).Should(k8sFixture.ExistByName())
Expect(configMap_test_1_046_argocd_3).Should(configmapFixture.HaveStringDataKeyValue("installationID", "instance-3"))
Expect(configMap_test_1_046_argocd_3).Should(configmapFixture.HaveStringDataKeyValue("application.resourceTrackingMethod", "annotation"))

By("adding managed-by label to test-1-046-argocd-(1/3), managed by Argo CD instances 1, 2 and 3")
namespace.Update(source_ns_1_NS, func(n *corev1.Namespace) {
if n.Labels == nil {
n.Labels = map[string]string{}
}
n.Labels["argocd.argoproj.io/managed-by"] = "test-1-046-argocd-1"
})

namespace.Update(source_ns_2_NS, func(n *corev1.Namespace) {
if n.Labels == nil {
n.Labels = map[string]string{}
}
n.Labels["argocd.argoproj.io/managed-by"] = "test-1-046-argocd-2"
})

namespace.Update(source_ns_3_NS, func(n *corev1.Namespace) {
n.Labels["argocd.argoproj.io/managed-by"] = "test-1-046-argocd-3"
if n.Annotations == nil {
n.Annotations = map[string]string{}
}
n.Annotations["argocd.argoproj.io/managed-by"] = "test-1-046-argocd-3"
})

By("verifying role is created in the correct source-ns-(1/3) namespaces, for instances")
role_appController_source_ns_1 := &rbacv1.Role{
ObjectMeta: metav1.ObjectMeta{
Name: "argocd-1-argocd-application-controller",
Namespace: "source-ns-1",
},
}
Eventually(role_appController_source_ns_1).Should(k8sFixture.ExistByName())

role_appController_source_ns_2 := &rbacv1.Role{
ObjectMeta: metav1.ObjectMeta{
Name: "argocd-2-argocd-application-controller",
Namespace: "source-ns-2",
},
}
Eventually(role_appController_source_ns_2).Should(k8sFixture.ExistByName())

role_appController_source_ns_3 := &rbacv1.Role{
ObjectMeta: metav1.ObjectMeta{
Name: "argocd-3-argocd-application-controller",
Namespace: "source-ns-3",
},
}
Eventually(role_appController_source_ns_3).Should(k8sFixture.ExistByName())

By("by defining a simple Argo CD Application for both Argo CD instances, to deploy to source namespaces 1/2 respectively")
application_test_1_046_argocd_1 := &argocdv1alpha1.Application{
ObjectMeta: metav1.ObjectMeta{
Name: "test-app",
Namespace: "test-1-046-argocd-1",
},
Spec: argocdv1alpha1.ApplicationSpec{
Project: "default",
Source: &argocdv1alpha1.ApplicationSource{
RepoURL: "https://github.com/redhat-developer/gitops-operator",
Path: "test/examples/nginx",
TargetRevision: "HEAD",
},
Destination: argocdv1alpha1.ApplicationDestination{
Server: "https://kubernetes.default.svc",
Namespace: "source-ns-1",
},
SyncPolicy: &argocdv1alpha1.SyncPolicy{
Automated: &argocdv1alpha1.SyncPolicyAutomated{},
},
},
}
Expect(k8sClient.Create(ctx, application_test_1_046_argocd_1)).To(Succeed())

application_test_1_046_argocd_2 := &argocdv1alpha1.Application{
ObjectMeta: metav1.ObjectMeta{
Name: "test-app",
Namespace: "test-1-046-argocd-2",
},
Spec: argocdv1alpha1.ApplicationSpec{
Project: "default",
Source: &argocdv1alpha1.ApplicationSource{
RepoURL: "https://github.com/redhat-developer/gitops-operator",
Path: "test/examples/nginx",
TargetRevision: "HEAD",
},
Destination: argocdv1alpha1.ApplicationDestination{
Server: "https://kubernetes.default.svc",
Namespace: "source-ns-2",
},
SyncPolicy: &argocdv1alpha1.SyncPolicy{
Automated: &argocdv1alpha1.SyncPolicyAutomated{},
},
},
}
Expect(k8sClient.Create(ctx, application_test_1_046_argocd_2)).To(Succeed())
application_test_1_046_argocd_3 := &argocdv1alpha1.Application{
ObjectMeta: metav1.ObjectMeta{
Name: "test-app",
Namespace: "test-1-046-argocd-3",
},
Spec: argocdv1alpha1.ApplicationSpec{
Project: "default",
Source: &argocdv1alpha1.ApplicationSource{
RepoURL: "https://github.com/redhat-developer/gitops-operator",
Path: "test/examples/nginx",
TargetRevision: "HEAD",
},
Destination: argocdv1alpha1.ApplicationDestination{
Server: "https://kubernetes.default.svc",
Namespace: "source-ns-3",
},
SyncPolicy: &argocdv1alpha1.SyncPolicy{
Automated: &argocdv1alpha1.SyncPolicyAutomated{},
},
},
}
Expect(k8sClient.Create(ctx, application_test_1_046_argocd_3)).To(Succeed())

By("verifying that the Applications successfully deployed, and that they have the correct installation-id and tracking-id, based on which Argo CD instance deployed them")

Eventually(application_test_1_046_argocd_1, "4m", "5s").Should(application.HaveHealthStatusCode(health.HealthStatusHealthy))
Eventually(application_test_1_046_argocd_1, "4m", "5s").Should(application.HaveSyncStatusCode(argocdv1alpha1.SyncStatusCodeSynced))

Eventually(application_test_1_046_argocd_2, "4m", "5s").Should(application.HaveHealthStatusCode(health.HealthStatusHealthy))
Eventually(application_test_1_046_argocd_2, "4m", "5s").Should(application.HaveSyncStatusCode(argocdv1alpha1.SyncStatusCodeSynced))

Eventually(application_test_1_046_argocd_3, "4m", "5s").Should(application.HaveHealthStatusCode(health.HealthStatusHealthy))
Eventually(application_test_1_046_argocd_3, "4m", "5s").Should(application.HaveSyncStatusCode(argocdv1alpha1.SyncStatusCodeSynced))

deployment_source_ns_1 := &appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Name: "nginx-deployment",
Namespace: "source-ns-1",
},
}
Eventually(deployment_source_ns_1).Should(k8sFixture.ExistByName())
Eventually(deployment_source_ns_1).Should(k8sFixture.HaveAnnotationWithValue("argocd.argoproj.io/installation-id", "instance-1"))
Eventually(deployment_source_ns_1).Should(k8sFixture.HaveAnnotationWithValue("argocd.argoproj.io/tracking-id", "test-app:apps/Deployment:source-ns-1/nginx-deployment"))

Eventually(deployment_source_ns_1).Should(k8sFixture.HaveLabelWithValue("app.kubernetes.io/instance", "test-app"))

deployment_source_ns_2 := &appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Name: "nginx-deployment",
Namespace: "source-ns-2",
},
}
Eventually(deployment_source_ns_2).Should(k8sFixture.ExistByName())
Eventually(deployment_source_ns_2).Should(k8sFixture.HaveAnnotationWithValue("argocd.argoproj.io/installation-id", "instance-2"))
Eventually(deployment_source_ns_2).Should(k8sFixture.HaveAnnotationWithValue("argocd.argoproj.io/tracking-id", "test-app:apps/Deployment:source-ns-2/nginx-deployment"))

Eventually(deployment_source_ns_2).Should(k8sFixture.HaveLabelWithValue("app.kubernetes.io/instance", "test-app"))

deployment_source_ns_3 := &appsv1.Deployment{
ObjectMeta: metav1.ObjectMeta{
Name: "nginx-deployment",
Namespace: "source-ns-3",
},
}
Eventually(deployment_source_ns_3).Should(k8sFixture.ExistByName())
Eventually(deployment_source_ns_3).Should(k8sFixture.HaveAnnotationWithValue("argocd.argoproj.io/installation-id", "instance-3"))
Eventually(deployment_source_ns_3).Should(k8sFixture.HaveAnnotationWithValue("argocd.argoproj.io/tracking-id", "test-app:apps/Deployment:source-ns-3/nginx-deployment"))

Eventually(deployment_source_ns_3).Should(k8sFixture.NotHaveLabelWithValue("app.kubernetes.io/instance", "test-app"))
})

})
})
Loading