From 84c30e0a66fa3f562c0a3821632890d113b8e2ae Mon Sep 17 00:00:00 2001 From: Abhilash Shetty Date: Fri, 28 Jun 2024 06:43:37 +0000 Subject: [PATCH] test(ci): adding volgroup test Signed-off-by: Abhilash Shetty --- tests/lvm_utils.go | 27 ++++++++++++++++++--------- tests/provision_test.go | 8 ++++---- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/tests/lvm_utils.go b/tests/lvm_utils.go index 18a72f8c..bf385e1a 100644 --- a/tests/lvm_utils.go +++ b/tests/lvm_utils.go @@ -32,45 +32,50 @@ func createPV(size int) string { ginkgo.By("Creating Pv") back_file_args := []string{ + "mktemp", "-t", "openebs_lvm_localpv_disk_XXXXX", "--dry-run", } - file, _, _ := execAtLocal("mktemp", nil, back_file_args...) + file, _, _ := execAtLocal("sudo", nil, back_file_args...) file_str := strings.TrimSpace(string(file[:])) size_str := strconv.Itoa(size) + "G" device_args := []string{ + "truncate", "-s", size_str, file_str, } - _, _, err := execAtLocal("truncate", nil, device_args...) + _, _, err := execAtLocal("sudo", nil, device_args...) gomega.Expect(err).ShouldNot(gomega.HaveOccurred(), "create device failed") args_loop := []string{ + "losetup", "-f", file_str, "--show", } - stdout_loop, _, err := execAtLocal("losetup", nil, args_loop...) + stdout_loop, _, err := execAtLocal("sudo", nil, args_loop...) gomega.Expect(err).To(gomega.BeNil(), "loop device create failed") stdout_loop_str := strings.TrimSpace(string(stdout_loop[:])) args_pv := []string{ + "pvcreate", stdout_loop_str, } - _, _, err_pv := execAtLocal("pvcreate", nil, args_pv...) + _, _, err_pv := execAtLocal("sudo", nil, args_pv...) gomega.Expect(err_pv).To(gomega.BeNil(), "pv create failed") return stdout_loop_str } func vgEmpty(name string) bool { args_lvs := []string{ + "vgs", name, "--options", "lv_count", "--noheadings", } - lvs, _, _ := execAtLocal("vgs", nil, args_lvs...) + lvs, _, _ := execAtLocal("sudo", nil, args_lvs...) lvs_str := strings.TrimSpace(string(lvs)) lv_cnt, _ := strconv.Atoi(lvs_str) fmt.Printf("lvs cnt is %d\n", lv_cnt) @@ -85,33 +90,37 @@ func vgEmpty(name string) bool { func removePV(device string) { ginkgo.By("remove pv") args_pv := []string{ + "pvremove", device, "-y", } - _, _, err_pv := execAtLocal("pvremove", nil, args_pv...) + _, _, err_pv := execAtLocal("sudo", nil, args_pv...) gomega.Expect(err_pv).To(gomega.BeNil(), "pv remove failed") args_lo := []string{ + "losetup", device, "-O", "BACK-FILE", "--noheadings", } - dev, _, _ := execAtLocal("losetup", nil, args_lo...) + dev, _, _ := execAtLocal("sudo", nil, args_lo...) dev_str := strings.TrimSpace(string(dev)) args_loop := []string{ + "losetup", "-d", device, } - _, _, err_loop := execAtLocal("losetup", nil, args_loop...) + _, _, err_loop := execAtLocal("sudo", nil, args_loop...) gomega.Expect(err_loop).To(gomega.BeNil(), "loop device remove failed") args_file := []string{ + "rm", "-f", dev_str, } - _, _, err_file := execAtLocal("rm", nil, args_file...) + _, _, err_file := execAtLocal("sudo", nil, args_file...) gomega.Expect(err_file).To(gomega.BeNil(), "file remove failed") } diff --git a/tests/provision_test.go b/tests/provision_test.go index 356531c0..26ec43b6 100644 --- a/tests/provision_test.go +++ b/tests/provision_test.go @@ -254,13 +254,13 @@ func leakProtectionTest() { } func volumeCreationTest() { - /*device := setupVg(40, "lvmvg") + 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")*/ + cleanupVg(device, "lvmvg") } func schedulingTest() { @@ -269,8 +269,8 @@ func schedulingTest() { } func capacityTest() { - /*device := setupVg(40, "lvmvg") + device := setupVg(40, "lvmvg") By("Running thin volume capacity test", thinVolCapacityTest) By("Running sized snapshot test", sizedSnapshotTest) - cleanupVg(device, "lvmvg")*/ + cleanupVg(device, "lvmvg") }