Skip to content

Commit

Permalink
e2e: volumgroupsnapshot increase pvc count & loop 5 times
Browse files Browse the repository at this point in the history
Signed-off-by: Praveen M <[email protected]>
  • Loading branch information
iPraveenParihar committed Dec 5, 2024
1 parent 69bf906 commit 0764605
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 86 deletions.
42 changes: 21 additions & 21 deletions e2e/rbd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down
132 changes: 67 additions & 65 deletions e2e/volumegroupsnapshot_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0764605

Please sign in to comment.