Skip to content

Commit

Permalink
Merge pull request #622 from kubernetes-sigs/multi-nfs-vol-test
Browse files Browse the repository at this point in the history
test: add multiple NFS volume mount test
  • Loading branch information
andyzhangx committed Apr 23, 2021
2 parents 50ff8a4 + 5c1c2ef commit 378c578
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 5 deletions.
34 changes: 34 additions & 0 deletions test/e2e/dynamic_provisioning_test.go
Expand Up @@ -752,6 +752,40 @@ var _ = ginkgo.Describe("Dynamic Provisioning", func() {
test.Run(cs, ns)
})

ginkgo.It("should create a pod with multiple NFS volumes [file.csi.azure.com]", func() {
skipIfTestingInWindowsCluster()
skipIfUsingInTreeVolumePlugin()

volumes := []testsuites.VolumeDetails{}
for i := 1; i <= 6; i++ {
volume := testsuites.VolumeDetails{
ClaimSize: "100Gi",
VolumeMount: testsuites.VolumeMountDetails{
NameGenerate: "test-volume-",
MountPathGenerate: "/mnt/test-",
},
}
volumes = append(volumes, volume)
}

pods := []testsuites.PodDetails{
{
Cmd: convertToPowershellCommandIfNecessary("echo 'hello world' > /mnt/test-1/data && grep 'hello world' /mnt/test-1/data"),
Volumes: volumes,
IsWindows: isWindowsCluster,
},
}
test := testsuites.DynamicallyProvisionedPodWithMultiplePVsTest{
CSIDriver: testDriver,
Pods: pods,
StorageClassParameters: map[string]string{
"skuName": "Premium_LRS",
"protocol": "nfs",
},
}
test.Run(cs, ns)
})

ginkgo.It("should create a statefulset object, write and read to it, delete the pod and write and read to it again [file.csi.azure.com]", func() {
skipIfUsingInTreeVolumePlugin()

Expand Down
Expand Up @@ -29,13 +29,14 @@ import (
// Waiting for the PV provisioner to create a new PV
// Testing if the Pod(s) Cmd is run with a 0 exit code
type DynamicallyProvisionedPodWithMultiplePVsTest struct {
CSIDriver driver.DynamicPVTestDriver
Pods []PodDetails
CSIDriver driver.DynamicPVTestDriver
Pods []PodDetails
StorageClassParameters map[string]string
}

func (t *DynamicallyProvisionedPodWithMultiplePVsTest) Run(client clientset.Interface, namespace *v1.Namespace) {
for _, pod := range t.Pods {
tpod, cleanup := pod.SetupWithDynamicMultipleVolumes(client, namespace, t.CSIDriver)
tpod, cleanup := pod.SetupWithDynamicMultipleVolumes(client, namespace, t.CSIDriver, t.StorageClassParameters)
// defer must be called here for resources not get removed before using them
for i := range cleanup {
defer cleanup[i]()
Expand Down
6 changes: 4 additions & 2 deletions test/e2e/testsuites/specs.go
Expand Up @@ -106,12 +106,14 @@ func (pod *PodDetails) SetupWithDynamicVolumes(client clientset.Interface, names
}

// SetupWithDynamicMultipleVolumes each pod will be mounted with multiple volumes with different storage account types
func (pod *PodDetails) SetupWithDynamicMultipleVolumes(client clientset.Interface, namespace *v1.Namespace, csiDriver driver.DynamicPVTestDriver) (*TestPod, []func()) {
func (pod *PodDetails) SetupWithDynamicMultipleVolumes(client clientset.Interface, namespace *v1.Namespace, csiDriver driver.DynamicPVTestDriver, storageClassParameters map[string]string) (*TestPod, []func()) {
tpod := NewTestPod(client, namespace, pod.Cmd, pod.IsWindows)
cleanupFuncs := make([]func(), 0)
accountTypeCount := len(supportedStorageAccountTypes)
for n, v := range pod.Volumes {
storageClassParameters := map[string]string{"skuName": supportedStorageAccountTypes[n%accountTypeCount]}
if len(storageClassParameters) == 0 {
storageClassParameters = map[string]string{"skuName": supportedStorageAccountTypes[n%accountTypeCount]}
}
tpvc, funcs := v.SetupDynamicPersistentVolumeClaim(client, namespace, csiDriver, storageClassParameters)
cleanupFuncs = append(cleanupFuncs, funcs...)
if v.VolumeMode == Block {
Expand Down

0 comments on commit 378c578

Please sign in to comment.