Skip to content

Commit

Permalink
e2e: Apply formatting to rbd suite and helper
Browse files Browse the repository at this point in the history
Apply formatting for previous changes separately to make the commit
diffs easier to read.

Signed-off-by: Marcel Lauhoff <marcel.lauhoff@suse.com>
  • Loading branch information
Marcel Lauhoff committed Aug 24, 2022
1 parent 3ac02be commit 2a1a995
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 44 deletions.
98 changes: 55 additions & 43 deletions e2e/rbd.go
Original file line number Diff line number Diff line change
Expand Up @@ -1850,7 +1850,8 @@ var _ = Describe("RBD", func() {
})

ByFileAndBlockEncryption("create a PVC and bind it to an app using rbd-nbd mounter with encryption", func(
validator encryptionValidateFunc, _ validateFunc, encryptionType string) {
validator encryptionValidateFunc, _ validateFunc, encryptionType string,
) {
err := deleteResource(rbdExamplePath + "storageclass.yaml")
if err != nil {
e2elog.Failf("failed to delete storageclass: %v", err)
Expand Down Expand Up @@ -1923,7 +1924,8 @@ var _ = Describe("RBD", func() {
})

ByFileAndBlockEncryption("Resize Encrypted Block PVC and check Device size", func(
validator encryptionValidateFunc, _ validateFunc, encType string) {
validator encryptionValidateFunc, _ validateFunc, encType string,
) {
err := deleteResource(rbdExamplePath + "storageclass.yaml")
if err != nil {
e2elog.Failf("failed to delete storageclass: %v", err)
Expand Down Expand Up @@ -1968,7 +1970,8 @@ var _ = Describe("RBD", func() {
})

ByFileAndBlockEncryption("create a PVC and bind it to an app with encrypted RBD volume with VaultKMS", func(
validator encryptionValidateFunc, _ validateFunc, encType string) {
validator encryptionValidateFunc, _ validateFunc, encType string,
) {
err := deleteResource(rbdExamplePath + "storageclass.yaml")
if err != nil {
e2elog.Failf("failed to delete storageclass: %v", err)
Expand Down Expand Up @@ -2000,7 +2003,8 @@ var _ = Describe("RBD", func() {
})

ByFileAndBlockEncryption("create a PVC and bind it to an app with encrypted RBD volume with VaultTokensKMS", func(
validator encryptionValidateFunc, _ validateFunc, encType string) {
validator encryptionValidateFunc, _ validateFunc, encType string,
) {
err := deleteResource(rbdExamplePath + "storageclass.yaml")
if err != nil {
e2elog.Failf("failed to delete storageclass: %v", err)
Expand Down Expand Up @@ -2053,7 +2057,8 @@ var _ = Describe("RBD", func() {
})

ByFileAndBlockEncryption("create a PVC and bind it to an app with encrypted RBD volume with VaultTenantSA KMS", func(
validator encryptionValidateFunc, _ validateFunc, encType string) {
validator encryptionValidateFunc, _ validateFunc, encType string,
) {
err := deleteResource(rbdExamplePath + "storageclass.yaml")
if err != nil {
e2elog.Failf("failed to delete storageclass: %v", err)
Expand Down Expand Up @@ -2091,40 +2096,41 @@ var _ = Describe("RBD", func() {
}
})

ByFileAndBlockEncryption("create a PVC and bind it to an app with encrypted RBD volume with SecretsMetadataKMS", func(
validator encryptionValidateFunc, _ validateFunc, encType string) {
err := deleteResource(rbdExamplePath + "storageclass.yaml")
if err != nil {
e2elog.Failf("failed to delete storageclass: %v", err)
}
scOpts := map[string]string{
"encrypted": "true",
"encryptionKMSID": "secrets-metadata-test",
"encryptionType": encType,
}
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, scOpts, deletePolicy)
if err != nil {
e2elog.Failf("failed to create storageclass: %v", err)
}
err = validator(pvcPath, appPath, noKMS, f)
if err != nil {
e2elog.Failf("failed to validate encrypted pvc: %v", err)
}
// validate created backend rbd images
validateRBDImageCount(f, 0, defaultRBDPool)
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
err = deleteResource(rbdExamplePath + "storageclass.yaml")
if err != nil {
e2elog.Failf("failed to delete storageclass: %v", err)
}
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, nil, deletePolicy)
if err != nil {
e2elog.Failf("failed to create storageclass: %v", err)
}
})
ByFileAndBlockEncryption("create a PVC and bind it to an app with encrypted RBD volume with SecretsMetadataKMS",
func(validator encryptionValidateFunc, _ validateFunc, encType string) {
err := deleteResource(rbdExamplePath + "storageclass.yaml")
if err != nil {
e2elog.Failf("failed to delete storageclass: %v", err)
}
scOpts := map[string]string{
"encrypted": "true",
"encryptionKMSID": "secrets-metadata-test",
"encryptionType": encType,
}
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, scOpts, deletePolicy)
if err != nil {
e2elog.Failf("failed to create storageclass: %v", err)
}
err = validator(pvcPath, appPath, noKMS, f)
if err != nil {
e2elog.Failf("failed to validate encrypted pvc: %v", err)
}
// validate created backend rbd images
validateRBDImageCount(f, 0, defaultRBDPool)
validateOmapCount(f, 0, rbdType, defaultRBDPool, volumesType)
err = deleteResource(rbdExamplePath + "storageclass.yaml")
if err != nil {
e2elog.Failf("failed to delete storageclass: %v", err)
}
err = createRBDStorageClass(f.ClientSet, f, defaultSCName, nil, nil, deletePolicy)
if err != nil {
e2elog.Failf("failed to create storageclass: %v", err)
}
})

ByFileAndBlockEncryption("test RBD volume encryption with user secrets based SecretsMetadataKMS", func(
validator encryptionValidateFunc, _ validateFunc, encType string) {
validator encryptionValidateFunc, _ validateFunc, encType string,
) {
err := deleteResource(rbdExamplePath + "storageclass.yaml")
if err != nil {
e2elog.Failf("failed to delete storageclass: %v", err)
Expand Down Expand Up @@ -2298,7 +2304,8 @@ var _ = Describe("RBD", func() {
})

ByFileAndBlockEncryption("create an encrypted PVC snapshot and restore it for an app with VaultKMS", func(
validator encryptionValidateFunc, isEncryptedPVC validateFunc, encType string) {
validator encryptionValidateFunc, isEncryptedPVC validateFunc, encType string,
) {
err := deleteResource(rbdExamplePath + "storageclass.yaml")
if err != nil {
e2elog.Failf("failed to delete storageclass: %v", err)
Expand Down Expand Up @@ -2330,7 +2337,8 @@ var _ = Describe("RBD", func() {
})

ByFileAndBlockEncryption("Validate PVC restore from vaultKMS to vaultTenantSAKMS", func(
validator encryptionValidateFunc, isEncryptedPVC validateFunc, encType string) {
validator encryptionValidateFunc, isEncryptedPVC validateFunc, encType string,
) {
restoreSCName := "restore-sc"
err := deleteResource(rbdExamplePath + "storageclass.yaml")
if err != nil {
Expand Down Expand Up @@ -2389,7 +2397,8 @@ var _ = Describe("RBD", func() {
})

ByFileAndBlockEncryption("Validate PVC-PVC clone with different SC from vaultKMS to vaultTenantSAKMS", func(
validator encryptionValidateFunc, isValidPVC validateFunc, encType string) {
validator encryptionValidateFunc, isValidPVC validateFunc, encType string,
) {
restoreSCName := "restore-sc"
err := deleteResource(rbdExamplePath + "storageclass.yaml")
if err != nil {
Expand Down Expand Up @@ -2452,7 +2461,8 @@ var _ = Describe("RBD", func() {
})

ByFileAndBlockEncryption("create an encrypted PVC-PVC clone and bind it to an app", func(
validator encryptionValidateFunc, isValidPVC validateFunc, encType string) {
validator encryptionValidateFunc, isValidPVC validateFunc, encType string,
) {
err := deleteResource(rbdExamplePath + "storageclass.yaml")
if err != nil {
e2elog.Failf("failed to delete storageclass: %v", err)
Expand Down Expand Up @@ -2489,7 +2499,8 @@ var _ = Describe("RBD", func() {
})

ByFileAndBlockEncryption("create an encrypted PVC-PVC clone and bind it to an app with VaultKMS", func(
validator encryptionValidateFunc, isValidPVC validateFunc, encType string) {
validator encryptionValidateFunc, isValidPVC validateFunc, encType string,
) {
err := deleteResource(rbdExamplePath + "storageclass.yaml")
if err != nil {
e2elog.Failf("failed to delete storageclass: %v", err)
Expand Down Expand Up @@ -4046,7 +4057,8 @@ var _ = Describe("RBD", func() {

By("clone PVC to a bigger size PVC", func() {
ByFileAndBlockEncryption("clone PVC to bigger size encrypted PVC with VaultKMS", func(
validator encryptionValidateFunc, _ validateFunc, encType string) {
validator encryptionValidateFunc, _ validateFunc, encType string,
) {
scOpts := map[string]string{
"encrypted": "true",
"encryptionType": encType,
Expand Down
8 changes: 7 additions & 1 deletion e2e/rbd_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,12 @@ var noPVCValidation validateFunc

type imageValidateFunc func(f *framework.Framework, rbdImageSpec, pvName, appName string) error

func isEncryptedPVC(f *framework.Framework, pvc *v1.PersistentVolumeClaim, app *v1.Pod, validateFunc imageValidateFunc) error {
func isEncryptedPVC(
f *framework.Framework,
pvc *v1.PersistentVolumeClaim,
app *v1.Pod,
validateFunc imageValidateFunc,
) error {
imageData, err := getImageInfoFromPVC(pvc.Namespace, pvc.Name, f)
if err != nil {
return err
Expand Down Expand Up @@ -670,6 +675,7 @@ func validateEncryptedFilesystem(f *framework.Framework, rbdImageSpec, pvName, a
return fmt.Errorf("error checking file encrypted attribute of %q. listing filesystem+attrs: %s %s",
volumeMountPath, stdOut, stdErr)
}

return fmt.Errorf("error checking file encrypted attribute: %w", err)
}

Expand Down

0 comments on commit 2a1a995

Please sign in to comment.