@@ -94,17 +94,17 @@ func TestAutoSyncSelfHealEnabled(t *testing.T) {
94
94
})
95
95
}
96
96
97
+ // TestAutoSyncRetryAndRefreshEnabled verifies that auto-sync+refresh picks up fixed commits automatically
97
98
func TestAutoSyncRetryAndRefreshEnabled (t * testing.T ) {
98
99
limits := []int64 {
99
- 100 , // Repeat enough times to see we move on to 3rd commit without reaching the limit
100
+ 100 , // Repeat enough times to see we move on to the 3rd commit without reaching the limit
100
101
- 1 , // Repeat forever
101
102
}
102
103
103
104
for _ , limit := range limits {
104
105
Given (t ).
105
106
Path (guestbookPath ).
106
- When ().
107
- // Correctly configured app should be auto-synced once created
107
+ When (). // I create an app with auto-sync and Refresh
108
108
CreateFromFile (func (app * Application ) {
109
109
app .Spec .SyncPolicy = & SyncPolicy {
110
110
Automated : & SyncPolicyAutomated {},
@@ -114,15 +114,14 @@ func TestAutoSyncRetryAndRefreshEnabled(t *testing.T) {
114
114
},
115
115
}
116
116
}).
117
- Then ().
117
+ Then (). // It should auto-sync correctly
118
118
Expect (OperationPhaseIs (OperationSucceeded )).
119
119
Expect (SyncStatusIs (SyncStatusCodeSynced )).
120
120
Expect (NoConditions ()).
121
- // Broken commit should make the app stuck retrying indefinitely
122
- When ().
121
+ When (). // Auto-sync encounters broken commit
123
122
PatchFile ("guestbook-ui-deployment.yaml" , `[{"op": "replace", "path": "/spec/revisionHistoryLimit", "value": "badValue"}]` ).
124
123
Refresh (RefreshTypeNormal ).
125
- Then ().
124
+ Then (). // It should keep on trying to sync it
126
125
Expect (OperationPhaseIs (OperationRunning )).
127
126
Expect (SyncStatusIs (SyncStatusCodeOutOfSync )).
128
127
Expect (OperationRetriedTimes (1 )).
@@ -133,13 +132,11 @@ func TestAutoSyncRetryAndRefreshEnabled(t *testing.T) {
133
132
Expect (OperationPhaseIs (OperationRunning )).
134
133
Expect (SyncStatusIs (SyncStatusCodeOutOfSync )).
135
134
Expect (OperationRetriedTimes (2 )).
136
- // Push fix commit and see the app pick it up
137
- When ().
138
- // Fix declaration
135
+ When (). // I push a fixed commit (while auto-sync in progress)
139
136
PatchFile ("guestbook-ui-deployment.yaml" , `[{"op": "replace", "path": "/spec/revisionHistoryLimit", "value": 42}]` ).
140
137
Refresh (RefreshTypeNormal ).
141
- Then ().
142
- // Wait for the sync retry to pick up new commit
138
+ Then (). // Argo CD should pick it up and sync it successfully
139
+ // Wait for the sync retry to pick up a new commit
143
140
And (func (_ * Application ) {
144
141
time .Sleep (10 * time .Second )
145
142
}).
@@ -148,3 +145,56 @@ func TestAutoSyncRetryAndRefreshEnabled(t *testing.T) {
148
145
Expect (OperationPhaseIs (OperationSucceeded ))
149
146
}
150
147
}
148
+
149
+ // TestAutoSyncRetryAndRefreshManualSync verifies that auto-sync+refresh do not pick new commits on manual sync
150
+ func TestAutoSyncRetryAndRefreshManualSync (t * testing.T ) {
151
+ Given (t ).
152
+ Path (guestbookPath ).
153
+ When (). // I create an app with auto-sync and Refresh
154
+ CreateFromFile (func (app * Application ) {
155
+ app .Spec .SyncPolicy = & SyncPolicy {
156
+ Automated : & SyncPolicyAutomated {},
157
+ Retry : & RetryStrategy {
158
+ Limit : - 1 ,
159
+ Refresh : true ,
160
+ },
161
+ }
162
+ }).
163
+ Then (). // It should auto-sync correctly
164
+ Expect (OperationPhaseIs (OperationSucceeded )).
165
+ Expect (SyncStatusIs (SyncStatusCodeSynced )).
166
+ Expect (NoConditions ()).
167
+ When (). // I manually sync the app on a broken commit
168
+ PatchFile ("guestbook-ui-deployment.yaml" , `[{"op": "replace", "path": "/spec/revisionHistoryLimit", "value": "badValue"}]` ).
169
+ Sync ("--async" ).
170
+ Then (). // Argo should keep on retrying
171
+ Expect (OperationPhaseIs (OperationRunning )).
172
+ //Expect(SyncStatusIs(SyncStatusCodeOutOfSync)).
173
+ Expect (OperationRetriedTimes (1 )).
174
+ And (func (_ * Application ) {
175
+ // Wait to make sure the condition is consistent
176
+ time .Sleep (10 * time .Second )
177
+ }).
178
+ Expect (OperationPhaseIs (OperationRunning )).
179
+ //Expect(SyncStatusIs(SyncStatusCodeOutOfSync)).
180
+ Expect (OperationRetriedTimes (2 )).
181
+ When (). // I push a fixed commit (during manual sync)
182
+ PatchFile ("guestbook-ui-deployment.yaml" , `[{"op": "replace", "path": "/spec/revisionHistoryLimit", "value": 42}]` ).
183
+ Then (). // Argo CD should keep on retrying the one from the tyme of the sync start
184
+ And (func (_ * Application ) {
185
+ // Wait to make sure the condition is consistent
186
+ time .Sleep (10 * time .Second )
187
+ }).
188
+ Expect (OperationRetriedTimes (3 )).
189
+ When (). // I terminate the stuck sync and start a new manual one (when ref points to fixed commit)
190
+ TerminateOp ().
191
+ And (func () {
192
+ // Wait for the operation to terminate before starting new sync
193
+ time .Sleep (1 * time .Second )
194
+ }).
195
+ Sync ("--async" ).
196
+ Then (). // Argo CD syncs successfully
197
+ Expect (NoConditions ()).
198
+ Expect (SyncStatusIs (SyncStatusCodeSynced )).
199
+ Expect (OperationPhaseIs (OperationSucceeded ))
200
+ }
0 commit comments