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 c677204 commit c3a2790
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 @@ -1840,7 +1840,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 @@ -1913,7 +1914,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 @@ -1958,7 +1960,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 @@ -1990,7 +1993,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 @@ -2043,7 +2047,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 @@ -2081,40 +2086,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 @@ -2288,7 +2294,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 @@ -2320,7 +2327,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 @@ -2379,7 +2387,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 @@ -2442,7 +2451,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 @@ -2479,7 +2489,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 @@ -4036,7 +4047,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 c3a2790

Please sign in to comment.