From eb1c365d0cf1a2a744284c74fa701da88749f555 Mon Sep 17 00:00:00 2001 From: pashakostohrys Date: Fri, 11 Aug 2023 21:42:55 +0300 Subject: [PATCH] feat: verify apply out of sync flag Signed-off-by: pashakostohrys --- test/e2e/fixture/app/actions.go | 4 ++++ test/e2e/fixture/app/context.go | 6 ++++++ test/e2e/sync_options_test.go | 17 +++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/test/e2e/fixture/app/actions.go b/test/e2e/fixture/app/actions.go index 5a2ca2748885a..f4fd167db1024 100644 --- a/test/e2e/fixture/app/actions.go +++ b/test/e2e/fixture/app/actions.go @@ -366,6 +366,10 @@ func (a *Actions) Sync(args ...string) *Actions { args = append(args, "--force") } + if a.context.applyOutOfSyncOnly { + args = append(args, "--apply-out-of-sync-only") + } + if a.context.replace { args = append(args, "--replace") } diff --git a/test/e2e/fixture/app/context.go b/test/e2e/fixture/app/context.go index d653b6a0280ca..aa961f30d15fa 100644 --- a/test/e2e/fixture/app/context.go +++ b/test/e2e/fixture/app/context.go @@ -38,6 +38,7 @@ type Context struct { project string revision string force bool + applyOutOfSyncOnly bool directoryRecurse bool replace bool helmPassCredentials bool @@ -341,6 +342,11 @@ func (c *Context) Force() *Context { return c } +func (c *Context) ApplyOutOfSyncOnly() *Context { + c.applyOutOfSyncOnly = true + return c +} + func (c *Context) HelmPassCredentials() *Context { c.helmPassCredentials = true return c diff --git a/test/e2e/sync_options_test.go b/test/e2e/sync_options_test.go index 657c8b117705b..b26034e4a7327 100644 --- a/test/e2e/sync_options_test.go +++ b/test/e2e/sync_options_test.go @@ -80,6 +80,23 @@ func TestSyncWithStatusIgnored(t *testing.T) { Expect(SyncStatusIs(SyncStatusCodeSynced)) } +func TestSyncWithApplyOutOfSyncOnly(t *testing.T) { + Given(t). + Path(guestbookPath). + ApplyOutOfSyncOnly(). + When(). + CreateFromFile(func(app *Application) { + }). + Then(). + Expect(SyncStatusIs(SyncStatusCodeOutOfSync)). + // app should remain synced when app has skipped annotation even if git change detected + When(). + PatchFile("guestbook-ui-deployment.yaml", `[{ "op": "replace", "path": "/spec/replicas", "value": 1 }]`). + Sync(). + Then(). + Expect(ResourceResultIs(ResourceResult{Group: "apps", Version: "v1", Kind: "Deployment", Namespace: "guestbook", Name: "guestbook-ui", Message: "deployment.apps/guestbook-ui created", SyncPhase: SyncPhaseSync, HookPhase: OperationRunning})) +} + func TestSyncWithSkipHook(t *testing.T) { fixture.SkipOnEnv(t, "OPENSHIFT") Given(t).