Skip to content

Commit d62d9b5

Browse files
Add pd-extreme e2e test case of defaulting to default iops when iops not
set
1 parent 20bbe2b commit d62d9b5

File tree

2 files changed

+61
-16
lines changed

2 files changed

+61
-16
lines changed

pkg/gce-cloud-provider/compute/gce-compute.go

+9-6
Original file line numberDiff line numberDiff line change
@@ -564,12 +564,15 @@ func (cloud *CloudProvider) insertZonalDisk(
564564
}
565565

566566
diskToCreate := &computev1.Disk{
567-
Name: volKey.Name,
568-
SizeGb: common.BytesToGbRoundUp(capBytes),
569-
Description: description,
570-
Type: cloud.GetDiskTypeURI(project, volKey, params.DiskType),
571-
Labels: params.Labels,
572-
ProvisionedIops: params.ProvisionedIOPSOnCreate,
567+
Name: volKey.Name,
568+
SizeGb: common.BytesToGbRoundUp(capBytes),
569+
Description: description,
570+
Type: cloud.GetDiskTypeURI(project, volKey, params.DiskType),
571+
Labels: params.Labels,
572+
}
573+
574+
if params.ProvisionedIOPSOnCreate > 0 {
575+
diskToCreate.ProvisionedIops = params.ProvisionedIOPSOnCreate
573576
}
574577

575578
if snapshotID != "" {

test/e2e/tests/single_zone_e2e_test.go

+52-10
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,17 @@ import (
4444
const (
4545
testNamePrefix = "gcepd-csi-e2e-"
4646

47-
defaultSizeGb int64 = 5
48-
defaultExtremeSizeGb int64 = 500
49-
defaultRepdSizeGb int64 = 200
50-
defaultMwSizeGb int64 = 200
51-
defaultVolumeLimit int64 = 127
52-
readyState = "READY"
53-
standardDiskType = "pd-standard"
54-
extremeDiskType = "pd-extreme"
55-
provisionedIOPSOnCreate = "12345"
56-
provisionedIOPSOnCreateInt = int64(12345)
47+
defaultSizeGb int64 = 5
48+
defaultExtremeSizeGb int64 = 500
49+
defaultRepdSizeGb int64 = 200
50+
defaultMwSizeGb int64 = 200
51+
defaultVolumeLimit int64 = 127
52+
readyState = "READY"
53+
standardDiskType = "pd-standard"
54+
extremeDiskType = "pd-extreme"
55+
provisionedIOPSOnCreate = "12345"
56+
provisionedIOPSOnCreateInt = int64(12345)
57+
provisionedIOPSOnCreateDefaultInt = int64(100000)
5758

5859
defaultEpsilon = 500000000 // 500M
5960
)
@@ -419,6 +420,47 @@ var _ = Describe("GCE PD CSI Driver", func() {
419420
Entry("on pd-extreme", extremeDiskType),
420421
)
421422

423+
DescribeTable("Should create and delete pd-extreme disk with default iops",
424+
func(diskType string) {
425+
Expect(testContexts).ToNot(BeEmpty())
426+
testContext := getRandomTestContext()
427+
428+
p, z, _ := testContext.Instance.GetIdentity()
429+
client := testContext.Client
430+
431+
// Create Disk
432+
disk := typeToDisk[diskType]
433+
volName := testNamePrefix + string(uuid.NewUUID())
434+
435+
diskSize := defaultExtremeSizeGb
436+
437+
volume, err := client.CreateVolume(volName, disk.params, diskSize, nil, nil)
438+
439+
Expect(err).To(BeNil(), "CreateVolume failed with error: %v", err)
440+
441+
// Validate Disk Created
442+
cloudDisk, err := computeService.Disks.Get(p, z, volName).Do()
443+
Expect(err).To(BeNil(), "Could not get disk from cloud directly")
444+
Expect(cloudDisk.Status).To(Equal(readyState))
445+
Expect(cloudDisk.SizeGb).To(Equal(defaultExtremeSizeGb))
446+
Expect(disk.Type).To(ContainSubstring(extremeDiskType))
447+
Expect(disk.ProvisionedIops).To(Equal(provisionedIOPSOnCreateInt))
448+
Expect(cloudDisk.Name).To(Equal(volName))
449+
disk.validate(cloudDisk)
450+
451+
defer func() {
452+
// Delete Disk
453+
client.DeleteVolume(volume.VolumeId)
454+
Expect(err).To(BeNil(), "DeleteVolume failed")
455+
456+
// Validate Disk Deleted
457+
_, err = computeService.Disks.Get(p, z, volName).Do()
458+
Expect(gce.IsGCEError(err, "notFound")).To(BeTrue(), "Expected disk to not be found")
459+
}()
460+
},
461+
Entry("on pd-extreme", extremeDiskType),
462+
)
463+
422464
DescribeTable("Should create and delete disk with labels",
423465
func(diskType string) {
424466
Expect(testContexts).ToNot(BeEmpty())

0 commit comments

Comments
 (0)