Skip to content

Commit

Permalink
Fixed e2e for CSI snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
YashwantGohokar committed Feb 18, 2025
1 parent ef5156e commit 3551697
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 83 deletions.
164 changes: 82 additions & 82 deletions test/e2e/cloud-provider-oci/csi_snapshot_restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,88 +39,88 @@ const (
var _ = Describe("Snapshot Creation and Restore", func() {
f := framework.NewBackupFramework("snapshot-restore")

Context("[cloudprovider][storage][csi][snapshot][restore][test1]", func() {
//tests := []struct{
// attachmentType string
// backupType string
// fsType string
//}{
// {framework.AttachmentTypeParavirtualized, framework.BackupTypeIncremental, ""},
// {framework.AttachmentTypeParavirtualized, framework.BackupTypeFull, ""},
// {framework.AttachmentTypeISCSI, framework.BackupTypeIncremental, ""},
// {framework.AttachmentTypeISCSI, framework.BackupTypeFull, ""},
// {framework.AttachmentTypeISCSI, framework.BackupTypeIncremental, "xfs"},
// {framework.AttachmentTypeParavirtualized, framework.BackupTypeFull, "ext3"},
//}
//for _, entry := range tests {
// entry := entry
// testName := "Should be able to create and restore " + entry.backupType + " snapshot from " + entry.attachmentType + " volume "
// if entry.fsType != "" {
// testName += " with " + entry.fsType + " fsType"
// }
// It(testName, func() {
// scParams := map[string]string{framework.AttachmentType: entry.attachmentType}
// vscParams := map[string]string{framework.BackupType: entry.backupType}
// scParams[framework.FstypeKey] = entry.fsType
// testSnapshotAndRestore(f, scParams, vscParams)
// })
//}
//It("FS should get expanded when a PVC is restored with a lesser size backup (iscsi)", func() {
// checkOrInstallCRDs(f)
// scParams := map[string]string{framework.AttachmentType: framework.AttachmentTypeISCSI}
// vscParams := map[string]string{framework.BackupType: framework.BackupTypeFull}
// pvcJig := framework.NewPVCTestJig(f.ClientSet, "csi-snapshot-restore-e2e-tests")
// pvcJig.InitialiseSnapClient(f.SnapClientSet)
//
// scName := f.CreateStorageClassOrFail(f.Namespace.Name, BVDriverName, scParams, pvcJig.Labels, BindingModeWaitForFirstConsumer, true, ReclaimPolicyDelete, nil)
// pvc := pvcJig.CreateAndAwaitPVCOrFailCSI(f.Namespace.Name, framework.MinVolumeBlock, scName, nil, v1.PersistentVolumeFilesystem, v1.ReadWriteOnce, v1.ClaimPending)
//
// _ = pvcJig.NewPodForCSI("pod-original", f.Namespace.Name, pvc.Name, setupF.AdLabel)
//
// time.Sleep(60 * time.Second) //waiting for pod to up and running
//
// vscName := f.CreateVolumeSnapshotClassOrFail(f.Namespace.Name, BVDriverName, vscParams, ReclaimPolicyDelete)
// vs := pvcJig.CreateAndAwaitVolumeSnapshotOrFail(f.Namespace.Name, vscName, pvc.Name, nil)
//
// pvcRestore := pvcJig.CreateAndAwaitPVCOrFailSnapshotSource(f.Namespace.Name, framework.MaxVolumeBlock, scName, vs.Name, v1.ClaimPending, nil)
// podRestoreName := pvcJig.NewPodForCSI("pod-restored", f.Namespace.Name, pvcRestore.Name, setupF.AdLabel)
//
// time.Sleep(60 * time.Second) //waiting for pod to up and running
//
// pvcJig.CheckUsableVolumeSizeInsidePod(f.Namespace.Name, podRestoreName, "99G")
//
// f.VolumeIds = append(f.VolumeIds, pvc.Spec.VolumeName)
// _ = f.DeleteVolumeSnapshotClass(f.Namespace.Name)
// _ = f.DeleteStorageClass(f.Namespace.Name)
//})
//It("FS should get expanded when a PVC is restored with a lesser size backup (paravirtualized)", func() {
// checkOrInstallCRDs(f)
// scParams := map[string]string{framework.AttachmentType: framework.AttachmentTypeParavirtualized}
// vscParams := map[string]string{framework.BackupType: framework.BackupTypeFull}
// pvcJig := framework.NewPVCTestJig(f.ClientSet, "csi-snapshot-restore-e2e-tests")
// pvcJig.InitialiseSnapClient(f.SnapClientSet)
//
// scName := f.CreateStorageClassOrFail(f.Namespace.Name, BVDriverName, scParams, pvcJig.Labels, BindingModeWaitForFirstConsumer, true, ReclaimPolicyDelete, nil)
// pvc := pvcJig.CreateAndAwaitPVCOrFailCSI(f.Namespace.Name, framework.MinVolumeBlock, scName, nil, v1.PersistentVolumeFilesystem, v1.ReadWriteOnce, v1.ClaimPending)
//
// _ = pvcJig.NewPodForCSI("pod-original", f.Namespace.Name, pvc.Name, setupF.AdLabel)
//
// time.Sleep(60 * time.Second) //waiting for pod to up and running
//
// vscName := f.CreateVolumeSnapshotClassOrFail(f.Namespace.Name, BVDriverName, vscParams, ReclaimPolicyDelete)
// vs := pvcJig.CreateAndAwaitVolumeSnapshotOrFail(f.Namespace.Name, vscName, pvc.Name, nil)
//
// pvcRestore := pvcJig.CreateAndAwaitPVCOrFailSnapshotSource(f.Namespace.Name, framework.MaxVolumeBlock, scName, vs.Name, v1.ClaimPending, nil)
// podRestoreName := pvcJig.NewPodForCSI("pod-restored", f.Namespace.Name, pvcRestore.Name, setupF.AdLabel)
//
// time.Sleep(60 * time.Second) //waiting for pod to up and running
//
// pvcJig.CheckUsableVolumeSizeInsidePod(f.Namespace.Name, podRestoreName, "99G")
//
// f.VolumeIds = append(f.VolumeIds, pvc.Spec.VolumeName)
// _ = f.DeleteVolumeSnapshotClass(f.Namespace.Name)
// _ = f.DeleteStorageClass(f.Namespace.Name)
//})
Context("[cloudprovider][storage][csi][snapshot][restore]", func() {
tests := []struct{
attachmentType string
backupType string
fsType string
}{
{framework.AttachmentTypeParavirtualized, framework.BackupTypeIncremental, ""},
{framework.AttachmentTypeParavirtualized, framework.BackupTypeFull, ""},
{framework.AttachmentTypeISCSI, framework.BackupTypeIncremental, ""},
{framework.AttachmentTypeISCSI, framework.BackupTypeFull, ""},
{framework.AttachmentTypeISCSI, framework.BackupTypeIncremental, "xfs"},
{framework.AttachmentTypeParavirtualized, framework.BackupTypeFull, "ext3"},
}
for _, entry := range tests {
entry := entry
testName := "Should be able to create and restore " + entry.backupType + " snapshot from " + entry.attachmentType + " volume "
if entry.fsType != "" {
testName += " with " + entry.fsType + " fsType"
}
It(testName, func() {
scParams := map[string]string{framework.AttachmentType: entry.attachmentType}
vscParams := map[string]string{framework.BackupType: entry.backupType}
scParams[framework.FstypeKey] = entry.fsType
testSnapshotAndRestore(f, scParams, vscParams, v1.PersistentVolumeBlock)
})
}
It("FS should get expanded when a PVC is restored with a lesser size backup (iscsi)", func() {
checkOrInstallCRDs(f)
scParams := map[string]string{framework.AttachmentType: framework.AttachmentTypeISCSI}
vscParams := map[string]string{framework.BackupType: framework.BackupTypeFull}
pvcJig := framework.NewPVCTestJig(f.ClientSet, "csi-snapshot-restore-e2e-tests")
pvcJig.InitialiseSnapClient(f.SnapClientSet)

scName := f.CreateStorageClassOrFail(f.Namespace.Name, BVDriverName, scParams, pvcJig.Labels, BindingModeWaitForFirstConsumer, true, ReclaimPolicyDelete, nil)
pvc := pvcJig.CreateAndAwaitPVCOrFailCSI(f.Namespace.Name, framework.MinVolumeBlock, scName, nil, v1.PersistentVolumeFilesystem, v1.ReadWriteOnce, v1.ClaimPending)

_ = pvcJig.NewPodForCSI("pod-original", f.Namespace.Name, pvc.Name, setupF.AdLabel, v1.PersistentVolumeBlock)

time.Sleep(60 * time.Second) //waiting for pod to up and running

vscName := f.CreateVolumeSnapshotClassOrFail(f.Namespace.Name, BVDriverName, vscParams, ReclaimPolicyDelete)
vs := pvcJig.CreateAndAwaitVolumeSnapshotOrFail(f.Namespace.Name, vscName, pvc.Name, nil)

pvcRestore := pvcJig.CreateAndAwaitPVCOrFailSnapshotSource(f.Namespace.Name, framework.MaxVolumeBlock, scName, vs.Name, v1.ClaimPending, false, nil)
podRestoreName := pvcJig.NewPodForCSI("pod-restored", f.Namespace.Name, pvcRestore.Name, setupF.AdLabel, v1.PersistentVolumeBlock)

time.Sleep(60 * time.Second) //waiting for pod to up and running

pvcJig.CheckUsableVolumeSizeInsidePod(f.Namespace.Name, podRestoreName, "99G")

f.VolumeIds = append(f.VolumeIds, pvc.Spec.VolumeName)
_ = f.DeleteVolumeSnapshotClass(f.Namespace.Name)
_ = f.DeleteStorageClass(f.Namespace.Name)
})
It("FS should get expanded when a PVC is restored with a lesser size backup (paravirtualized)", func() {
checkOrInstallCRDs(f)
scParams := map[string]string{framework.AttachmentType: framework.AttachmentTypeParavirtualized}
vscParams := map[string]string{framework.BackupType: framework.BackupTypeFull}
pvcJig := framework.NewPVCTestJig(f.ClientSet, "csi-snapshot-restore-e2e-tests")
pvcJig.InitialiseSnapClient(f.SnapClientSet)

scName := f.CreateStorageClassOrFail(f.Namespace.Name, BVDriverName, scParams, pvcJig.Labels, BindingModeWaitForFirstConsumer, true, ReclaimPolicyDelete, nil)
pvc := pvcJig.CreateAndAwaitPVCOrFailCSI(f.Namespace.Name, framework.MinVolumeBlock, scName, nil, v1.PersistentVolumeFilesystem, v1.ReadWriteOnce, v1.ClaimPending)

_ = pvcJig.NewPodForCSI("pod-original", f.Namespace.Name, pvc.Name, setupF.AdLabel, v1.PersistentVolumeBlock)

time.Sleep(60 * time.Second) //waiting for pod to up and running

vscName := f.CreateVolumeSnapshotClassOrFail(f.Namespace.Name, BVDriverName, vscParams, ReclaimPolicyDelete)
vs := pvcJig.CreateAndAwaitVolumeSnapshotOrFail(f.Namespace.Name, vscName, pvc.Name, nil)

pvcRestore := pvcJig.CreateAndAwaitPVCOrFailSnapshotSource(f.Namespace.Name, framework.MaxVolumeBlock, scName, vs.Name, v1.ClaimPending, false, nil)
podRestoreName := pvcJig.NewPodForCSI("pod-restored", f.Namespace.Name, pvcRestore.Name, setupF.AdLabel, v1.PersistentVolumeBlock)

time.Sleep(60 * time.Second) //waiting for pod to up and running

pvcJig.CheckUsableVolumeSizeInsidePod(f.Namespace.Name, podRestoreName, "99G")

f.VolumeIds = append(f.VolumeIds, pvc.Spec.VolumeName)
_ = f.DeleteVolumeSnapshotClass(f.Namespace.Name)
_ = f.DeleteStorageClass(f.Namespace.Name)
})
It("Should be able to create and restore a snapshot from a backup(static case)", func() {
checkOrInstallCRDs(f)
scParams := map[string]string{framework.AttachmentType: framework.AttachmentTypeISCSI}
Expand Down
1 change: 0 additions & 1 deletion test/e2e/framework/service_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,6 @@ func EnsureLoadBalancerResourcesDeleted(ip, portRange string) error {
}

func (j *ServiceTestJig) WaitForLoadBalancerDestroyOrFail(namespace, name string, ip string, port int, timeout time.Duration) *v1.Service {
// TODO: once support ticket 21807001 is resolved, reduce this timeout back to something reasonable
defer func() {
if err := EnsureLoadBalancerResourcesDeleted(ip, strconv.Itoa(port)); err != nil {
Logf("Failed to delete cloud resources for service: %s %d (%v)", ip, port, err)
Expand Down

0 comments on commit 3551697

Please sign in to comment.