mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-09 16:00:22 +00:00
e2e: pvc mounting when snap and parent pvc is deleted
Added an E2E test to test below case * Create PVC * Create Snapshot from PVC * Delete PVC * Create Clone from Snapshot * Delete Snapshot * Mount clone to Application * Delete Application and PVC Clone Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
parent
67d73cd6e9
commit
fa36a46682
106
e2e/rbd.go
106
e2e/rbd.go
@ -1088,6 +1088,112 @@ var _ = Describe("RBD", func() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
By("validate PVC mounting if snapshot and parent PVC are deleted", func() {
|
||||||
|
// snapshot beta is only supported from v1.17+
|
||||||
|
if !k8sVersionGreaterEquals(f.ClientSet, 1, 17) {
|
||||||
|
Skip("pvc restore is only supported from v1.17+")
|
||||||
|
}
|
||||||
|
err := createRBDSnapshotClass(f)
|
||||||
|
if err != nil {
|
||||||
|
e2elog.Failf("failed to create storageclass with error %v", err)
|
||||||
|
}
|
||||||
|
defer func() {
|
||||||
|
err = deleteRBDSnapshotClass()
|
||||||
|
if err != nil {
|
||||||
|
e2elog.Failf("failed to delete VolumeSnapshotClass: %v", err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
// create PVC and bind it to an app
|
||||||
|
pvc, err := loadPVC(pvcPath)
|
||||||
|
if err != nil {
|
||||||
|
e2elog.Failf("failed to load PVC with error %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
pvc.Namespace = f.UniqueName
|
||||||
|
app, err := loadApp(appPath)
|
||||||
|
if err != nil {
|
||||||
|
e2elog.Failf("failed to load application with error %v", err)
|
||||||
|
}
|
||||||
|
app.Namespace = f.UniqueName
|
||||||
|
err = createPVCAndApp("", f, pvc, app, deployTimeout)
|
||||||
|
if err != nil {
|
||||||
|
e2elog.Failf("failed to create PVC and application with error %v", err)
|
||||||
|
}
|
||||||
|
// validate created backend rbd images
|
||||||
|
validateRBDImageCount(f, 1)
|
||||||
|
|
||||||
|
snap := getSnapshot(snapshotPath)
|
||||||
|
snap.Namespace = f.UniqueName
|
||||||
|
snap.Spec.Source.PersistentVolumeClaimName = &pvc.Name
|
||||||
|
|
||||||
|
err = createSnapshot(&snap, deployTimeout)
|
||||||
|
if err != nil {
|
||||||
|
e2elog.Failf("failed to create snapshot with error %v", err)
|
||||||
|
}
|
||||||
|
// validate created backend rbd images
|
||||||
|
// parent PVC + snapshot
|
||||||
|
totalImages := 2
|
||||||
|
validateRBDImageCount(f, totalImages)
|
||||||
|
pvcClone, err := loadPVC(pvcClonePath)
|
||||||
|
if err != nil {
|
||||||
|
e2elog.Failf("failed to load PVC with error %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// delete parent PVC
|
||||||
|
err = deletePVCAndApp("", f, pvc, app)
|
||||||
|
if err != nil {
|
||||||
|
e2elog.Failf("failed to delete PVC and application with error %v", err)
|
||||||
|
}
|
||||||
|
// validate created backend rbd images
|
||||||
|
validateRBDImageCount(f, 1)
|
||||||
|
|
||||||
|
// create clone PVC
|
||||||
|
pvcClone.Namespace = f.UniqueName
|
||||||
|
err = createPVCAndvalidatePV(f.ClientSet, pvcClone, deployTimeout)
|
||||||
|
if err != nil {
|
||||||
|
e2elog.Failf("failed to create PVC with error %v", err)
|
||||||
|
}
|
||||||
|
// validate created backend rbd images = snapshot + clone
|
||||||
|
totalImages = 2
|
||||||
|
validateRBDImageCount(f, totalImages)
|
||||||
|
|
||||||
|
// delete snapshot
|
||||||
|
err = deleteSnapshot(&snap, deployTimeout)
|
||||||
|
if err != nil {
|
||||||
|
e2elog.Failf("failed to delete snapshot with error %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// validate created backend rbd images = clone
|
||||||
|
totalImages = 1
|
||||||
|
validateRBDImageCount(f, totalImages)
|
||||||
|
|
||||||
|
appClone, err := loadApp(appClonePath)
|
||||||
|
if err != nil {
|
||||||
|
e2elog.Failf("failed to load application with error %v", err)
|
||||||
|
}
|
||||||
|
appClone.Namespace = f.UniqueName
|
||||||
|
appClone.Spec.Volumes[0].PersistentVolumeClaim.ClaimName = pvcClone.Name
|
||||||
|
|
||||||
|
// create application
|
||||||
|
err = createApp(f.ClientSet, appClone, deployTimeout)
|
||||||
|
if err != nil {
|
||||||
|
e2elog.Failf("failed to create application with error %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = deletePod(appClone.Name, appClone.Namespace, f.ClientSet, deployTimeout)
|
||||||
|
if err != nil {
|
||||||
|
e2elog.Failf("failed to delete application with error %v", err)
|
||||||
|
}
|
||||||
|
// delete PVC clone
|
||||||
|
err = deletePVCAndValidatePV(f.ClientSet, pvcClone, deployTimeout)
|
||||||
|
if err != nil {
|
||||||
|
e2elog.Failf("failed to delete PVC with error %v", err)
|
||||||
|
}
|
||||||
|
// validate created backend rbd images
|
||||||
|
validateRBDImageCount(f, 0)
|
||||||
|
})
|
||||||
|
|
||||||
By("ensuring all operations will work within a rados namespace", func() {
|
By("ensuring all operations will work within a rados namespace", func() {
|
||||||
updateConfigMap := func(radosNS string) {
|
updateConfigMap := func(radosNS string) {
|
||||||
radosNamespace = radosNS
|
radosNamespace = radosNS
|
||||||
|
Loading…
Reference in New Issue
Block a user