From b8d2144fb4270002463f07ebbea19520fce27d29 Mon Sep 17 00:00:00 2001 From: Abhilash Shetty Date: Thu, 13 Jun 2024 10:45:37 +0000 Subject: [PATCH] test: add missing validations in existing ci test Signed-off-by: Abhilash Shetty --- tests/provision_test.go | 25 ++++++++++++++++++++++++- tests/utils.go | 6 ++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/tests/provision_test.go b/tests/provision_test.go index 56c6e728..8c0dea1e 100644 --- a/tests/provision_test.go +++ b/tests/provision_test.go @@ -74,23 +74,46 @@ func blockVolCreationTest() { By("Creating and deploying app pod", createDeployVerifyBlockApp) By("verifying LVMVolume object", VerifyLVMVolume) + By("Online resizing the block volume") + resizeAndVerifyPVC(true, "8Gi") + By("create snapshot") + createSnapshot(pvcName, snapName) + By("verify snapshot") + verifySnapshotCreated(snapName) By("Deleting application deployment") deleteAppDeployment(appName) By("Deleting pvc") deleteAndVerifyPVC(pvcName) + By("Verifying that PV exists after PVC deletion") + verifyPVForPVC(true, pvcName) + By("Deleting snapshot") + deleteSnapshot(pvcName, snapName) + By("Verifying that PV is deleted after snapshot deletion") + verifyPVForPVC(false, pvcName) By("Deleting storage class", deleteStorageClass) } func thinVolCreationTest() { By("Creating thinProvision storage class", createThinStorageClass) By("creating and verifying PVC bound status", createAndVerifyPVC) - By("Creating and deploying app pod", createDeployVerifyApp) By("verifying LVMVolume object", VerifyLVMVolume) + By("Online resizing the block volume") + resizeAndVerifyPVC(true, "8Gi") + By("create snapshot") + createSnapshot(pvcName, snapName) + By("verify snapshot") + verifySnapshotCreated(snapName) By("Deleting application deployment") deleteAppDeployment(appName) By("Deleting pvc") deleteAndVerifyPVC(pvcName) + By("Verifying that PV exists after PVC deletion") + verifyPVForPVC(true, pvcName) + By("Deleting snapshot") + deleteSnapshot(pvcName, snapName) + By("Verifying that PV is deleted after snapshot deletion") + verifyPVForPVC(false, pvcName) By("Deleting thinProvision storage class", deleteStorageClass) } diff --git a/tests/utils.go b/tests/utils.go index c7b42428..4a07a1fc 100644 --- a/tests/utils.go +++ b/tests/utils.go @@ -69,6 +69,7 @@ func IsPVCResizedEventually(pvcName string, newCapacity string, shouldPass bool) Get(pvcName, metav1.GetOptions{}) gomega.Expect(err).ShouldNot(gomega.HaveOccurred()) pvcStorage := volume.Status.Capacity[corev1.ResourceName(corev1.ResourceStorage)] + gomega.Expect(err).ShouldNot(gomega.HaveOccurred()) return pvcStorage == newStorage }, 120, 5). @@ -135,6 +136,7 @@ func createStorageClass() { ginkgo.By("building a default storage class") scObj, err = sc.NewBuilder(). WithGenerateName(scName). + WithVolumeExpansion(true). WithParametersNew(parameters). WithProvisioner(LocalProvisioner).Build() gomega.Expect(err).ShouldNot(gomega.HaveOccurred(), @@ -158,6 +160,7 @@ func createThinStorageClass() { scObj, err = sc.NewBuilder(). WithGenerateName(scName). WithParametersNew(parameters). + WithVolumeExpansion(true). WithProvisioner(LocalProvisioner).Build() gomega.Expect(err).ShouldNot(gomega.HaveOccurred(), "while building thinProvision storageclass obj with prefix {%s}", scName) @@ -177,9 +180,12 @@ func VerifyLVMVolume() { gomega.Expect(vol.Spec.VolGroup).To(gomega.Equal(scObj.Parameters["volgroup"]), "while checking volume group of lvm volume", pvcObj.Spec.VolumeName) + gomega.Expect(vol.Status.State).To(gomega.Equal("Ready"), + "While checking if lvmvolume: %s is in Ready state", pvcObj.Spec.VolumeName) gomega.Expect(vol.Finalizers[0]).To(gomega.Equal(lvm.LVMFinalizer), "while checking finializer to be set {%s}", pvcObj.Spec.VolumeName) } + func deleteStorageClass() { err := SCClient.Delete(scObj.Name, &metav1.DeleteOptions{}) gomega.Expect(err).To(gomega.BeNil(),