-
Notifications
You must be signed in to change notification settings - Fork 348
ginkgo test for GITOPS-5701-1-122_validate_user_defined_appproject #1068
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
openshift-merge-bot
merged 6 commits into
redhat-developer:master
from
Naveena-058:GITOPS-5701-1-122_validate_user_defined_appproject
Feb 17, 2026
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1dd7f4f
ginkgo test for GITOPS-5701-1-122_validate_user_defined_appproject
nas438 d32ad22
Merge branch 'redhat-developer:master' into GITOPS-5701-1-122_validat…
Naveena-058 b33f475
Update test name
nas438 c8e50c1
Merge branch 'master' into GITOPS-5701-1-122_validate_user_defined_ap…
Naveena-058 3b694a8
Merge branch 'redhat-developer:master' into GITOPS-5701-1-122_validat…
Naveena-058 d17f175
Merge branch 'master' into GITOPS-5701-1-122_validate_user_defined_ap…
Naveena-058 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
163 changes: 163 additions & 0 deletions
163
test/openshift/e2e/ginkgo/parallel/1-122_validate_user_defined_appproject.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,163 @@ | ||
| /* | ||
| 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" | ||
|
|
||
| argov1beta1api "github.com/argoproj-labs/argocd-operator/api/v1beta1" | ||
| 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" | ||
| corev1 "k8s.io/api/core/v1" | ||
| metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
| "sigs.k8s.io/controller-runtime/pkg/client" | ||
|
|
||
| "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture" | ||
| applicationFixture "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture/application" | ||
| 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" | ||
| fixtureUtils "github.com/redhat-developer/gitops-operator/test/openshift/e2e/ginkgo/fixture/utils" | ||
| ) | ||
|
|
||
| var _ = Describe("GitOps Operator Parallel E2E Tests", func() { | ||
|
|
||
| Context("1-122_validate_user_defined_appproject", func() { | ||
|
|
||
| var ( | ||
| k8sClient client.Client | ||
| ctx context.Context | ||
| ns *corev1.Namespace | ||
| cleanupFunc func() | ||
| cleanupFuncs []func() | ||
| ) | ||
|
|
||
| BeforeEach(func() { | ||
| fixture.EnsureParallelCleanSlate() | ||
|
|
||
| k8sClient, _ = fixtureUtils.GetE2ETestKubeClient() | ||
| ctx = context.Background() | ||
| }) | ||
|
|
||
| AfterEach(func() { | ||
| // Clean up all additional namespaces | ||
| for _, cleanup := range cleanupFuncs { | ||
| if cleanup != nil { | ||
| cleanup() | ||
| } | ||
| } | ||
| cleanupFuncs = nil | ||
|
|
||
| if cleanupFunc != nil { | ||
| cleanupFunc() | ||
| } | ||
|
|
||
| fixture.OutputDebugOnFail(ns) | ||
| }) | ||
|
|
||
| It("verifies creating and configuring a user-defined AppProject instance with target namespaces and Application CR referencing it", func() { | ||
|
|
||
| By("creating namespace-scoped Argo CD instance") | ||
| ns, cleanupFunc = fixture.CreateRandomE2ETestNamespaceWithCleanupFunc() | ||
|
|
||
| argoCD := &argov1beta1api.ArgoCD{ | ||
| ObjectMeta: metav1.ObjectMeta{Name: "argocd", Namespace: ns.Name}, | ||
| Spec: argov1beta1api.ArgoCDSpec{}, | ||
| } | ||
| Expect(k8sClient.Create(ctx, argoCD)).To(Succeed()) | ||
|
|
||
| By("waiting for ArgoCD CR to be reconciled and the instance to be ready") | ||
| Eventually(argoCD, "8m", "10s").Should(argocdFixture.BeAvailable()) | ||
|
|
||
| By("creating target namespace for deployment") | ||
| var targetNS *corev1.Namespace | ||
| targetNS, targetCleanup := fixture.CreateManagedNamespaceWithCleanupFunc(ns.Name+"-target", ns.Name) | ||
| cleanupFuncs = append(cleanupFuncs, targetCleanup) | ||
|
|
||
| By("creating and configuring a user-defined AppProject instance with the target namespace") | ||
| appProjectName := "user-defined-project" | ||
| appProject := &argocdv1alpha1.AppProject{ | ||
| ObjectMeta: metav1.ObjectMeta{ | ||
| Name: appProjectName, | ||
| Namespace: ns.Name, | ||
| }, | ||
| Spec: argocdv1alpha1.AppProjectSpec{ | ||
| SourceRepos: []string{"*"}, | ||
| Destinations: []argocdv1alpha1.ApplicationDestination{ | ||
| { | ||
| Server: "https://kubernetes.default.svc", | ||
| Namespace: targetNS.Name, | ||
| }, | ||
| }, | ||
| ClusterResourceWhitelist: []metav1.GroupKind{ | ||
| { | ||
| Group: "*", | ||
| Kind: "*", | ||
| }, | ||
| }, | ||
| }, | ||
| } | ||
| Expect(k8sClient.Create(ctx, appProject)).To(Succeed()) | ||
|
|
||
| By("verifying AppProject exists and is configured correctly") | ||
| Eventually(appProject, "2m", "5s").Should(k8sFixture.ExistByName(), "AppProject did not exist within timeout") | ||
|
|
||
| // Verify AppProject configuration | ||
| Expect(k8sClient.Get(ctx, client.ObjectKeyFromObject(appProject), appProject)).To(Succeed()) | ||
| Expect(len(appProject.Spec.Destinations)).To(BeNumerically(">", 0), "AppProject should have at least one destination configured") | ||
| Expect(appProject.Spec.Destinations[0].Namespace).To(Equal(targetNS.Name), "AppProject destination should match target namespace") | ||
| Expect(appProject.Spec.Destinations[0].Server).To(Equal("https://kubernetes.default.svc"), "AppProject destination server should be configured") | ||
|
|
||
| By("creating and configuring the Application CR to reference the target namespace and user-defined AppProject instance") | ||
| app := &argocdv1alpha1.Application{ | ||
| ObjectMeta: metav1.ObjectMeta{ | ||
| Name: "test-app", | ||
| Namespace: ns.Name, | ||
| }, | ||
| Spec: argocdv1alpha1.ApplicationSpec{ | ||
| Project: appProjectName, | ||
| 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: targetNS.Name, | ||
| }, | ||
| SyncPolicy: &argocdv1alpha1.SyncPolicy{ | ||
| Automated: &argocdv1alpha1.SyncPolicyAutomated{}, | ||
| }, | ||
| }, | ||
| } | ||
| Expect(k8sClient.Create(ctx, app)).To(Succeed()) | ||
|
|
||
| By("verifying Application is healthy and syncs successfully") | ||
| Eventually(app, "8m", "10s").Should(applicationFixture.HaveHealthStatusCode(health.HealthStatusHealthy), "Application did not reach healthy status within timeout") | ||
| Eventually(app, "8m", "10s").Should(applicationFixture.HaveSyncStatusCode(argocdv1alpha1.SyncStatusCodeSynced), "Application did not sync within timeout") | ||
|
|
||
| By("verifying Application references the user-defined AppProject") | ||
| Expect(k8sClient.Get(ctx, client.ObjectKeyFromObject(app), app)).To(Succeed()) | ||
| Expect(app.Spec.Project).To(Equal(appProjectName), "Application should reference the user-defined AppProject") | ||
|
|
||
| By("verifying Application targets the correct namespace") | ||
| Expect(app.Spec.Destination.Namespace).To(Equal(targetNS.Name), "Application should target the configured namespace") | ||
|
|
||
| }) | ||
| }) | ||
| }) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you update the file name to match the test name i.e
122_validate_user_defined_appproject.