From 73547e1c30d7891c3501e7862f6c8e25269db189 Mon Sep 17 00:00:00 2001 From: Drew Sirenko <68304519+AndrewSirenko@users.noreply.github.com> Date: Thu, 30 Nov 2023 19:06:20 -0600 Subject: [PATCH] Refactor E2E: Standardize adding CreateVolume parameters to testcases Refactor E2E: Remove hidden performance parameter setting Fixup E2E: Pre-Provisioned volumes don't use VolumeType Fixup E2E: Pre-Provisioned defaultVolumeType typo Refactor E2E: Standardize adding CreateVolume parameters to testcases Refactor E2E: Generalize format_options CreateVolumeDetails helper fcn. --- pkg/driver/constants.go | 3 + tests/e2e/driver/ebs_csi_driver.go | 67 ------ tests/e2e/dynamic_provisioning.go | 208 ++++++++++++------ tests/e2e/format_options.go | 77 ++++--- tests/e2e/pre_provsioning.go | 34 ++- tests/e2e/testsuites/e2e_utils.go | 19 ++ tests/e2e/testsuites/format_options_tester.go | 25 +-- tests/e2e/testsuites/specs.go | 36 ++- 8 files changed, 244 insertions(+), 225 deletions(-) diff --git a/pkg/driver/constants.go b/pkg/driver/constants.go index 3854bf8ea9..19839369a9 100644 --- a/pkg/driver/constants.go +++ b/pkg/driver/constants.go @@ -82,6 +82,9 @@ const ( // BlockExpressKey increases the iops limit for io2 volumes to the block express limit BlockExpressKey = "blockexpress" + // FSTypeKey configures the file system type that will be formatted during volume creation. + FSTypeKey = "csi.storage.k8s.io/fstype" + // BlockSizeKey configures the block size when formatting a volume BlockSizeKey = "blocksize" diff --git a/tests/e2e/driver/ebs_csi_driver.go b/tests/e2e/driver/ebs_csi_driver.go index ac34277f70..39a459436d 100644 --- a/tests/e2e/driver/ebs_csi_driver.go +++ b/tests/e2e/driver/ebs_csi_driver.go @@ -108,31 +108,6 @@ func (d *ebsCSIDriver) GetPersistentVolume(volumeID string, fsType string, size } } -// GetParameters returns the parameters specific for this driver -func GetParameters(volumeType string, fsType string, encrypted bool, additionalParameters map[string]string) map[string]string { - parameters := map[string]string{ - "type": volumeType, - "csi.storage.k8s.io/fstype": fsType, - } - if iopsPerGB := IOPSPerGBForVolumeType(volumeType); iopsPerGB != "" { - parameters[ebscsidriver.IopsPerGBKey] = iopsPerGB - } - if iops := IOPSForVolumeType(volumeType); iops != "" { - parameters[ebscsidriver.IopsKey] = iops - } - if throughput := ThroughputForVolumeType(volumeType); throughput != "" { - parameters[ebscsidriver.ThroughputKey] = throughput - } - if encrypted { - parameters[ebscsidriver.EncryptedKey] = True - } - for k, v := range additionalParameters { - parameters[k] = v - } - - return parameters -} - // MinimumSizeForVolumeType returns the minimum disk size for each volumeType func MinimumSizeForVolumeType(volumeType string) string { switch volumeType { @@ -148,45 +123,3 @@ func MinimumSizeForVolumeType(volumeType string) string { return "1Gi" } } - -// IOPSPerGBForVolumeType returns the maximum iops per GB for each volumeType -// Otherwise returns an empty string -func IOPSPerGBForVolumeType(volumeType string) string { - switch volumeType { - case "io1": - // Maximum IOPS/GB for io1 is 50 - return "50" - case "io2": - // Maximum IOPS/GB for io2 is 500 - return "500" - default: - return "" - } -} - -// IOPSForVolumeType returns the maximum iops for each volumeType -// Otherwise returns an empty string -func IOPSForVolumeType(volumeType string) string { - switch volumeType { - case "gp3": - // Maximum IOPS for gp3 is 16000. However, maximum IOPS/GB for gp3 is 500. - // Since the tests will run using minimum volume capacity (1GB), set to 3000 - // because minimum IOPS for gp3 is 3000. - return "3000" - default: - return "" - } -} - -// ThroughputPerVolumeType returns the maximum throughput for each volumeType -// Otherwise returns an empty string -func ThroughputForVolumeType(volumeType string) string { - switch volumeType { - case "gp3": - // Maximum throughput for gp3 is 1000. However, maximum throughput/iops for gp3 is 0.25 - // Since the default iops is 3000, set to 750. - return "750" - default: - return "" - } -} diff --git a/tests/e2e/dynamic_provisioning.go b/tests/e2e/dynamic_provisioning.go index 48cf268d3c..c39de5b51c 100644 --- a/tests/e2e/dynamic_provisioning.go +++ b/tests/e2e/dynamic_provisioning.go @@ -60,15 +60,23 @@ var _ = Describe("[ebs-csi-e2e] [single-az] Dynamic Provisioning", func() { for _, fs := range fsTypes { volumeType := t fsType := fs + + createVolumeParameters := map[string]string{ + ebscsidriver.VolumeTypeKey: volumeType, + ebscsidriver.FSTypeKey: fsType, + } + if volumeType == awscloud.VolumeTypeIO1 || volumeType == awscloud.VolumeTypeIO2 { + createVolumeParameters[ebscsidriver.IopsKey] = testsuites.DefaultIopsIoVolumes + } + It(fmt.Sprintf("should create a volume on demand with volume type %q and fs type %q", volumeType, fsType), func() { pods := []testsuites.PodDetails{ { Cmd: "echo 'hello world' > /mnt/test-1/data && grep 'hello world' /mnt/test-1/data", Volumes: []testsuites.VolumeDetails{ { - VolumeType: volumeType, - FSType: fsType, - ClaimSize: driver.MinimumSizeForVolumeType(volumeType), + CreateVolumeParameters: createVolumeParameters, + ClaimSize: driver.MinimumSizeForVolumeType(volumeType), VolumeMount: testsuites.VolumeMountDetails{ NameGenerate: "test-volume-", MountPathGenerate: "/mnt/test-", @@ -88,16 +96,24 @@ var _ = Describe("[ebs-csi-e2e] [single-az] Dynamic Provisioning", func() { for _, t := range volumeTypes { volumeType := t + + createVolumeParameters := map[string]string{ + ebscsidriver.VolumeTypeKey: volumeType, + ebscsidriver.FSTypeKey: ebscsidriver.FSTypeExt4, + ebscsidriver.EncryptedKey: "true", + } + if volumeType == awscloud.VolumeTypeIO1 || volumeType == awscloud.VolumeTypeIO2 { + createVolumeParameters[ebscsidriver.IopsKey] = testsuites.DefaultIopsIoVolumes + } + It(fmt.Sprintf("should create a volume on demand with volumeType %q and encryption", volumeType), func() { pods := []testsuites.PodDetails{ { Cmd: "echo 'hello world' > /mnt/test-1/data && grep 'hello world' /mnt/test-1/data", Volumes: []testsuites.VolumeDetails{ { - VolumeType: volumeType, - FSType: ebscsidriver.FSTypeExt4, - Encrypted: true, - ClaimSize: driver.MinimumSizeForVolumeType(volumeType), + CreateVolumeParameters: createVolumeParameters, + ClaimSize: driver.MinimumSizeForVolumeType(volumeType), VolumeMount: testsuites.VolumeMountDetails{ NameGenerate: "test-volume-", MountPathGenerate: "/mnt/test-", @@ -120,8 +136,10 @@ var _ = Describe("[ebs-csi-e2e] [single-az] Dynamic Provisioning", func() { Cmd: "echo 'hello world' > /mnt/test-1/data && grep 'hello world' /mnt/test-1/data", Volumes: []testsuites.VolumeDetails{ { - VolumeType: awscloud.VolumeTypeGP2, - FSType: ebscsidriver.FSTypeExt4, + CreateVolumeParameters: map[string]string{ + ebscsidriver.VolumeTypeKey: awscloud.VolumeTypeGP2, + ebscsidriver.FSTypeKey: ebscsidriver.FSTypeExt4, + }, MountOptions: []string{"rw"}, ClaimSize: driver.MinimumSizeForVolumeType(awscloud.VolumeTypeGP2), VolumeMount: testsuites.VolumeMountDetails{ @@ -146,8 +164,10 @@ var _ = Describe("[ebs-csi-e2e] [single-az] Dynamic Provisioning", func() { Cmd: "echo 'hello world' > /mnt/test-1/data && echo 'hello world' > /mnt/test-2/data && grep 'hello world' /mnt/test-1/data && grep 'hello world' /mnt/test-2/data", Volumes: []testsuites.VolumeDetails{ { - VolumeType: awscloud.VolumeTypeGP2, - FSType: ebscsidriver.FSTypeExt3, + CreateVolumeParameters: map[string]string{ + ebscsidriver.VolumeTypeKey: awscloud.VolumeTypeGP2, + ebscsidriver.FSTypeKey: ebscsidriver.FSTypeExt3, + }, VolumeBindingMode: &volumeBindingMode, ClaimSize: driver.MinimumSizeForVolumeType(awscloud.VolumeTypeGP2), VolumeMount: testsuites.VolumeMountDetails{ @@ -156,8 +176,11 @@ var _ = Describe("[ebs-csi-e2e] [single-az] Dynamic Provisioning", func() { }, }, { - VolumeType: awscloud.VolumeTypeIO1, - FSType: ebscsidriver.FSTypeExt4, + CreateVolumeParameters: map[string]string{ + ebscsidriver.VolumeTypeKey: awscloud.VolumeTypeIO1, + ebscsidriver.IopsKey: testsuites.DefaultIopsIoVolumes, + ebscsidriver.FSTypeKey: ebscsidriver.FSTypeExt4, + }, ClaimSize: driver.MinimumSizeForVolumeType(awscloud.VolumeTypeIO1), VolumeBindingMode: &volumeBindingMode, VolumeMount: testsuites.VolumeMountDetails{ @@ -181,9 +204,11 @@ var _ = Describe("[ebs-csi-e2e] [single-az] Dynamic Provisioning", func() { Cmd: "echo 'hello world' > /mnt/test-1/data && grep 'hello world' /mnt/test-1/data", Volumes: []testsuites.VolumeDetails{ { - VolumeType: awscloud.VolumeTypeGP2, - FSType: ebscsidriver.FSTypeExt3, - ClaimSize: driver.MinimumSizeForVolumeType(awscloud.VolumeTypeGP2), + CreateVolumeParameters: map[string]string{ + ebscsidriver.VolumeTypeKey: awscloud.VolumeTypeGP2, + ebscsidriver.FSTypeKey: ebscsidriver.FSTypeExt3, + }, + ClaimSize: driver.MinimumSizeForVolumeType(awscloud.VolumeTypeGP2), VolumeMount: testsuites.VolumeMountDetails{ NameGenerate: "test-volume-", MountPathGenerate: "/mnt/test-", @@ -195,9 +220,12 @@ var _ = Describe("[ebs-csi-e2e] [single-az] Dynamic Provisioning", func() { Cmd: "echo 'hello world' > /mnt/test-1/data && grep 'hello world' /mnt/test-1/data", Volumes: []testsuites.VolumeDetails{ { - VolumeType: awscloud.VolumeTypeIO1, - FSType: ebscsidriver.FSTypeExt4, - ClaimSize: driver.MinimumSizeForVolumeType(awscloud.VolumeTypeIO1), + CreateVolumeParameters: map[string]string{ + ebscsidriver.VolumeTypeKey: awscloud.VolumeTypeIO1, + ebscsidriver.IopsKey: testsuites.DefaultIopsIoVolumes, + ebscsidriver.FSTypeKey: ebscsidriver.FSTypeExt4, + }, + ClaimSize: driver.MinimumSizeForVolumeType(awscloud.VolumeTypeIO1), VolumeMount: testsuites.VolumeMountDetails{ NameGenerate: "test-volume-", MountPathGenerate: "/mnt/test-", @@ -219,8 +247,10 @@ var _ = Describe("[ebs-csi-e2e] [single-az] Dynamic Provisioning", func() { Cmd: "dd if=/dev/zero of=/dev/xvda bs=1024k count=100", Volumes: []testsuites.VolumeDetails{ { - VolumeType: awscloud.VolumeTypeGP2, - FSType: ebscsidriver.FSTypeExt4, + CreateVolumeParameters: map[string]string{ + ebscsidriver.VolumeTypeKey: awscloud.VolumeTypeGP2, + ebscsidriver.FSTypeKey: ebscsidriver.FSTypeExt4, + }, ClaimSize: driver.MinimumSizeForVolumeType(awscloud.VolumeTypeGP2), VolumeMode: testsuites.Block, VolumeDevice: testsuites.VolumeDeviceDetails{ @@ -244,7 +274,10 @@ var _ = Describe("[ebs-csi-e2e] [single-az] Dynamic Provisioning", func() { { Volumes: []testsuites.VolumeDetails{ { - VolumeType: awscloud.VolumeTypeIO2, + CreateVolumeParameters: map[string]string{ + ebscsidriver.VolumeTypeKey: awscloud.VolumeTypeIO2, + ebscsidriver.IopsKey: testsuites.DefaultIopsIoVolumes, + }, ClaimSize: driver.MinimumSizeForVolumeType(awscloud.VolumeTypeIO2), VolumeMode: testsuites.Block, VolumeDevice: testsuites.VolumeDeviceDetails{ @@ -259,7 +292,10 @@ var _ = Describe("[ebs-csi-e2e] [single-az] Dynamic Provisioning", func() { { Volumes: []testsuites.VolumeDetails{ { - VolumeType: awscloud.VolumeTypeIO2, + CreateVolumeParameters: map[string]string{ + ebscsidriver.VolumeTypeKey: awscloud.VolumeTypeIO2, + ebscsidriver.IopsKey: testsuites.DefaultIopsIoVolumes, + }, ClaimSize: driver.MinimumSizeForVolumeType(awscloud.VolumeTypeIO2), VolumeMode: testsuites.Block, VolumeDevice: testsuites.VolumeDeviceDetails{ @@ -289,7 +325,10 @@ var _ = Describe("[ebs-csi-e2e] [single-az] Dynamic Provisioning", func() { { Volumes: []testsuites.VolumeDetails{ { - VolumeType: awscloud.VolumeTypeIO2, + CreateVolumeParameters: map[string]string{ + ebscsidriver.VolumeTypeKey: awscloud.VolumeTypeIO2, + ebscsidriver.IopsKey: testsuites.DefaultIopsIoVolumes, + }, ClaimSize: driver.MinimumSizeForVolumeType(awscloud.VolumeTypeIO2), VolumeMode: testsuites.Block, VolumeDevice: testsuites.VolumeDeviceDetails{ @@ -304,7 +343,10 @@ var _ = Describe("[ebs-csi-e2e] [single-az] Dynamic Provisioning", func() { { Volumes: []testsuites.VolumeDetails{ { - VolumeType: awscloud.VolumeTypeIO2, + CreateVolumeParameters: map[string]string{ + ebscsidriver.VolumeTypeKey: awscloud.VolumeTypeIO2, + ebscsidriver.IopsKey: testsuites.DefaultIopsIoVolumes, + }, ClaimSize: driver.MinimumSizeForVolumeType(awscloud.VolumeTypeIO2), VolumeMode: testsuites.Block, VolumeDevice: testsuites.VolumeDeviceDetails{ @@ -333,8 +375,11 @@ var _ = Describe("[ebs-csi-e2e] [single-az] Dynamic Provisioning", func() { { Volumes: []testsuites.VolumeDetails{ { - VolumeType: awscloud.VolumeTypeIO2, - FSType: ebscsidriver.FSTypeExt4, + CreateVolumeParameters: map[string]string{ + ebscsidriver.VolumeTypeKey: awscloud.VolumeTypeIO2, + ebscsidriver.IopsKey: testsuites.DefaultIopsIoVolumes, + ebscsidriver.FSTypeKey: ebscsidriver.FSTypeExt4, + }, VolumeMode: testsuites.FileSystem, ClaimSize: driver.MinimumSizeForVolumeType(awscloud.VolumeTypeIO2), VolumeMount: testsuites.VolumeMountDetails{ @@ -349,8 +394,11 @@ var _ = Describe("[ebs-csi-e2e] [single-az] Dynamic Provisioning", func() { { Volumes: []testsuites.VolumeDetails{ { - VolumeType: awscloud.VolumeTypeIO2, - FSType: ebscsidriver.FSTypeExt4, + CreateVolumeParameters: map[string]string{ + ebscsidriver.VolumeTypeKey: awscloud.VolumeTypeIO2, + ebscsidriver.IopsKey: testsuites.DefaultIopsIoVolumes, + ebscsidriver.FSTypeKey: ebscsidriver.FSTypeExt4, + }, VolumeMode: testsuites.FileSystem, ClaimSize: driver.MinimumSizeForVolumeType(awscloud.VolumeTypeIO2), VolumeMount: testsuites.VolumeMountDetails{ @@ -380,7 +428,9 @@ var _ = Describe("[ebs-csi-e2e] [single-az] Dynamic Provisioning", func() { { Volumes: []testsuites.VolumeDetails{ { - VolumeType: awscloud.VolumeTypeGP3, + CreateVolumeParameters: map[string]string{ + ebscsidriver.VolumeTypeKey: awscloud.VolumeTypeGP3, + }, ClaimSize: driver.MinimumSizeForVolumeType(awscloud.VolumeTypeGP3), VolumeBindingMode: &volumeBindingMode, VolumeMode: testsuites.Block, @@ -395,7 +445,9 @@ var _ = Describe("[ebs-csi-e2e] [single-az] Dynamic Provisioning", func() { { Volumes: []testsuites.VolumeDetails{ { - VolumeType: awscloud.VolumeTypeGP3, + CreateVolumeParameters: map[string]string{ + ebscsidriver.VolumeTypeKey: awscloud.VolumeTypeGP3, + }, ClaimSize: driver.MinimumSizeForVolumeType(awscloud.VolumeTypeGP3), VolumeBindingMode: &volumeBindingMode, VolumeMode: testsuites.Block, @@ -426,8 +478,11 @@ var _ = Describe("[ebs-csi-e2e] [single-az] Dynamic Provisioning", func() { Cmd: "dd if=/dev/zero of=/dev/xvda bs=1024k count=100 && echo 'hello world' > /mnt/test-1/data && grep 'hello world' /mnt/test-1/data", Volumes: []testsuites.VolumeDetails{ { - VolumeType: awscloud.VolumeTypeIO1, - FSType: ebscsidriver.FSTypeExt4, + CreateVolumeParameters: map[string]string{ + ebscsidriver.VolumeTypeKey: awscloud.VolumeTypeIO1, + ebscsidriver.IopsKey: testsuites.DefaultIopsIoVolumes, + ebscsidriver.FSTypeKey: ebscsidriver.FSTypeExt4, + }, ClaimSize: driver.MinimumSizeForVolumeType(awscloud.VolumeTypeIO1), VolumeBindingMode: &volumeBindingMode, VolumeMount: testsuites.VolumeMountDetails{ @@ -436,8 +491,10 @@ var _ = Describe("[ebs-csi-e2e] [single-az] Dynamic Provisioning", func() { }, }, { - VolumeType: awscloud.VolumeTypeGP2, - FSType: ebscsidriver.FSTypeExt4, + CreateVolumeParameters: map[string]string{ + ebscsidriver.VolumeTypeKey: awscloud.VolumeTypeGP2, + ebscsidriver.FSTypeKey: ebscsidriver.FSTypeExt4, + }, MountOptions: []string{"rw"}, ClaimSize: driver.MinimumSizeForVolumeType(awscloud.VolumeTypeGP2), VolumeBindingMode: &volumeBindingMode, @@ -463,9 +520,11 @@ var _ = Describe("[ebs-csi-e2e] [single-az] Dynamic Provisioning", func() { Cmd: "while true; do echo $(date -u) >> /mnt/test-1/data; sleep 1; done", Volumes: []testsuites.VolumeDetails{ { - VolumeType: awscloud.VolumeTypeGP2, - FSType: ebscsidriver.FSTypeExt3, - ClaimSize: driver.MinimumSizeForVolumeType(awscloud.VolumeTypeGP2), + CreateVolumeParameters: map[string]string{ + ebscsidriver.VolumeTypeKey: awscloud.VolumeTypeGP2, + ebscsidriver.FSTypeKey: ebscsidriver.FSTypeExt3, + }, + ClaimSize: driver.MinimumSizeForVolumeType(awscloud.VolumeTypeGP2), VolumeMount: testsuites.VolumeMountDetails{ NameGenerate: "test-volume-", MountPathGenerate: "/mnt/test-", @@ -477,9 +536,12 @@ var _ = Describe("[ebs-csi-e2e] [single-az] Dynamic Provisioning", func() { Cmd: "while true; do echo $(date -u) >> /mnt/test-1/data; sleep 1; done", Volumes: []testsuites.VolumeDetails{ { - VolumeType: awscloud.VolumeTypeIO1, - FSType: ebscsidriver.FSTypeExt4, - ClaimSize: driver.MinimumSizeForVolumeType(awscloud.VolumeTypeIO1), + CreateVolumeParameters: map[string]string{ + ebscsidriver.VolumeTypeKey: awscloud.VolumeTypeIO1, + ebscsidriver.IopsKey: testsuites.DefaultIopsIoVolumes, + ebscsidriver.FSTypeKey: ebscsidriver.FSTypeExt4, + }, + ClaimSize: driver.MinimumSizeForVolumeType(awscloud.VolumeTypeIO1), VolumeMount: testsuites.VolumeMountDetails{ NameGenerate: "test-volume-", MountPathGenerate: "/mnt/test-", @@ -503,9 +565,11 @@ var _ = Describe("[ebs-csi-e2e] [single-az] Dynamic Provisioning", func() { Cmd: "touch /mnt/test-1/data", Volumes: []testsuites.VolumeDetails{ { - VolumeType: awscloud.VolumeTypeGP2, - FSType: ebscsidriver.FSTypeExt4, - ClaimSize: driver.MinimumSizeForVolumeType(awscloud.VolumeTypeGP2), + CreateVolumeParameters: map[string]string{ + ebscsidriver.VolumeTypeKey: awscloud.VolumeTypeGP2, + ebscsidriver.FSTypeKey: ebscsidriver.FSTypeExt4, + }, + ClaimSize: driver.MinimumSizeForVolumeType(awscloud.VolumeTypeGP2), VolumeMount: testsuites.VolumeMountDetails{ NameGenerate: "test-volume-", MountPathGenerate: "/mnt/test-", @@ -526,8 +590,10 @@ var _ = Describe("[ebs-csi-e2e] [single-az] Dynamic Provisioning", func() { reclaimPolicy := v1.PersistentVolumeReclaimDelete volumes := []testsuites.VolumeDetails{ { - VolumeType: awscloud.VolumeTypeGP2, - FSType: ebscsidriver.FSTypeExt4, + CreateVolumeParameters: map[string]string{ + ebscsidriver.VolumeTypeKey: awscloud.VolumeTypeGP2, + ebscsidriver.FSTypeKey: ebscsidriver.FSTypeExt4, + }, ClaimSize: driver.MinimumSizeForVolumeType(awscloud.VolumeTypeGP2), ReclaimPolicy: &reclaimPolicy, }, @@ -546,8 +612,10 @@ var _ = Describe("[ebs-csi-e2e] [single-az] Dynamic Provisioning", func() { reclaimPolicy := v1.PersistentVolumeReclaimRetain volumes := []testsuites.VolumeDetails{ { - VolumeType: awscloud.VolumeTypeGP2, - FSType: ebscsidriver.FSTypeExt4, + CreateVolumeParameters: map[string]string{ + ebscsidriver.VolumeTypeKey: awscloud.VolumeTypeGP2, + ebscsidriver.FSTypeKey: ebscsidriver.FSTypeExt4, + }, ClaimSize: driver.MinimumSizeForVolumeType(awscloud.VolumeTypeGP2), ReclaimPolicy: &reclaimPolicy, }, @@ -573,9 +641,11 @@ var _ = Describe("[ebs-csi-e2e] [single-az] Dynamic Provisioning", func() { Cmd: "echo 'hello world' >> /mnt/test-1/data && while true; do sleep 1; done", Volumes: []testsuites.VolumeDetails{ { - VolumeType: awscloud.VolumeTypeGP2, - FSType: ebscsidriver.FSTypeExt3, - ClaimSize: driver.MinimumSizeForVolumeType(awscloud.VolumeTypeGP2), + CreateVolumeParameters: map[string]string{ + ebscsidriver.VolumeTypeKey: awscloud.VolumeTypeGP2, + ebscsidriver.FSTypeKey: ebscsidriver.FSTypeExt3, + }, + ClaimSize: driver.MinimumSizeForVolumeType(awscloud.VolumeTypeGP2), VolumeMount: testsuites.VolumeMountDetails{ NameGenerate: "test-volume-", MountPathGenerate: "/mnt/test-", @@ -600,9 +670,11 @@ var _ = Describe("[ebs-csi-e2e] [single-az] Dynamic Provisioning", func() { Cmd: "echo 'hello world' >> /mnt/test-1/data && grep 'hello world' /mnt/test-1/data && sync", Volumes: []testsuites.VolumeDetails{ { - VolumeType: awscloud.VolumeTypeGP2, - FSType: ebscsidriver.FSTypeExt4, - ClaimSize: driver.MinimumSizeForVolumeType(awscloud.VolumeTypeGP2), + CreateVolumeParameters: map[string]string{ + ebscsidriver.VolumeTypeKey: awscloud.VolumeTypeGP2, + ebscsidriver.FSTypeKey: ebscsidriver.FSTypeExt4, + }, + ClaimSize: driver.MinimumSizeForVolumeType(awscloud.VolumeTypeGP2), VolumeMount: testsuites.VolumeMountDetails{ NameGenerate: "test-volume-", MountPathGenerate: "/mnt/test-", @@ -647,9 +719,11 @@ var _ = Describe("[ebs-csi-e2e] [single-az] Snapshot", func() { Cmd: "echo 'hello world' >> /mnt/test-1/data && grep 'hello world' /mnt/test-1/data && sync", Volumes: []testsuites.VolumeDetails{ { - VolumeType: awscloud.VolumeTypeGP2, - FSType: ebscsidriver.FSTypeExt4, - ClaimSize: driver.MinimumSizeForVolumeType(awscloud.VolumeTypeGP2), + CreateVolumeParameters: map[string]string{ + ebscsidriver.VolumeTypeKey: awscloud.VolumeTypeGP2, + ebscsidriver.FSTypeKey: ebscsidriver.FSTypeExt4, + }, + ClaimSize: driver.MinimumSizeForVolumeType(awscloud.VolumeTypeGP2), VolumeMount: testsuites.VolumeMountDetails{ NameGenerate: "test-volume-", MountPathGenerate: "/mnt/test-", @@ -661,9 +735,11 @@ var _ = Describe("[ebs-csi-e2e] [single-az] Snapshot", func() { Cmd: "grep 'hello world' /mnt/test-1/data", Volumes: []testsuites.VolumeDetails{ { - VolumeType: awscloud.VolumeTypeGP2, - FSType: ebscsidriver.FSTypeExt4, - ClaimSize: driver.MinimumSizeForVolumeType(awscloud.VolumeTypeGP2), + CreateVolumeParameters: map[string]string{ + ebscsidriver.VolumeTypeKey: awscloud.VolumeTypeGP2, + ebscsidriver.FSTypeKey: ebscsidriver.FSTypeExt4, + }, + ClaimSize: driver.MinimumSizeForVolumeType(awscloud.VolumeTypeGP2), VolumeMount: testsuites.VolumeMountDetails{ NameGenerate: "test-volume-", MountPathGenerate: "/mnt/test-", @@ -703,8 +779,10 @@ var _ = Describe("[ebs-csi-e2e] [multi-az] Dynamic Provisioning", func() { Cmd: "echo 'hello world' > /mnt/test-1/data && grep 'hello world' /mnt/test-1/data", Volumes: []testsuites.VolumeDetails{ { - VolumeType: awscloud.VolumeTypeGP2, - FSType: ebscsidriver.FSTypeExt4, + CreateVolumeParameters: map[string]string{ + ebscsidriver.VolumeTypeKey: awscloud.VolumeTypeGP2, + ebscsidriver.FSTypeKey: ebscsidriver.FSTypeExt4, + }, ClaimSize: driver.MinimumSizeForVolumeType(awscloud.VolumeTypeGP2), VolumeBindingMode: &volumeBindingMode, VolumeMount: testsuites.VolumeMountDetails{ @@ -734,8 +812,10 @@ var _ = Describe("[ebs-csi-e2e] [multi-az] Dynamic Provisioning", func() { Cmd: "echo 'hello world' > /mnt/test-1/data && grep 'hello world' /mnt/test-1/data", Volumes: []testsuites.VolumeDetails{ { - VolumeType: awscloud.VolumeTypeGP2, - FSType: ebscsidriver.FSTypeExt4, + CreateVolumeParameters: map[string]string{ + ebscsidriver.VolumeTypeKey: awscloud.VolumeTypeGP2, + ebscsidriver.FSTypeKey: ebscsidriver.FSTypeExt4, + }, ClaimSize: driver.MinimumSizeForVolumeType(awscloud.VolumeTypeGP2), VolumeBindingMode: &volumeBindingMode, AllowedTopologyValues: allowedTopologyZones, diff --git a/tests/e2e/format_options.go b/tests/e2e/format_options.go index f42f088c24..4ae170d961 100644 --- a/tests/e2e/format_options.go +++ b/tests/e2e/format_options.go @@ -28,40 +28,6 @@ import ( var ( testedFsTypes = []string{ebscsidriver.FSTypeExt4} - - formatOptionTests = map[string]testsuites.FormatOptionTest{ - ebscsidriver.BlockSizeKey: { - CreateVolumeParameters: map[string]string{ - ebscsidriver.BlockSizeKey: "1024", - }, - }, - ebscsidriver.InodeSizeKey: { - CreateVolumeParameters: map[string]string{ - ebscsidriver.InodeSizeKey: "512", - }, - }, - ebscsidriver.BytesPerInodeKey: { - CreateVolumeParameters: map[string]string{ - ebscsidriver.BytesPerInodeKey: "8192", - }, - }, - ebscsidriver.NumberOfInodesKey: { - CreateVolumeParameters: map[string]string{ - ebscsidriver.NumberOfInodesKey: "200192", - }, - }, - ebscsidriver.Ext4BigAllocKey: { - CreateVolumeParameters: map[string]string{ - ebscsidriver.Ext4BigAllocKey: "true", - }, - }, - ebscsidriver.Ext4ClusterSizeKey: { - CreateVolumeParameters: map[string]string{ - ebscsidriver.Ext4BigAllocKey: "true", - ebscsidriver.Ext4ClusterSizeKey: "16384", - }, - }, - } ) var _ = Describe("[ebs-csi-e2e] [single-az] [format-options] Formatting a volume", func() { @@ -81,6 +47,47 @@ var _ = Describe("[ebs-csi-e2e] [single-az] [format-options] Formatting a volume }) for _, fsType := range testedFsTypes { + + formatOptionTests := map[string]testsuites.FormatOptionTest{ + ebscsidriver.BlockSizeKey: { + CreateVolumeParameters: map[string]string{ + ebscsidriver.BlockSizeKey: "1024", + ebscsidriver.FSTypeKey: fsType, + }, + }, + ebscsidriver.InodeSizeKey: { + CreateVolumeParameters: map[string]string{ + ebscsidriver.InodeSizeKey: "512", + ebscsidriver.FSTypeKey: fsType, + }, + }, + ebscsidriver.BytesPerInodeKey: { + CreateVolumeParameters: map[string]string{ + ebscsidriver.BytesPerInodeKey: "8192", + ebscsidriver.FSTypeKey: fsType, + }, + }, + ebscsidriver.NumberOfInodesKey: { + CreateVolumeParameters: map[string]string{ + ebscsidriver.NumberOfInodesKey: "200192", + ebscsidriver.FSTypeKey: fsType, + }, + }, + ebscsidriver.Ext4BigAllocKey: { + CreateVolumeParameters: map[string]string{ + ebscsidriver.Ext4BigAllocKey: "true", + ebscsidriver.FSTypeKey: fsType, + }, + }, + ebscsidriver.Ext4ClusterSizeKey: { + CreateVolumeParameters: map[string]string{ + ebscsidriver.Ext4BigAllocKey: "true", + ebscsidriver.Ext4ClusterSizeKey: "16384", + ebscsidriver.FSTypeKey: fsType, + }, + }, + } + Context(fmt.Sprintf("using an %s filesystem", fsType), func() { for testedParameter, formatOptionTestCase := range formatOptionTests { formatOptionTestCase := formatOptionTestCase @@ -90,7 +97,7 @@ var _ = Describe("[ebs-csi-e2e] [single-az] [format-options] Formatting a volume Context(fmt.Sprintf("with a custom %s parameter", testedParameter), func() { It("successfully mounts and is resizable", func() { - formatOptionTestCase.Run(cs, ns, ebsDriver, fsType) + formatOptionTestCase.Run(cs, ns, ebsDriver) }) }) } diff --git a/tests/e2e/pre_provsioning.go b/tests/e2e/pre_provsioning.go index c6da7e5b0d..cd77e6e6ca 100644 --- a/tests/e2e/pre_provsioning.go +++ b/tests/e2e/pre_provsioning.go @@ -37,7 +37,7 @@ import ( const ( defaultDiskSize = 4 - defaultVoluemType = awscloud.VolumeTypeGP3 + defaultVolumeType = awscloud.VolumeTypeGP3 awsAvailabilityZonesEnv = "AWS_AVAILABILITY_ZONES" @@ -83,7 +83,7 @@ var _ = Describe("[ebs-csi-e2e] [single-az] Pre-Provisioned", func() { diskOptions := &awscloud.DiskOptions{ CapacityBytes: defaultDiskSizeBytes, - VolumeType: defaultVoluemType, + VolumeType: defaultVolumeType, AvailabilityZone: availabilityZone, Tags: map[string]string{awscloud.VolumeNameTagKey: dummyVolumeName, awscloud.AwsEbsDriverTagKey: "true"}, } @@ -128,9 +128,9 @@ var _ = Describe("[ebs-csi-e2e] [single-az] Pre-Provisioned", func() { Cmd: "echo 'hello world' > /mnt/test-1/data && grep 'hello world' /mnt/test-1/data", Volumes: []testsuites.VolumeDetails{ { - VolumeID: volumeID, - FSType: ebscsidriver.FSTypeExt4, - ClaimSize: diskSize, + VolumeID: volumeID, + PreProvisionedVolumeFsType: ebscsidriver.FSTypeExt4, + ClaimSize: diskSize, VolumeMount: testsuites.VolumeMountDetails{ NameGenerate: "test-volume-", MountPathGenerate: "/mnt/test-", @@ -172,9 +172,9 @@ var _ = Describe("[ebs-csi-e2e] [single-az] Pre-Provisioned", func() { Cmd: "echo 'hello world' > /mnt/test-1/data && grep 'hello world' /mnt/test-1/data", Volumes: []testsuites.VolumeDetails{ { - VolumeID: volumeID, - FSType: ebscsidriver.FSTypeExt4, - ClaimSize: diskSize, + VolumeID: volumeID, + PreProvisionedVolumeFsType: ebscsidriver.FSTypeExt4, + ClaimSize: diskSize, VolumeMount: testsuites.VolumeMountDetails{ NameGenerate: "test-volume-", MountPathGenerate: "/mnt/test-", @@ -195,10 +195,10 @@ var _ = Describe("[ebs-csi-e2e] [single-az] Pre-Provisioned", func() { reclaimPolicy := v1.PersistentVolumeReclaimRetain volumes := []testsuites.VolumeDetails{ { - VolumeID: volumeID, - FSType: ebscsidriver.FSTypeExt4, - ClaimSize: diskSize, - ReclaimPolicy: &reclaimPolicy, + VolumeID: volumeID, + PreProvisionedVolumeFsType: ebscsidriver.FSTypeExt4, + ClaimSize: diskSize, + ReclaimPolicy: &reclaimPolicy, }, } test := testsuites.PreProvisionedReclaimPolicyTest{ @@ -213,10 +213,10 @@ var _ = Describe("[ebs-csi-e2e] [single-az] Pre-Provisioned", func() { skipManuallyDeletingVolume = true volumes := []testsuites.VolumeDetails{ { - VolumeID: volumeID, - FSType: ebscsidriver.FSTypeExt4, - ClaimSize: diskSize, - ReclaimPolicy: &reclaimPolicy, + VolumeID: volumeID, + PreProvisionedVolumeFsType: ebscsidriver.FSTypeExt4, + ClaimSize: diskSize, + ReclaimPolicy: &reclaimPolicy, }, } test := testsuites.PreProvisionedReclaimPolicyTest{ @@ -286,7 +286,6 @@ var _ = Describe("[ebs-csi-e2e] [single-az] Pre-Provisioned with Multi-Attach", { Volumes: []testsuites.VolumeDetails{ { - VolumeType: awscloud.VolumeTypeIO2, ClaimSize: driver.MinimumSizeForVolumeType(awscloud.VolumeTypeIO2), VolumeMode: testsuites.Block, VolumeDevice: testsuites.VolumeDeviceDetails{ @@ -302,7 +301,6 @@ var _ = Describe("[ebs-csi-e2e] [single-az] Pre-Provisioned with Multi-Attach", { Volumes: []testsuites.VolumeDetails{ { - VolumeType: awscloud.VolumeTypeIO2, ClaimSize: driver.MinimumSizeForVolumeType(awscloud.VolumeTypeIO2), VolumeMode: testsuites.Block, VolumeDevice: testsuites.VolumeDeviceDetails{ diff --git a/tests/e2e/testsuites/e2e_utils.go b/tests/e2e/testsuites/e2e_utils.go index 7896add539..33a8b0b472 100644 --- a/tests/e2e/testsuites/e2e_utils.go +++ b/tests/e2e/testsuites/e2e_utils.go @@ -19,8 +19,27 @@ import "fmt" const ( DefaultVolumeName = "test-volume-1" DefaultMountPath = "/mnt/default-mount" + + DefaultIopsIoVolumes = "100" ) func PodCmdWriteToVolume(volumeMountPath string) string { return fmt.Sprintf("echo 'hello world' >> %s/data && grep 'hello world' %s/data && sync", volumeMountPath, volumeMountPath) } + +func CreateVolumeDetails(createVolumeParameters map[string]string, volumeSize string) *VolumeDetails { + allowVolumeExpansion := true + + volume := VolumeDetails{ + MountOptions: []string{"rw"}, + ClaimSize: volumeSize, + VolumeMount: VolumeMountDetails{ + NameGenerate: DefaultVolumeName, + MountPathGenerate: DefaultMountPath, + }, + AllowVolumeExpansion: &allowVolumeExpansion, + CreateVolumeParameters: createVolumeParameters, + } + + return &volume +} diff --git a/tests/e2e/testsuites/format_options_tester.go b/tests/e2e/testsuites/format_options_tester.go index 7d11538a85..80a4eb28a3 100644 --- a/tests/e2e/testsuites/format_options_tester.go +++ b/tests/e2e/testsuites/format_options_tester.go @@ -15,7 +15,7 @@ limitations under the License. package testsuites import ( - awscloud "github.com/kubernetes-sigs/aws-ebs-csi-driver/pkg/cloud" + ebscsidriver "github.com/kubernetes-sigs/aws-ebs-csi-driver/pkg/driver" "github.com/kubernetes-sigs/aws-ebs-csi-driver/tests/e2e/driver" . "github.com/onsi/ginkgo/v2" v1 "k8s.io/api/core/v1" @@ -32,9 +32,9 @@ const ( volumeSizeIncreaseAmtGi = 1 ) -func (t *FormatOptionTest) Run(client clientset.Interface, namespace *v1.Namespace, ebsDriver driver.PVTestDriver, fsType string) { +func (t *FormatOptionTest) Run(client clientset.Interface, namespace *v1.Namespace, ebsDriver driver.PVTestDriver) { By("setting up pvc with custom format option") - volumeDetails := createFormatOptionVolumeDetails(fsType, t) + volumeDetails := CreateVolumeDetails(t.CreateVolumeParameters, driver.MinimumSizeForVolumeType(t.CreateVolumeParameters[ebscsidriver.VolumeTypeKey])) testPvc, _ := volumeDetails.SetupDynamicPersistentVolumeClaim(client, namespace, ebsDriver) defer testPvc.Cleanup() @@ -54,25 +54,6 @@ func (t *FormatOptionTest) Run(client clientset.Interface, namespace *v1.Namespa resizeTestPod.WaitForSuccess() } -func createFormatOptionVolumeDetails(fsType string, t *FormatOptionTest) *VolumeDetails { - allowVolumeExpansion := true - - volume := VolumeDetails{ - VolumeType: awscloud.VolumeTypeGP2, - FSType: fsType, - MountOptions: []string{"rw"}, - ClaimSize: driver.MinimumSizeForVolumeType(awscloud.VolumeTypeGP2), - VolumeMount: VolumeMountDetails{ - NameGenerate: DefaultVolumeName, - MountPathGenerate: DefaultMountPath, - }, - AllowVolumeExpansion: &allowVolumeExpansion, - AdditionalParameters: t.CreateVolumeParameters, - } - - return &volume -} - func createPodWithVolume(client clientset.Interface, namespace *v1.Namespace, cmd string, testPvc *TestPersistentVolumeClaim, volumeDetails *VolumeDetails) *TestPod { testPod := NewTestPod(client, namespace, cmd) testPod.SetupVolume(testPvc.persistentVolumeClaim, volumeDetails.VolumeMount.NameGenerate, volumeDetails.VolumeMount.MountPathGenerate, volumeDetails.VolumeMount.ReadOnly) diff --git a/tests/e2e/testsuites/specs.go b/tests/e2e/testsuites/specs.go index f845284683..57d5021d1f 100644 --- a/tests/e2e/testsuites/specs.go +++ b/tests/e2e/testsuites/specs.go @@ -33,22 +33,20 @@ type PodDetails struct { } type VolumeDetails struct { - VolumeType string - FSType string - Encrypted bool - MountOptions []string - ClaimSize string - ReclaimPolicy *v1.PersistentVolumeReclaimPolicy - AllowVolumeExpansion *bool - VolumeBindingMode *storagev1.VolumeBindingMode - AccessMode v1.PersistentVolumeAccessMode - AllowedTopologyValues []string - VolumeMode VolumeMode - VolumeMount VolumeMountDetails - VolumeDevice VolumeDeviceDetails - VolumeID string // Optional, used with pre-provisioned volumes - DataSource *DataSource // Optional, used with PVCs created from snapshots - AdditionalParameters map[string]string // Optional, used when testing formatting options + MountOptions []string + ClaimSize string + ReclaimPolicy *v1.PersistentVolumeReclaimPolicy + AllowVolumeExpansion *bool + VolumeBindingMode *storagev1.VolumeBindingMode + AccessMode v1.PersistentVolumeAccessMode + AllowedTopologyValues []string + VolumeMode VolumeMode + VolumeMount VolumeMountDetails + VolumeDevice VolumeDeviceDetails + CreateVolumeParameters map[string]string // Optional, used when dynamically-provisioned volumes + VolumeID string // Optional, used with pre-provisioned volumes + PreProvisionedVolumeFsType string // Optional, used with pre-provisioned volumes + DataSource *DataSource // Optional, used with PVCs created from snapshots } type VolumeMode int @@ -121,7 +119,7 @@ func (pod *PodDetails) SetupDeployment(client clientset.Interface, namespace *v1 volume := pod.Volumes[0] By("setting up the StorageClass") - storageClass := csiDriver.GetDynamicProvisionStorageClass(driver.GetParameters(volume.VolumeType, volume.FSType, volume.Encrypted, volume.AdditionalParameters), volume.MountOptions, volume.ReclaimPolicy, volume.AllowVolumeExpansion, volume.VolumeBindingMode, volume.AllowedTopologyValues, namespace.Name) + storageClass := csiDriver.GetDynamicProvisionStorageClass(volume.CreateVolumeParameters, volume.MountOptions, volume.ReclaimPolicy, volume.AllowVolumeExpansion, volume.VolumeBindingMode, volume.AllowedTopologyValues, namespace.Name) tsc := NewTestStorageClass(client, namespace, storageClass) createdStorageClass := tsc.Create() cleanupFuncs = append(cleanupFuncs, tsc.Cleanup) @@ -141,7 +139,7 @@ func (pod *PodDetails) SetupDeployment(client clientset.Interface, namespace *v1 func (volume *VolumeDetails) SetupDynamicPersistentVolumeClaim(client clientset.Interface, namespace *v1.Namespace, csiDriver driver.DynamicPVTestDriver) (*TestPersistentVolumeClaim, []func()) { cleanupFuncs := make([]func(), 0) By("setting up the StorageClass") - storageClass := csiDriver.GetDynamicProvisionStorageClass(driver.GetParameters(volume.VolumeType, volume.FSType, volume.Encrypted, volume.AdditionalParameters), volume.MountOptions, volume.ReclaimPolicy, volume.AllowVolumeExpansion, volume.VolumeBindingMode, volume.AllowedTopologyValues, namespace.Name) + storageClass := csiDriver.GetDynamicProvisionStorageClass(volume.CreateVolumeParameters, volume.MountOptions, volume.ReclaimPolicy, volume.AllowVolumeExpansion, volume.VolumeBindingMode, volume.AllowedTopologyValues, namespace.Name) tsc := NewTestStorageClass(client, namespace, storageClass) createdStorageClass := tsc.Create() cleanupFuncs = append(cleanupFuncs, tsc.Cleanup) @@ -175,7 +173,7 @@ func (volume *VolumeDetails) SetupPreProvisionedPersistentVolumeClaim(client cli volumeMode = v1.PersistentVolumeBlock } By("setting up the PV") - pv := csiDriver.GetPersistentVolume(volume.VolumeID, volume.FSType, volume.ClaimSize, volume.ReclaimPolicy, namespace.Name, volume.AccessMode, volumeMode) + pv := csiDriver.GetPersistentVolume(volume.VolumeID, volume.PreProvisionedVolumeFsType, volume.ClaimSize, volume.ReclaimPolicy, namespace.Name, volume.AccessMode, volumeMode) tpv := NewTestPreProvisionedPersistentVolume(client, pv) tpv.Create() By("setting up the PVC")