Skip to content

Commit

Permalink
fix volume cloning and add e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
umagnus committed Jul 31, 2024
1 parent 43512a8 commit 95c09ac
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pkg/blob/controllerserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ func (d *Driver) copyBlobContainer(authAzcopyEnv []string, srcPath string, srcAc
case util.AzcopyJobNotFound:
klog.V(2).Infof("copy blob container %s to %s", srcPath, dstContainerName)
execFunc := func() error {
cmd := exec.Command("azcopy", "copy", srcPath+srcAccountSASToken, dstPath+dstAccountSASToken, "--recursive", "--check-length=false")
cmd := exec.Command("azcopy", "copy", srcPath+srcAccountSASToken, dstPath+dstAccountSASToken, "--recursive", "--check-length=false", "--s2s-preserve-access-tier=false")
if len(authAzcopyEnv) > 0 {
cmd.Env = append(os.Environ(), authAzcopyEnv...)
}
Expand Down
75 changes: 75 additions & 0 deletions test/e2e/dynamic_provisioning_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1006,4 +1006,79 @@ var _ = ginkgo.Describe("[blob-csi-e2e] Dynamic Provisioning", func() {
}
test.Run(ctx, cs, ns)
})

ginkgo.It("should clone a volume from an existing NFSv3 volume to another storage class [nfs]", func(ctx ginkgo.SpecContext) {
pod := testsuites.PodDetails{
Cmd: "echo 'hello world' > /mnt/test-1/data && grep 'hello world' /mnt/test-1/data",
Volumes: []testsuites.VolumeDetails{
{
ClaimSize: "10Gi",
MountOptions: []string{
"nconnect=8",
},
VolumeMount: testsuites.VolumeMountDetails{
NameGenerate: "test-volume-",
MountPathGenerate: "/mnt/test-",
},
},
},
}
podWithClonedVolume := testsuites.PodDetails{
Cmd: "grep 'hello world' /mnt/test-1/data",
}
test := testsuites.DynamicallyProvisionedVolumeCloningTest{
CSIDriver: testDriver,
Pod: pod,
PodWithClonedVolume: podWithClonedVolume,
StorageClassParameters: map[string]string{
"skuName": "Premium_LRS",
"protocol": "nfs",
"mountPermissions": "0755",
"allowsharedkeyaccess": "true",
},
ClonedStorageClassParameters: map[string]string{
"skuName": "Standard_LRS",
"protocol": "nfs",
"mountPermissions": "0755",
"allowsharedkeyaccess": "true",
},
}
test.Run(ctx, cs, ns)
})

ginkgo.It("should clone a volume from an existing blobfuse2 volume to another storage class [fuse2]", func(ctx ginkgo.SpecContext) {
pod := testsuites.PodDetails{
Cmd: "echo 'hello world' > /mnt/test-1/data && grep 'hello world' /mnt/test-1/data",
Volumes: []testsuites.VolumeDetails{
{
ClaimSize: "10Gi",
MountOptions: []string{
"-o allow_other",
"--virtual-directory=true", // blobfuse2 mount options
},
VolumeMount: testsuites.VolumeMountDetails{
NameGenerate: "test-volume-",
MountPathGenerate: "/mnt/test-",
},
},
},
}
podWithClonedVolume := testsuites.PodDetails{
Cmd: "grep 'hello world' /mnt/test-1/data",
}
test := testsuites.DynamicallyProvisionedVolumeCloningTest{
CSIDriver: testDriver,
Pod: pod,
PodWithClonedVolume: podWithClonedVolume,
StorageClassParameters: map[string]string{
"skuName": "Standard_LRS",
"protocol": "fuse2",
},
ClonedStorageClassParameters: map[string]string{
"skuName": "Premium_LRS",
"protocol": "fuse2",
},
}
test.Run(ctx, cs, ns)
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ import (
// DynamicallyProvisionedVolumeCloningTest will provision required StorageClass(es), PVC(s) and Pod(s)
// ClonedVolumeSize optional for when testing for cloned volume with different size to the original volume
type DynamicallyProvisionedVolumeCloningTest struct {
CSIDriver driver.DynamicPVTestDriver
Pod PodDetails
PodWithClonedVolume PodDetails
ClonedVolumeSize string
StorageClassParameters map[string]string
CSIDriver driver.DynamicPVTestDriver
Pod PodDetails
PodWithClonedVolume PodDetails
ClonedVolumeSize string
StorageClassParameters map[string]string
ClonedStorageClassParameters map[string]string
}

func (t *DynamicallyProvisionedVolumeCloningTest) Run(ctx context.Context, client clientset.Interface, namespace *v1.Namespace) {
Expand Down Expand Up @@ -69,7 +70,11 @@ func (t *DynamicallyProvisionedVolumeCloningTest) Run(ctx context.Context, clien
}

t.PodWithClonedVolume.Volumes = []VolumeDetails{clonedVolume}
tpod, cleanups = t.PodWithClonedVolume.SetupWithDynamicVolumes(ctx, client, namespace, t.CSIDriver, t.StorageClassParameters)
clonedStorageClassParameters := t.StorageClassParameters
if t.ClonedStorageClassParameters != nil {
clonedStorageClassParameters = t.ClonedStorageClassParameters
}
tpod, cleanups = t.PodWithClonedVolume.SetupWithDynamicVolumes(ctx, client, namespace, t.CSIDriver, clonedStorageClassParameters)
for i := range cleanups {
defer cleanups[i](ctx)
}
Expand Down

0 comments on commit 95c09ac

Please sign in to comment.