Skip to content

Commit 1c4dd87

Browse files
committed
chore: add e2e test for Delete/Prune option on application
Signed-off-by: Arthur Outhenin-Chalandre <[email protected]>
1 parent fcf0d09 commit 1c4dd87

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

test/e2e/app_management_test.go

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1730,6 +1730,7 @@ func TestPermissionDeniedWithNegatedServer(t *testing.T) {
17301730

17311731
// make sure that if we deleted a resource from the app, it is not pruned if annotated with Prune=false
17321732
func TestSyncOptionPruneFalse(t *testing.T) {
1733+
// Resource level
17331734
Given(t).
17341735
Path("two-nice-pods").
17351736
When().
@@ -1748,6 +1749,55 @@ func TestSyncOptionPruneFalse(t *testing.T) {
17481749
Expect(OperationPhaseIs(OperationSucceeded)).
17491750
Expect(SyncStatusIs(SyncStatusCodeOutOfSync)).
17501751
Expect(ResourceSyncStatusIs("Pod", "pod-1", SyncStatusCodeOutOfSync))
1752+
1753+
// App level
1754+
Given(t).
1755+
Path("two-nice-pods").
1756+
When().
1757+
CreateApp().
1758+
PatchApp(`[{
1759+
"op": "add",
1760+
"path": "/spec/syncPolicy",
1761+
"value": { "syncOptions": ["Prune=false"] }
1762+
}]`).
1763+
Sync().
1764+
Then().
1765+
Expect(OperationPhaseIs(OperationSucceeded)).
1766+
Expect(SyncStatusIs(SyncStatusCodeSynced)).
1767+
When().
1768+
DeleteFile("pod-1.yaml").
1769+
Refresh(RefreshTypeHard).
1770+
IgnoreErrors().
1771+
Sync().
1772+
Then().
1773+
Expect(OperationPhaseIs(OperationSucceeded)).
1774+
Expect(SyncStatusIs(SyncStatusCodeOutOfSync)).
1775+
Expect(ResourceSyncStatusIs("Pod", "pod-1", SyncStatusCodeOutOfSync))
1776+
1777+
// Also check that another setting on a resource level correctly override app level
1778+
Given(t).
1779+
Path("two-nice-pods").
1780+
When().
1781+
CreateApp().
1782+
PatchApp(`[{
1783+
"op": "add",
1784+
"path": "/spec/syncPolicy",
1785+
"value": { "syncOptions": ["Prune=true"] }
1786+
}]`).
1787+
PatchFile("pod-1.yaml", `[{"op": "add", "path": "/metadata/annotations", "value": {"argocd.argoproj.io/sync-options": "Prune=false"}}]`).
1788+
Sync().
1789+
Then().
1790+
Expect(OperationPhaseIs(OperationSucceeded)).
1791+
Expect(SyncStatusIs(SyncStatusCodeSynced)).
1792+
When().
1793+
DeleteFile("pod-1.yaml").
1794+
Refresh(RefreshTypeHard).
1795+
IgnoreErrors().
1796+
Sync().
1797+
Then().
1798+
Expect(OperationPhaseIs(OperationSucceeded)).
1799+
Expect(SyncStatusIs(SyncStatusCodeOutOfSync)).
1800+
Expect(ResourceSyncStatusIs("Pod", "pod-1", SyncStatusCodeOutOfSync))
17511801
}
17521802

17531803
// make sure that if we have an invalid manifest, we can add it if we disable validation, we get a server error rather than a client error
@@ -3085,6 +3135,40 @@ func TestDeletionConfirmation(t *testing.T) {
30853135
}).
30863136
When().ConfirmDeletion().
30873137
Then().Expect(DoesNotExist())
3138+
3139+
ctx = Given(t)
3140+
ctx.
3141+
And(func() {
3142+
_, err := fixture.KubeClientset.CoreV1().ConfigMaps(fixture.DeploymentNamespace()).Create(
3143+
t.Context(), &corev1.ConfigMap{
3144+
ObjectMeta: metav1.ObjectMeta{
3145+
Name: "test-configmap",
3146+
Labels: map[string]string{
3147+
common.LabelKeyAppInstance: ctx.AppName(),
3148+
},
3149+
},
3150+
}, metav1.CreateOptions{})
3151+
require.NoError(t, err)
3152+
}).
3153+
Path(guestbookPath).
3154+
Async(true).
3155+
When().
3156+
CreateApp().Then().When().
3157+
PatchApp(`[{
3158+
"op": "add",
3159+
"path": "/spec/syncPolicy",
3160+
"value": { "syncOptions": ["Delete=confirm", "Prune=confirm"] }
3161+
}]`).Sync().
3162+
Then().Expect(OperationPhaseIs(OperationRunning)).
3163+
When().ConfirmDeletion().
3164+
Then().Expect(OperationPhaseIs(OperationSucceeded)).
3165+
When().Delete(true).
3166+
Then().
3167+
And(func(app *Application) {
3168+
assert.NotNil(t, app.DeletionTimestamp)
3169+
}).
3170+
When().ConfirmDeletion().
3171+
Then().Expect(DoesNotExist())
30883172
}
30893173

30903174
func TestLastTransitionTimeUnchangedError(t *testing.T) {

0 commit comments

Comments
 (0)