Skip to content

Commit 0f2900f

Browse files
committed
Remove remaining entries check and fix cleanup
1 parent 63cb159 commit 0f2900f

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

pkg/sanity/controller.go

+5-16
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,8 @@ var _ = DescribeSanity("ListVolumes [Controller Server]", func(sc *SanityContext
272272
// currentTotalVols is the total number of volumes at a given time. It
273273
// is used to verify that all the volumes have been listed.
274274
currentTotalVols := 0
275+
// newVolIDs to keep a record of the newly created volume ids.
276+
var newVolIDs []string
275277

276278
// Get the number of existing volumes.
277279
vols, err := c.ListVolumes(
@@ -311,6 +313,7 @@ var _ = DescribeSanity("ListVolumes [Controller Server]", func(sc *SanityContext
311313
vol, err := c.CreateVolume(context.Background(), req)
312314
Expect(err).NotTo(HaveOccurred())
313315
Expect(vol).NotTo(BeNil())
316+
newVolIDs = append(newVolIDs, vol.GetVolume().GetId())
314317
}
315318

316319
// Update the current total vols count.
@@ -331,26 +334,12 @@ var _ = DescribeSanity("ListVolumes [Controller Server]", func(sc *SanityContext
331334
Expect(nextToken).To(Equal(strconv.Itoa(maxEntries)))
332335
Expect(len(vols.GetEntries())).To(Equal(maxEntries))
333336

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-
346337
if initialTotalVols < minVolCount {
347338

348339
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 {
352341
delReq := &csi.DeleteVolumeRequest{
353-
VolumeId: name + strconv.Itoa(i),
342+
VolumeId: volID,
354343
}
355344

356345
if sc.Secrets != nil {

0 commit comments

Comments
 (0)