Skip to content

Commit 0a2c616

Browse files
committed
test: move driver restart test to pre_provisioned test suites
1 parent f70c105 commit 0a2c616

File tree

6 files changed

+98
-103
lines changed

6 files changed

+98
-103
lines changed

test/e2e/driver/blob_csi_driver.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ func InitBlobCSIDriver() PVTestDriver {
3939
}
4040
}
4141

42-
func (d *blobCSIDriver) GetDynamicProvisionStorageClass(parameters map[string]string, mountOptions []string, reclaimPolicy *v1.PersistentVolumeReclaimPolicy, bindingMode *storagev1.VolumeBindingMode, allowedTopologyValues []string, namespace string) *storagev1.StorageClass {
42+
func (d *blobCSIDriver) GetProvisionStorageClass(parameters map[string]string, mountOptions []string, reclaimPolicy *v1.PersistentVolumeReclaimPolicy, bindingMode *storagev1.VolumeBindingMode, allowedTopologyValues []string, namespace string) *storagev1.StorageClass {
4343
provisioner := d.driverName
44-
generateName := fmt.Sprintf("%s-%s-dynamic-sc-", namespace, provisioner)
44+
generateName := fmt.Sprintf("%s-%s-sc-", namespace, provisioner)
4545
return getStorageClass(generateName, provisioner, parameters, mountOptions, reclaimPolicy, bindingMode, nil)
4646
}
4747

@@ -87,9 +87,3 @@ func (d *blobCSIDriver) GetPersistentVolume(volumeID string, fsType string, size
8787
},
8888
}
8989
}
90-
91-
func (d *blobCSIDriver) GetPreProvisionStorageClass(parameters map[string]string, mountOptions []string, reclaimPolicy *v1.PersistentVolumeReclaimPolicy, bindingMode *storagev1.VolumeBindingMode, allowedTopologyValues []string, namespace string) *storagev1.StorageClass {
92-
provisioner := d.driverName
93-
generateName := fmt.Sprintf("%s-%s-pre-provisioned-sc-", namespace, provisioner)
94-
return getStorageClass(generateName, provisioner, parameters, mountOptions, reclaimPolicy, bindingMode, nil)
95-
}

test/e2e/driver/driver.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,16 @@ type PVTestDriver interface {
2929

3030
// DynamicPVTestDriver represents an interface for a CSI driver that supports DynamicPV
3131
type DynamicPVTestDriver interface {
32-
// GetDynamicProvisionStorageClass returns a StorageClass dynamic provision Persistent Volume
33-
GetDynamicProvisionStorageClass(parameters map[string]string, mountOptions []string, reclaimPolicy *v1.PersistentVolumeReclaimPolicy, bindingMode *storagev1.VolumeBindingMode, allowedTopologyValues []string, namespace string) *storagev1.StorageClass
32+
// GetProvisionStorageClass returns a StorageClass dynamic provision Persistent Volume
33+
GetProvisionStorageClass(parameters map[string]string, mountOptions []string, reclaimPolicy *v1.PersistentVolumeReclaimPolicy, bindingMode *storagev1.VolumeBindingMode, allowedTopologyValues []string, namespace string) *storagev1.StorageClass
3434
}
3535

3636
// PreProvisionedVolumeTestDriver represents an interface for a CSI driver that supports pre-provisioned volume
3737
type PreProvisionedVolumeTestDriver interface {
3838
// GetPersistentVolume returns a PersistentVolume with pre-provisioned volumeHandle
3939
GetPersistentVolume(volumeID string, fsType string, size string, reclaimPolicy *v1.PersistentVolumeReclaimPolicy, namespace string, attrib map[string]string, nodeStageSecretRef string) *v1.PersistentVolume
40-
// GetPreProvisionStorageClass returns a StorageClass with existing container
41-
GetPreProvisionStorageClass(parameters map[string]string, mountOptions []string, reclaimPolicy *v1.PersistentVolumeReclaimPolicy, bindingMode *storagev1.VolumeBindingMode, allowedTopologyValues []string, namespace string) *storagev1.StorageClass
40+
// GetProvisionStorageClass returns a StorageClass with existing container
41+
GetProvisionStorageClass(parameters map[string]string, mountOptions []string, reclaimPolicy *v1.PersistentVolumeReclaimPolicy, bindingMode *storagev1.VolumeBindingMode, allowedTopologyValues []string, namespace string) *storagev1.StorageClass
4242
}
4343

4444
func getStorageClass(

test/e2e/dynamic_provisioning_test.go

Lines changed: 0 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -568,92 +568,4 @@ var _ = ginkgo.Describe("[blob-csi-e2e] Dynamic Provisioning", func() {
568568
}
569569
test.Run(cs, ns)
570570
})
571-
572-
ginkgo.It("nfs volume mount is still valid after driver restart [blob.csi.azure.com]", func() {
573-
// print driver logs before driver restart
574-
blobLog := testCmd{
575-
command: "bash",
576-
args: []string{"test/utils/blob_log.sh"},
577-
startLog: "===================blob log (before restart)===================",
578-
endLog: "====================================================================",
579-
}
580-
execTestCmd([]testCmd{blobLog})
581-
582-
pod := testsuites.PodDetails{
583-
Cmd: "echo 'hello world' >> /mnt/test-1/data && while true; do sleep 3600; done",
584-
Volumes: []testsuites.VolumeDetails{
585-
{
586-
ClaimSize: "10Gi",
587-
VolumeMount: testsuites.VolumeMountDetails{
588-
NameGenerate: "test-volume-",
589-
MountPathGenerate: "/mnt/test-",
590-
},
591-
},
592-
},
593-
}
594-
595-
podCheckCmd := []string{"cat", "/mnt/test-1/data"}
596-
expectedString := "hello world\n"
597-
test := testsuites.DynamicallyProvisionedRestartDriverTest{
598-
CSIDriver: testDriver,
599-
Pod: pod,
600-
PodCheck: &testsuites.PodExecCheck{
601-
Cmd: podCheckCmd,
602-
ExpectedString: expectedString,
603-
},
604-
StorageClassParameters: map[string]string{"protocol": "nfs"},
605-
RestartDriverFunc: func() {
606-
restartDriver := testCmd{
607-
command: "bash",
608-
args: []string{"test/utils/restart_driver_daemonset.sh"},
609-
startLog: "Restart driver node daemonset ...",
610-
endLog: "Restart driver node daemonset done successfully",
611-
}
612-
execTestCmd([]testCmd{restartDriver})
613-
},
614-
}
615-
test.Run(cs, ns)
616-
})
617-
618-
ginkgo.It("blobfuse volume mount is still valid after driver restart [blob.csi.azure.com]", func() {
619-
_, useBlobfuseProxy := os.LookupEnv("ENABLE_BLOBFUSE_PROXY")
620-
if !useBlobfuseProxy {
621-
ginkgo.Skip("skip this test since blobfuse-proxy is not enabled")
622-
}
623-
624-
pod := testsuites.PodDetails{
625-
Cmd: "echo 'hello world' >> /mnt/test-1/data && while true; do sleep 3600; done",
626-
Volumes: []testsuites.VolumeDetails{
627-
{
628-
ClaimSize: "10Gi",
629-
VolumeMount: testsuites.VolumeMountDetails{
630-
NameGenerate: "test-volume-",
631-
MountPathGenerate: "/mnt/test-",
632-
},
633-
},
634-
},
635-
}
636-
637-
podCheckCmd := []string{"cat", "/mnt/test-1/data"}
638-
expectedString := "hello world\n"
639-
test := testsuites.DynamicallyProvisionedRestartDriverTest{
640-
CSIDriver: testDriver,
641-
Pod: pod,
642-
PodCheck: &testsuites.PodExecCheck{
643-
Cmd: podCheckCmd,
644-
ExpectedString: expectedString,
645-
},
646-
StorageClassParameters: map[string]string{"skuName": "Standard_LRS"},
647-
RestartDriverFunc: func() {
648-
restartDriver := testCmd{
649-
command: "bash",
650-
args: []string{"test/utils/restart_driver_daemonset.sh"},
651-
startLog: "Restart driver node daemonset ...",
652-
endLog: "Restart driver node daemonset done successfully",
653-
}
654-
execTestCmd([]testCmd{restartDriver})
655-
},
656-
}
657-
test.Run(cs, ns)
658-
})
659571
})

test/e2e/pre_provisioning_test.go

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package e2e
1919
import (
2020
"context"
2121
"fmt"
22+
"os"
2223
"time"
2324

2425
"sigs.k8s.io/blob-csi-driver/test/e2e/driver"
@@ -330,6 +331,94 @@ var _ = ginkgo.Describe("[blob-csi-e2e] Pre-Provisioned", func() {
330331
}
331332
test.Run(cs, ns)
332333
})
334+
335+
ginkgo.It("nfs volume mount is still valid after driver restart [blob.csi.azure.com]", func() {
336+
// print driver logs before driver restart
337+
blobLog := testCmd{
338+
command: "bash",
339+
args: []string{"test/utils/blob_log.sh"},
340+
startLog: "===================blob log (before restart)===================",
341+
endLog: "====================================================================",
342+
}
343+
execTestCmd([]testCmd{blobLog})
344+
345+
pod := testsuites.PodDetails{
346+
Cmd: "echo 'hello world' >> /mnt/test-1/data && while true; do sleep 3600; done",
347+
Volumes: []testsuites.VolumeDetails{
348+
{
349+
ClaimSize: "10Gi",
350+
VolumeMount: testsuites.VolumeMountDetails{
351+
NameGenerate: "test-volume-",
352+
MountPathGenerate: "/mnt/test-",
353+
},
354+
},
355+
},
356+
}
357+
358+
podCheckCmd := []string{"cat", "/mnt/test-1/data"}
359+
expectedString := "hello world\n"
360+
test := testsuites.DynamicallyProvisionedRestartDriverTest{
361+
CSIDriver: testDriver,
362+
Pod: pod,
363+
PodCheck: &testsuites.PodExecCheck{
364+
Cmd: podCheckCmd,
365+
ExpectedString: expectedString,
366+
},
367+
StorageClassParameters: map[string]string{"protocol": "nfs"},
368+
RestartDriverFunc: func() {
369+
restartDriver := testCmd{
370+
command: "bash",
371+
args: []string{"test/utils/restart_driver_daemonset.sh"},
372+
startLog: "Restart driver node daemonset ...",
373+
endLog: "Restart driver node daemonset done successfully",
374+
}
375+
execTestCmd([]testCmd{restartDriver})
376+
},
377+
}
378+
test.Run(cs, ns)
379+
})
380+
381+
ginkgo.It("blobfuse volume mount is still valid after driver restart [blob.csi.azure.com]", func() {
382+
_, useBlobfuseProxy := os.LookupEnv("ENABLE_BLOBFUSE_PROXY")
383+
if !useBlobfuseProxy {
384+
ginkgo.Skip("skip this test since blobfuse-proxy is not enabled")
385+
}
386+
387+
pod := testsuites.PodDetails{
388+
Cmd: "echo 'hello world' >> /mnt/test-1/data && while true; do sleep 3600; done",
389+
Volumes: []testsuites.VolumeDetails{
390+
{
391+
ClaimSize: "10Gi",
392+
VolumeMount: testsuites.VolumeMountDetails{
393+
NameGenerate: "test-volume-",
394+
MountPathGenerate: "/mnt/test-",
395+
},
396+
},
397+
},
398+
}
399+
400+
podCheckCmd := []string{"cat", "/mnt/test-1/data"}
401+
expectedString := "hello world\n"
402+
test := testsuites.DynamicallyProvisionedRestartDriverTest{
403+
CSIDriver: testDriver,
404+
Pod: pod,
405+
PodCheck: &testsuites.PodExecCheck{
406+
Cmd: podCheckCmd,
407+
ExpectedString: expectedString,
408+
},
409+
StorageClassParameters: map[string]string{"skuName": "Standard_LRS"},
410+
RestartDriverFunc: func() {
411+
restartDriver := testCmd{
412+
command: "bash",
413+
args: []string{"test/utils/restart_driver_daemonset.sh"},
414+
startLog: "Restart driver node daemonset ...",
415+
endLog: "Restart driver node daemonset done successfully",
416+
}
417+
execTestCmd([]testCmd{restartDriver})
418+
},
419+
}
420+
test.Run(cs, ns)
421+
})
333422
})
334423

335424
func makeCreateVolumeReq(volumeName, secretNamespace string) *csi.CreateVolumeRequest {

test/e2e/testsuites/pre_provisioned_existing_credentials_tester.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func (t *PreProvisionedExistingCredentialsTest) Run(client clientset.Interface,
5151
}
5252

5353
ginkgo.By("creating the storageclass with existing credentials")
54-
sc := t.CSIDriver.GetPreProvisionStorageClass(parameters, volume.MountOptions, volume.ReclaimPolicy, volume.VolumeBindingMode, volume.AllowedTopologyValues, namespace.Name)
54+
sc := t.CSIDriver.GetProvisionStorageClass(parameters, volume.MountOptions, volume.ReclaimPolicy, volume.VolumeBindingMode, volume.AllowedTopologyValues, namespace.Name)
5555
tsc := NewTestStorageClass(client, namespace, sc)
5656
createdStorageClass := tsc.Create()
5757
defer tsc.Cleanup()

test/e2e/testsuites/specs.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ func (pod *PodDetails) SetupDeployment(client clientset.Interface, namespace *v1
152152
cleanupFuncs := make([]func(), 0)
153153
volume := pod.Volumes[0]
154154
ginkgo.By("setting up the StorageClass")
155-
storageClass := csiDriver.GetDynamicProvisionStorageClass(storageClassParameters, volume.MountOptions, volume.ReclaimPolicy, volume.VolumeBindingMode, volume.AllowedTopologyValues, namespace.Name)
155+
storageClass := csiDriver.GetProvisionStorageClass(storageClassParameters, volume.MountOptions, volume.ReclaimPolicy, volume.VolumeBindingMode, volume.AllowedTopologyValues, namespace.Name)
156156
tsc := NewTestStorageClass(client, namespace, storageClass)
157157
createdStorageClass := tsc.Create()
158158
cleanupFuncs = append(cleanupFuncs, tsc.Cleanup)
@@ -172,7 +172,7 @@ func (pod *PodDetails) SetupDeployment(client clientset.Interface, namespace *v1
172172
func (volume *VolumeDetails) SetupDynamicPersistentVolumeClaim(client clientset.Interface, namespace *v1.Namespace, csiDriver driver.DynamicPVTestDriver, storageClassParameters map[string]string) (*TestPersistentVolumeClaim, []func()) {
173173
cleanupFuncs := make([]func(), 0)
174174
ginkgo.By("setting up the StorageClass")
175-
storageClass := csiDriver.GetDynamicProvisionStorageClass(storageClassParameters, volume.MountOptions, volume.ReclaimPolicy, volume.VolumeBindingMode, volume.AllowedTopologyValues, namespace.Name)
175+
storageClass := csiDriver.GetProvisionStorageClass(storageClassParameters, volume.MountOptions, volume.ReclaimPolicy, volume.VolumeBindingMode, volume.AllowedTopologyValues, namespace.Name)
176176
tsc := NewTestStorageClass(client, namespace, storageClass)
177177
createdStorageClass := tsc.Create()
178178
cleanupFuncs = append(cleanupFuncs, tsc.Cleanup)

0 commit comments

Comments
 (0)