@@ -272,6 +272,8 @@ var _ = DescribeSanity("ListVolumes [Controller Server]", func(sc *SanityContext
272
272
// currentTotalVols is the total number of volumes at a given time. It
273
273
// is used to verify that all the volumes have been listed.
274
274
currentTotalVols := 0
275
+ // newVolIDs to keep a record of the newly created volume ids.
276
+ var newVolIDs []string
275
277
276
278
// Get the number of existing volumes.
277
279
vols , err := c .ListVolumes (
@@ -311,6 +313,7 @@ var _ = DescribeSanity("ListVolumes [Controller Server]", func(sc *SanityContext
311
313
vol , err := c .CreateVolume (context .Background (), req )
312
314
Expect (err ).NotTo (HaveOccurred ())
313
315
Expect (vol ).NotTo (BeNil ())
316
+ newVolIDs = append (newVolIDs , vol .GetVolume ().GetId ())
314
317
}
315
318
316
319
// Update the current total vols count.
@@ -331,26 +334,12 @@ var _ = DescribeSanity("ListVolumes [Controller Server]", func(sc *SanityContext
331
334
Expect (nextToken ).To (Equal (strconv .Itoa (maxEntries )))
332
335
Expect (len (vols .GetEntries ())).To (Equal (maxEntries ))
333
336
334
- // Request list volumes with starting_token and no max entries.
335
- vols , err = c .ListVolumes (
336
- context .Background (),
337
- & csi.ListVolumesRequest {
338
- StartingToken : nextToken ,
339
- })
340
- Expect (err ).NotTo (HaveOccurred ())
341
- Expect (vols ).NotTo (BeNil ())
342
-
343
- // Ensure that all the remaining entries are returned at once.
344
- Expect (len (vols .GetEntries ())).To (Equal (currentTotalVols - maxEntries ))
345
-
346
337
if initialTotalVols < minVolCount {
347
338
348
339
By ("cleaning up deleting the volumes" )
349
- requiredVols := minVolCount - initialTotalVols
350
- name := "sanity"
351
- for i := 1 ; i <= requiredVols ; i ++ {
340
+ for _ , volID := range newVolIDs {
352
341
delReq := & csi.DeleteVolumeRequest {
353
- VolumeId : name + strconv . Itoa ( i ) ,
342
+ VolumeId : volID ,
354
343
}
355
344
356
345
if sc .Secrets != nil {
0 commit comments