From cf300970a6cf86836aa0c1043db43e85832cf383 Mon Sep 17 00:00:00 2001 From: Parag Kamble Date: Wed, 22 May 2024 14:41:20 +0530 Subject: [PATCH] Incorporated review comments Signed-off-by: Parag Kamble --- ocs_ci/helpers/keyrotation_helper.py | 22 +++++++++++++++---- .../encryption/test_encryption_keyrotation.py | 2 ++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/ocs_ci/helpers/keyrotation_helper.py b/ocs_ci/helpers/keyrotation_helper.py index 71f046cb9737..4af3f9bdda1c 100644 --- a/ocs_ci/helpers/keyrotation_helper.py +++ b/ocs_ci/helpers/keyrotation_helper.py @@ -100,12 +100,19 @@ def enable_keyrotation(self): self.storagecluster_obj.patch( params=param, format_type="merge", resource_name=self.cluster_name ) - self.storagecluster_obj.wait_for_resource( + resource_status = self.storagecluster_obj.wait_for_resource( constants.STATUS_READY, self.storagecluster_obj.resource_name, column="PHASE", timeout=180, ) + + if not resource_status: + log.info( + f"StorageCluster resource is not reach to state {constants.STATUS_READY}" + ) + return False + self.storagecluster_obj.reload_data() log.info("Keyrotation is enabled in storegeclujster object.") return True @@ -123,12 +130,19 @@ def disable_keyrotation(self): param = '[{"op":"replace","path":"/spec/encryption/keyRotation/enable","value":False}]' self.storagecluster_obj.patch(params=param, format_type="json") - self.storagecluster_obj.wait_for_resource( + resource_status = self.storagecluster_obj.wait_for_resource( constants.STATUS_READY, self.storagecluster_obj.resource_name, column="PHASE", timeout=180, ) + + if not resource_status: + log.info( + f"StorageCluster resource is not reach to state {constants.STATUS_READY}" + ) + return False + self.storagecluster_obj.reload_data() log.info("Keyrotation is Disabled in storagecluster object.") return True @@ -199,7 +213,7 @@ def get_noobaa_backend_secret(self): Retrieves the backend secret for Noobaa. Returns: - str, str: A tuple containing the Noobaa backend root key and secret. + tuple (str, str): containing the Noobaa backend root key and secret. Raises: ValueError: If failed to retrieve the backend secret. @@ -219,7 +233,7 @@ def get_noobaa_volume_secret(self): Retrieves the volume secret for Noobaa. Returns: - str, str: A tuple containing the Noobaa volume root key and secret. + tuple (str, str): containing the Noobaa volume root key and secret. Raises: ValueError: If failed to retrieve the volume secret. diff --git a/tests/functional/encryption/test_encryption_keyrotation.py b/tests/functional/encryption/test_encryption_keyrotation.py index 37b825fde348..804617e71350 100644 --- a/tests/functional/encryption/test_encryption_keyrotation.py +++ b/tests/functional/encryption/test_encryption_keyrotation.py @@ -38,6 +38,7 @@ def finalizer(): request.addfinalizer(finalizer) + @pytest.mark.polarion_id("OCS-5790") def test_osd_keyrotation(self): """ Test to verify the key rotation of the OSD @@ -123,6 +124,7 @@ def compare_old_with_new_keys(): log.info("Changing the keyrotation value to default.") osd_keyrotation.set_keyrotation_schedule("@weekly") + @pytest.mark.polarion_id("OCS-5791") def test_noobaa_keyrotation(self): """ Test to verify the keyrotation for noobaa.