From 39feee04052cc22ef99baa5867340aac727ac9da Mon Sep 17 00:00:00 2001 From: "Li. Sparks" <15156525868@163.com> Date: Sun, 18 Aug 2024 12:52:23 +0800 Subject: [PATCH 1/3] fixed e2e TestSyncPolicyCreateUpdate&TestSyncPolicyCreateOnly bug Signed-off-by: Li. Sparks <15156525868@163.com> --- test/e2e/applicationset_test.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/test/e2e/applicationset_test.go b/test/e2e/applicationset_test.go index 90496fa57d5a4..7523ac136e57d 100644 --- a/test/e2e/applicationset_test.go +++ b/test/e2e/applicationset_test.go @@ -845,7 +845,10 @@ func TestSyncPolicyCreateUpdate(t *testing.T) { Spec: v1alpha1.ApplicationSetSpec{ GoTemplate: true, Template: v1alpha1.ApplicationSetTemplate{ - ApplicationSetTemplateMeta: v1alpha1.ApplicationSetTemplateMeta{Name: "{{.cluster}}-guestbook-sync-policy-create-update"}, + ApplicationSetTemplateMeta: v1alpha1.ApplicationSetTemplateMeta{ + Name: "{{.cluster}}-guestbook-sync-policy-create-update", + Finalizers: []string{"resources-finalizer.argocd.argoproj.io"}, + }, Spec: argov1alpha1.ApplicationSpec{ Project: "default", Source: &argov1alpha1.ApplicationSource{ @@ -915,7 +918,7 @@ func TestSyncPolicyCreateUpdate(t *testing.T) { // Delete the ApplicationSet, and verify it deletes the Applications When(). - Delete().Then().Expect(ApplicationsDoNotExist([]argov1alpha1.Application{*expectedAppNewMetadata})) + Delete().Then().Expect(ApplicationsExist([]argov1alpha1.Application{*expectedAppNewMetadata})) } func TestSyncPolicyCreateDelete(t *testing.T) { @@ -1052,7 +1055,10 @@ func TestSyncPolicyCreateOnly(t *testing.T) { Spec: v1alpha1.ApplicationSetSpec{ GoTemplate: true, Template: v1alpha1.ApplicationSetTemplate{ - ApplicationSetTemplateMeta: v1alpha1.ApplicationSetTemplateMeta{Name: "{{.cluster}}-guestbook-sync-policy-create-only"}, + ApplicationSetTemplateMeta: v1alpha1.ApplicationSetTemplateMeta{ + Name: "{{.cluster}}-guestbook-sync-policy-create-only", + Finalizers: []string{"resources-finalizer.argocd.argoproj.io"}, + }, Spec: argov1alpha1.ApplicationSpec{ Project: "default", Source: &argov1alpha1.ApplicationSource{ @@ -1113,7 +1119,7 @@ func TestSyncPolicyCreateOnly(t *testing.T) { // Delete the ApplicationSet, and verify it deletes the Applications When(). - Delete().Then().Expect(ApplicationsDoNotExist([]argov1alpha1.Application{*expectedAppNewNamespace})) + Delete().Then().Expect(ApplicationsExist([]argov1alpha1.Application{*expectedAppNewNamespace})) } func TestSimpleGitDirectoryGenerator(t *testing.T) { From 6239d9745e08867c25b75425745b19bedca82b7c Mon Sep 17 00:00:00 2001 From: "Li. Sparks" <15156525868@163.com> Date: Sun, 18 Aug 2024 14:13:20 +0800 Subject: [PATCH 2/3] format Signed-off-by: Li. Sparks <15156525868@163.com> --- test/e2e/applicationset_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/e2e/applicationset_test.go b/test/e2e/applicationset_test.go index 7523ac136e57d..46d0cd73c8532 100644 --- a/test/e2e/applicationset_test.go +++ b/test/e2e/applicationset_test.go @@ -846,7 +846,7 @@ func TestSyncPolicyCreateUpdate(t *testing.T) { GoTemplate: true, Template: v1alpha1.ApplicationSetTemplate{ ApplicationSetTemplateMeta: v1alpha1.ApplicationSetTemplateMeta{ - Name: "{{.cluster}}-guestbook-sync-policy-create-update", + Name: "{{.cluster}}-guestbook-sync-policy-create-update", Finalizers: []string{"resources-finalizer.argocd.argoproj.io"}, }, Spec: argov1alpha1.ApplicationSpec{ @@ -1056,7 +1056,7 @@ func TestSyncPolicyCreateOnly(t *testing.T) { GoTemplate: true, Template: v1alpha1.ApplicationSetTemplate{ ApplicationSetTemplateMeta: v1alpha1.ApplicationSetTemplateMeta{ - Name: "{{.cluster}}-guestbook-sync-policy-create-only", + Name: "{{.cluster}}-guestbook-sync-policy-create-only", Finalizers: []string{"resources-finalizer.argocd.argoproj.io"}, }, Spec: argov1alpha1.ApplicationSpec{ From 37b1d0189fc5acaf0b0497d81ff1165161bac439 Mon Sep 17 00:00:00 2001 From: "Li. Sparks" <15156525868@163.com> Date: Sun, 25 Aug 2024 10:30:21 +0800 Subject: [PATCH 3/3] change the comment, explain why apps still exists Signed-off-by: Li. Sparks <15156525868@163.com> --- test/e2e/applicationset_test.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/test/e2e/applicationset_test.go b/test/e2e/applicationset_test.go index 46d0cd73c8532..5df36d591b1d9 100644 --- a/test/e2e/applicationset_test.go +++ b/test/e2e/applicationset_test.go @@ -916,7 +916,9 @@ func TestSyncPolicyCreateUpdate(t *testing.T) { // verify the ApplicationSet status conditions were set correctly Expect(ApplicationSetHasConditions("sync-policy-create-update", ExpectedConditions)). - // Delete the ApplicationSet, and verify it deletes the Applications + // Delete the ApplicationSet, and verify it not deletes the Applications + // As policy is create-update, AppSet controller will remove all generated applications's ownerReferences on delete AppSet + // So AppSet deletion will be reflected, but all the applications it generates will still exist When(). Delete().Then().Expect(ApplicationsExist([]argov1alpha1.Application{*expectedAppNewMetadata})) } @@ -1117,7 +1119,9 @@ func TestSyncPolicyCreateOnly(t *testing.T) { // verify the ApplicationSet status conditions were set correctly Expect(ApplicationSetHasConditions("sync-policy-create-only", ExpectedConditions)). - // Delete the ApplicationSet, and verify it deletes the Applications + // Delete the ApplicationSet, and verify it not deletes the Applications + // As policy is create-update, AppSet controller will remove all generated applications's ownerReferences on delete AppSet + // So AppSet deletion will be reflected, but all the applications it generates will still exist When(). Delete().Then().Expect(ApplicationsExist([]argov1alpha1.Application{*expectedAppNewNamespace})) }