Skip to content

Commit

Permalink
Merge pull request #1478 from kubernetes-sigs/add-nfs-snapshot-test
Browse files Browse the repository at this point in the history
test: add nfs snapshot e2e test
  • Loading branch information
andyzhangx authored Oct 11, 2023
2 parents 9628fe9 + 32d1241 commit 3d1b8d0
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 3 deletions.
38 changes: 36 additions & 2 deletions test/e2e/dynamic_provisioning_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -689,15 +689,14 @@ var _ = ginkgo.Describe("Dynamic Provisioning", func() {
test.Run(ctx, cs, ns)
})

ginkgo.It("should create a pod, write and read to it, take a volume snapshot, and validate whether it is ready to use [file.csi.azure.com]", func(ctx ginkgo.SpecContext) {
ginkgo.It("should create a pod, write and read to it, take a smb volume snapshot, and validate whether it is ready to use [file.csi.azure.com]", func(ctx ginkgo.SpecContext) {
skipIfTestingInWindowsCluster()
skipIfUsingInTreeVolumePlugin()

pod := testsuites.PodDetails{
Cmd: "echo 'hello world' > /mnt/test-1/data",
Volumes: []testsuites.VolumeDetails{
{
FSType: "ext4",
ClaimSize: "10Gi",
VolumeMount: testsuites.VolumeMountDetails{
NameGenerate: "test-volume-",
Expand All @@ -721,6 +720,41 @@ var _ = ginkgo.Describe("Dynamic Provisioning", func() {
test.Run(ctx, cs, snapshotrcs, ns)
})

ginkgo.It("should create a pod, write and read to it, take a nfs volume snapshot, and validate whether it is ready to use [file.csi.azure.com]", func(ctx ginkgo.SpecContext) {
skipIfTestingInWindowsCluster()
skipIfUsingInTreeVolumePlugin()
if !supportSnapshotwithNFS {
ginkgo.Skip("take snapshot on nfs file share is not supported on current region")
}

pod := testsuites.PodDetails{
Cmd: "echo 'hello world' > /mnt/test-1/data",
Volumes: []testsuites.VolumeDetails{
{
ClaimSize: "100Gi",
VolumeMount: testsuites.VolumeMountDetails{
NameGenerate: "test-volume-",
MountPathGenerate: "/mnt/test-",
},
},
},
}
podWithSnapshot := testsuites.PodDetails{
Cmd: "grep 'hello world' /mnt/test-1/data",
}
test := testsuites.DynamicallyProvisionedVolumeSnapshotTest{
CSIDriver: testDriver,
Pod: pod,
PodWithSnapshot: podWithSnapshot,
StorageClassParameters: map[string]string{
"skuName": "Premium_LRS",
"selectRandomMatchingAccount": "true",
"protocol": "nfs",
},
}
test.Run(ctx, cs, snapshotrcs, ns)
})

ginkgo.It("should create a volume on demand with mount options (Bring Your Own Key) [file.csi.azure.com] [Windows]", func(ctx ginkgo.SpecContext) {
skipIfUsingInTreeVolumePlugin()
// get storage account secret name
Expand Down
11 changes: 10 additions & 1 deletion test/e2e/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ var (
"csi.storage.k8s.io/provisioner-secret-namespace": "default",
"csi.storage.k8s.io/node-stage-secret-namespace": "default",
}
supportZRSwithNFS bool
supportZRSwithNFS bool
supportSnapshotwithNFS bool
)

type testCmd struct {
Expand Down Expand Up @@ -105,6 +106,14 @@ var _ = ginkgo.BeforeSuite(func(ctx ginkgo.SpecContext) {
}
}

// check whether current region supports snapshot with NFS protocol
supportedRegions = []string{"canadacentral", "uksouth", "francesouth", "francecentral", "germanywestcentral"}
for _, region := range supportedRegions {
if creds.Location == region {
supportSnapshotwithNFS = true
}
}

// Install Azure File CSI Driver on cluster from project root
e2eBootstrap := testCmd{
command: "make",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package testsuites

import (
"context"
"time"

"sigs.k8s.io/azurefile-csi-driver/test/e2e/driver"

Expand Down Expand Up @@ -58,6 +59,9 @@ func (t *DynamicallyProvisionedVolumeSnapshotTest) Run(ctx context.Context, clie
tvsc, cleanup := CreateVolumeSnapshotClass(ctx, restclient, namespace, t.CSIDriver)
defer cleanup()

ginkgo.By("sleeping for 5 seconds to wait for data to be written to the volume")
time.Sleep(5 * time.Second)

ginkgo.By("taking snapshots")
snapshot := tvsc.CreateSnapshot(ctx, tpvc.persistentVolumeClaim)
defer tvsc.DeleteSnapshot(ctx, snapshot)
Expand Down

0 comments on commit 3d1b8d0

Please sign in to comment.