github.com/argoproj/argo-cd/v2@v2.10.5/test/e2e/app_sync_options_test.go (about) 1 package e2e 2 3 import ( 4 "testing" 5 6 "github.com/argoproj/gitops-engine/pkg/health" 7 . "github.com/argoproj/gitops-engine/pkg/sync/common" 8 "github.com/stretchr/testify/assert" 9 v1 "k8s.io/api/core/v1" 10 11 . "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" 12 . "github.com/argoproj/argo-cd/v2/test/e2e/fixture" 13 . "github.com/argoproj/argo-cd/v2/test/e2e/fixture/app" 14 ) 15 16 // Given application is set with --sync-option CreateNamespace=true and --sync-option ServerSideApply=true 17 // 18 // application --dest-namespace exists 19 // 20 // Then, --dest-namespace is created with server side apply 21 // application is synced and healthy with resource 22 // application resources created with server side apply in the newly created namespace. 23 func TestNamespaceCreationWithSSA(t *testing.T) { 24 SkipOnEnv(t, "OPENSHIFT") 25 namespace := "guestbook-ui-with-ssa" 26 defer func() { 27 if !t.Skipped() { 28 _, err := Run("", "kubectl", "delete", "namespace", namespace) 29 assert.NoError(t, err) 30 } 31 }() 32 33 ctx := Given(t) 34 ctx. 35 SetAppNamespace(AppNamespace()). 36 Timeout(30). 37 Path("guestbook"). 38 When(). 39 CreateFromFile(func(app *Application) { 40 app.Spec.SyncPolicy = &SyncPolicy{ 41 SyncOptions: SyncOptions{"CreateNamespace=true", "ServerSideApply=true"}, 42 } 43 }). 44 Then(). 45 Expect(NoNamespace(namespace)). 46 When(). 47 AppSet("--dest-namespace", namespace). 48 Sync(). 49 Then(). 50 Expect(Success("")). 51 Expect(Namespace(namespace, func(app *Application, ns *v1.Namespace) { 52 assert.NotContains(t, ns.Annotations, "kubectl.kubernetes.io/last-applied-configuration") 53 })). 54 Expect(SyncStatusIs(SyncStatusCodeSynced)). 55 Expect(HealthIs(health.HealthStatusHealthy)). 56 Expect(OperationPhaseIs(OperationSucceeded)). 57 Expect(ResourceHealthWithNamespaceIs("Deployment", "guestbook-ui", namespace, health.HealthStatusHealthy)). 58 Expect(ResourceSyncStatusWithNamespaceIs("Deployment", "guestbook-ui", namespace, SyncStatusCodeSynced)). 59 Expect(ResourceHealthWithNamespaceIs("Service", "guestbook-ui", namespace, health.HealthStatusHealthy)). 60 Expect(ResourceSyncStatusWithNamespaceIs("Service", "guestbook-ui", namespace, SyncStatusCodeSynced)) 61 }