diff --git a/tests/lvm_utils.go b/tests/lvm_utils.go index 39f7c961..bc029d5f 100644 --- a/tests/lvm_utils.go +++ b/tests/lvm_utils.go @@ -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{ @@ -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", @@ -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, @@ -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") diff --git a/tests/provision_test.go b/tests/provision_test.go index 8affe013..1bedff6f 100644 --- a/tests/provision_test.go +++ b/tests/provision_test.go @@ -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) } @@ -240,14 +240,14 @@ 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() { @@ -255,8 +255,8 @@ func lvmOpsTest() { } 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) } diff --git a/tests/utils.go b/tests/utils.go index e0db0c63..6fa28fe6 100644 --- a/tests/utils.go +++ b/tests/utils.go @@ -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")