From 0764605a81e04f550b3833c32b279b818828fb2c Mon Sep 17 00:00:00 2001 From: Praveen M Date: Wed, 4 Dec 2024 23:43:11 +0530 Subject: [PATCH] e2e: volumgroupsnapshot increase pvc count & loop 5 times Signed-off-by: Praveen M --- e2e/rbd.go | 42 +++++----- e2e/volumegroupsnapshot_base.go | 132 ++++++++++++++++---------------- 2 files changed, 88 insertions(+), 86 deletions(-) diff --git a/e2e/rbd.go b/e2e/rbd.go index d47469a8b7b..59a53b7aeb6 100644 --- a/e2e/rbd.go +++ b/e2e/rbd.go @@ -550,6 +550,27 @@ var _ = Describe("RBD", func() { validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType) }) + By("test volumeGroupSnapshot", func() { + supported, err := librbdSupportsVolumeGroupSnapshot(f) + if err != nil { + framework.Failf("failed to check for VolumeGroupSnapshot support: %v", err) + } + if !supported { + Skip("librbd does not support required VolumeGroupSnapshot function(s)") + } + + scName := "csi-rbd-sc" + snapshotter, err := newRBDVolumeGroupSnapshot(f, f.UniqueName, scName, false, deployTimeout, 10) + if err != nil { + framework.Failf("failed to create RBDVolumeGroupSnapshot: %v", err) + } + + err = snapshotter.TestVolumeGroupSnapshot() + if err != nil { + framework.Failf("failed to test volumeGroupSnapshot: %v", err) + } + }) + By("reattach the old PV to a new PVC and check if PVC metadata is updated on RBD image", func() { reattachPVCNamespace := f.Namespace.Name + "-2" pvc, err := loadPVC(pvcPath) @@ -4871,27 +4892,6 @@ var _ = Describe("RBD", func() { } }) - By("test volumeGroupSnapshot", func() { - supported, err := librbdSupportsVolumeGroupSnapshot(f) - if err != nil { - framework.Failf("failed to check for VolumeGroupSnapshot support: %v", err) - } - if !supported { - Skip("librbd does not support required VolumeGroupSnapshot function(s)") - } - - scName := "csi-rbd-sc" - snapshotter, err := newRBDVolumeGroupSnapshot(f, f.UniqueName, scName, false, deployTimeout, 3) - if err != nil { - framework.Failf("failed to create RBDVolumeGroupSnapshot: %v", err) - } - - err = snapshotter.TestVolumeGroupSnapshot() - if err != nil { - framework.Failf("failed to test volumeGroupSnapshot: %v", err) - } - }) - // delete RBD provisioner secret err := deleteCephUser(f, keyringRBDProvisionerUsername) if err != nil { diff --git a/e2e/volumegroupsnapshot_base.go b/e2e/volumegroupsnapshot_base.go index 47bb177386d..41409d71546 100644 --- a/e2e/volumegroupsnapshot_base.go +++ b/e2e/volumegroupsnapshot_base.go @@ -432,73 +432,75 @@ func (v volumeGroupSnapshotterBase) DeleteVolumeGroupSnapshotClass(groupSnapshot } func (v *volumeGroupSnapshotterBase) testVolumeGroupSnapshot(vol VolumeGroupSnapshotter) error { - pvcLabels := map[string]string{"pvc": "vgsc"} - pvcs, err := v.CreatePVCs(v.namespace, pvcLabels) - if err != nil { - return fmt.Errorf("failed to create PVCs: %w", err) - } + for i := 0; i < 5; i++ { + pvcLabels := map[string]string{"pvc": "vgsc"} + pvcs, err := v.CreatePVCs(v.namespace, pvcLabels) + if err != nil { + return fmt.Errorf("failed to create PVCs: %w", err) + } - vgsc, err := vol.GetVolumeGroupSnapshotClass() - if err != nil { - return fmt.Errorf("failed to get volume group snapshot class: %w", err) - } - // Create a volume group snapshot class - vgscName := v.framework.Namespace.Name + "-vgsc" - vgsc.Name = vgscName - err = v.CreateVolumeGroupSnapshotClass(vgsc) - if err != nil { - return fmt.Errorf("failed to create volume group snapshot: %w", err) - } - vgsName := v.framework.Namespace.Name + "-vgs" - // Create a volume group snapshot - volumeGroupSnapshot, err := v.CreateVolumeGroupSnapshot(vgsName, vgscName, pvcLabels) - if err != nil { - return fmt.Errorf("failed to create volume group snapshot: %w", err) - } + vgsc, err := vol.GetVolumeGroupSnapshotClass() + if err != nil { + return fmt.Errorf("failed to get volume group snapshot class: %w", err) + } + // Create a volume group snapshot class + vgscName := v.framework.Namespace.Name + "-vgsc" + vgsc.Name = vgscName + err = v.CreateVolumeGroupSnapshotClass(vgsc) + if err != nil { + return fmt.Errorf("failed to create volume group snapshot: %w", err) + } + vgsName := v.framework.Namespace.Name + "-vgs" + // Create a volume group snapshot + volumeGroupSnapshot, err := v.CreateVolumeGroupSnapshot(vgsName, vgscName, pvcLabels) + if err != nil { + return fmt.Errorf("failed to create volume group snapshot: %w", err) + } - clonePVCs, err := v.CreatePVCClones(volumeGroupSnapshot) - if err != nil { - return fmt.Errorf("failed to create clones: %w", err) - } - // create pods using the cloned PVCs - pods, err := v.CreatePods(clonePVCs) - if err != nil { - return fmt.Errorf("failed to create pods: %w", err) - } - // validate the resources in the backend - err = vol.ValidateResourcesForCreate(volumeGroupSnapshot) - if err != nil { - return fmt.Errorf("failed to validate resources for create: %w", err) - } - // Delete the pods - err = v.DeletePods(pods) - if err != nil { - return fmt.Errorf("failed to delete pods: %w", err) - } - // Delete the clones - err = v.DeletePVCs(clonePVCs) - if err != nil { - return fmt.Errorf("failed to delete clones: %w", err) - } - // Delete the PVCs - err = v.DeletePVCs(pvcs) - if err != nil { - return fmt.Errorf("failed to delete PVCs: %w", err) - } - // Delete the volume group snapshot - err = v.DeleteVolumeGroupSnapshot(volumeGroupSnapshot.Name) - if err != nil { - return fmt.Errorf("failed to delete volume group snapshot: %w", err) - } - // validate the resources in the backend after deleting the resources - err = vol.ValidateResourcesForDelete() - if err != nil { - return fmt.Errorf("failed to validate resources for delete: %w", err) - } - // Delete the volume group snapshot class - err = v.DeleteVolumeGroupSnapshotClass(vgscName) - if err != nil { - return fmt.Errorf("failed to delete volume group snapshot class: %w", err) + clonePVCs, err := v.CreatePVCClones(volumeGroupSnapshot) + if err != nil { + return fmt.Errorf("failed to create clones: %w", err) + } + // create pods using the cloned PVCs + pods, err := v.CreatePods(clonePVCs) + if err != nil { + return fmt.Errorf("failed to create pods: %w", err) + } + // validate the resources in the backend + err = vol.ValidateResourcesForCreate(volumeGroupSnapshot) + if err != nil { + return fmt.Errorf("failed to validate resources for create: %w", err) + } + // Delete the pods + err = v.DeletePods(pods) + if err != nil { + return fmt.Errorf("failed to delete pods: %w", err) + } + // Delete the clones + err = v.DeletePVCs(clonePVCs) + if err != nil { + return fmt.Errorf("failed to delete clones: %w", err) + } + // Delete the PVCs + err = v.DeletePVCs(pvcs) + if err != nil { + return fmt.Errorf("failed to delete PVCs: %w", err) + } + // Delete the volume group snapshot + err = v.DeleteVolumeGroupSnapshot(volumeGroupSnapshot.Name) + if err != nil { + return fmt.Errorf("failed to delete volume group snapshot: %w", err) + } + // validate the resources in the backend after deleting the resources + err = vol.ValidateResourcesForDelete() + if err != nil { + return fmt.Errorf("failed to validate resources for delete: %w", err) + } + // Delete the volume group snapshot class + err = v.DeleteVolumeGroupSnapshotClass(vgscName) + if err != nil { + return fmt.Errorf("failed to delete volume group snapshot class: %w", err) + } } return nil