Skip to content

Commit

Permalink
feat: tracking method e2e (argoproj#7310)
Browse files Browse the repository at this point in the history
feat: tracking method e2e (argoproj#7310)

Signed-off-by: pashavictorovich <[email protected]>
  • Loading branch information
pasha-codefresh authored Sep 28, 2021
1 parent bb88a1c commit a731997
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
73 changes: 73 additions & 0 deletions test/e2e/deployment_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
package e2e

import (
"fmt"
"testing"

"github.com/stretchr/testify/assert"

"github.com/argoproj/argo-cd/v2/util/argo"

"github.com/argoproj/gitops-engine/pkg/health"
. "github.com/argoproj/gitops-engine/pkg/sync/common"

. "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1"
. "github.com/argoproj/argo-cd/v2/test/e2e/fixture"
. "github.com/argoproj/argo-cd/v2/test/e2e/fixture/app"
)

Expand All @@ -31,3 +37,70 @@ func TestDeployment(t *testing.T) {
]`).
Sync()
}

func TestDeploymentWithAnnotationTrackingMode(t *testing.T) {
ctx := Given(t)

SetTrackingMethod(string(argo.TrackingMethodAnnotation))
ctx.
Path("deployment").
When().
Create().
Sync().
Then().
Expect(OperationPhaseIs(OperationSucceeded)).
Expect(SyncStatusIs(SyncStatusCodeSynced)).
Expect(HealthIs(health.HealthStatusHealthy)).
When().
Then().
And(func(app *Application) {
out, err := RunCli("app", "manifests", app.Name)
assert.NoError(t, err)
assert.Contains(t, out, fmt.Sprintf(`annotations:
app.kubernetes.io/instance: %s`, Name()))
})
}

func TestDeploymentWithLabelTrackingMode(t *testing.T) {
ctx := Given(t)
SetTrackingMethod(string(argo.TrackingMethodLabel))
ctx.
Path("deployment").
When().
Create().
Sync().
Then().
Expect(OperationPhaseIs(OperationSucceeded)).
Expect(SyncStatusIs(SyncStatusCodeSynced)).
Expect(HealthIs(health.HealthStatusHealthy)).
When().
Then().
And(func(app *Application) {
out, err := RunCli("app", "manifests", app.Name)
assert.NoError(t, err)
assert.Contains(t, out, fmt.Sprintf(`labels:
app: nginx
app.kubernetes.io/instance: %s`, Name()))
})
}

func TestDeploymentWithoutTrackingMode(t *testing.T) {
Given(t).
Path("deployment").
When().
Create().
Sync().
Then().
Expect(OperationPhaseIs(OperationSucceeded)).
Expect(SyncStatusIs(SyncStatusCodeSynced)).
Expect(HealthIs(health.HealthStatusHealthy)).
When().
Then().
And(func(app *Application) {
out, err := RunCli("app", "manifests", app.Name)
assert.NoError(t, err)
assert.Contains(t, out, fmt.Sprintf(`labels:
app: nginx
app.kubernetes.io/instance: %s`, Name()))
})
}
7 changes: 7 additions & 0 deletions test/e2e/fixture/fixture.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,13 @@ func SetResourceOverrides(overrides map[string]v1alpha1.ResourceOverride) {
SetResourceOverridesSplitKeys(overrides)
}

func SetTrackingMethod(trackingMethod string) {
updateSettingConfigMap(func(cm *corev1.ConfigMap) error {
cm.Data["application.resourceTrackingMethod"] = trackingMethod
return nil
})
}

func SetResourceOverridesSplitKeys(overrides map[string]v1alpha1.ResourceOverride) {
updateSettingConfigMap(func(cm *corev1.ConfigMap) error {
for k, v := range overrides {
Expand Down

0 comments on commit a731997

Please sign in to comment.