diff --git a/pkg/gce-cloud-provider/compute/gce-compute.go b/pkg/gce-cloud-provider/compute/gce-compute.go index 63402cd23..c03ceeac9 100644 --- a/pkg/gce-cloud-provider/compute/gce-compute.go +++ b/pkg/gce-cloud-provider/compute/gce-compute.go @@ -315,6 +315,7 @@ func (cloud *CloudProvider) ListSnapshots(ctx context.Context, filter string) ([ return nil, "", err } items = append(items, snapshotList.Items...) + nextPageToken = snapshotList.NextPageToken } return items, "", nil } @@ -1310,6 +1311,7 @@ func (cloud *CloudProvider) ListImages(ctx context.Context, filter string) ([]*c return nil, "", err } items = append(items, imageList.Items...) + nextPageToken = imageList.NextPageToken } return items, "", nil } diff --git a/test/e2e/tests/single_zone_e2e_test.go b/test/e2e/tests/single_zone_e2e_test.go index e3749d8f8..f50994ea6 100644 --- a/test/e2e/tests/single_zone_e2e_test.go +++ b/test/e2e/tests/single_zone_e2e_test.go @@ -1065,6 +1065,10 @@ var _ = Describe("GCE PD CSI Driver", func() { }) Expect(err).To(BeNil(), "Could not wait for snapshot be ready") + snapshots, err := client.ListSnapshots() + Expect(err).To(BeNil(), "Could not list snapshots") + Expect(snapshots).To(ContainElement(snapshotID), "Couldn't find snapshot ID") + defer func() { // Delete Disk err := client.DeleteVolume(volID) @@ -1124,6 +1128,10 @@ var _ = Describe("GCE PD CSI Driver", func() { Expect(err).To(BeNil(), "Failed to parse snapshot ID") Expect(snapshotType).To(Equal(common.DiskImageType), "Expected images type in snapshot ID") + snapshots, err := client.ListSnapshots() + Expect(err).To(BeNil(), "Could not list snapshots") + Expect(snapshots).To(ContainElement(snapshotID), "Couldn't find snapshot ID") + defer func() { // Delete Disk err := client.DeleteVolume(volID) diff --git a/test/remote/client-wrappers.go b/test/remote/client-wrappers.go index 9994f9ea8..9f8696233 100644 --- a/test/remote/client-wrappers.go +++ b/test/remote/client-wrappers.go @@ -310,6 +310,20 @@ func (c *CsiClient) NodeGetVolumeStats(volumeID, volumePath string) (available, return } +func (c *CsiClient) ListSnapshots() ([]string, error) { + lsr := &csipb.ListSnapshotsRequest{} + resp, err := c.ctrlClient.ListSnapshots(context.Background(), lsr) + if err != nil { + return nil, err + } + + snapshots := []string{} + for _, e := range resp.Entries { + snapshots = append(snapshots, e.Snapshot.SnapshotId) + } + return snapshots, nil +} + func (c *CsiClient) CreateSnapshot(snapshotName, sourceVolumeId string, params map[string]string) (string, error) { csr := &csipb.CreateSnapshotRequest{