diff --git a/tests/provision_test.go b/tests/provision_test.go index 276e64729..4aec84992 100644 --- a/tests/provision_test.go +++ b/tests/provision_test.go @@ -27,36 +27,59 @@ var _ = Describe("[zfspv] TEST VOLUME PROVISIONING", func() { }) func fsVolCreationTest() { - fstypes := []string{"zfs", "ext4", "xfs", "btrfs"} - for _, fstype := range fstypes { - By("####### Creating the storage class : " + fstype + " #######") - createFstypeStorageClass(fstype) - By("creating and verifying PVC bound status", createAndVerifyPVC) - By("Creating and deploying app pod", createDeployVerifyApp) - By("verifying ZFSVolume object", VerifyZFSVolume) - By("verifying ZFSVolume property change", VerifyZFSVolumePropEdit) - - createSnapshot(pvcName, snapName) - verifySnapshotCreated(snapName) - createClone(clonePvcName, snapName, scObj.Name) - By("Creating and deploying clone app pod", createDeployVerifyCloneApp) - - // btrfs does not support online resize - if fstype != "btrfs" { - By("Resizing the PVC", resizeAndVerifyPVC) - } - By("Deleting clone and main application deployment") - deleteAppDeployment(cloneAppName) - deleteAppDeployment(appName) - - By("Deleting snapshot, main pvc and clone pvc") - deletePVC(clonePvcName) - deleteSnapshot(pvcName, snapName) - deletePVC(pvcName) - By("Deleting storage class", deleteStorageClass) + storageClass := getStoragClassParams() + for _, params := range storageClass { + exhaustiveVolumeTests(params) } } +// Test to cater create, snapshot, clone and delete resources +func exhaustiveVolumeTests(parameters map[string]string) { + fstype := parameters["fstype"] + create(parameters) + snapshotAndCloneCreate() + // btrfs does not support online resize + if fstype != "btrfs" { + By("Resizing the PVC", resizeAndVerifyPVC) + } + snapshotAndCloneCleanUp() + cleanUp() +} + +// Creates the resources +func create(parameters map[string]string) { + By("####### Creating the storage class : " + parameters["fstype"] + " #######") + createFstypeStorageClass(parameters) + By("creating and verifying PVC bound status", createAndVerifyPVC) + By("Creating and deploying app pod", createDeployVerifyApp) + By("verifying ZFSVolume object", VerifyZFSVolume) + By("verifying storage class parameters") + VerifyStorageClassParams(parameters) + +} + +// Creates the snapshot/clone resources +func snapshotAndCloneCreate() { + createSnapshot(pvcName, snapName) + verifySnapshotCreated(snapName) + createClone(clonePvcName, snapName, scObj.Name) + By("Creating and deploying clone app pod", createDeployVerifyCloneApp) +} + +// Removes the snapshot/clone resources +func snapshotAndCloneCleanUp() { + deleteAppDeployment(cloneAppName) + deletePVC(clonePvcName) + deleteSnapshot(pvcName, snapName) +} + +// Removes the resources +func cleanUp() { + deleteAppDeployment(appName) + deletePVC(pvcName) + By("Deleting storage class", deleteStorageClass) +} + func blockVolCreationTest() { By("Creating default storage class", createStorageClass) By("creating and verifying PVC bound status", createAndVerifyBlockPVC) diff --git a/tests/utils.go b/tests/utils.go index e598b23ad..af1023700 100644 --- a/tests/utils.go +++ b/tests/utils.go @@ -106,17 +106,34 @@ func IsPVCDeletedEventually(pvcName string) bool { Should(gomega.BeTrue()) } -func createFstypeStorageClass(ftype string) { +// VerifyStorageClassParams verifies the volume properties set at creation time +func VerifyStorageClassParams(parameters map[string]string) { + for propertyKey, propertyVal := range parameters { + if propertyKey != "fstype" && propertyKey != "thinprovision" { + vol, err := ZFSClient.WithNamespace(OpenEBSNamespace). + Get(pvcObj.Spec.VolumeName, metav1.GetOptions{}) + gomega.Expect(err).To(gomega.BeNil(), "while fetching the zfs volume {%s}", vol.Name) + status := IsPropUpdatedEventually(vol, propertyKey, propertyVal) + gomega.Expect(status).To(gomega.Equal(true), "while updating {%s%}={%s%} {%s}", propertyKey, propertyVal, vol.Name) + } + } +} + +func createFstypeStorageClass(addons map[string]string) { var ( err error ) parameters := map[string]string{ "poolname": POOLNAME, - "fstype": ftype, } - ginkgo.By("building a " + ftype + " storage class") + // Update params with addons + for key, value := range addons { + parameters[key] = value + } + + ginkgo.By("building a " + addons["ftype"] + " storage class") scObj, err = sc.NewBuilder(). WithGenerateName(scName). WithVolumeExpansion(true). @@ -585,3 +602,56 @@ func deletePVC(pvcname string) { status := IsPVCDeletedEventually(pvcname) gomega.Expect(status).To(gomega.Equal(true), "while trying to get deleted pvc") } + +func getStoragClassParams() []map[string]string { + parameter1 := map[string]string{ + "fstype": "zfs", + "compression": "lz4", + } + parameter2 := map[string]string{ + "fstype": "zfs", + "compression": "lz4", + "dedup": "on", + } + parameter3 := map[string]string{ + "fstype": "zfs", + "compression": "zstd-6", + "dedup": "on", + "thinprovision": "yes", + } + parameter4 := map[string]string{ + "fstype": "zfs", + "dedup": "on", + } + parameter5 := map[string]string{ + "fstype": "zfs", + "compression": "gzip", + "thinprovision": "yes", + } + parameter6 := map[string]string{ + "fstype": "zfs", + "compression": "gzip", + "dedup": "on", + "thinprovision": "yes", + } + parameter7 := map[string]string{ + "fstype": "xfs", + "compression": "zstd-6", + } + parameter8 := map[string]string{ + "fstype": "xfs", + "compression": "zstd-6", + "dedup": "on", + "thinprovision": "yes", + } + parameter9 := map[string]string{ + "fstype": "ext4", + "dedup": "on", + } + parameter10 := map[string]string{ + "fstype": "btrfs", + "compression": "zstd-6", + "dedup": "on", + } + return []map[string]string{parameter1, parameter2, parameter3, parameter4, parameter5, parameter6, parameter7, parameter8, parameter9, parameter10} +}