From d4c5f5d478daca63cd15490d61b603a5dafa9caa Mon Sep 17 00:00:00 2001 From: darshanime Date: Sat, 13 Jun 2020 20:37:45 +0530 Subject: [PATCH] feat: add e2e test for disable global status Signed-off-by: darshanime --- test/e2e/sync_options_test.go | 36 +++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/test/e2e/sync_options_test.go b/test/e2e/sync_options_test.go index aae54795cf18..3a9f4b075cf2 100644 --- a/test/e2e/sync_options_test.go +++ b/test/e2e/sync_options_test.go @@ -5,7 +5,11 @@ import ( "testing" . "github.com/argoproj/gitops-engine/pkg/sync/common" + "github.com/argoproj/gitops-engine/pkg/utils/errors" + "k8s.io/apimachinery/pkg/types" + . "github.com/argoproj/argo-cd/pkg/apis/application/v1alpha1" + "github.com/argoproj/argo-cd/test/e2e/fixture" . "github.com/argoproj/argo-cd/test/e2e/fixture/app" ) @@ -41,3 +45,35 @@ func TestSyncOptionsValidateTrue(t *testing.T) { Then(). Expect(OperationPhaseIs(OperationFailed)) } + +func TestSyncWithStatusIgnored(t *testing.T) { + Given(t). + Path(guestbookPath). + When(). + And(func() { + fixture.SetResourceOverrides(map[string]ResourceOverride{ + "/": { + IgnoreDifferences: "jsonPointers:\n- /status", + }, + }) + }). + CreateFromFile(func(app *Application) { + app.Spec.SyncPolicy = &SyncPolicy{Automated: &SyncPolicyAutomated{SelfHeal: true}} + }). + Then(). + Expect(SyncStatusIs(SyncStatusCodeSynced)). + // app should remain synced if git change detected + When(). + PatchFile("guestbook-ui-deployment.yaml", `[{ "op": "add", "path": "/status", "value": { "observedGeneration": 1 }}]`). + Refresh(RefreshTypeNormal). + Then(). + Expect(SyncStatusIs(SyncStatusCodeSynced)). + // app should remain synced if k8s change detected + When(). + And(func() { + errors.FailOnErr(fixture.KubeClientset.AppsV1().Deployments(fixture.DeploymentNamespace()).Patch( + "guestbook-ui", types.JSONPatchType, []byte(`[{ "op": "replace", "path": "/status/observedGeneration", "value": 2 }]`))) + }). + Then(). + Expect(SyncStatusIs(SyncStatusCodeSynced)) +}