mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-27 16:50:23 +00:00
e2e: add test cases for snapshot-restore chain with depth 2
Signed-off-by: Rakshith R <rar@redhat.com>
(cherry picked from commit 9321b4bce4
)
This commit is contained in:
parent
33234c1b51
commit
dc046d0204
139
e2e/rbd.go
139
e2e/rbd.go
@ -1785,6 +1785,145 @@ var _ = Describe("RBD", func() {
|
|||||||
validateRBDImageCount(f, 0, defaultRBDPool)
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
By(
|
||||||
|
"validate PVC mounting if snapshot and parent PVC are deleted chained with depth 2",
|
||||||
|
func() {
|
||||||
|
// snapshot beta is only supported from v1.17+
|
||||||
|
if !k8sVersionGreaterEquals(f.ClientSet, 1, 17) {
|
||||||
|
Skip("pvc restore is only supported from v1.17+")
|
||||||
|
}
|
||||||
|
snapChainDepth := 2
|
||||||
|
|
||||||
|
err := deleteResource(rbdExamplePath + "storageclass.yaml")
|
||||||
|
if err != nil {
|
||||||
|
e2elog.Failf("failed to delete storageclass with error %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = createRBDStorageClass(
|
||||||
|
f.ClientSet,
|
||||||
|
f,
|
||||||
|
defaultSCName,
|
||||||
|
nil,
|
||||||
|
map[string]string{
|
||||||
|
"encrypted": "true",
|
||||||
|
"encryptionKMSID": "vault-test",
|
||||||
|
},
|
||||||
|
deletePolicy)
|
||||||
|
if err != nil {
|
||||||
|
e2elog.Failf("failed to create storageclass with error %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
err = deleteResource(rbdExamplePath + "storageclass.yaml")
|
||||||
|
if err != nil {
|
||||||
|
e2elog.Failf("failed to delete storageclass with error %v", err)
|
||||||
|
}
|
||||||
|
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, nil, deletePolicy)
|
||||||
|
if err != nil {
|
||||||
|
e2elog.Failf("failed to create storageclass with error %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, defaultRBDPool)
|
||||||
|
for i := 0; i < snapChainDepth; i++ {
|
||||||
|
var pvcClone *v1.PersistentVolumeClaim
|
||||||
|
snap := getSnapshot(snapshotPath)
|
||||||
|
snap.Name = fmt.Sprintf("%s-%d", snap.Name, i)
|
||||||
|
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, defaultRBDPool)
|
||||||
|
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, defaultRBDPool)
|
||||||
|
|
||||||
|
// create clone PVC
|
||||||
|
pvcClone.Name = fmt.Sprintf("%s-%d", pvcClone.Name, i)
|
||||||
|
pvcClone.Namespace = f.UniqueName
|
||||||
|
pvcClone.Spec.DataSource.Name = snap.Name
|
||||||
|
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, defaultRBDPool)
|
||||||
|
|
||||||
|
// 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, defaultRBDPool)
|
||||||
|
|
||||||
|
app.Spec.Volumes[0].PersistentVolumeClaim.ClaimName = pvcClone.Name
|
||||||
|
// create application
|
||||||
|
err = createApp(f.ClientSet, app, deployTimeout)
|
||||||
|
if err != nil {
|
||||||
|
e2elog.Failf("failed to create application with error %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
pvc = pvcClone
|
||||||
|
}
|
||||||
|
|
||||||
|
err = deletePod(app.Name, app.Namespace, f.ClientSet, deployTimeout)
|
||||||
|
if err != nil {
|
||||||
|
e2elog.Failf("failed to delete application with error %v", err)
|
||||||
|
}
|
||||||
|
// delete PVC clone
|
||||||
|
err = deletePVCAndValidatePV(f.ClientSet, pvc, deployTimeout)
|
||||||
|
if err != nil {
|
||||||
|
e2elog.Failf("failed to delete PVC with error %v", err)
|
||||||
|
}
|
||||||
|
// validate created backend rbd images
|
||||||
|
validateRBDImageCount(f, 0, defaultRBDPool)
|
||||||
|
})
|
||||||
|
|
||||||
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