mirror of
https://github.com/TECHNOFAB11/zfs-localpv.git
synced 2025-12-11 22:10:11 +01:00
feat(resize): adding BDD test for Online volume expansion
Signed-off-by: Pawan <pawan@mayadata.io>
This commit is contained in:
parent
86e623a369
commit
7178387c1e
3 changed files with 58 additions and 0 deletions
|
|
@ -31,6 +31,7 @@ func datasetCreationTest() {
|
||||||
By("creating and verifying PVC bound status", createAndVerifyPVC)
|
By("creating and verifying PVC bound status", createAndVerifyPVC)
|
||||||
By("Creating and deploying app pod", createDeployVerifyApp)
|
By("Creating and deploying app pod", createDeployVerifyApp)
|
||||||
By("verifying ZFSVolume object", VerifyZFSVolume)
|
By("verifying ZFSVolume object", VerifyZFSVolume)
|
||||||
|
By("Resizing the PVC", resizeAndVerifyPVC)
|
||||||
By("verifying ZFSVolume property change", VerifyZFSVolumePropEdit)
|
By("verifying ZFSVolume property change", VerifyZFSVolumePropEdit)
|
||||||
By("Deleting application deployment", deleteAppDeployment)
|
By("Deleting application deployment", deleteAppDeployment)
|
||||||
By("Deleting pvc", deletePVC)
|
By("Deleting pvc", deletePVC)
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,7 @@ var (
|
||||||
appPod *corev1.PodList
|
appPod *corev1.PodList
|
||||||
accessModes = []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce}
|
accessModes = []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce}
|
||||||
capacity = "5368709120" // 5Gi
|
capacity = "5368709120" // 5Gi
|
||||||
|
NewCapacity = "8589934592" // 8Gi, for testing resize
|
||||||
KubeConfigPath string
|
KubeConfigPath string
|
||||||
OpenEBSNamespace string
|
OpenEBSNamespace string
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,8 @@ import (
|
||||||
corev1 "k8s.io/api/core/v1"
|
corev1 "k8s.io/api/core/v1"
|
||||||
k8serrors "k8s.io/apimachinery/pkg/api/errors"
|
k8serrors "k8s.io/apimachinery/pkg/api/errors"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|
||||||
|
"k8s.io/apimachinery/pkg/api/resource"
|
||||||
)
|
)
|
||||||
|
|
||||||
// IsPVCBoundEventually checks if the pvc is bound or not eventually
|
// IsPVCBoundEventually checks if the pvc is bound or not eventually
|
||||||
|
|
@ -47,6 +49,23 @@ func IsPVCBoundEventually(pvcName string) bool {
|
||||||
Should(BeTrue())
|
Should(BeTrue())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsPVCResizedEventually checks if the pvc is bound or not eventually
|
||||||
|
func IsPVCResizedEventually(pvcName string, newCapacity string) bool {
|
||||||
|
newStorage, err := resource.ParseQuantity(NewCapacity)
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return Eventually(func() bool {
|
||||||
|
volume, err := PVCClient.
|
||||||
|
Get(pvcName, metav1.GetOptions{})
|
||||||
|
Expect(err).ShouldNot(HaveOccurred())
|
||||||
|
pvcStorage := volume.Spec.Resources.Requests[corev1.ResourceName(corev1.ResourceStorage)]
|
||||||
|
return pvcStorage == newStorage
|
||||||
|
},
|
||||||
|
60, 5).
|
||||||
|
Should(BeTrue())
|
||||||
|
}
|
||||||
|
|
||||||
// IsPodRunningEventually return true if the pod comes to running state
|
// IsPodRunningEventually return true if the pod comes to running state
|
||||||
func IsPodRunningEventually(namespace, podName string) bool {
|
func IsPodRunningEventually(namespace, podName string) bool {
|
||||||
return Eventually(func() bool {
|
return Eventually(func() bool {
|
||||||
|
|
@ -122,6 +141,7 @@ func createZfsStorageClass() {
|
||||||
scObj, err = sc.NewBuilder().
|
scObj, err = sc.NewBuilder().
|
||||||
WithGenerateName(scName).
|
WithGenerateName(scName).
|
||||||
WithParametersNew(parameters).
|
WithParametersNew(parameters).
|
||||||
|
WithVolumeExpansion(true).
|
||||||
WithProvisioner(ZFSProvisioner).Build()
|
WithProvisioner(ZFSProvisioner).Build()
|
||||||
Expect(err).ShouldNot(HaveOccurred(),
|
Expect(err).ShouldNot(HaveOccurred(),
|
||||||
"while building zfs storageclass obj with prefix {%s}", scName)
|
"while building zfs storageclass obj with prefix {%s}", scName)
|
||||||
|
|
@ -302,6 +322,42 @@ func createAndVerifyPVC() {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func resizeAndVerifyPVC() {
|
||||||
|
var (
|
||||||
|
err error
|
||||||
|
pvcName = "zfspv-pvc"
|
||||||
|
)
|
||||||
|
By("updating the pvc with new size")
|
||||||
|
pvcObj, err = pvc.BuildFrom(pvcObj).
|
||||||
|
WithCapacity(NewCapacity).Build()
|
||||||
|
Expect(err).To(
|
||||||
|
BeNil(),
|
||||||
|
"while building pvc {%s} in namespace {%s}",
|
||||||
|
pvcName,
|
||||||
|
OpenEBSNamespace,
|
||||||
|
)
|
||||||
|
pvcObj, err = PVCClient.WithNamespace(OpenEBSNamespace).Update(pvcObj)
|
||||||
|
Expect(err).To(
|
||||||
|
BeNil(),
|
||||||
|
"while updating pvc {%s} in namespace {%s}",
|
||||||
|
pvcName,
|
||||||
|
OpenEBSNamespace,
|
||||||
|
)
|
||||||
|
|
||||||
|
By("verifying pvc size to be updated")
|
||||||
|
|
||||||
|
status := IsPVCResizedEventually(pvcName, NewCapacity)
|
||||||
|
Expect(status).To(Equal(true),
|
||||||
|
"while checking pvc resize")
|
||||||
|
|
||||||
|
pvcObj, err = PVCClient.WithNamespace(OpenEBSNamespace).Get(pvcObj.Name, metav1.GetOptions{})
|
||||||
|
Expect(err).To(
|
||||||
|
BeNil(),
|
||||||
|
"while retrieving pvc {%s} in namespace {%s}",
|
||||||
|
pvcName,
|
||||||
|
OpenEBSNamespace,
|
||||||
|
)
|
||||||
|
}
|
||||||
func createDeployVerifyApp() {
|
func createDeployVerifyApp() {
|
||||||
By("creating and deploying app pod", createAndDeployAppPod)
|
By("creating and deploying app pod", createAndDeployAppPod)
|
||||||
time.Sleep(30 * time.Second)
|
time.Sleep(30 * time.Second)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue