From d9fb06c50117313c77f9ddaec65c35269e6206a1 Mon Sep 17 00:00:00 2001 From: Parag Kamble Date: Mon, 18 Dec 2023 19:39:36 +0530 Subject: [PATCH] Adding tests automation for BZ 2246388 (#9048) * Adding tests automation for BZ 2246388 Signed-off-by: Parag Kamble * Moved else statement to outerblock Signed-off-by: Parag Kamble --------- Signed-off-by: Parag Kamble --- ocs_ci/helpers/helpers.py | 2 + .../test_storageclass_encryption_option.py | 68 +++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 tests/functional/storageclass/test_storageclass_encryption_option.py diff --git a/ocs_ci/helpers/helpers.py b/ocs_ci/helpers/helpers.py index c0fc2d19381..b74af55fe33 100644 --- a/ocs_ci/helpers/helpers.py +++ b/ocs_ci/helpers/helpers.py @@ -742,6 +742,7 @@ def create_storage_class( sc_data = templating.load_yaml(yamls[interface_type]) if interface_type == constants.CEPHBLOCKPOOL: + sc_data["parameters"]["encrypted"] = "false" interface = constants.RBD_INTERFACE sc_data["provisioner"] = ( provisioner if provisioner else defaults.RBD_PROVISIONER @@ -756,6 +757,7 @@ def create_storage_class( sc_data["parameters"]["encryptionKMSID"] = ( encryption_kms_id if encryption_kms_id else get_encryption_kmsid()[0] ) + elif interface_type == constants.CEPHFILESYSTEM: interface = constants.CEPHFS_INTERFACE sc_data["parameters"]["fsName"] = fs_name if fs_name else get_cephfs_name() diff --git a/tests/functional/storageclass/test_storageclass_encryption_option.py b/tests/functional/storageclass/test_storageclass_encryption_option.py new file mode 100644 index 00000000000..d7ec3873d1c --- /dev/null +++ b/tests/functional/storageclass/test_storageclass_encryption_option.py @@ -0,0 +1,68 @@ +import pytest +import logging +from ocs_ci.ocs import constants +from ocs_ci.framework.pytest_customization.marks import ( + green_squad, + skipif_ocs_version, + tier1, +) + +log = logging.getLogger(__name__) + + +class TestStorageClassEncryptionOptions: + @green_squad + @tier1 + @pytest.mark.bugzilla("2246388") + @skipif_ocs_version("<4.13") + @pytest.mark.polarion_id("OCS-5386") + def test_storageclass_encryption_options( + self, + storageclass_factory, + pvc_factory, + pod_factory, + project_factory, + ): + """ + StorageClass creation test with "encrypted='false'". + Steps: + + 1. Create a StorageClass with the option "encrypted='false'". + 2. Create a PVC that belongs to the previously created StorageClass. + 3. Verify that the StorageClass has the "encrypted='false'" option. + 4. Create a pod and attach the previously created PVC. + 5. Verify that the pod is in the 'Running' state. + """ + + # Create a project + proj_obj = project_factory() + + # Create a storage class with encryption set to false + log.info("Creating a storage class with encryption='false'.") + sc_obj = storageclass_factory(encrypted=False) + + # Verify the storage class encryption option + log.info("Verifying the storage class encryption option.") + assert ( + sc_obj.data["parameters"]["encrypted"] == "false" + ), f"Storageclass {sc_obj.name} does not have encrypted='false' option." + + # Create PVC + log.info("Creating a PVC using the storage class.") + pvc_obj = pvc_factory( + interface=constants.CEPHBLOCKPOOL, + project=proj_obj, + storageclass=sc_obj, + size=5, + status=constants.STATUS_BOUND, + ) + + # Create a POD + log.info("Creating a pod and attaching the PVC.") + pod_obj = pod_factory(pvc=pvc_obj) + + # Verify the pod status + log.info("Verifying the pod status.") + assert ( + pod_obj.data["status"]["phase"] == constants.STATUS_RUNNING + ), f"Pod {pod_obj.name} is not in {constants.STATUS_RUNNING} state."