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 39790b4 commit 84c30e0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 13 deletions.
27 changes: 18 additions & 9 deletions tests/lvm_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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")
}

Expand Down
8 changes: 4 additions & 4 deletions tests/provision_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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")
}

0 comments on commit 84c30e0

Please sign in to comment.