Skip to content

Commit

Permalink
test(ci): adding volgroup tests
Browse files Browse the repository at this point in the history
Signed-off-by: Abhilash Shetty <[email protected]>
  • Loading branch information
abhilashshetty04 committed Jun 27, 2024
1 parent a3423ad commit eb55b79
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 19 deletions.
36 changes: 24 additions & 12 deletions tests/lvm_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
// This creates loopdevice using the size passed as arg,
// Uses the new loop device to create PV. returns loopdevice name to the caller.
func createPV(size int) string {
time.Sleep(2 * time.Second)
ginkgo.By("Creating Pv")

back_file_args := []string{
Expand Down Expand Up @@ -86,7 +85,6 @@ func vgEmpty(name string) bool {

// Does pvremove on specified device. Deletes loop device and the file backing loop device.
func removePV(device string) {
time.Sleep(2 * time.Second)
ginkgo.By("remove pv")
args_pv := []string{
"pvremove",
Expand Down Expand Up @@ -124,7 +122,6 @@ func removePV(device string) {

// Creates vg on the specified device, Device passed should be a pv.
func createVg(name string, device string) {
time.Sleep(2 * time.Second)
ginkgo.By("Creating vg")
args_vg := []string{
"vgcreate", name,
Expand All @@ -148,19 +145,34 @@ func extendVg(name string, device string) {
// Does vhremove on specified vg with force flag,
// lv will be forcedeleted if vg is not empty.
func removeVg(name string) {
vg_empty := vgEmpty(name)
if vg_empty{
fmt.Printf("No lv in vg before vg remove\n")
} else {
fmt.Printf("lv in vg before vg remove\n")
}
time.Sleep(2 * time.Second)
ginkgo.By("Removing vg")
retries := 5
current_retry := 0
force := false
for {
if current_retry < retries {
vg_empty := vgEmpty(name)
if vg_empty {
fmt.Printf("No lv in vg before vg remove\n")
break
} else {
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
}
current_retry += 1
time.Sleep(2 * time.Second)
}

args_vg := []string{
"vgremove",
name,
"-f",
"-y",
}
if force {
args_vg = append(args_vg, "-y")
}
_, _, err_vg := execAtLocal("sudo", nil, args_vg...)
gomega.Expect(err_vg).To(gomega.BeNil(), "vg remove failed")
Expand Down
12 changes: 6 additions & 6 deletions tests/provision_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ func deleteAppAndPvc(appnames []string, pvcname string) {
deleteAndVerifyPVC(pvcName)
}

func setup(size int) string {
func setupVg(size int) string {
device := createPV(size)
createVg("lvmvg", device)
return device
}

func cleanup(device string) {
func cleanupVg(device string) {
removeVg("lvmvg")
removePV(device)
}
Expand Down Expand Up @@ -240,23 +240,23 @@ func lvmOps() {
}

func volumeCreationTest() {
device := setup(40)
device := setupVg(40)
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)
By("Running vg not present test", vgNotPresentTest)
cleanup(device)
cleanupVg(device)
}

func lvmOpsTest() {
By("Running Lvm Ops", lvmOps)
}

func capacityTest() {
device := setup(40)
device := setupVg(40)
By("Running thin volume capacity test", thinVolCapacityTest)
By("Running sized snapshot test", sizedSnapshotTest)
cleanup(device)
cleanupVg(device)
}
2 changes: 1 addition & 1 deletion tests/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ func createAndVerifyPVC(expect_bound bool) {
)

ginkgo.By("verifying pvc status as bound\n")
ok := IsPVCBoundEventually(pvcName, 15, 3)
ok := IsPVCBoundEventually(pvcName, 30, 3)

gomega.Expect(ok).To(gomega.Equal(expect_bound),
"while checking status equal to Not Bound")
Expand Down

0 comments on commit eb55b79

Please sign in to comment.