Skip to content

Commit

Permalink
added e2e test
Browse files Browse the repository at this point in the history
Signed-off-by: Atif Ali <[email protected]>
  • Loading branch information
aali309 committed Feb 6, 2025
1 parent beed298 commit e5d4883
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 4 deletions.
9 changes: 9 additions & 0 deletions test/e2e/fixture/app/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -519,3 +519,12 @@ func (a *Actions) SetTrackingLabel(trackingLabel string) *Actions {
errors.CheckError(fixture.SetTrackingLabel(trackingLabel))
return a
}

// AddAnnotatedTag creates an annotated git tag
func (a *Actions) AddAnnotatedTag(tag, message string) *Actions {
_, err := fixture.RunCli("git", "tag", "-a", tag, "-m", message)
errors.CheckError(err)
_, err = fixture.RunCli("git", "push", "origin", tag)
errors.CheckError(err)
return a
}
45 changes: 45 additions & 0 deletions test/e2e/git_test.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package e2e

import (
"encoding/json"
"strings"
"testing"

appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"

. "github.com/argoproj/argo-cd/v3/pkg/apis/application/v1alpha1"
"github.com/argoproj/argo-cd/v3/test/e2e/fixture"
. "github.com/argoproj/argo-cd/v3/test/e2e/fixture/app"
"github.com/stretchr/testify/assert"
)

func TestGitSemverResolutionNotUsingConstraint(t *testing.T) {
Expand Down Expand Up @@ -90,3 +93,45 @@ func TestGitSemverResolutionUsingConstraintWithLeadingZero(t *testing.T) {
Expect(SyncStatusIs(SyncStatusCodeSynced)).
Expect(Pod(func(p corev1.Pod) bool { return strings.HasPrefix(p.Name, "new-app") }))
}

func TestAnnotatedTagInStatusSyncRevision(t *testing.T) {
Given(t).
Path("deployment").
RepoURLType(fixture.RepoURLTypeFile).
Revision("my-annotated-tag").
When().
//AddAnnotatedTag("my-annotated-tag", "Testing annotated tag resolution").
CreateFromFile(func(app *Application) {
app.Spec.SyncPolicy = &SyncPolicy{
Automated: &SyncPolicyAutomated{
Prune: true,
SelfHeal: false,
},
}
}).
Sync().
Then().
// Verify initial sync succeeds and uses commit SHA
Expect(SyncStatusIs(SyncStatusCodeSynced)).
And(func(app *Application) {
// Verify the revision is a commit SHA, not the tag ref
assert.Len(t, app.Status.Sync.Revision, 40) // SHA-1 is 40 chars
assert.NotContains(t, app.Status.Sync.Revision, "refs/tags/")
}).
When().
// Make a manual change
PatchFile("deployment.yaml", `[
{"op": "replace", "path": "/spec/revisionHistoryLimit", "value": 10}
]`).
Then().
// Verify change persists (not reverted) but shows OutOfSync
Expect(SyncStatusIs(SyncStatusCodeOutOfSync)).
And(func(app *Application) {
// Get deployment from live manifest
deployment := &appsv1.Deployment{}
err := json.Unmarshal([]byte(app.Status.Resources[0].Health.Status), deployment)
assert.NoError(t, err)
assert.Equal(t, int32(10), deployment.Spec.RevisionHistoryLimit)
assert.Len(t, app.Status.Sync.Revision, 40)
})
}
9 changes: 5 additions & 4 deletions test/e2e/testdata/deployment/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ metadata:
labels:
app: nginx
spec:
revisionHistoryLimit: 3
replicas: 0
selector:
matchLabels:
Expand All @@ -15,7 +16,7 @@ spec:
app: nginx
spec:
containers:
- name: nginx
image: quay.io/argoprojlabs/argocd-e2e-container:0.1
ports:
- containerPort: 80
- name: nginx
image: quay.io/argoprojlabs/argocd-e2e-container:0.1
ports:
- containerPort: 80

0 comments on commit e5d4883

Please sign in to comment.