Skip to content

Commit fc39ab1

Browse files
Add pd-extreme e2e test case of defaulting to default iops when iops not
set
1 parent 5a51c74 commit fc39ab1

File tree

2 files changed

+51
-7
lines changed

2 files changed

+51
-7
lines changed

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

+9-6
Original file line numberDiff line numberDiff line change
@@ -574,12 +574,15 @@ func (cloud *CloudProvider) insertZonalDisk(
574574
}
575575

576576
diskToCreate := &computev1.Disk{
577-
Name: volKey.Name,
578-
SizeGb: common.BytesToGbRoundUp(capBytes),
579-
Description: description,
580-
Type: cloud.GetDiskTypeURI(project, volKey, params.DiskType),
581-
Labels: params.Labels,
582-
ProvisionedIops: params.ProvisionedIOPSOnCreate,
577+
Name: volKey.Name,
578+
SizeGb: common.BytesToGbRoundUp(capBytes),
579+
Description: description,
580+
Type: cloud.GetDiskTypeURI(project, volKey, params.DiskType),
581+
Labels: params.Labels,
582+
}
583+
584+
if params.ProvisionedIOPSOnCreate > 0 {
585+
diskToCreate.ProvisionedIops = params.ProvisionedIOPSOnCreate
583586
}
584587

585588
if snapshotID != "" {

test/e2e/tests/single_zone_e2e_test.go

+42-1
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ const (
5656
hdtDiskType = "hyperdisk-throughput"
5757
provisionedIOPSOnCreate = "12345"
5858
provisionedIOPSOnCreateInt = int64(12345)
59+
provisionedIOPSOnCreateDefaultInt = int64(100000)
5960
provisionedThroughputOnCreate = "66Mi"
6061
provisionedThroughputOnCreateInt = int64(66)
61-
6262
defaultEpsilon = 500000000 // 500M
6363
)
6464

@@ -424,6 +424,47 @@ var _ = Describe("GCE PD CSI Driver", func() {
424424
Entry("on pd-extreme", extremeDiskType),
425425
)
426426

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

0 commit comments

Comments
 (0)