Skip to content

Commit

Permalink
fix: ApplicationSet e2e TestSyncPolicyCreateUpdate&TestSyncPolicyCrea…
Browse files Browse the repository at this point in the history
…teOnly test race condition bug argoproj#19577 (argoproj#19578)

* fixed e2e TestSyncPolicyCreateUpdate&TestSyncPolicyCreateOnly bug

Signed-off-by: Li. Sparks <[email protected]>

* format

Signed-off-by: Li. Sparks <[email protected]>

* change the comment, explain why apps still exists

Signed-off-by: Li. Sparks <[email protected]>

---------

Signed-off-by: Li. Sparks <[email protected]>
  • Loading branch information
a244591052 authored Aug 29, 2024
1 parent 3feab7a commit 2c8a574
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions test/e2e/applicationset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -913,9 +916,11 @@ 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(ApplicationsDoNotExist([]argov1alpha1.Application{*expectedAppNewMetadata}))
Delete().Then().Expect(ApplicationsExist([]argov1alpha1.Application{*expectedAppNewMetadata}))
}

func TestSyncPolicyCreateDelete(t *testing.T) {
Expand Down Expand Up @@ -1052,7 +1057,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{
Expand Down Expand Up @@ -1111,9 +1119,11 @@ 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(ApplicationsDoNotExist([]argov1alpha1.Application{*expectedAppNewNamespace}))
Delete().Then().Expect(ApplicationsExist([]argov1alpha1.Application{*expectedAppNewNamespace}))
}

func TestSimpleGitDirectoryGenerator(t *testing.T) {
Expand Down

0 comments on commit 2c8a574

Please sign in to comment.