e2e: remove 1.17 based test enablement in cephfs

Considering we are far out of these release and only care about
kubernetes releases from v1.20, there is no need to have this
version check in place for the tests.

Signed-off-by: Humble Chirammal <hchiramm@redhat.com>
This commit is contained in:
Humble Chirammal 2021-11-03 17:37:36 +05:30 committed by mergify[bot]
parent 2ac3f129c0
commit 7090a18141

View File

@ -659,59 +659,56 @@ var _ = Describe("cephfs", func() {
}) })
By("Delete snapshot after deleting subvolume and snapshot from backend", func() { By("Delete snapshot after deleting subvolume and snapshot from backend", func() {
// snapshot beta is only supported from v1.17+ err := createCephFSSnapshotClass(f)
if k8sVersionGreaterEquals(f.ClientSet, 1, 17) { if err != nil {
err := createCephFSSnapshotClass(f) e2elog.Failf("failed to create CephFS snapshotclass with error %v", err)
if err != nil { }
e2elog.Failf("failed to create CephFS snapshotclass with error %v", err) pvc, err := loadPVC(pvcPath)
} if err != nil {
pvc, err := loadPVC(pvcPath) e2elog.Failf("failed to load PVC with error %v", err)
if err != nil { }
e2elog.Failf("failed to load PVC with error %v", err)
}
pvc.Namespace = f.UniqueName pvc.Namespace = f.UniqueName
err = createPVCAndvalidatePV(f.ClientSet, pvc, deployTimeout) err = createPVCAndvalidatePV(f.ClientSet, pvc, deployTimeout)
if err != nil { if err != nil {
e2elog.Failf("failed to create PVC with error %v", err) e2elog.Failf("failed to create PVC with error %v", err)
} }
snap := getSnapshot(snapshotPath) snap := getSnapshot(snapshotPath)
snap.Namespace = f.UniqueName snap.Namespace = f.UniqueName
snap.Spec.Source.PersistentVolumeClaimName = &pvc.Name snap.Spec.Source.PersistentVolumeClaimName = &pvc.Name
// create snapshot // create snapshot
snap.Name = f.UniqueName snap.Name = f.UniqueName
err = createSnapshot(&snap, deployTimeout) err = createSnapshot(&snap, deployTimeout)
if err != nil { if err != nil {
e2elog.Failf("failed to create snapshot (%s): %v", snap.Name, err) e2elog.Failf("failed to create snapshot (%s): %v", snap.Name, err)
} }
err = deleteBackingCephFSSubvolumeSnapshot(f, pvc, &snap) err = deleteBackingCephFSSubvolumeSnapshot(f, pvc, &snap)
if err != nil { if err != nil {
e2elog.Failf("failed to delete backing snapshot for snapname with error=%s", err) e2elog.Failf("failed to delete backing snapshot for snapname with error=%s", err)
} }
err = deleteBackingCephFSVolume(f, pvc) err = deleteBackingCephFSVolume(f, pvc)
if err != nil { if err != nil {
e2elog.Failf("failed to delete backing subvolume error=%s", err) e2elog.Failf("failed to delete backing subvolume error=%s", err)
} }
err = deleteSnapshot(&snap, deployTimeout) err = deleteSnapshot(&snap, deployTimeout)
if err != nil { if err != nil {
e2elog.Failf("failed to delete snapshot with error=%s", err) e2elog.Failf("failed to delete snapshot with error=%s", err)
} else { } else {
e2elog.Logf("successfully deleted snapshot") e2elog.Logf("successfully deleted snapshot")
} }
err = deletePVCAndValidatePV(f.ClientSet, pvc, deployTimeout) err = deletePVCAndValidatePV(f.ClientSet, pvc, deployTimeout)
if err != nil { if err != nil {
e2elog.Failf("failed to delete PVC with error %v", err) e2elog.Failf("failed to delete PVC with error %v", err)
} }
err = deleteResource(cephFSExamplePath + "snapshotclass.yaml") err = deleteResource(cephFSExamplePath + "snapshotclass.yaml")
if err != nil { if err != nil {
e2elog.Failf("failed to delete CephFS snapshotclass with error %v", err) e2elog.Failf("failed to delete CephFS snapshotclass with error %v", err)
}
} }
}) })
@ -720,301 +717,296 @@ var _ = Describe("cephfs", func() {
// this should work because of the snapshot // this should work because of the snapshot
// retention feature. Restore a PVC from that // retention feature. Restore a PVC from that
// snapshot. // snapshot.
// snapshot beta is only supported from v1.17+
if k8sVersionGreaterEquals(f.ClientSet, 1, 17) {
err := createCephFSSnapshotClass(f)
if err != nil {
e2elog.Failf("failed to create CephFS snapshotclass with error %v", err)
}
pvc, err := loadPVC(pvcPath)
if err != nil {
e2elog.Failf("failed to load PVC with error %v", err)
}
pvc.Namespace = f.UniqueName err := createCephFSSnapshotClass(f)
err = createPVCAndvalidatePV(f.ClientSet, pvc, deployTimeout) if err != nil {
if err != nil { e2elog.Failf("failed to create CephFS snapshotclass with error %v", err)
e2elog.Failf("failed to create PVC with error %v", err) }
} pvc, err := loadPVC(pvcPath)
if err != nil {
e2elog.Failf("failed to load PVC with error %v", err)
}
snap := getSnapshot(snapshotPath) pvc.Namespace = f.UniqueName
snap.Namespace = f.UniqueName err = createPVCAndvalidatePV(f.ClientSet, pvc, deployTimeout)
snap.Spec.Source.PersistentVolumeClaimName = &pvc.Name if err != nil {
// create snapshot e2elog.Failf("failed to create PVC with error %v", err)
snap.Name = f.UniqueName }
err = createSnapshot(&snap, deployTimeout)
if err != nil {
e2elog.Failf("failed to create snapshot (%s): %v", snap.Name, err)
}
// Delete the parent pvc before restoring snap := getSnapshot(snapshotPath)
// another one from snapshot. snap.Namespace = f.UniqueName
err = deletePVCAndValidatePV(f.ClientSet, pvc, deployTimeout) snap.Spec.Source.PersistentVolumeClaimName = &pvc.Name
if err != nil { // create snapshot
e2elog.Failf("failed to delete PVC with error %v", err) snap.Name = f.UniqueName
} err = createSnapshot(&snap, deployTimeout)
if err != nil {
e2elog.Failf("failed to create snapshot (%s): %v", snap.Name, err)
}
pvcClone, err := loadPVC(pvcClonePath) // Delete the parent pvc before restoring
if err != nil { // another one from snapshot.
e2elog.Failf("failed to load PVC with error %v", err) err = deletePVCAndValidatePV(f.ClientSet, pvc, deployTimeout)
} if err != nil {
e2elog.Failf("failed to delete PVC with error %v", err)
}
appClone, err := loadApp(appClonePath) pvcClone, err := loadPVC(pvcClonePath)
if err != nil { if err != nil {
e2elog.Failf("failed to load application with error %v", err) e2elog.Failf("failed to load PVC with error %v", err)
} }
pvcClone.Namespace = f.UniqueName appClone, err := loadApp(appClonePath)
appClone.Namespace = f.UniqueName if err != nil {
pvcClone.Spec.DataSource.Name = snap.Name e2elog.Failf("failed to load application with error %v", err)
}
// create PVC from the snapshot pvcClone.Namespace = f.UniqueName
name := f.UniqueName appClone.Namespace = f.UniqueName
err = createPVCAndApp(name, f, pvcClone, appClone, deployTimeout) pvcClone.Spec.DataSource.Name = snap.Name
if err != nil {
e2elog.Logf("failed to create PVC and app (%s): %v", f.UniqueName, err)
}
// delete clone and app // create PVC from the snapshot
err = deletePVCAndApp(name, f, pvcClone, appClone) name := f.UniqueName
if err != nil { err = createPVCAndApp(name, f, pvcClone, appClone, deployTimeout)
e2elog.Failf("failed to delete PVC and app (%s): %v", f.UniqueName, err) if err != nil {
} e2elog.Logf("failed to create PVC and app (%s): %v", f.UniqueName, err)
}
// delete snapshot // delete clone and app
err = deleteSnapshot(&snap, deployTimeout) err = deletePVCAndApp(name, f, pvcClone, appClone)
if err != nil { if err != nil {
e2elog.Failf("failed to delete snapshot (%s): %v", f.UniqueName, err) e2elog.Failf("failed to delete PVC and app (%s): %v", f.UniqueName, err)
} }
err = deleteResource(cephFSExamplePath + "snapshotclass.yaml") // delete snapshot
if err != nil { err = deleteSnapshot(&snap, deployTimeout)
e2elog.Failf("failed to delete CephFS snapshotclass with error %v", err) if err != nil {
} e2elog.Failf("failed to delete snapshot (%s): %v", f.UniqueName, err)
}
err = deleteResource(cephFSExamplePath + "snapshotclass.yaml")
if err != nil {
e2elog.Failf("failed to delete CephFS snapshotclass with error %v", err)
} }
}) })
By("create a PVC clone and bind it to an app", func() { By("create a PVC clone and bind it to an app", func() {
// snapshot beta is only supported from v1.17+ var wg sync.WaitGroup
if k8sVersionGreaterEquals(f.ClientSet, 1, 17) { totalCount := 3
var wg sync.WaitGroup wgErrs := make([]error, totalCount)
totalCount := 3 // totalSubvolumes represents the subvolumes in backend
wgErrs := make([]error, totalCount) // always totalCount+parentPVC
// totalSubvolumes represents the subvolumes in backend totalSubvolumes := totalCount + 1
// always totalCount+parentPVC wg.Add(totalCount)
totalSubvolumes := totalCount + 1 err := createCephFSSnapshotClass(f)
wg.Add(totalCount) if err != nil {
err := createCephFSSnapshotClass(f) e2elog.Failf("failed to delete CephFS storageclass with error %v", err)
if err != nil {
e2elog.Failf("failed to delete CephFS storageclass with error %v", err)
}
pvc, err := loadPVC(pvcPath)
if err != nil {
e2elog.Failf("failed to load PVC with error %v", err)
}
pvc.Namespace = f.UniqueName
err = createPVCAndvalidatePV(f.ClientSet, pvc, deployTimeout)
if err != nil {
e2elog.Failf("failed to create PVC with error %v", err)
}
app, err := loadApp(appPath)
if err != nil {
e2elog.Failf("failed to load application with error %v", err)
}
app.Namespace = f.UniqueName
app.Spec.Volumes[0].PersistentVolumeClaim.ClaimName = pvc.Name
label := make(map[string]string)
label[appKey] = appLabel
app.Labels = label
opt := metav1.ListOptions{
LabelSelector: fmt.Sprintf("%s=%s", appKey, label[appKey]),
}
wErr := writeDataInPod(app, &opt, f)
if wErr != nil {
e2elog.Failf("failed to write data with error %v", wErr)
}
snap := getSnapshot(snapshotPath)
snap.Namespace = f.UniqueName
snap.Spec.Source.PersistentVolumeClaimName = &pvc.Name
// create snapshot
for i := 0; i < totalCount; i++ {
go func(n int, s snapapi.VolumeSnapshot) {
s.Name = fmt.Sprintf("%s%d", f.UniqueName, n)
wgErrs[n] = createSnapshot(&s, deployTimeout)
wg.Done()
}(i, snap)
}
wg.Wait()
failed := 0
for i, err := range wgErrs {
if err != nil {
// not using Failf() as it aborts the test and does not log other errors
e2elog.Logf("failed to create snapshot (%s%d): %v", f.UniqueName, i, err)
failed++
}
}
if failed != 0 {
e2elog.Failf("creating snapshots failed, %d errors were logged", failed)
}
pvcClone, err := loadPVC(pvcClonePath)
if err != nil {
e2elog.Failf("failed to load PVC with error %v", err)
}
appClone, err := loadApp(appClonePath)
if err != nil {
e2elog.Failf("failed to load application with error %v", err)
}
pvcClone.Namespace = f.UniqueName
appClone.Namespace = f.UniqueName
pvcClone.Spec.DataSource.Name = fmt.Sprintf("%s%d", f.UniqueName, 0)
// create multiple PVC from same snapshot
wg.Add(totalCount)
for i := 0; i < totalCount; i++ {
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
name := fmt.Sprintf("%s%d", f.UniqueName, n)
wgErrs[n] = createPVCAndApp(name, f, &p, &a, deployTimeout)
if wgErrs[n] == nil {
err = validateSubvolumePath(f, p.Name, p.Namespace, fileSystemName, subvolumegroup)
if err != nil {
wgErrs[n] = err
}
}
wg.Done()
}(i, *pvcClone, *appClone)
}
wg.Wait()
for i, err := range wgErrs {
if err != nil {
// not using Failf() as it aborts the test and does not log other errors
e2elog.Logf("failed to create PVC and app (%s%d): %v", f.UniqueName, i, err)
failed++
}
}
if failed != 0 {
e2elog.Failf("creating PVCs and apps failed, %d errors were logged", failed)
}
validateSubvolumeCount(f, totalSubvolumes, fileSystemName, subvolumegroup)
wg.Add(totalCount)
// delete clone and app
for i := 0; i < totalCount; i++ {
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
name := fmt.Sprintf("%s%d", f.UniqueName, n)
p.Spec.DataSource.Name = name
wgErrs[n] = deletePVCAndApp(name, f, &p, &a)
wg.Done()
}(i, *pvcClone, *appClone)
}
wg.Wait()
for i, err := range wgErrs {
if err != nil {
// not using Failf() as it aborts the test and does not log other errors
e2elog.Logf("failed to delete PVC and app (%s%d): %v", f.UniqueName, i, err)
failed++
}
}
if failed != 0 {
e2elog.Failf("deleting PVCs and apps failed, %d errors were logged", failed)
}
parentPVCCount := totalSubvolumes - totalCount
validateSubvolumeCount(f, parentPVCCount, fileSystemName, subvolumegroup)
// create clones from different snapshots and bind it to an
// app
wg.Add(totalCount)
for i := 0; i < totalCount; i++ {
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
name := fmt.Sprintf("%s%d", f.UniqueName, n)
p.Spec.DataSource.Name = name
wgErrs[n] = createPVCAndApp(name, f, &p, &a, deployTimeout)
if wgErrs[n] == nil {
err = validateSubvolumePath(f, p.Name, p.Namespace, fileSystemName, subvolumegroup)
if err != nil {
wgErrs[n] = err
}
}
wg.Done()
}(i, *pvcClone, *appClone)
}
wg.Wait()
for i, err := range wgErrs {
if err != nil {
// not using Failf() as it aborts the test and does not log other errors
e2elog.Logf("failed to create PVC and app (%s%d): %v", f.UniqueName, i, err)
failed++
}
}
if failed != 0 {
e2elog.Failf("creating PVCs and apps failed, %d errors were logged", failed)
}
validateSubvolumeCount(f, totalSubvolumes, fileSystemName, subvolumegroup)
wg.Add(totalCount)
// delete snapshot
for i := 0; i < totalCount; i++ {
go func(n int, s snapapi.VolumeSnapshot) {
s.Name = fmt.Sprintf("%s%d", f.UniqueName, n)
wgErrs[n] = deleteSnapshot(&s, deployTimeout)
wg.Done()
}(i, snap)
}
wg.Wait()
for i, err := range wgErrs {
if err != nil {
// not using Failf() as it aborts the test and does not log other errors
e2elog.Logf("failed to delete snapshot (%s%d): %v", f.UniqueName, i, err)
failed++
}
}
if failed != 0 {
e2elog.Failf("deleting snapshots failed, %d errors were logged", failed)
}
wg.Add(totalCount)
// delete clone and app
for i := 0; i < totalCount; i++ {
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
name := fmt.Sprintf("%s%d", f.UniqueName, n)
p.Spec.DataSource.Name = name
wgErrs[n] = deletePVCAndApp(name, f, &p, &a)
wg.Done()
}(i, *pvcClone, *appClone)
}
wg.Wait()
for i, err := range wgErrs {
if err != nil {
// not using Failf() as it aborts the test and does not log other errors
e2elog.Logf("failed to delete PVC and app (%s%d): %v", f.UniqueName, i, err)
failed++
}
}
if failed != 0 {
e2elog.Failf("deleting PVCs and apps failed, %d errors were logged", failed)
}
validateSubvolumeCount(f, parentPVCCount, fileSystemName, subvolumegroup)
// delete parent pvc
err = deletePVCAndApp("", f, pvc, app)
if err != nil {
e2elog.Failf("failed to delete PVC or application with error %v", err)
}
validateSubvolumeCount(f, 0, fileSystemName, subvolumegroup)
} }
pvc, err := loadPVC(pvcPath)
if err != nil {
e2elog.Failf("failed to load PVC with error %v", err)
}
pvc.Namespace = f.UniqueName
err = createPVCAndvalidatePV(f.ClientSet, pvc, deployTimeout)
if err != nil {
e2elog.Failf("failed to create PVC with error %v", err)
}
app, err := loadApp(appPath)
if err != nil {
e2elog.Failf("failed to load application with error %v", err)
}
app.Namespace = f.UniqueName
app.Spec.Volumes[0].PersistentVolumeClaim.ClaimName = pvc.Name
label := make(map[string]string)
label[appKey] = appLabel
app.Labels = label
opt := metav1.ListOptions{
LabelSelector: fmt.Sprintf("%s=%s", appKey, label[appKey]),
}
wErr := writeDataInPod(app, &opt, f)
if wErr != nil {
e2elog.Failf("failed to write data with error %v", wErr)
}
snap := getSnapshot(snapshotPath)
snap.Namespace = f.UniqueName
snap.Spec.Source.PersistentVolumeClaimName = &pvc.Name
// create snapshot
for i := 0; i < totalCount; i++ {
go func(n int, s snapapi.VolumeSnapshot) {
s.Name = fmt.Sprintf("%s%d", f.UniqueName, n)
wgErrs[n] = createSnapshot(&s, deployTimeout)
wg.Done()
}(i, snap)
}
wg.Wait()
failed := 0
for i, err := range wgErrs {
if err != nil {
// not using Failf() as it aborts the test and does not log other errors
e2elog.Logf("failed to create snapshot (%s%d): %v", f.UniqueName, i, err)
failed++
}
}
if failed != 0 {
e2elog.Failf("creating snapshots failed, %d errors were logged", failed)
}
pvcClone, err := loadPVC(pvcClonePath)
if err != nil {
e2elog.Failf("failed to load PVC with error %v", err)
}
appClone, err := loadApp(appClonePath)
if err != nil {
e2elog.Failf("failed to load application with error %v", err)
}
pvcClone.Namespace = f.UniqueName
appClone.Namespace = f.UniqueName
pvcClone.Spec.DataSource.Name = fmt.Sprintf("%s%d", f.UniqueName, 0)
// create multiple PVC from same snapshot
wg.Add(totalCount)
for i := 0; i < totalCount; i++ {
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
name := fmt.Sprintf("%s%d", f.UniqueName, n)
wgErrs[n] = createPVCAndApp(name, f, &p, &a, deployTimeout)
if wgErrs[n] == nil {
err = validateSubvolumePath(f, p.Name, p.Namespace, fileSystemName, subvolumegroup)
if err != nil {
wgErrs[n] = err
}
}
wg.Done()
}(i, *pvcClone, *appClone)
}
wg.Wait()
for i, err := range wgErrs {
if err != nil {
// not using Failf() as it aborts the test and does not log other errors
e2elog.Logf("failed to create PVC and app (%s%d): %v", f.UniqueName, i, err)
failed++
}
}
if failed != 0 {
e2elog.Failf("creating PVCs and apps failed, %d errors were logged", failed)
}
validateSubvolumeCount(f, totalSubvolumes, fileSystemName, subvolumegroup)
wg.Add(totalCount)
// delete clone and app
for i := 0; i < totalCount; i++ {
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
name := fmt.Sprintf("%s%d", f.UniqueName, n)
p.Spec.DataSource.Name = name
wgErrs[n] = deletePVCAndApp(name, f, &p, &a)
wg.Done()
}(i, *pvcClone, *appClone)
}
wg.Wait()
for i, err := range wgErrs {
if err != nil {
// not using Failf() as it aborts the test and does not log other errors
e2elog.Logf("failed to delete PVC and app (%s%d): %v", f.UniqueName, i, err)
failed++
}
}
if failed != 0 {
e2elog.Failf("deleting PVCs and apps failed, %d errors were logged", failed)
}
parentPVCCount := totalSubvolumes - totalCount
validateSubvolumeCount(f, parentPVCCount, fileSystemName, subvolumegroup)
// create clones from different snapshots and bind it to an
// app
wg.Add(totalCount)
for i := 0; i < totalCount; i++ {
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
name := fmt.Sprintf("%s%d", f.UniqueName, n)
p.Spec.DataSource.Name = name
wgErrs[n] = createPVCAndApp(name, f, &p, &a, deployTimeout)
if wgErrs[n] == nil {
err = validateSubvolumePath(f, p.Name, p.Namespace, fileSystemName, subvolumegroup)
if err != nil {
wgErrs[n] = err
}
}
wg.Done()
}(i, *pvcClone, *appClone)
}
wg.Wait()
for i, err := range wgErrs {
if err != nil {
// not using Failf() as it aborts the test and does not log other errors
e2elog.Logf("failed to create PVC and app (%s%d): %v", f.UniqueName, i, err)
failed++
}
}
if failed != 0 {
e2elog.Failf("creating PVCs and apps failed, %d errors were logged", failed)
}
validateSubvolumeCount(f, totalSubvolumes, fileSystemName, subvolumegroup)
wg.Add(totalCount)
// delete snapshot
for i := 0; i < totalCount; i++ {
go func(n int, s snapapi.VolumeSnapshot) {
s.Name = fmt.Sprintf("%s%d", f.UniqueName, n)
wgErrs[n] = deleteSnapshot(&s, deployTimeout)
wg.Done()
}(i, snap)
}
wg.Wait()
for i, err := range wgErrs {
if err != nil {
// not using Failf() as it aborts the test and does not log other errors
e2elog.Logf("failed to delete snapshot (%s%d): %v", f.UniqueName, i, err)
failed++
}
}
if failed != 0 {
e2elog.Failf("deleting snapshots failed, %d errors were logged", failed)
}
wg.Add(totalCount)
// delete clone and app
for i := 0; i < totalCount; i++ {
go func(n int, p v1.PersistentVolumeClaim, a v1.Pod) {
name := fmt.Sprintf("%s%d", f.UniqueName, n)
p.Spec.DataSource.Name = name
wgErrs[n] = deletePVCAndApp(name, f, &p, &a)
wg.Done()
}(i, *pvcClone, *appClone)
}
wg.Wait()
for i, err := range wgErrs {
if err != nil {
// not using Failf() as it aborts the test and does not log other errors
e2elog.Logf("failed to delete PVC and app (%s%d): %v", f.UniqueName, i, err)
failed++
}
}
if failed != 0 {
e2elog.Failf("deleting PVCs and apps failed, %d errors were logged", failed)
}
validateSubvolumeCount(f, parentPVCCount, fileSystemName, subvolumegroup)
// delete parent pvc
err = deletePVCAndApp("", f, pvc, app)
if err != nil {
e2elog.Failf("failed to delete PVC or application with error %v", err)
}
validateSubvolumeCount(f, 0, fileSystemName, subvolumegroup)
}) })
By("create a PVC-PVC clone and bind it to an app", func() { By("create a PVC-PVC clone and bind it to an app", func() {