diff --git a/e2e/rbd.go b/e2e/rbd.go index 71bb1120c..478467432 100644 --- a/e2e/rbd.go +++ b/e2e/rbd.go @@ -1924,6 +1924,106 @@ var _ = Describe("RBD", func() { validateRBDImageCount(f, 0, defaultRBDPool) }) + By("validate PVC Clone 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+") + } + cloneChainDepth := 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) + } + defer func() { + 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 < cloneChainDepth; i++ { + var pvcClone *v1.PersistentVolumeClaim + pvcClone, err = loadPVC(pvcSmartClonePath) + if err != nil { + e2elog.Failf("failed to load PVC with error %v", err) + } + + // create clone PVC + pvcClone.Name = fmt.Sprintf("%s-%d", pvcClone.Name, i) + pvcClone.Namespace = f.UniqueName + pvcClone.Spec.DataSource.Name = pvc.Name + err = createPVCAndvalidatePV(f.ClientSet, pvcClone, deployTimeout) + if err != nil { + e2elog.Failf("failed to create 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) + } + + 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() { updateConfigMap := func(radosNS string) { radosNamespace = radosNS