Skip to content

Commit

Permalink
verifying zfs volume parameters
Browse files Browse the repository at this point in the history
Signed-off-by: Pawan <[email protected]>
  • Loading branch information
pawanpraka1 committed Dec 3, 2019
1 parent 9cd452c commit 03c5825
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 14 deletions.
1 change: 1 addition & 0 deletions tests/provision_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ var _ = Describe("[zfspv] TEST VOLUME PROVISIONING", func() {

func volumeCreationTest() {
By("creating and verifying PVC bound status", createAndVerifyPVC)
By("verifying ZFSVolume object", VerifyZFSVolume)
By("Creating and deploying app pod", createDeployVerifyApp)
By("Deleting application deployment", deleteAppDeployment)
By("Deleting pvc", deletePVC)
Expand Down
10 changes: 8 additions & 2 deletions tests/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@ import (
"testing"
)

const (
// zfs pool name where volume provisioning will happen
POOLNAME = "zfspv-pool"
)

var (
SCClient *sc.Kubeclient
PVCClient *pvc.Kubeclient
Expand All @@ -43,12 +48,13 @@ var (
appName = "busybox-zfspv"

nsObj *corev1.Namespace
scObj *storagev1.StorageClass
scObjExt4 *storagev1.StorageClass
scObjZfs *storagev1.StorageClass
deployObj *appsv1.Deployment
pvcObj *corev1.PersistentVolumeClaim
appPod *corev1.PodList
accessModes = []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce}
capacity = "5Gi"
capacity = "5368709120" // 5Gi
KubeConfigPath string
)

Expand Down
62 changes: 50 additions & 12 deletions tests/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/openebs/zfs-localpv/pkg/zfs"
"github.com/openebs/zfs-localpv/tests/container"
"github.com/openebs/zfs-localpv/tests/deploy"
"github.com/openebs/zfs-localpv/tests/k8svolume"
Expand Down Expand Up @@ -77,27 +78,64 @@ func createStorageClass() {
err error
)

parameters := map[string]string{
"poolname": "zfspv-pool",
parametersZfs := map[string]string{
"poolname": POOLNAME,
"fstype": "zfs",
}

By("building a sc")
scObj, err = sc.NewBuilder().
WithGenerateName(scName).
WithParametersNew(parameters).
scNameZfs := scName + "zfs"

By("building a zfs storage class")
scObjZfs, err = sc.NewBuilder().
WithGenerateName(scNameZfs).
WithParametersNew(parametersZfs).
WithProvisioner(ZFSProvisioner).Build()
Expect(err).ShouldNot(HaveOccurred(),
"while building storageclass obj with prefix {%s}", scNameZfs)

scObjZfs, err = SCClient.Create(scObjZfs)
Expect(err).To(BeNil(), "while creating a storageclass {%s}", scNameZfs)

parametersExt4 := map[string]string{
"poolname": POOLNAME,
"fstype": "ext4",
}

scNameExt4 := scName + "ext4"

By("building a ext4 storage class")
scObjExt4, err = sc.NewBuilder().
WithGenerateName(scNameExt4).
WithParametersNew(parametersExt4).
WithProvisioner(ZFSProvisioner).Build()
Expect(err).ShouldNot(HaveOccurred(),
"while building storageclass obj with prefix {%s}", scName)
"while building storageclass obj with prefix {%s}", scNameExt4)

scObjExt4, err = SCClient.Create(scObjExt4)
Expect(err).To(BeNil(), "while creating a storageclass {%s}", scNameExt4)
}

func VerifyZFSVolume() {
vol, err := zfs.GetVolume(pvcName)
Expect(err).To(BeNil(), "while fetching the zfs volume {%s}", pvcName)

scObj, err = SCClient.Create(scObj)
Expect(err).To(BeNil(), "while creating a storageclass {%s}", scName)
Expect(vol.Spec.PoolName).To(Equal(scObjZfs.Parameters["poolname"]),
"while checking poolname of zfs volume")
Expect(vol.Spec.FsType).To(Equal(scObjZfs.Parameters["fstype"]),
"while checking fstype of zfs volume")
Expect(vol.Spec.VolumeType).To(Equal(zfs.VOLTYPE_DATASET),
"while checking Volume type as dataset")
Expect(vol.Spec.Capacity).To(Equal(capacity),
"while checking capacity of zfs volume")
}

func deleteStorageClass() {
err := SCClient.Delete(scObj.Name, &metav1.DeleteOptions{})
err := SCClient.Delete(scObjZfs.Name, &metav1.DeleteOptions{})
Expect(err).To(BeNil(),
"while deleting zfs storageclass {%s}", scObjZfs.Name)
err = SCClient.Delete(scObjExt4.Name, &metav1.DeleteOptions{})
Expect(err).To(BeNil(),
"while deleting storageclass {%s}", scObj.Name)
"while deleting ext4 storageclass {%s}", scObjExt4.Name)
}

func createAndVerifyPVC() {
Expand All @@ -109,7 +147,7 @@ func createAndVerifyPVC() {
pvcObj, err = pvc.NewBuilder().
WithName(pvcName).
WithNamespace(openebsNamespace).
WithStorageClass(scObj.Name).
WithStorageClass(scObjZfs.Name).
WithAccessModes(accessModes).
WithCapacity(capacity).Build()
Expect(err).ShouldNot(
Expand Down

0 comments on commit 03c5825

Please sign in to comment.