Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: refactor lvm tests and add lvm tests to lvm testplan #69

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions common/k8stest/util_fio_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,10 @@ func (dfa *FioApplication) DeployFio(fioArgsSet common.FioAppArgsSet, podPrefix
func (dfa *FioApplication) CreateVolume() error {
var err error

if dfa.status.createdPVC || dfa.status.importedVolume {
return nil
}

decoration := dfa.OpenEbsEngine.String()

if dfa.VolType.String() == "" {
Expand Down
2 changes: 1 addition & 1 deletion common/lvm/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func SetupLvmNodes(vgName string, size int64) (LvmNodesDevicePvVgConfig, error)
if strings.Contains(workerNodes[0], "kind-") {
imgDir = "/host/host/mnt"
} else {
imgDir = "/tmp"
imgDir = "/mnt"
}

loopDevice := e2e_agent.LoopDevice{
Expand Down
2 changes: 1 addition & 1 deletion common/zfs/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func SetupZfsNodes(poolName string, size int64) (ZfsNodesDevicePoolConfig, error
if strings.Contains(workerNodes[0], "kind-") {
imgDir = "/host/host/mnt"
} else {
imgDir = "/tmp"
imgDir = "/mnt"
}
loopDevice := e2e_agent.LoopDevice{
Size: size,
Expand Down
128 changes: 68 additions & 60 deletions src/tests/lvm/common/util_resize.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package common

import (
"fmt"
"time"

"github.com/openebs/openebs-e2e/common/e2e_agent"
"github.com/openebs/openebs-e2e/common/lvm"
"github.com/openebs/openebs-e2e/common/mayastor/volume_resize"

"github.com/openebs/openebs-e2e/common"
Expand All @@ -15,85 +15,85 @@ import (
logf "sigs.k8s.io/controller-runtime/pkg/log"
)

var NodeConfig lvm.LvmNodesDevicePvVgConfig
var ResizeApp k8stest.FioApplication
var ResizeApp2 k8stest.FioApplication
var defFioCompletionTime = 240 // in seconds
var ThinPoolNode string

func LvmVolumeResizeTest(decor string, engine common.OpenEbsEngine, volType common.VolumeType, fstype common.FileSystemType, volBindModeWait bool, thinProvisioned common.YesNoVal) {
func LvmVolumeResizeTest(decor string, engine common.OpenEbsEngine, vgName string, volType common.VolumeType, fstype common.FileSystemType, volBindModeWait bool, thinProvisioned common.YesNoVal) {

var ftSize1, ftSize2 uint64
app := k8stest.FioApplication{
Decor: decor,
VolSizeMb: 4096,
OpenEbsEngine: engine,
VolType: volType,
FsType: fstype,
Loops: 5,
VolWaitForFirstConsumer: volBindModeWait,
SkipPvcVerificationAfterCreate: true,
// after fio completes sleep of a long time
PostOpSleep: 600000,
}

loopDevice := e2e_agent.LoopDevice{
Size: 10737418240,
ImgDir: "/tmp",
// setup sc parameters
lvmScOptions := k8stest.LvmOptions{
VolGroup: vgName,
Storage: "lvm",
ThinProvision: thinProvisioned,
}

workerNodes, err := lvm.ListLvmNode(common.NSOpenEBS())
Expect(err).ToNot(HaveOccurred(), "failed to list worker node")

NodeConfig = lvm.LvmNodesDevicePvVgConfig{
VgName: "lvmvg",
NodeDeviceMap: make(map[string]e2e_agent.LoopDevice), // Properly initialize the map
}
for _, node := range workerNodes {
NodeConfig.NodeDeviceMap[node] = loopDevice
ResizeApp = k8stest.FioApplication{
Decor: decor,
VolSizeMb: 1024,
OpenEbsEngine: engine,
VolType: volType,
FsType: fstype,
Loops: 3,
VolWaitForFirstConsumer: volBindModeWait,
Lvm: lvmScOptions,
// after fio completes sleep of a long time
PostOpSleep: 600000,
AllowVolumeExpansion: common.AllowVolumeExpansionEnable,
}

logf.Log.Info("setup node with loop device, pv and vg", "node config", NodeConfig)
err = NodeConfig.ConfigureLvmNodesWithDeviceAndVg()
Expect(err).ToNot(HaveOccurred(), "failed to setup node")

// setup sc parameters
app.Lvm = k8stest.LvmOptions{
VolGroup: NodeConfig.VgName,
Storage: "lvm",
ThinProvision: thinProvisioned,
if ResizeApp.FsType == common.BtrfsFsType {
ResizeApp.FsPercent = 60
}

logf.Log.Info("create sc, pvc, fio pod")
err = app.DeployApplication()
err := ResizeApp.DeployApplication()
Expect(err).To(BeNil(), "failed to deploy app")

var node string
if thinProvisioned == common.Yes {
node, err = k8stest.GetNodeNameForScheduledPod(ResizeApp.GetPodName(), common.NSDefault)
Expect(err).To(BeNil(), "failed to get node name for %s app", ResizeApp.GetPodName())
nodeIp, err := k8stest.GetNodeIPAddress(node)
Expect(err).To(BeNil(), "failed to get node %s ip", node)
ThinPoolNode = *nodeIp
logf.Log.Info("App node", "name", node, "IP", ThinPoolNode)
out, err := e2e_agent.LvmLvChangeMonitor(ThinPoolNode, vgName)
Expect(err).To(BeNil(), "failed to set up lv change monitor on node %s with vg %s, output: %s", node, vgName, out)
}

// sleep for 30 seconds before resizing volume
logf.Log.Info("Sleep before resizing volume", "duration", volume_resize.DefSleepTime)
time.Sleep(time.Duration(volume_resize.DefSleepTime) * time.Second)

expandedVolumeSizeMb := app.VolSizeMb + 1024
expandedVolumeSizeMb := ResizeApp.VolSizeMb + 1024
// expand volume by editing pvc size
logf.Log.Info("Update volume size", "new size in MiB", expandedVolumeSizeMb)
_, err = k8stest.UpdatePvcSize(app.GetPvcName(), common.NSDefault, expandedVolumeSizeMb)
Expect(err).ToNot(HaveOccurred(), "failed to expand volume %s, error: %v", app.GetPvcName(), err)
_, err = k8stest.UpdatePvcSize(ResizeApp.GetPvcName(), common.NSDefault, expandedVolumeSizeMb)
Expect(err).ToNot(HaveOccurred(), "failed to expand volume %s, error: %v", ResizeApp.GetPvcName(), err)

// verify pvc capacity to new size
logf.Log.Info("Verify pvc resize status")
pvcResizeStatus, err := volume_resize.WaitForPvcResize(app.GetPvcName(), common.NSDefault, expandedVolumeSizeMb)
Expect(err).ToNot(HaveOccurred(), "failed to verify resized pvc %s, error: %v", app.GetPvcName(), err)
Expect(pvcResizeStatus).To(BeTrue(), "failed to resized pvc %s, error: %v", app.GetPvcName(), err)
pvcResizeStatus, err := volume_resize.WaitForPvcResize(ResizeApp.GetPvcName(), common.NSDefault, expandedVolumeSizeMb)
Expect(err).ToNot(HaveOccurred(), "failed to verify resized pvc %s, error: %v", ResizeApp.GetPvcName(), err)
Expect(pvcResizeStatus).To(BeTrue(), "failed to resized pvc %s, error: %v", ResizeApp.GetPvcName(), err)

// Check fio pod status
logf.Log.Info("Check fio pod status")
phase, _, err := k8stest.CheckFioPodCompleted(app.GetPodName(), common.NSDefault)
phase, _, err := k8stest.CheckFioPodCompleted(ResizeApp.GetPodName(), common.NSDefault)
Expect(err).To(BeNil(), "CheckPodComplete got error %s", err)
Expect(phase).ShouldNot(Equal(coreV1.PodFailed), "fio pod phase is %s", phase)

// wait for fio completion - monitoring log output
exitValue, fErr := app.WaitFioComplete(volume_resize.DefFioCompletionTime, 5)
exitValue, fErr := ResizeApp.WaitFioComplete(volume_resize.DefFioCompletionTime, 5)
Expect(fErr).ToNot(HaveOccurred())
logf.Log.Info("fio complete", "exit value", exitValue)
Expect(exitValue == 0).Should(BeTrue(), "fio exit value is not 0")

// print fio target sizes retrieved by monitoring log output
ftSizes, ffErr := app.FioTargetSizes()
ftSizes, ffErr := ResizeApp.FioTargetSizes()
Expect(ffErr).ToNot(HaveOccurred())
for path, size := range ftSizes {
logf.Log.Info("ftSize (poc_resize_1)", "path", path, "size", volume_resize.ByteSizeString(size), "bytes", size)
Expand All @@ -102,23 +102,26 @@ func LvmVolumeResizeTest(decor string, engine common.OpenEbsEngine, volType comm
Expect(len(ftSizes)).To(BeNumerically("==", 1), "unexpected fio target sizes")

// second instance of e2e-fio, volume parameters should be the same as the 1st app instance
app2 := app
app2.Decor = app.Decor + "second-app"
ResizeApp2 = k8stest.FioApplication{
Decor: fmt.Sprintf("%s-2", ResizeApp.Decor),
Loops: 2,
FsPercent: ResizeApp.FsPercent,
}

// Before deploying the 2nd app instance - "import" the volume
// from the first app
err = app2.ImportVolumeFromApp(&app)
// Before deploying the 2nd app instance - "import" the volume from the first app
err = ResizeApp2.ImportVolumeFromApp(&ResizeApp)
Expect(err).ToNot(HaveOccurred(), "import volume failed")
// then deploy
err = app2.DeployApplication()

// then deploy second fio app to use resized volume
err = ResizeApp2.DeployApplication()
Expect(err).ToNot(HaveOccurred(), "deploy 2nd app failed")

exitValue, fErr = app2.WaitFioComplete(volume_resize.DefFioCompletionTime, 5)
exitValue, fErr = ResizeApp2.WaitFioComplete(volume_resize.DefFioCompletionTime, 5)
Expect(fErr).ToNot(HaveOccurred())
logf.Log.Info("fio complete", "exit value", exitValue)
Expect(exitValue == 0).Should(BeTrue(), "fio exit value is not 0")

ftSizes, ffErr = app2.FioTargetSizes()
ftSizes, ffErr = ResizeApp2.FioTargetSizes()
Expect(ffErr).ToNot(HaveOccurred())
for path, size := range ftSizes {
logf.Log.Info("ftSize (poc_resize_2)", "path", path, "size", volume_resize.ByteSizeString(size), "bytes", size)
Expand All @@ -131,15 +134,20 @@ func LvmVolumeResizeTest(decor string, engine common.OpenEbsEngine, volType comm
Expect(ftSize2).To(BeNumerically(">", ftSize1))

// second app should complete normally
err = app2.WaitComplete(volume_resize.DefFioCompletionTime)
Expect(err).ToNot(HaveOccurred(), "app2 did not complete")
err = ResizeApp2.WaitComplete(defFioCompletionTime)
Expect(err).ToNot(HaveOccurred(), "ResizeApp2 did not complete")

// cleanup the second instance of e2e-fio app
err = app2.Cleanup()
err = ResizeApp2.Cleanup()
Expect(err).ToNot(HaveOccurred(), "app2 cleanup failed")

// cleanup the first instance of e2e-fio app
err = app.Cleanup()
err = ResizeApp.Cleanup()
Expect(err).ToNot(HaveOccurred(), "app1 cleanup failed")

if thinProvisioned == common.Yes {
out, err := e2e_agent.LvmLvRemoveThinPool(ThinPoolNode, vgName)
Expect(err).To(BeNil(), "failed to remove lv thin pool on node %s with vg %s, output: %s", node, vgName, out)
ThinPoolNode = ""
}
}
46 changes: 46 additions & 0 deletions src/tests/lvm/common/util_snapshot.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package common

import (
"fmt"

"github.com/openebs/openebs-e2e/common/k8stest"
"github.com/openebs/openebs-e2e/common/mayastor/snapshot"

logf "sigs.k8s.io/controller-runtime/pkg/log"
)

// LvmVolumeSnapshotVerify verify snapshot and content to be ready
// it also verify that snapshot and content restore size should be zero
func LvmVolumeSnapshotVerify(snapshotName, snapshotContentName, namespace string, skipSnapError bool) (bool, error) {

logf.Log.Info("Verify lvm snapshot content ready status")
contentReady, err := snapshot.WaitForSnapshotContentReadyStatus(snapshotContentName, skipSnapError)
if err != nil {
return contentReady, err
} else if !contentReady {
logf.Log.Info("Snapshot content not ready", "VolumeSnapshotContent.status.readyToUse", contentReady)
return contentReady, err
}
logf.Log.Info("Verify snapshot ready status")
snapshotReady, err := snapshot.WaitForSnapshotReadyStatus(snapshotName, namespace, skipSnapError)
if err != nil {
return snapshotReady, err
} else if !snapshotReady {
logf.Log.Info("Snapshot not ready", "VolumeSnapshot.status.readyToUse", snapshotReady)
return snapshotReady, err
}

logf.Log.Info("Verify snapshot restore size is zero")
restoreSize, err := k8stest.GetSnapshotRestoreSize(snapshotName, namespace)
if err != nil {
return false, err
}

restoreSizeInt, conversionStatus := restoreSize.AsInt64()
if !conversionStatus {
return false, fmt.Errorf("failed to convert snapshot restore size into int:, restore size: %v", restoreSize)
} else if restoreSizeInt != 0 {
return false, fmt.Errorf("snapshot restore size is not 0")
}
return true, nil
}
Loading