Skip to content
Merged
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ build: generate fmt vet ## Build manager binary.

.PHONY: run
run: manifests generate fmt vet ## Run a controller from your host.
CLUSTER_SCOPED_ARGO_ROLLOUTS_NAMESPACES=argo-rollouts,test-rom-ns-1,rom-ns-1,openshift-gitops ARGOCD_CLUSTER_CONFIG_NAMESPACES=openshift-gitops REDIS_CONFIG_PATH="build/redis" go run ./cmd/main.go
CLUSTER_SCOPED_ARGO_ROLLOUTS_NAMESPACES=argo-rollouts,test-rom-ns-1,rom-ns-1,openshift-gitops ARGOCD_CLUSTER_CONFIG_NAMESPACES="openshift-gitops, argocd-e2e-cluster-config, argocd-test-impersonation-1-046, argocd-agent-principal-1-051, argocd-agent-agent-1-052, appset-argocd, appset-old-ns, appset-new-ns" REDIS_CONFIG_PATH="build/redis" go run ./cmd/main.go

.PHONY: docker-build
docker-build: test ## Build docker image with the manager.
Expand Down
4 changes: 2 additions & 2 deletions controllers/argocd/openshift/openshift_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,10 @@ func TestAdminClusterRoleMapper(t *testing.T) {

// Sort both slices to ensure consistent comparison
sort.Slice(result, func(i, j int) bool {
return result[i].NamespacedName.Name < result[j].NamespacedName.Name
return result[i].Name < result[j].Name
})
sort.Slice(expectedRequests, func(i, j int) bool {
return expectedRequests[i].NamespacedName.Name < expectedRequests[j].NamespacedName.Name
return expectedRequests[i].Name < expectedRequests[j].Name
})

assert.Equal(t, expectedRequests, result)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.24.6

require (
github.com/argoproj-labs/argo-rollouts-manager v0.0.6-0.20250731075119-a100fc1d88b8
github.com/argoproj-labs/argocd-operator v0.0.0-20251125105011-0c039cea85fd
github.com/argoproj-labs/argocd-operator v0.16.0-rc1.0.20251204063443-9249b2daeeba
github.com/argoproj/argo-cd/v3 v3.1.5
github.com/argoproj/gitops-engine v0.7.1-0.20250905160054-e48120133eec
github.com/go-logr/logr v1.4.3
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +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.6-0.20250731075119-a100fc1d88b8 h1:6+eo7BKrNkSIhQ1nnyCUloSNrGzghlb8r8e7GokoeBo=
github.com/argoproj-labs/argo-rollouts-manager v0.0.6-0.20250731075119-a100fc1d88b8/go.mod h1:yTwzKUV79YyI764hkXdVojGYBA9yKJk3qXx5mRuQ2Xc=
github.com/argoproj-labs/argocd-operator v0.0.0-20251125105011-0c039cea85fd h1:67RjGDPc5LI2aWGSnnOtAi9LoMSnuBP0oFm5LLoyQlk=
github.com/argoproj-labs/argocd-operator v0.0.0-20251125105011-0c039cea85fd/go.mod h1:NCFt9E3K/eXfjfuXGQXLe+zKQCeRCaZv7ZsbbXFPpOw=
github.com/argoproj-labs/argocd-operator v0.16.0-rc1.0.20251204063443-9249b2daeeba h1:78B//Rfc/acaf/4JDGDHwPtOuNHRujC+j9UiMBDyO8A=
github.com/argoproj-labs/argocd-operator v0.16.0-rc1.0.20251204063443-9249b2daeeba/go.mod h1:NCFt9E3K/eXfjfuXGQXLe+zKQCeRCaZv7ZsbbXFPpOw=
github.com/argoproj/argo-cd/v3 v3.1.5 h1:dm1SY5CaILDIQIQINA4H6uJrXpExyif2Yz5915g91kQ=
github.com/argoproj/argo-cd/v3 v3.1.5/go.mod h1:ZHb/LOz/hr88VWMJiVTd8DGYL7MheHCAT8S6DgYOBFo=
github.com/argoproj/gitops-engine v0.7.1-0.20250905160054-e48120133eec h1:rNAwbRQFvRIuW/e2bU+B10mlzghYXsnwZedYeA7Drz4=
Expand Down
25 changes: 25 additions & 0 deletions test/openshift/e2e/ginkgo/fixture/fixture.go
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,29 @@ func OutputDebugOnFail(namespaceParams ...any) {
GinkgoWriter.Println(kubectlOutput)
GinkgoWriter.Println("----------------------------------------------------------------")

kubectlOutput, err = osFixture.ExecCommandWithOutputParam(false, "kubectl", "get", "deployments", "-n", namespace, "-o", "yaml")
if err != nil {
GinkgoWriter.Println("unable to list", namespace, err, kubectlOutput)
continue
}

GinkgoWriter.Println("")
GinkgoWriter.Println("----------------------------------------------------------------")
GinkgoWriter.Println("'kubectl get deployments -n " + namespace + " -o yaml")
GinkgoWriter.Println(kubectlOutput)
GinkgoWriter.Println("----------------------------------------------------------------")

kubectlOutput, err = osFixture.ExecCommandWithOutputParam(false, "kubectl", "get", "events", "-n", namespace)
if err != nil {
GinkgoWriter.Println("unable to get events for namespace", err, kubectlOutput)
} else {
GinkgoWriter.Println("")
GinkgoWriter.Println("----------------------------------------------------------------")
GinkgoWriter.Println("'kubectl get events -n " + namespace + ":")
GinkgoWriter.Println(kubectlOutput)
GinkgoWriter.Println("----------------------------------------------------------------")
}

}

kubectlOutput, err := osFixture.ExecCommandWithOutputParam(false, "kubectl", "get", "argocds", "-A", "-o", "yaml")
Expand All @@ -875,6 +898,8 @@ func OutputDebugOnFail(namespaceParams ...any) {
GinkgoWriter.Println("----------------------------------------------------------------")
}

GinkgoWriter.Println("You can skip this debug output by setting 'SKIP_DEBUG_OUTPUT=true'")

}

func outputPodLog(podSubstring string) {
Expand Down
2 changes: 2 additions & 0 deletions test/openshift/e2e/ginkgo/fixture/k8s/fixture.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ func NotHaveLabelWithValue(key string, value string) matcher.GomegaMatcher {
return true
}

GinkgoWriter.Println("NotHaveLabelWithValue: not expected: ", key, "/", value, ". actual:", labels[key])

return labels[key] != value

}, BeTrue())
Expand Down
10 changes: 10 additions & 0 deletions test/openshift/e2e/ginkgo/fixture/secret/fixture.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,16 @@ func HaveDataKeyValue(key string, value []byte) matcher.GomegaMatcher {

}

// NotHaveDataKey returns true if Secret's .data 'key' does not exist, false otherwise
func NotHaveDataKey(key string) matcher.GomegaMatcher {
return fetchSecret(func(secret *corev1.Secret) bool {
_, exists := secret.Data[key]
GinkgoWriter.Println("NotHaveDataKey - key:", key, "Exists:", exists)
return !exists
})

}

// This is intentionally NOT exported, for now. Create another function in this file/package that calls this function, and export that.
func fetchSecret(f func(*corev1.Secret) bool) matcher.GomegaMatcher {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ import (
namespaceFixture "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture/namespace"
"github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture/utils"

corev1 "k8s.io/api/core/v1"
rbacv1 "k8s.io/api/rbac/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
)
Expand All @@ -22,8 +24,10 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
Context("1-036_validate_role_rolebinding_for_source_namespace", func() {

var (
ctx context.Context
k8sClient client.Client
ctx context.Context
k8sClient client.Client
argoNamespace *corev1.Namespace
cleanupArgoNSFunc func()

defaultNSArgoCD *v1beta1.ArgoCD

Expand All @@ -39,30 +43,39 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {

AfterEach(func() {

fixture.OutputDebugOnFail("default")
fixture.OutputDebugOnFail(argoNamespace)

// Clean up argo cd instance created in test namespace first (before deleting the namespace itself)
Expect(defaultNSArgoCD).ToNot(BeNil())
err := k8sClient.Delete(ctx, defaultNSArgoCD)
if err != nil && !apierrors.IsNotFound(err) {
Expect(err).ToNot(HaveOccurred())
}

// Clean up namespaces created
for _, namespaceCleanupFunction := range cleanupFunctions {
namespaceCleanupFunction()
}

// Clean up argo cd instance created in 'default' NS
Expect(defaultNSArgoCD).ToNot(BeNil())
Expect(k8sClient.Delete(ctx, defaultNSArgoCD)).To(Succeed())

})

It("verifies that ArgoCD CR '.spec.sourceNamespaces' field wildcard-matching matches and manages only namespaces which match the wildcard", func() {

fixture.SetEnvInOperatorSubscriptionOrDeployment("ARGOCD_CLUSTER_CONFIG_NAMESPACES", "openshift-gitops, argocd-e2e-cluster-config")

By("creating cluster-scoped namespace for Argo CD instance")
argoNamespace, cleanupArgoNSFunc = fixture.CreateNamespaceWithCleanupFunc("argocd-e2e-cluster-config")
cleanupFunctions = append(cleanupFunctions, cleanupArgoNSFunc)

By("creating test NS")
testNS, cleanupFunc := fixture.CreateNamespaceWithCleanupFunc("test")
cleanupFunctions = append(cleanupFunctions, cleanupFunc)

By("creating Argo CD instance in default NS, with 'test' sourceNamespace only")
By("creating Argo CD instance in argocd-e2e-cluster-config NS, with 'test' sourceNamespace only")
defaultNSArgoCD = &v1beta1.ArgoCD{
ObjectMeta: metav1.ObjectMeta{
Name: "example-argocd",
Namespace: "default",
Namespace: argoNamespace.Name,
},
Spec: v1beta1.ArgoCDSpec{
SourceNamespaces: []string{
Expand All @@ -73,7 +86,7 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
Expect(k8sClient.Create(ctx, defaultNSArgoCD)).To(Succeed())

By("verifying Argo CD instance starts managing the namespace via managed-by-cluster-argocd label")
Eventually(testNS).Should(namespaceFixture.HaveLabel("argocd.argoproj.io/managed-by-cluster-argocd", "default"))
Eventually(testNS).Should(namespaceFixture.HaveLabel("argocd.argoproj.io/managed-by-cluster-argocd", argoNamespace.Name))

expectRoleAndRoleBindingValues := func(name string, ns string) {

Expand Down Expand Up @@ -107,12 +120,12 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
{
Kind: "ServiceAccount",
Name: "example-argocd-argocd-server",
Namespace: "default",
Namespace: argoNamespace.Name,
},
{
Kind: "ServiceAccount",
Name: "example-argocd-argocd-application-controller",
Namespace: "default",
Namespace: argoNamespace.Name,
},
}))

Expand All @@ -133,7 +146,7 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
})

By("verifying test-1 NS becomes managed, and expected role/rolebindings exist in test* namespaces but not dev")
Eventually(test1NS).Should(namespaceFixture.HaveLabel("argocd.argoproj.io/managed-by-cluster-argocd", "default"))
Eventually(test1NS).Should(namespaceFixture.HaveLabel("argocd.argoproj.io/managed-by-cluster-argocd", argoNamespace.Name))

expectRoleAndRoleBindingValues("example-argocd_test", "test")

Expand Down Expand Up @@ -161,7 +174,7 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
cleanupFunctions = append(cleanupFunctions, cleanupFunc)

By("verifying the test-2 namespace becomes managed by the argo cd instance, and has the expected role/rolebinding")
Eventually(test2NS, "2m", "5s").Should(namespaceFixture.HaveLabel("argocd.argoproj.io/managed-by-cluster-argocd", "default"))
Eventually(test2NS, "2m", "5s").Should(namespaceFixture.HaveLabel("argocd.argoproj.io/managed-by-cluster-argocd", argoNamespace.Name))

expectRoleAndRoleBindingValues("example-argocd_test-2", "test-2")

Expand All @@ -173,17 +186,17 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
})

By("verifying test, test-1, test-2, and dev are all managed and have the expected roles")
Eventually(testNS).Should(namespaceFixture.HaveLabel("argocd.argoproj.io/managed-by-cluster-argocd", "default"))
Consistently(testNS).Should(namespaceFixture.HaveLabel("argocd.argoproj.io/managed-by-cluster-argocd", "default"))
Eventually(testNS).Should(namespaceFixture.HaveLabel("argocd.argoproj.io/managed-by-cluster-argocd", argoNamespace.Name))
Consistently(testNS).Should(namespaceFixture.HaveLabel("argocd.argoproj.io/managed-by-cluster-argocd", argoNamespace.Name))

Eventually(test1NS).Should(namespaceFixture.HaveLabel("argocd.argoproj.io/managed-by-cluster-argocd", "default"))
Consistently(test1NS).Should(namespaceFixture.HaveLabel("argocd.argoproj.io/managed-by-cluster-argocd", "default"))
Eventually(test1NS).Should(namespaceFixture.HaveLabel("argocd.argoproj.io/managed-by-cluster-argocd", argoNamespace.Name))
Consistently(test1NS).Should(namespaceFixture.HaveLabel("argocd.argoproj.io/managed-by-cluster-argocd", argoNamespace.Name))

Eventually(test2NS).Should(namespaceFixture.HaveLabel("argocd.argoproj.io/managed-by-cluster-argocd", "default"))
Consistently(test2NS).Should(namespaceFixture.HaveLabel("argocd.argoproj.io/managed-by-cluster-argocd", "default"))
Eventually(test2NS).Should(namespaceFixture.HaveLabel("argocd.argoproj.io/managed-by-cluster-argocd", argoNamespace.Name))
Consistently(test2NS).Should(namespaceFixture.HaveLabel("argocd.argoproj.io/managed-by-cluster-argocd", argoNamespace.Name))

Eventually(devNS).Should(namespaceFixture.HaveLabel("argocd.argoproj.io/managed-by-cluster-argocd", "default"))
Consistently(devNS).Should(namespaceFixture.HaveLabel("argocd.argoproj.io/managed-by-cluster-argocd", "default"))
Eventually(devNS).Should(namespaceFixture.HaveLabel("argocd.argoproj.io/managed-by-cluster-argocd", argoNamespace.Name))
Consistently(devNS).Should(namespaceFixture.HaveLabel("argocd.argoproj.io/managed-by-cluster-argocd", argoNamespace.Name))

expectRoleAndRoleBindingValues("example-argocd_test", "test")
expectRoleAndRoleBindingValues("example-argocd_test-1", "test-1")
Expand All @@ -208,11 +221,11 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
cleanupFunctions = append(cleanupFunctions, cleanupFunc)

By("verifying test-ns-1 and dev-ns-1 are managed, but other-ns isn't")
Eventually(test_ns_1NS).Should(namespaceFixture.HaveLabel("argocd.argoproj.io/managed-by-cluster-argocd", "default"))
Consistently(test_ns_1NS).Should(namespaceFixture.HaveLabel("argocd.argoproj.io/managed-by-cluster-argocd", "default"))
Eventually(test_ns_1NS).Should(namespaceFixture.HaveLabel("argocd.argoproj.io/managed-by-cluster-argocd", argoNamespace.Name))
Consistently(test_ns_1NS).Should(namespaceFixture.HaveLabel("argocd.argoproj.io/managed-by-cluster-argocd", argoNamespace.Name))

Eventually(dev_ns_1NS).Should(namespaceFixture.HaveLabel("argocd.argoproj.io/managed-by-cluster-argocd", "default"))
Consistently(dev_ns_1NS).Should(namespaceFixture.HaveLabel("argocd.argoproj.io/managed-by-cluster-argocd", "default"))
Eventually(dev_ns_1NS).Should(namespaceFixture.HaveLabel("argocd.argoproj.io/managed-by-cluster-argocd", argoNamespace.Name))
Consistently(dev_ns_1NS).Should(namespaceFixture.HaveLabel("argocd.argoproj.io/managed-by-cluster-argocd", argoNamespace.Name))

expectRoleAndRoleBindingValues("example-argocd_test-ns-1", "test-ns-1")
expectRoleAndRoleBindingValues("example-argocd_dev-ns-1", "dev-ns-1")
Expand All @@ -239,18 +252,18 @@ var _ = Describe("GitOps Operator Sequential E2E Tests", func() {
})

By("verifying dev-ns-1 eventually becomes unmanaged")
Eventually(dev_ns_1NS).ShouldNot(namespaceFixture.HaveLabel("argocd.argoproj.io/managed-by-cluster-argocd", "default"))
Consistently(dev_ns_1NS).ShouldNot(namespaceFixture.HaveLabel("argocd.argoproj.io/managed-by-cluster-argocd", "default"))
Eventually(dev_ns_1NS).ShouldNot(namespaceFixture.HaveLabel("argocd.argoproj.io/managed-by-cluster-argocd", argoNamespace.Name))
Consistently(dev_ns_1NS).ShouldNot(namespaceFixture.HaveLabel("argocd.argoproj.io/managed-by-cluster-argocd", argoNamespace.Name))

devns1Role := &rbacv1.Role{
ObjectMeta: metav1.ObjectMeta{
Name: " example-argocd_dev-ns-1",
Name: "example-argocd_dev-ns-1",
Namespace: dev_ns_1NS.Name,
},
}
devns1RoleBinding := &rbacv1.RoleBinding{
ObjectMeta: metav1.ObjectMeta{
Name: " example-argocd_dev-ns-1",
Name: "example-argocd_dev-ns-1",
Namespace: dev_ns_1NS.Name,
},
}
Expand Down
Loading