e2e: testcase for pvc-pvc clone with different SC & encryption

Signed-off-by: Rakshith R <rar@redhat.com>
(cherry picked from commit badcac38d3)
This commit is contained in:
Rakshith R 2022-04-26 12:08:49 +05:30 committed by mergify[bot]
parent 584c87ce34
commit fe22a44540
2 changed files with 70 additions and 0 deletions

View File

@ -632,6 +632,7 @@ var _ = Describe("RBD", func() {
appPath, appPath,
pvcSmartClonePath, pvcSmartClonePath,
appSmartClonePath, appSmartClonePath,
defaultSCName,
erasureCodedPool, erasureCodedPool,
noKMS, noKMS,
noPVCValidation, noPVCValidation,
@ -1857,6 +1858,7 @@ var _ = Describe("RBD", func() {
appPath, appPath,
pvcSmartClonePath, pvcSmartClonePath,
appSmartClonePath, appSmartClonePath,
defaultSCName,
noDataPool, noDataPool,
noKMS, noKMS,
noPVCValidation, noPVCValidation,
@ -1947,6 +1949,66 @@ var _ = Describe("RBD", func() {
} }
}) })
By("Validate PVC-PVC clone with different SC from vaultKMS to vaultTenantSAKMS", func() {
restoreSCName := "restore-sc"
err := deleteResource(rbdExamplePath + "storageclass.yaml")
if err != nil {
e2elog.Failf("failed to delete storageclass: %v", err)
}
scOpts := map[string]string{
"encrypted": "true",
"encryptionKMSID": "vault-test",
}
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, scOpts, deletePolicy)
if err != nil {
e2elog.Failf("failed to create storageclass: %v", err)
}
scOpts = map[string]string{
"encrypted": "true",
"encryptionKMSID": "vault-tenant-sa-test",
}
err = createRBDStorageClass(f.ClientSet, f, restoreSCName, nil, scOpts, deletePolicy)
if err != nil {
e2elog.Failf("failed to create storageclass: %v", err)
}
err = createTenantServiceAccount(f.ClientSet, f.UniqueName)
if err != nil {
e2elog.Failf("failed to create ServiceAccount: %v", err)
}
defer deleteTenantServiceAccount(f.UniqueName)
validatePVCClone(1,
pvcPath,
appPath,
pvcSmartClonePath,
appSmartClonePath,
restoreSCName,
noDataPool,
secretsMetadataKMS,
isEncryptedPVC,
f)
err = retryKubectlArgs(cephCSINamespace, kubectlDelete, deployTimeout, "storageclass", restoreSCName)
if err != nil {
e2elog.Failf("failed to delete storageclass %q: %v", restoreSCName, err)
}
err = deleteResource(rbdExamplePath + "storageclass.yaml")
if err != nil {
e2elog.Failf("failed to delete storageclass: %v", err)
}
// validate created backend rbd images
validateRBDImageCount(f, 0, defaultRBDPool)
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, nil, deletePolicy)
if err != nil {
e2elog.Failf("failed to create storageclass: %v", err)
}
})
By("create an encrypted PVC-PVC clone and bind it to an app", func() { By("create an encrypted PVC-PVC clone and bind it to an app", func() {
err := deleteResource(rbdExamplePath + "storageclass.yaml") err := deleteResource(rbdExamplePath + "storageclass.yaml")
if err != nil { if err != nil {
@ -1966,6 +2028,7 @@ var _ = Describe("RBD", func() {
appPath, appPath,
pvcSmartClonePath, pvcSmartClonePath,
appSmartClonePath, appSmartClonePath,
defaultSCName,
noDataPool, noDataPool,
secretsMetadataKMS, secretsMetadataKMS,
isEncryptedPVC, isEncryptedPVC,
@ -2000,6 +2063,7 @@ var _ = Describe("RBD", func() {
appPath, appPath,
pvcSmartClonePath, pvcSmartClonePath,
appSmartClonePath, appSmartClonePath,
defaultSCName,
noDataPool, noDataPool,
vaultKMS, vaultKMS,
isEncryptedPVC, isEncryptedPVC,
@ -2032,6 +2096,7 @@ var _ = Describe("RBD", func() {
rawAppPath, rawAppPath,
pvcBlockSmartClonePath, pvcBlockSmartClonePath,
appBlockSmartClonePath, appBlockSmartClonePath,
defaultSCName,
noDataPool, noDataPool,
noKMS, noKMS,
noPVCValidation, noPVCValidation,

View File

@ -633,6 +633,7 @@ func writeDataAndCalChecksum(app *v1.Pod, opt *metav1.ListOptions, f *framework.
func validatePVCClone( func validatePVCClone(
totalCount int, totalCount int,
sourcePvcPath, sourceAppPath, clonePvcPath, clonePvcAppPath, sourcePvcPath, sourceAppPath, clonePvcPath, clonePvcAppPath,
restoreSCName,
dataPool string, dataPool string,
kms kmsConfig, kms kmsConfig,
validatePVC validateFunc, validatePVC validateFunc,
@ -684,6 +685,10 @@ func validatePVCClone(
} }
pvcClone.Spec.DataSource.Name = pvc.Name pvcClone.Spec.DataSource.Name = pvc.Name
pvcClone.Namespace = f.UniqueName pvcClone.Namespace = f.UniqueName
if restoreSCName != "" {
pvcClone.Spec.StorageClassName = &restoreSCName
}
appClone, err := loadApp(clonePvcAppPath) appClone, err := loadApp(clonePvcAppPath)
if err != nil { if err != nil {
e2elog.Failf("failed to load application: %v", err) e2elog.Failf("failed to load application: %v", err)