From 0f626b705ad51b961ae0980f0d1cb50a30c1f927 Mon Sep 17 00:00:00 2001 From: Marcel Lauhoff Date: Wed, 13 Jul 2022 17:59:10 +0200 Subject: [PATCH] e2e: Add helper to run encryption tests on block and file Add a `By` wrapper to parameterize encryption related test functions and run them on both block and file encryption Signed-off-by: Marcel Lauhoff --- e2e/rbd.go | 9 +++++++++ e2e/rbd_helper.go | 2 ++ 2 files changed, 11 insertions(+) diff --git a/e2e/rbd.go b/e2e/rbd.go index 4383d1774..24559c419 100644 --- a/e2e/rbd.go +++ b/e2e/rbd.go @@ -232,6 +232,15 @@ func checkClusternameInMetadata(f *framework.Framework, ns, pool, image string) } } +// ByFileAndBlockEncryption wraps ginkgo's By to run the test body using file and block encryption specific validators. +func ByFileAndBlockEncryption( + text string, + callback func(validator encryptionValidateFunc, encryptionType string), +) { + By(text+" (block)", func() { callback(validateEncryptedPVCAndAppBinding, "block") }) + By(text+" (file)", func() { callback(validateEncryptedFilesystemAndAppBinding, "file") }) +} + var _ = Describe("RBD", func() { f := framework.NewDefaultFramework(rbdType) var c clientset.Interface diff --git a/e2e/rbd_helper.go b/e2e/rbd_helper.go index d55385f78..ec2e0f479 100644 --- a/e2e/rbd_helper.go +++ b/e2e/rbd_helper.go @@ -482,6 +482,8 @@ func validateCloneInDifferentPool(f *framework.Framework, snapshotPool, cloneSc, return nil } +type encryptionValidateFunc func(pvcPath, appPath string, kms kmsConfig, f *framework.Framework) error + func validateEncryptedPVCAndAppBinding(pvcPath, appPath string, kms kmsConfig, f *framework.Framework) error { pvc, app, err := createPVCAndAppBinding(pvcPath, appPath, f, deployTimeout) if err != nil {