@@ -50,6 +50,7 @@ func TestSyncContent(t *testing.T) {
50
50
},
51
51
},
52
52
expectedListCalls : []listCall {{"sid1-1" , map [string ]string {}, true , time .Now (), 1 , nil }},
53
+ expectSuccess : true ,
53
54
errors : noerrors ,
54
55
test : testSyncContent ,
55
56
},
@@ -78,6 +79,7 @@ func TestSyncContent(t *testing.T) {
78
79
},
79
80
},
80
81
expectedListCalls : []listCall {{"sid1-2" , map [string ]string {}, true , time .Now (), 1 , nil }},
82
+ expectSuccess : true ,
81
83
errors : noerrors ,
82
84
test : testSyncContent ,
83
85
},
@@ -140,6 +142,7 @@ func TestSyncContent(t *testing.T) {
140
142
size : defaultSize ,
141
143
},
142
144
},
145
+ expectSuccess : true ,
143
146
initialSecrets : []* v1.Secret {secret ()},
144
147
expectedEvents : noevents ,
145
148
errors : noerrors ,
@@ -195,6 +198,98 @@ func TestSyncContent(t *testing.T) {
195
198
errors : noerrors ,
196
199
test : testSyncContent ,
197
200
},
201
+ {
202
+ name : "1-7: Just created un-ready snapshot should be requeued" ,
203
+ // A new snapshot should be created
204
+ initialContents : withContentStatus (newContentArray ("content1-7" , "snapuid1-7" , "snap1-7" , "sid1-7" , defaultClass , "" , "volume-handle-1-7" , retainPolicy , nil , & defaultSize , true ),
205
+ nil ),
206
+ expectedContents : withContentAnnotations (withContentStatus (newContentArray ("content1-7" , "snapuid1-7" , "snap1-7" , "sid1-7" , defaultClass , "" , "volume-handle-1-7" , retainPolicy , nil , & defaultSize , true ),
207
+ & crdv1.VolumeSnapshotContentStatus {SnapshotHandle : toStringPointer ("snapuid1-7" ), RestoreSize : & defaultSize , ReadyToUse : & False }),
208
+ map [string ]string {}),
209
+ expectedEvents : noevents ,
210
+ expectedCreateCalls : []createCall {
211
+ {
212
+ volumeHandle : "volume-handle-1-7" ,
213
+ snapshotName : "snapshot-snapuid1-7" ,
214
+ driverName : mockDriverName ,
215
+ snapshotId : "snapuid1-7" ,
216
+ parameters : map [string ]string {
217
+ utils .PrefixedVolumeSnapshotNameKey : "snap1-7" ,
218
+ utils .PrefixedVolumeSnapshotNamespaceKey : "default" ,
219
+ utils .PrefixedVolumeSnapshotContentNameKey : "content1-7" ,
220
+ },
221
+ creationTime : timeNow ,
222
+ readyToUse : false ,
223
+ size : defaultSize ,
224
+ },
225
+ },
226
+ errors : noerrors ,
227
+ expectRequeue : true ,
228
+ expectSuccess : true ,
229
+ test : testSyncContent ,
230
+ },
231
+ {
232
+ name : "1-8: Un-ready snapshot that remains un-ready should be requeued" ,
233
+ // An un-ready snapshot already exists, it will be refreshed
234
+ initialContents : withContentAnnotations (withContentStatus (newContentArray ("content1-8" , "snapuid1-8" , "snap1-8" , "sid1-8" , defaultClass , "" , "volume-handle-1-8" , retainPolicy , nil , & defaultSize , true ),
235
+ & crdv1.VolumeSnapshotContentStatus {SnapshotHandle : toStringPointer ("snapuid1-8" ), RestoreSize : & defaultSize , ReadyToUse : & False }),
236
+ map [string ]string {}),
237
+ expectedContents : withContentAnnotations (withContentStatus (newContentArray ("content1-8" , "snapuid1-8" , "snap1-8" , "sid1-8" , defaultClass , "" , "volume-handle-1-8" , retainPolicy , nil , & defaultSize , true ),
238
+ & crdv1.VolumeSnapshotContentStatus {SnapshotHandle : toStringPointer ("snapuid1-8" ), RestoreSize : & defaultSize , ReadyToUse : & False }),
239
+ map [string ]string {}),
240
+ expectedEvents : noevents ,
241
+ expectedCreateCalls : []createCall {
242
+ {
243
+ volumeHandle : "volume-handle-1-8" ,
244
+ snapshotName : "snapshot-snapuid1-8" ,
245
+ driverName : mockDriverName ,
246
+ snapshotId : "snapuid1-8" ,
247
+ parameters : map [string ]string {
248
+ utils .PrefixedVolumeSnapshotNameKey : "snap1-8" ,
249
+ utils .PrefixedVolumeSnapshotNamespaceKey : "default" ,
250
+ utils .PrefixedVolumeSnapshotContentNameKey : "content1-8" ,
251
+ },
252
+ creationTime : timeNow ,
253
+ readyToUse : false ,
254
+ size : defaultSize ,
255
+ },
256
+ },
257
+ errors : noerrors ,
258
+ expectRequeue : true ,
259
+ expectSuccess : true ,
260
+ test : testSyncContent ,
261
+ },
262
+ {
263
+ name : "1-9: Un-ready snapshot that becomes ready should not be requeued" ,
264
+ // An un-ready snapshot already exists, it will be refreshed
265
+ initialContents : withContentAnnotations (withContentStatus (newContentArray ("content1-9" , "snapuid1-9" , "snap1-9" , "sid1-9" , defaultClass , "" , "volume-handle-1-9" , retainPolicy , nil , & defaultSize , true ),
266
+ & crdv1.VolumeSnapshotContentStatus {SnapshotHandle : toStringPointer ("snapuid1-9" ), RestoreSize : & defaultSize , ReadyToUse : & False }),
267
+ map [string ]string {}),
268
+ expectedContents : withContentAnnotations (withContentStatus (newContentArray ("content1-9" , "snapuid1-9" , "snap1-9" , "sid1-9" , defaultClass , "" , "volume-handle-1-9" , retainPolicy , nil , & defaultSize , true ),
269
+ & crdv1.VolumeSnapshotContentStatus {SnapshotHandle : toStringPointer ("snapuid1-9" ), RestoreSize : & defaultSize , ReadyToUse : & True }),
270
+ map [string ]string {}),
271
+ expectedEvents : noevents ,
272
+ expectedCreateCalls : []createCall {
273
+ {
274
+ volumeHandle : "volume-handle-1-9" ,
275
+ snapshotName : "snapshot-snapuid1-9" ,
276
+ driverName : mockDriverName ,
277
+ snapshotId : "snapuid1-9" ,
278
+ parameters : map [string ]string {
279
+ utils .PrefixedVolumeSnapshotNameKey : "snap1-9" ,
280
+ utils .PrefixedVolumeSnapshotNamespaceKey : "default" ,
281
+ utils .PrefixedVolumeSnapshotContentNameKey : "content1-9" ,
282
+ },
283
+ creationTime : timeNow ,
284
+ readyToUse : true ,
285
+ size : defaultSize ,
286
+ },
287
+ },
288
+ errors : noerrors ,
289
+ expectRequeue : false ,
290
+ expectSuccess : true ,
291
+ test : testSyncContent ,
292
+ },
198
293
}
199
294
200
295
runSyncContentTests (t , tests , snapshotClasses )
0 commit comments