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 Jul 1, 2024
1 parent e96148b commit 5ad36ef
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 56 deletions.
7 changes: 3 additions & 4 deletions tests/lvm_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,10 @@ func extendVg(name string, device string) {
gomega.Expect(err_vg).To(gomega.BeNil(), "vg extend failed")
}

// Does vhremove on specified vg with force flag,
// lv will be forcedeleted if vg is not empty.
// Does vgremove on specified vg with -y flag if vg isnt empty after fer retires.
func removeVg(name string) {
ginkgo.By("Removing vg")
retries := 5
retries := 3
current_retry := 0
force := false
for {
Expand All @@ -163,7 +162,6 @@ func removeVg(name string) {
fmt.Printf("lv in vg during retry %d\n", current_retry)
}
} else {
fmt.Printf("vg still not empty after 5 seconds, moving on with force delete\n")
force = true
break
}
Expand All @@ -176,6 +174,7 @@ func removeVg(name string) {
name,
}
if force {
fmt.Printf("vg still not empty after 6 seconds, moving on with force delete\n")
args_vg = append(args_vg, "-y")
}
_, _, err_vg := execAtLocal("sudo", nil, args_vg...)
Expand Down
129 changes: 80 additions & 49 deletions tests/provision_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ func fsVolCreationTest() {
for _, fstype := range fstypes {
By("####### Creating the storage class : " + fstype + " #######")
createFstypeStorageClass(fstype)
By("creating and verifying PVC bound status")
By("Creating and verifying PVC bound status")
createAndVerifyPVC(true)
By("Creating and deploying app pod", createDeployVerifyApp)
By("verifying LVMVolume object")
VerifyLVMVolume(false, "")
By("Verifying LVMVolume object to be Ready")
VerifyLVMVolume(true, "")

resizeAndVerifyPVC(true, "8Gi")
// do not resize after creating the snapshot(not supported)
Expand Down Expand Up @@ -88,16 +88,16 @@ func fsVolCreationTest() {

func blockVolCreationTest() {
By("Creating default storage class", createStorageClass)
By("creating and verifying PVC bound status")
By("Creating and verifying PVC bound status")
createAndVerifyBlockPVC(true)
By("Creating and deploying app pod", createDeployVerifyBlockApp)
By("verifying LVMVolume object")
VerifyLVMVolume(false, "")
By("Verifying LVMVolume object to be Ready")
VerifyLVMVolume(true, "")
By("Online resizing the block volume")
resizeAndVerifyPVC(true, "8Gi")
By("create snapshot")
By("Creating snapshot")
createSnapshot(pvcName, snapName, snapYAML)
By("verify snapshot")
By("Verifying snapshot")
verifySnapshotCreated(snapName)
deleteAppAndPvc(appNames, pvcName)
By("Verifying that PV exists after PVC deletion")
Expand All @@ -109,57 +109,75 @@ func blockVolCreationTest() {
By("Deleting storage class", deleteStorageClass)
}

func vgExtendTest() {
func vgExtendNeededForProvsioningTest() {
device_0 := setupVg(7, "lvmvgdiff")
device := setupVg(3, "lvmvg")
device_1 := createPV(4)
defer removePV(device_1)
defer cleanupVg(device_0, "lvmvgdiff")
defer cleanupVg(device, "lvmvg")
By("Creating default storage class", createStorageClass)
By("creating and verifying PVC bound status")
By("Creating and verifying PVC Not Bound status")
createAndVerifyBlockPVC(false)
By("verifying LVMVolume object")
VerifyLVMVolume(true, "")
device_1 := createPV(4)
By("Verifying LVMVolume object to be not Ready")
VerifyLVMVolume(false, "")
extendVg("lvmvg", device_1)
By("verifying PVC bound status after vg extend")
By("Verifying PVC bound status after vg extend")
VerifyBlockPVC()
By("verifying LVMVolume object")
VerifyLVMVolume(false, "")
By("Verifying LVMVolume object to be Ready after vg extend")
VerifyLVMVolume(true, "")
By("Deleting pvc")
deleteAndVerifyPVC(pvcName)
By("Verifying that PV exists after PVC deletion")
By("Verifying that PV doesnt exists after PVC deletion")
verifyPVForPVC(false, pvcName)
By("Deleting storage class", deleteStorageClass)
cleanupVg(device_0, "lvmvgdiff")
cleanupVg(device, "lvmvg")
removePV(device_1)
}

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

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

func vgNotPresentTest() {
func vgSpecifiedNotPresentTest() {
device := setupVg(40, "lvmvg")
defer cleanupVg(device, "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, "")
By("Verifying LVMVolume object to be Not Ready")
VerifyLVMVolume(false, "")
By("Deleting pvc")
deleteAndVerifyPVC(pvcName)
By("Verifying that PV doesnt exists after PVC deletion")
verifyPVForPVC(false, pvcName)
By("Deleting storage class", deleteStorageClass)
cleanupVg(device, "lvmvg")
}

func sharedVolumeTest() {
Expand All @@ -169,11 +187,13 @@ func sharedVolumeTest() {
//we use two fio app pods for this test.
appNames = append(appNames, "fio-ci-1")
By("Creating and deploying app pod", createDeployVerifyApp)
By("verifying LVMVolume object")
VerifyLVMVolume(false, "")
By("Verifying LVMVolume object to be Not Ready")
VerifyLVMVolume(true, "")
By("Online resizing the shared volume")
resizeAndVerifyPVC(true, "8Gi")
deleteAppAndPvc(appNames, pvcName)
By("Verifying that PV doesnt exists after PVC deletion")
verifyPVForPVC(false, pvcName)
By("Deleting storage class", deleteStorageClass)
// Reset the app list back to original
appNames = appNames[:len(appNames)-1]
Expand All @@ -185,7 +205,7 @@ func thinVolCreationTest() {
createAndVerifyPVC(true)
By("Creating and deploying app pod", createDeployVerifyApp)
By("verifying LVMVolume object")
VerifyLVMVolume(false, "")
VerifyLVMVolume(true, "")
By("Online resizing the block volume")
resizeAndVerifyPVC(true, "8Gi")
By("create snapshot")
Expand All @@ -210,8 +230,10 @@ func thinVolCapacityTest() {
By("Creating and deploying app pod", createDeployVerifyApp)
By("verifying thinpool auto-extended", VerifyThinpoolExtend)
By("verifying LVMVolume object")
VerifyLVMVolume(false, "")
VerifyLVMVolume(true, "")
deleteAppAndPvc(appNames, pvcName)
By("Verifying that PV doesnt exists after PVC deletion")
verifyPVForPVC(false, pvcName)
By("Deleting thinProvision storage class", deleteStorageClass)
}

Expand All @@ -221,11 +243,15 @@ func sizedSnapFSTest() {
createAndVerifyPVC(true)
By("Creating and deploying app pod", createDeployVerifyApp)
By("verifying LVMVolume object")
VerifyLVMVolume(false, "")
VerifyLVMVolume(true, "")
createSnapshot(pvcName, snapName, sizedsnapYAML)
verifySnapshotCreated(snapName)
deleteAppAndPvc(appNames, pvcName)
By("Verifying that PV exists before Snapshot deletion")
verifyPVForPVC(true, pvcName)
deleteSnapshot(pvcName, snapName, sizedsnapYAML)
By("Verifying that PV doesnt exists after Snapshot deletion")
verifyPVForPVC(false, pvcName)
By("Deleting storage class", deleteStorageClass)
}

Expand All @@ -235,11 +261,15 @@ func sizedSnapBlockTest() {
createAndVerifyPVC(true)
By("Creating and deploying app pod", createDeployVerifyApp)
By("verifying LVMVolume object")
VerifyLVMVolume(false, "")
VerifyLVMVolume(true, "")
createSnapshot(pvcName, snapName, sizedsnapYAML)
verifySnapshotCreated(snapName)
deleteAppAndPvc(appNames, pvcName)
By("Verifying that PV exists before Snapshot deletion")
verifyPVForPVC(true, pvcName)
deleteSnapshot(pvcName, snapName, sizedsnapYAML)
By("Verifying that PV doesnt exists after Snapshot deletion")
verifyPVForPVC(false, pvcName)
By("Deleting storage class", deleteStorageClass)
}

Expand Down Expand Up @@ -271,23 +301,24 @@ func leakProtectionTest() {

func volumeCreationTest() {
device := setupVg(40, "lvmvg")
By("Running filesystem volume creation test", fsVolCreationTest)
By("Running block volume creation test", blockVolCreationTest)
By("Running thin volume creation test", thinVolCreationTest)
By("Running leak protection test", leakProtectionTest)
By("Running shared volume for two app pods on same node test", sharedVolumeTest)
cleanupVg(device, "lvmvg")
defer cleanupVg(device, "lvmvg")
By("###Running filesystem volume creation test###", fsVolCreationTest)
By("###Running block volume creation test###", blockVolCreationTest)
By("###Running thin volume creation test###", thinVolCreationTest)
By("###Running leak protection test###", leakProtectionTest)
By("###Running shared volume for two app pods on same node test###", sharedVolumeTest)
}

func schedulingTest() {
By("Running vg extend test", vgExtendTest)
By("Running vg not present test", vgNotPresentTest)
By("Running vg pattern test", vgPatternPresentTest)
By("###Running vg extend needed to provision test###", vgExtendNeededForProvsioningTest)
By("###Running vg specified in sc not present test###", vgSpecifiedNotPresentTest)
By("###Running lvmnode has vg matching vgpattern test###", vgPatternMatchPresentTest)
By("###Running lvmnode doesnt have vg matching vgpattern test###", vgPatternNoMatchPresentTest)
}

func capacityTest() {
device := setupVg(40, "lvmvg")
By("Running thin volume capacity test", thinVolCapacityTest)
By("Running sized snapshot test", sizedSnapshotTest)
cleanupVg(device, "lvmvg")
defer cleanupVg(device, "lvmvg")
By("###Running thin volume capacity test###", thinVolCapacityTest)
By("###Running sized snapshot test###", sizedSnapshotTest)
}
6 changes: 3 additions & 3 deletions tests/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,18 +246,18 @@ func createThinStorageClass() {
// VerifyLVMVolume verify the properties of a lvm-volume
// 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) {
func VerifyLVMVolume(expect_ready bool, expected_vg string) {
ginkgo.By("fetching lvm volume")
vol_name := ""
if no_provision {
if !expect_ready {
vol_name = pvcObj.ObjectMeta.Annotations["local.csi.openebs.io/csi-volume-name"]
} else {
vol_name = pvcObj.Spec.VolumeName
}
vol, err := LVMClient.WithNamespace(OpenEBSNamespace).
Get(vol_name, metav1.GetOptions{})

if no_provision {
if !expect_ready {
if vol != nil && vol.ObjectMeta.Name == vol_name {
// Even if scheduler cant find the vg for scheduling it creates lvmvolume cr anyway,
// It gets deleted, by the csi provisioner only when the owner node of cr marks is
Expand Down

0 comments on commit 5ad36ef

Please sign in to comment.