Skip to content

Commit

Permalink
test(ci): adding volgroup test
Browse files Browse the repository at this point in the history
Signed-off-by: Abhilash Shetty <[email protected]>
  • Loading branch information
abhilashshetty04 committed Jun 28, 2024
1 parent 84c30e0 commit e96148b
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 14 deletions.
37 changes: 27 additions & 10 deletions tests/provision_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func fsVolCreationTest() {
createAndVerifyPVC(true)
By("Creating and deploying app pod", createDeployVerifyApp)
By("verifying LVMVolume object")
VerifyLVMVolume(false)
VerifyLVMVolume(false, "")

resizeAndVerifyPVC(true, "8Gi")
// do not resize after creating the snapshot(not supported)
Expand Down Expand Up @@ -92,7 +92,7 @@ func blockVolCreationTest() {
createAndVerifyBlockPVC(true)
By("Creating and deploying app pod", createDeployVerifyBlockApp)
By("verifying LVMVolume object")
VerifyLVMVolume(false)
VerifyLVMVolume(false, "")
By("Online resizing the block volume")
resizeAndVerifyPVC(true, "8Gi")
By("create snapshot")
Expand All @@ -116,13 +116,13 @@ func vgExtendTest() {
By("creating and verifying PVC bound status")
createAndVerifyBlockPVC(false)
By("verifying LVMVolume object")
VerifyLVMVolume(true)
VerifyLVMVolume(true, "")
device_1 := createPV(4)
extendVg("lvmvg", device_1)
By("verifying PVC bound status after vg extend")
VerifyBlockPVC()
By("verifying LVMVolume object")
VerifyLVMVolume(false)
VerifyLVMVolume(false, "")
By("Deleting pvc")
deleteAndVerifyPVC(pvcName)
By("Verifying that PV exists after PVC deletion")
Expand All @@ -133,13 +133,29 @@ func vgExtendTest() {
removePV(device_1)
}

func vgPatternPresentTest() {
device := setupVg(20, "lvmvg112")
device_1 := setupVg(20, "lvmvg")
By("Creating custom storage class with non existing vg parameter", createVgPatternStorageClass)
By("creating and verifying PVC Not Bound status")
createAndVerifyPVC(true)
By("verifying LVMVolume object")
VerifyLVMVolume(false, "lvmvg112")
deleteAndVerifyPVC(pvcName)
By("Verifying that PV exists after PVC deletion")
verifyPVForPVC(false, pvcName)
By("Deleting storage class", deleteStorageClass)
cleanupVg(device, "lvmvg112")
cleanupVg(device_1, "lvmvg")
}

func vgNotPresentTest() {
device := setupVg(40, "lvmvg")
By("Creating custom storage class with non existing vg parameter", createStorageClassWithNonExistingVg)
By("creating and verifying PVC Not Bound status")
createAndVerifyPVC(false)
By("verifying LVMVolume object with no provision set")
VerifyLVMVolume(true)
VerifyLVMVolume(true, "")
By("Deleting pvc")
deleteAndVerifyPVC(pvcName)
By("Deleting storage class", deleteStorageClass)
Expand All @@ -154,7 +170,7 @@ func sharedVolumeTest() {
appNames = append(appNames, "fio-ci-1")
By("Creating and deploying app pod", createDeployVerifyApp)
By("verifying LVMVolume object")
VerifyLVMVolume(false)
VerifyLVMVolume(false, "")
By("Online resizing the shared volume")
resizeAndVerifyPVC(true, "8Gi")
deleteAppAndPvc(appNames, pvcName)
Expand All @@ -169,7 +185,7 @@ func thinVolCreationTest() {
createAndVerifyPVC(true)
By("Creating and deploying app pod", createDeployVerifyApp)
By("verifying LVMVolume object")
VerifyLVMVolume(false)
VerifyLVMVolume(false, "")
By("Online resizing the block volume")
resizeAndVerifyPVC(true, "8Gi")
By("create snapshot")
Expand All @@ -194,7 +210,7 @@ func thinVolCapacityTest() {
By("Creating and deploying app pod", createDeployVerifyApp)
By("verifying thinpool auto-extended", VerifyThinpoolExtend)
By("verifying LVMVolume object")
VerifyLVMVolume(false)
VerifyLVMVolume(false, "")
deleteAppAndPvc(appNames, pvcName)
By("Deleting thinProvision storage class", deleteStorageClass)
}
Expand All @@ -205,7 +221,7 @@ func sizedSnapFSTest() {
createAndVerifyPVC(true)
By("Creating and deploying app pod", createDeployVerifyApp)
By("verifying LVMVolume object")
VerifyLVMVolume(false)
VerifyLVMVolume(false, "")
createSnapshot(pvcName, snapName, sizedsnapYAML)
verifySnapshotCreated(snapName)
deleteAppAndPvc(appNames, pvcName)
Expand All @@ -219,7 +235,7 @@ func sizedSnapBlockTest() {
createAndVerifyPVC(true)
By("Creating and deploying app pod", createDeployVerifyApp)
By("verifying LVMVolume object")
VerifyLVMVolume(false)
VerifyLVMVolume(false, "")
createSnapshot(pvcName, snapName, sizedsnapYAML)
verifySnapshotCreated(snapName)
deleteAppAndPvc(appNames, pvcName)
Expand Down Expand Up @@ -266,6 +282,7 @@ func volumeCreationTest() {
func schedulingTest() {
By("Running vg extend test", vgExtendTest)
By("Running vg not present test", vgNotPresentTest)
By("Running vg pattern test", vgPatternPresentTest)
}

func capacityTest() {
Expand Down
15 changes: 11 additions & 4 deletions tests/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,9 @@ func createThinStorageClass() {
}

// VerifyLVMVolume verify the properties of a lvm-volume
func VerifyLVMVolume(no_provision bool) {
// expected_vg is supposed to be passed only when vgpatten was used for scheduling.
// If its volgroup in sc then we can just match volgroup with lvmvolume's vg field.
func VerifyLVMVolume(no_provision bool, expected_vg string) {
ginkgo.By("fetching lvm volume")
vol_name := ""
if no_provision {
Expand All @@ -267,9 +269,14 @@ func VerifyLVMVolume(no_provision bool) {
}
} else {
gomega.Expect(err).To(gomega.BeNil(), "while fetching the lvm volume {%s}", pvcObj.Spec.VolumeName)
gomega.Expect(vol.Spec.VolGroup).To(gomega.Equal(scObj.Parameters["volgroup"]),
"while checking volume group of lvm volume", pvcObj.Spec.VolumeName)

if expected_vg != "" {
fmt.Printf("vol is %v\n", vol)
gomega.Expect(vol.Spec.VolGroup).To(gomega.Equal(expected_vg),
"while checking volume group of lvm volume", pvcObj.Spec.VolumeName)
} else {
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)
Expand Down

0 comments on commit e96148b

Please sign in to comment.