Skip to content

Commit

Permalink
Merge pull request #310 from openebs/ci_refactor
Browse files Browse the repository at this point in the history
test(ci): add missing validations in existing ci test
  • Loading branch information
abhilashshetty04 authored Jun 14, 2024
2 parents 4a57750 + b8d2144 commit 8d41ce4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
25 changes: 24 additions & 1 deletion tests/provision_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
6 changes: 6 additions & 0 deletions tests/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,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).
Expand Down Expand Up @@ -137,6 +138,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(),
Expand All @@ -160,6 +162,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)
Expand All @@ -179,9 +182,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(),
Expand Down

0 comments on commit 8d41ce4

Please sign in to comment.