Skip to content

Commit

Permalink
Adding tests automation for BZ 2246388 (#9048)
Browse files Browse the repository at this point in the history
* Adding tests automation for BZ 2246388

Signed-off-by: Parag Kamble <[email protected]>

* Moved else statement to outerblock

Signed-off-by: Parag Kamble <[email protected]>

---------

Signed-off-by: Parag Kamble <[email protected]>
  • Loading branch information
paraggit authored Dec 18, 2023
1 parent 1a2a96c commit d9fb06c
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ocs_ci/helpers/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
@@ -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."

0 comments on commit d9fb06c

Please sign in to comment.