From f4d5fdf11484fef4e5c0d7ffe7beb8ab9531e8b5 Mon Sep 17 00:00:00 2001 From: Madhu Rajanna Date: Fri, 19 Feb 2021 11:31:27 +0530 Subject: [PATCH] e2e: add e2e for cephfs VolumeNamePrefix for PVC when user provides an option for VolumeNamePrefix create subvolume with the prefix which will be easy for user to identify the subvolumes belongs to the storageclass, Added an E2E testing to verify that the subvolume contains the Prefix what is provided in the storageclass. Signed-off-by: Madhu Rajanna --- e2e/cephfs.go | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/e2e/cephfs.go b/e2e/cephfs.go index c1147feac..ce78ea652 100644 --- a/e2e/cephfs.go +++ b/e2e/cephfs.go @@ -261,6 +261,52 @@ var _ = Describe("cephfs", func() { } }) + By("create PVC in storageClass with volumeNamePrefix", func() { + volumeNamePrefix := "foo-bar-" + err := createCephfsStorageClass(f.ClientSet, f, false, map[string]string{"volumeNamePrefix": volumeNamePrefix}) + if err != nil { + e2elog.Failf("failed to create storageclass with error %v", err) + } + // set up PVC + pvc, err := loadPVC(pvcPath) + if err != nil { + e2elog.Failf("failed to load PVC with error %v", err) + } + pvc.Namespace = f.UniqueName + err = createPVCAndvalidatePV(f.ClientSet, pvc, deployTimeout) + if err != nil { + e2elog.Failf("failed to create PVC with error %v", err) + } + + validateSubvolumeCount(f, 1, fileSystemName, subvolumegroup) + // list subvolumes and check if one of them has the same prefix + foundIt := false + subvolumes, err := listCephFSSubVolumes(f, fileSystemName, subvolumegroup) + if err != nil { + e2elog.Failf("failed to list subvolumes with error %v", err) + } + for _, subVol := range subvolumes { + fmt.Printf("Checking prefix on %s\n", subVol) + if strings.HasPrefix(subVol.Name, volumeNamePrefix) { + foundIt = true + break + } + } + // clean up after ourselves + err = deletePVCAndValidatePV(f.ClientSet, pvc, deployTimeout) + if err != nil { + e2elog.Failf("failed to delete PVC with error %v", err) + } + validateSubvolumeCount(f, 0, fileSystemName, subvolumegroup) + err = deleteResource(cephfsExamplePath + "storageclass.yaml") + if err != nil { + e2elog.Failf("failed to delete storageclass with error %v", err) + } + if !foundIt { + e2elog.Failf("could not find subvolume with prefix %s", volumeNamePrefix) + } + }) + By("create a storageclass with ceph-fuse and a PVC then bind it to an app", func() { params := map[string]string{ "mounter": "fuse",