e2e: update listRBDImages to list images in different pool

made pool as a argument of listRBDImages to support
listing of rbd images in different pools.

Co-authored-by: Madhu Rajanna <madhupr007@gmail.com>
Signed-off-by: Yug <yuggupta27@gmail.com>
This commit is contained in:
Yug 2021-03-19 14:39:28 +05:30 committed by mergify[bot]
parent d992803e9e
commit e302797217
3 changed files with 64 additions and 64 deletions

View File

@ -142,8 +142,8 @@ func createORDeleteRbdResouces(action string) {
}
}
func validateRBDImageCount(f *framework.Framework, count int) {
imageList, err := listRBDImages(f)
func validateRBDImageCount(f *framework.Framework, count int, pool string) {
imageList, err := listRBDImages(f, pool)
if err != nil {
e2elog.Failf("failed to list rbd images with error %v", err)
}
@ -304,7 +304,7 @@ var _ = Describe("RBD", func() {
e2elog.Failf("failed to validate owner of pvc with error %v", err)
}
// validate created backend rbd images
validateRBDImageCount(f, 0)
validateRBDImageCount(f, 0, defaultRBDPool)
})
By("create a PVC and bind it to an app", func() {
@ -313,7 +313,7 @@ var _ = Describe("RBD", func() {
e2elog.Failf("failed to validate pvc and application binding with error %v", err)
}
// validate created backend rbd images
validateRBDImageCount(f, 0)
validateRBDImageCount(f, 0, defaultRBDPool)
})
By("create a PVC and bind it to an app with normal user", func() {
@ -322,7 +322,7 @@ var _ = Describe("RBD", func() {
e2elog.Failf("failed to validate normal user pvc and application binding with error %v", err)
}
// validate created backend rbd images
validateRBDImageCount(f, 0)
validateRBDImageCount(f, 0, defaultRBDPool)
})
By("create a PVC and bind it to an app with ext4 as the FS ", func() {
@ -339,7 +339,7 @@ var _ = Describe("RBD", func() {
e2elog.Failf("failed to validate pvc and application binding with error %v", err)
}
// validate created backend rbd images
validateRBDImageCount(f, 0)
validateRBDImageCount(f, 0, defaultRBDPool)
err = deleteResource(rbdExamplePath + "storageclass.yaml")
if err != nil {
e2elog.Failf("failed to delete storageclass with error %v", err)
@ -364,7 +364,7 @@ var _ = Describe("RBD", func() {
e2elog.Failf("failed to validate pvc and application binding with error %v", err)
}
// validate created backend rbd images
validateRBDImageCount(f, 0)
validateRBDImageCount(f, 0, defaultRBDPool)
err = deleteResource(rbdExamplePath + "storageclass.yaml")
if err != nil {
e2elog.Failf("failed to delete storageclass with error %v", err)
@ -408,7 +408,7 @@ var _ = Describe("RBD", func() {
}
// validate created backend rbd images
validateRBDImageCount(f, 1)
validateRBDImageCount(f, 1, defaultRBDPool)
selector, err := getDaemonSetLabelSelector(f, cephCSINamespace, rbdDaemonsetName)
if err != nil {
@ -450,7 +450,7 @@ var _ = Describe("RBD", func() {
e2elog.Failf("failed to delete PVC and application with error %v", err)
}
// validate created backend rbd images
validateRBDImageCount(f, 0)
validateRBDImageCount(f, 0, defaultRBDPool)
err = deleteResource(rbdExamplePath + "storageclass.yaml")
if err != nil {
e2elog.Failf("failed to delete storageclass with error %v", err)
@ -497,7 +497,7 @@ var _ = Describe("RBD", func() {
e2elog.Failf("failed to create PVC and application with error %v", err)
}
// validate created backend rbd images
validateRBDImageCount(f, 1)
validateRBDImageCount(f, 1, defaultRBDPool)
selector, err := getDaemonSetLabelSelector(f, cephCSINamespace, rbdDaemonsetName)
if err != nil {
@ -583,7 +583,7 @@ var _ = Describe("RBD", func() {
e2elog.Failf("failed to delete PVC and application with error %v", err)
}
// validate created backend rbd images
validateRBDImageCount(f, 0)
validateRBDImageCount(f, 0, defaultRBDPool)
err = deleteResource(rbdExamplePath + "storageclass.yaml")
if err != nil {
e2elog.Failf("failed to delete storageclass with error %v", err)
@ -608,7 +608,7 @@ var _ = Describe("RBD", func() {
e2elog.Failf("failed to validate encrypted pvc with error %v", err)
}
// validate created backend rbd images
validateRBDImageCount(f, 0)
validateRBDImageCount(f, 0, defaultRBDPool)
err = deleteResource(rbdExamplePath + "storageclass.yaml")
if err != nil {
e2elog.Failf("failed to delete storageclass with error %v", err)
@ -637,7 +637,7 @@ var _ = Describe("RBD", func() {
e2elog.Failf("failed to validate encrypted pvc with error %v", err)
}
// validate created backend rbd images
validateRBDImageCount(f, 0)
validateRBDImageCount(f, 0, defaultRBDPool)
err = deleteResource(rbdExamplePath + "storageclass.yaml")
if err != nil {
e2elog.Failf("failed to delete storageclass with error %v", err)
@ -680,7 +680,7 @@ var _ = Describe("RBD", func() {
e2elog.Failf("failed to validate encrypted pvc with error %v", err)
}
// validate created backend rbd images
validateRBDImageCount(f, 0)
validateRBDImageCount(f, 0, defaultRBDPool)
// delete the Secret of the Tenant
err = c.CoreV1().Secrets(tenant).Delete(context.TODO(), token.Name, metav1.DeleteOptions{})
@ -716,7 +716,7 @@ var _ = Describe("RBD", func() {
e2elog.Failf("failed to validate encrypted pvc with error %v", err)
}
// validate created backend rbd images
validateRBDImageCount(f, 0)
validateRBDImageCount(f, 0, defaultRBDPool)
err = deleteResource(rbdExamplePath + "storageclass.yaml")
if err != nil {
e2elog.Failf("failed to delete storageclass with error %v", err)
@ -863,7 +863,7 @@ var _ = Describe("RBD", func() {
}
// validate created backend rbd images
validateRBDImageCount(f, totalCount)
validateRBDImageCount(f, totalCount, defaultRBDPool)
// delete PVC and app
for i := 0; i < totalCount; i++ {
name := fmt.Sprintf("%s%d", f.UniqueName, i)
@ -875,7 +875,7 @@ var _ = Describe("RBD", func() {
}
// validate created backend rbd images
validateRBDImageCount(f, 0)
validateRBDImageCount(f, 0, defaultRBDPool)
})
By("check data persist after recreating pod", func() {
@ -884,7 +884,7 @@ var _ = Describe("RBD", func() {
e2elog.Failf("failed to check data persist with error %v", err)
}
// validate created backend rbd images
validateRBDImageCount(f, 0)
validateRBDImageCount(f, 0, defaultRBDPool)
})
By("Resize Filesystem PVC and check application directory size", func() {
@ -909,7 +909,7 @@ var _ = Describe("RBD", func() {
}
// validate created backend rbd images
validateRBDImageCount(f, 0)
validateRBDImageCount(f, 0, defaultRBDPool)
}
})
@ -921,7 +921,7 @@ var _ = Describe("RBD", func() {
e2elog.Failf("failed to resize block PVC with error %v", err)
}
// validate created backend rbd images
validateRBDImageCount(f, 0)
validateRBDImageCount(f, 0, defaultRBDPool)
}
})
@ -943,7 +943,7 @@ var _ = Describe("RBD", func() {
}
// validate created backend rbd images
validateRBDImageCount(f, 1)
validateRBDImageCount(f, 1, defaultRBDPool)
// delete rbd nodeplugin pods
err = deletePodWithLabel("app=csi-rbdplugin", cephCSINamespace, false)
if err != nil {
@ -960,7 +960,7 @@ var _ = Describe("RBD", func() {
e2elog.Failf("failed to delete PVC and application with error %v", err)
}
// validate created backend rbd images
validateRBDImageCount(f, 0)
validateRBDImageCount(f, 0, defaultRBDPool)
})
By("create PVC in storageClass with volumeNamePrefix", func() {
@ -985,10 +985,10 @@ var _ = Describe("RBD", func() {
}
// validate created backend rbd images
validateRBDImageCount(f, 1)
validateRBDImageCount(f, 1, defaultRBDPool)
// list RBD images and check if one of them has the same prefix
foundIt := false
images, err := listRBDImages(f)
images, err := listRBDImages(f, defaultRBDPool)
if err != nil {
e2elog.Failf("failed to list rbd images with error %v", err)
}
@ -1006,7 +1006,7 @@ var _ = Describe("RBD", func() {
e2elog.Failf("failed to delete PVC with error %v", err)
}
// validate created backend rbd images
validateRBDImageCount(f, 0)
validateRBDImageCount(f, 0, defaultRBDPool)
err = deleteResource(rbdExamplePath + "storageclass.yaml")
if err != nil {
@ -1027,7 +1027,7 @@ var _ = Describe("RBD", func() {
e2elog.Failf("failed to validate rbd static pv with error %v", err)
}
// validate created backend rbd images
validateRBDImageCount(f, 0)
validateRBDImageCount(f, 0, defaultRBDPool)
})
By("validate RBD static Block PVC", func() {
@ -1036,7 +1036,7 @@ var _ = Describe("RBD", func() {
e2elog.Failf("failed to validate rbd block pv with error %v", err)
}
// validate created backend rbd images
validateRBDImageCount(f, 0)
validateRBDImageCount(f, 0, defaultRBDPool)
})
By("validate mount options in app pod", func() {
@ -1046,7 +1046,7 @@ var _ = Describe("RBD", func() {
e2elog.Failf("failed to check mount options with error %v", err)
}
// validate created backend rbd images
validateRBDImageCount(f, 0)
validateRBDImageCount(f, 0, defaultRBDPool)
})
By("creating an app with a PVC, using a topology constrained StorageClass", func() {
@ -1187,7 +1187,7 @@ var _ = Describe("RBD", func() {
e2elog.Failf("failed to create PVC with error %v", err)
}
// validate created backend rbd images
validateRBDImageCount(f, 1)
validateRBDImageCount(f, 1, defaultRBDPool)
// create an app and wait for 1 min for it to go to running state
err = createApp(f.ClientSet, app, 1)
@ -1200,7 +1200,7 @@ var _ = Describe("RBD", func() {
}
// validate created backend rbd images
validateRBDImageCount(f, 0)
validateRBDImageCount(f, 0, defaultRBDPool)
err = deleteResource(rbdExamplePath + "storageclass.yaml")
if err != nil {
e2elog.Failf("failed to delete storageclass with error %v", err)
@ -1242,7 +1242,7 @@ var _ = Describe("RBD", func() {
e2elog.Failf("failed to create PVC and application with error %v", err)
}
// validate created backend rbd images
validateRBDImageCount(f, 1)
validateRBDImageCount(f, 1, defaultRBDPool)
// delete pod as we should not create snapshot for in-use pvc
err = deletePod(app.Name, app.Namespace, f.ClientSet, deployTimeout)
if err != nil {
@ -1260,7 +1260,7 @@ var _ = Describe("RBD", func() {
// validate created backend rbd images
// parent PVC + snapshot
totalImages := 2
validateRBDImageCount(f, totalImages)
validateRBDImageCount(f, totalImages, defaultRBDPool)
pvcClone, err := loadPVC(pvcClonePath)
if err != nil {
e2elog.Failf("failed to load PVC with error %v", err)
@ -1276,7 +1276,7 @@ var _ = Describe("RBD", func() {
// validate created backend rbd images
// parent pvc+ snapshot + clone
totalImages = 3
validateRBDImageCount(f, totalImages)
validateRBDImageCount(f, totalImages, defaultRBDPool)
appClone, err := loadApp(appClonePath)
if err != nil {
@ -1340,7 +1340,7 @@ var _ = Describe("RBD", func() {
e2elog.Failf("failed to delete PVC with error %v", err)
}
// validate created backend rbd images
validateRBDImageCount(f, 0)
validateRBDImageCount(f, 0, defaultRBDPool)
}
})
@ -1377,7 +1377,7 @@ var _ = Describe("RBD", func() {
e2elog.Failf("failed to create PVC and application with error %v", err)
}
// validate created backend rbd images
validateRBDImageCount(f, 1)
validateRBDImageCount(f, 1, defaultRBDPool)
snap := getSnapshot(snapshotPath)
snap.Namespace = f.UniqueName
@ -1390,7 +1390,7 @@ var _ = Describe("RBD", func() {
// validate created backend rbd images
// parent PVC + snapshot
totalImages := 2
validateRBDImageCount(f, totalImages)
validateRBDImageCount(f, totalImages, defaultRBDPool)
pvcClone, err := loadPVC(pvcClonePath)
if err != nil {
e2elog.Failf("failed to load PVC with error %v", err)
@ -1402,7 +1402,7 @@ var _ = Describe("RBD", func() {
e2elog.Failf("failed to delete PVC and application with error %v", err)
}
// validate created backend rbd images
validateRBDImageCount(f, 1)
validateRBDImageCount(f, 1, defaultRBDPool)
// create clone PVC
pvcClone.Namespace = f.UniqueName
@ -1412,7 +1412,7 @@ var _ = Describe("RBD", func() {
}
// validate created backend rbd images = snapshot + clone
totalImages = 2
validateRBDImageCount(f, totalImages)
validateRBDImageCount(f, totalImages, defaultRBDPool)
// delete snapshot
err = deleteSnapshot(&snap, deployTimeout)
@ -1422,7 +1422,7 @@ var _ = Describe("RBD", func() {
// validate created backend rbd images = clone
totalImages = 1
validateRBDImageCount(f, totalImages)
validateRBDImageCount(f, totalImages, defaultRBDPool)
appClone, err := loadApp(appClonePath)
if err != nil {
@ -1447,7 +1447,7 @@ var _ = Describe("RBD", func() {
e2elog.Failf("failed to delete PVC with error %v", err)
}
// validate created backend rbd images
validateRBDImageCount(f, 0)
validateRBDImageCount(f, 0, defaultRBDPool)
})
By("ensuring all operations will work within a rados namespace", func() {
@ -1525,7 +1525,7 @@ var _ = Describe("RBD", func() {
e2elog.Failf("failed to validate owner of pvc with error %v", err)
}
// validate created backend rbd images
validateRBDImageCount(f, 0)
validateRBDImageCount(f, 0, defaultRBDPool)
// Create a PVC and bind it to an app within the namesapce
err = validatePVCAndAppBinding(pvcPath, appPath, f)
@ -1577,7 +1577,7 @@ var _ = Describe("RBD", func() {
e2elog.Failf("failed to create PVC with error %v", err)
}
// validate created backend rbd images
validateRBDImageCount(f, 1)
validateRBDImageCount(f, 1, defaultRBDPool)
snap := getSnapshot(snapshotPath)
snap.Namespace = f.UniqueName
@ -1586,7 +1586,7 @@ var _ = Describe("RBD", func() {
if err != nil {
e2elog.Failf("failed to create snapshot with error %v", err)
}
validateRBDImageCount(f, 2)
validateRBDImageCount(f, 2, defaultRBDPool)
err = validatePVCAndAppBinding(pvcClonePath, appClonePath, f)
if err != nil {
@ -1597,13 +1597,13 @@ var _ = Describe("RBD", func() {
e2elog.Failf("failed to delete snapshot with error %v", err)
}
// as snapshot is deleted the image count should be one
validateRBDImageCount(f, 1)
validateRBDImageCount(f, 1, defaultRBDPool)
err = deletePVCAndValidatePV(f.ClientSet, pvc, deployTimeout)
if err != nil {
e2elog.Failf("failed to delete PVC with error %v", err)
}
validateRBDImageCount(f, 0)
validateRBDImageCount(f, 0, defaultRBDPool)
}
// delete RBD provisioner secret
@ -1661,7 +1661,7 @@ var _ = Describe("RBD", func() {
e2elog.Failf("failed to create PVC and application with error %v", err)
}
// validate created backend rbd images
validateRBDImageCount(f, 1)
validateRBDImageCount(f, 1, defaultRBDPool)
opt := metav1.ListOptions{
LabelSelector: fmt.Sprintf("app=%s", app.Name),
@ -1680,7 +1680,7 @@ var _ = Describe("RBD", func() {
e2elog.Failf("failed to delete PVC and application with error %v", err)
}
// validate created backend rbd images
validateRBDImageCount(f, 0)
validateRBDImageCount(f, 0, defaultRBDPool)
})
By("create a thick-provisioned PVC", func() {
@ -1758,7 +1758,7 @@ var _ = Describe("RBD", func() {
e2elog.Failf("failed to validate controller with error %v", err)
}
// validate created backend rbd images
validateRBDImageCount(f, 0)
validateRBDImageCount(f, 0, defaultRBDPool)
err = createRBDStorageClass(f.ClientSet, f, nil, nil, deletePolicy)
if err != nil {
e2elog.Failf("failed to create storageclass with error %v", err)

View File

@ -303,11 +303,11 @@ func validateEncryptedImage(f *framework.Framework, rbdImageSpec string, app *v1
return nil
}
func listRBDImages(f *framework.Framework) ([]string, error) {
func listRBDImages(f *framework.Framework, pool string) ([]string, error) {
var imgInfos []string
stdout, stdErr, err := execCommandInToolBoxPod(f,
fmt.Sprintf("rbd ls --format=json %s", rbdOptions(defaultRBDPool)), rookNamespace)
fmt.Sprintf("rbd ls --format=json %s", rbdOptions(pool)), rookNamespace)
if err != nil {
return imgInfos, err
}
@ -554,7 +554,7 @@ func validateThickPVC(f *framework.Framework, pvc *v1.PersistentVolumeClaim, siz
if err != nil {
return fmt.Errorf("failed to create PVC with error %w", err)
}
validateRBDImageCount(f, 1)
validateRBDImageCount(f, 1, defaultRBDPool)
// nothing has been written, but the image should be allocated
du, err := getRbdDu(f, pvc)
@ -598,7 +598,7 @@ func validateThickPVC(f *framework.Framework, pvc *v1.PersistentVolumeClaim, siz
if err != nil {
return fmt.Errorf("failed to delete PVC with error: %w", err)
}
validateRBDImageCount(f, 0)
validateRBDImageCount(f, 0, defaultRBDPool)
return nil
}

View File

@ -561,7 +561,7 @@ func validatePVCClone(totalCount int, sourcePvcPath, sourceAppPath, clonePvcPath
}
}
// validate created backend rbd images
validateRBDImageCount(f, 1)
validateRBDImageCount(f, 1, defaultRBDPool)
pvcClone, err := loadPVC(clonePvcPath)
if err != nil {
e2elog.Failf("failed to load PVC with error %v", err)
@ -632,7 +632,7 @@ func validatePVCClone(totalCount int, sourcePvcPath, sourceAppPath, clonePvcPath
// total images in cluster is 1 parent rbd image+ total
// temporary clone+ total clones
totalCloneCount := totalCount + totalCount + 1
validateRBDImageCount(f, totalCloneCount)
validateRBDImageCount(f, totalCloneCount, defaultRBDPool)
// delete parent pvc
err = deletePVCAndValidatePV(f.ClientSet, pvc, deployTimeout)
if err != nil {
@ -640,7 +640,7 @@ func validatePVCClone(totalCount int, sourcePvcPath, sourceAppPath, clonePvcPath
}
totalCloneCount = totalCount + totalCount
validateRBDImageCount(f, totalCloneCount)
validateRBDImageCount(f, totalCloneCount, defaultRBDPool)
wg.Add(totalCount)
// delete clone and app
for i := 0; i < totalCount; i++ {
@ -664,7 +664,7 @@ func validatePVCClone(totalCount int, sourcePvcPath, sourceAppPath, clonePvcPath
e2elog.Failf("deleting PVCs and applications failed, %d errors were logged", failed)
}
validateRBDImageCount(f, 0)
validateRBDImageCount(f, 0, defaultRBDPool)
}
// nolint:gocyclo,gocognit,nestif // reduce complexity
@ -711,7 +711,7 @@ func validatePVCSnapshot(totalCount int, pvcPath, appPath, snapshotPath, pvcClon
if err != nil {
e2elog.Failf("failed to calculate checksum with error %v", err)
}
validateRBDImageCount(f, 1)
validateRBDImageCount(f, 1, defaultRBDPool)
snap := getSnapshot(snapshotPath)
snap.Namespace = f.UniqueName
snap.Spec.Source.PersistentVolumeClaimName = &pvc.Name
@ -752,7 +752,7 @@ func validatePVCSnapshot(totalCount int, pvcPath, appPath, snapshotPath, pvcClon
}
// total images in cluster is 1 parent rbd image+ total snaps
validateRBDImageCount(f, totalCount+1)
validateRBDImageCount(f, totalCount+1, defaultRBDPool)
pvcClone, err := loadPVC(pvcClonePath)
if err != nil {
e2elog.Failf("failed to load PVC with error %v", err)
@ -822,7 +822,7 @@ func validatePVCSnapshot(totalCount int, pvcPath, appPath, snapshotPath, pvcClon
// total images in cluster is 1 parent rbd image+ total
// snaps+ total clones
totalCloneCount := totalCount + totalCount + 1
validateRBDImageCount(f, totalCloneCount)
validateRBDImageCount(f, totalCloneCount, defaultRBDPool)
wg.Add(totalCount)
// delete clone and app
for i := 0; i < totalCount; i++ {
@ -848,7 +848,7 @@ func validatePVCSnapshot(totalCount int, pvcPath, appPath, snapshotPath, pvcClon
// total images in cluster is 1 parent rbd image+ total
// snaps
validateRBDImageCount(f, totalCount+1)
validateRBDImageCount(f, totalCount+1, defaultRBDPool)
// create clones from different snapshots and bind it to an
// app
wg.Add(totalCount)
@ -876,7 +876,7 @@ func validatePVCSnapshot(totalCount int, pvcPath, appPath, snapshotPath, pvcClon
// total images in cluster is 1 parent rbd image+ total
// snaps+ total clones
totalCloneCount = totalCount + totalCount + 1
validateRBDImageCount(f, totalCloneCount)
validateRBDImageCount(f, totalCloneCount, defaultRBDPool)
// delete parent pvc
err = deletePVCAndValidatePV(f.ClientSet, pvc, deployTimeout)
if err != nil {
@ -885,7 +885,7 @@ func validatePVCSnapshot(totalCount int, pvcPath, appPath, snapshotPath, pvcClon
// total images in cluster is total snaps+ total clones
totalSnapCount := totalCount + totalCount
validateRBDImageCount(f, totalSnapCount)
validateRBDImageCount(f, totalSnapCount, defaultRBDPool)
wg.Add(totalCount)
// delete snapshot
for i := 0; i < totalCount; i++ {
@ -929,7 +929,7 @@ func validatePVCSnapshot(totalCount int, pvcPath, appPath, snapshotPath, pvcClon
e2elog.Failf("deleting snapshots failed, %d errors were logged", failed)
}
validateRBDImageCount(f, totalCount)
validateRBDImageCount(f, totalCount, defaultRBDPool)
wg.Add(totalCount)
// delete clone and app
for i := 0; i < totalCount; i++ {
@ -954,7 +954,7 @@ func validatePVCSnapshot(totalCount int, pvcPath, appPath, snapshotPath, pvcClon
}
// validate created backend rbd images
validateRBDImageCount(f, 0)
validateRBDImageCount(f, 0, defaultRBDPool)
}
// validateController simulates the required operations to validate the