From 85b9f616e1e9cf2778ae87e0bf0631fadd2bfd6e Mon Sep 17 00:00:00 2001 From: Parag Kamble Date: Thu, 18 Jan 2024 07:19:57 +0530 Subject: [PATCH 1/5] replacing crypt device check from pod to node. Signed-off-by: Parag Kamble --- ocs_ci/ocs/node.py | 19 +++++++++++++++++++ .../test_encrypted_rbd_pvc_clone.py | 18 ++++++++---------- .../test_encrypted_rbd_pvc_snapshot.py | 18 +++++++----------- .../test_kmip_rbd_pv_encryption.py | 14 ++++++++------ .../pv_encryption/test_rbd_pv_encryption.py | 13 +++++++------ .../test_rbd_pv_encryption_vaulttenantsa.py | 9 ++++----- tests/ui/test_pv_encryption_ui.py | 13 +++++++------ 7 files changed, 60 insertions(+), 44 deletions(-) diff --git a/ocs_ci/ocs/node.py b/ocs_ci/ocs/node.py index 8ba1d4aab8c..a3e2f3d5060 100644 --- a/ocs_ci/ocs/node.py +++ b/ocs_ci/ocs/node.py @@ -2784,3 +2784,22 @@ def is_node_rack_or_zone_exist(failure_domain, node_name): """ node_obj = get_node_objs([node_name])[0] return get_node_rack_or_zone(failure_domain, node_obj) is not None + + +def list_encrypted_rbd_devices_onnode(node): + """ + Get rbd crypt devices from the node + + Args: + node: node name + + Returns: + List of encrypted osd device names + """ + node_obj = OCP(kind="node") + crypt_devices_out = node_obj.exec_oc_debug_cmd( + node=node, + cmd_list=["lsblk | grep crypt | awk '{print $1}'"], + ).split("\n") + crypt_devices = [device.strip() for device in crypt_devices_out if device != ""] + return crypt_devices diff --git a/tests/manage/pv_services/pv_encryption/test_encrypted_rbd_pvc_clone.py b/tests/manage/pv_services/pv_encryption/test_encrypted_rbd_pvc_clone.py index a367ea0afe9..bd09e6d596d 100644 --- a/tests/manage/pv_services/pv_encryption/test_encrypted_rbd_pvc_clone.py +++ b/tests/manage/pv_services/pv_encryption/test_encrypted_rbd_pvc_clone.py @@ -23,6 +23,7 @@ ) from ocs_ci.utility import kms from semantic_version import Version +from ocs_ci.ocs.node import list_encrypted_rbd_devices_onnode log = logging.getLogger(__name__) @@ -160,14 +161,13 @@ def test_pvc_to_pvc_clone(self, kv_version, kms_provider, pod_factory): log.info("Checking for encrypted device and running IO on all pods") for vol_handle, pod_obj in zip(self.vol_handles, self.pod_objs): - if pod_obj.exec_sh_cmd_on_pod( - command=f"lsblk | grep {vol_handle} | grep crypt" - ): - log.info(f"Encrypted device found in {pod_obj.name}") - else: + rbd_devices = list_encrypted_rbd_devices_onnode(pod_obj.get_node()) + crypt_device = [device for device in rbd_devices if vol_handle in device] + if not crypt_device: raise ResourceNotFoundError( f"Encrypted device not found in {pod_obj.name}" ) + log.info(f"File created during IO {pod_obj.name}") pod_obj.run_io( storage_type="block", @@ -242,11 +242,9 @@ def test_pvc_to_pvc_clone(self, kv_version, kms_provider, pod_factory): ) # Verify encrypted device is present and md5sum on all pods for vol_handle, pod_obj in zip(cloned_vol_handles, cloned_pod_objs): - if pod_obj.exec_sh_cmd_on_pod( - command=f"lsblk | grep {vol_handle} | grep crypt" - ): - log.info(f"Encrypted device found in {pod_obj.name}") - else: + rbd_devices = list_encrypted_rbd_devices_onnode(pod_obj.get_node()) + crypt_device = [device for device in rbd_devices if vol_handle in device] + if not crypt_device: raise ResourceNotFoundError( f"Encrypted device not found in {pod_obj.name}" ) diff --git a/tests/manage/pv_services/pv_encryption/test_encrypted_rbd_pvc_snapshot.py b/tests/manage/pv_services/pv_encryption/test_encrypted_rbd_pvc_snapshot.py index 44787dfaac9..c83f8db0af4 100644 --- a/tests/manage/pv_services/pv_encryption/test_encrypted_rbd_pvc_snapshot.py +++ b/tests/manage/pv_services/pv_encryption/test_encrypted_rbd_pvc_snapshot.py @@ -25,6 +25,7 @@ ) from ocs_ci.utility import kms from semantic_version import Version +from ocs_ci.ocs.node import list_encrypted_rbd_devices_onnode log = logging.getLogger(__name__) @@ -169,12 +170,9 @@ def test_encrypted_rbd_block_pvc_snapshot( ) for vol_handle, pod_obj in zip(self.vol_handles, self.pod_objs): - # Verify whether encrypted device is present inside the pod - if pod_obj.exec_sh_cmd_on_pod( - command=f"lsblk | grep {vol_handle} | grep crypt" - ): - log.info(f"Encrypted device found in {pod_obj.name}") - else: + rbd_devices = list_encrypted_rbd_devices_onnode(pod_obj.get_node()) + crypt_device = [device for device in rbd_devices if vol_handle in device] + if not crypt_device: raise ResourceNotFoundError( f"Encrypted device not found in {pod_obj.name}" ) @@ -329,11 +327,9 @@ def test_encrypted_rbd_block_pvc_snapshot( # Verify encrypted device is present and md5sum on all pods for vol_handle, pod_obj in zip(restore_vol_handles, restore_pod_objs): - if pod_obj.exec_sh_cmd_on_pod( - command=f"lsblk | grep {vol_handle} | grep crypt" - ): - log.info(f"Encrypted device found in {pod_obj.name}") - else: + rbd_devices = list_encrypted_rbd_devices_onnode(pod_obj.get_node()) + crypt_device = [device for device in rbd_devices if vol_handle in device] + if not crypt_device: raise ResourceNotFoundError( f"Encrypted device not found in {pod_obj.name}" ) diff --git a/tests/manage/pv_services/pv_encryption/test_kmip_rbd_pv_encryption.py b/tests/manage/pv_services/pv_encryption/test_kmip_rbd_pv_encryption.py index bb481c4e67c..3e635fefbdc 100644 --- a/tests/manage/pv_services/pv_encryption/test_kmip_rbd_pv_encryption.py +++ b/tests/manage/pv_services/pv_encryption/test_kmip_rbd_pv_encryption.py @@ -16,6 +16,8 @@ create_pods, ) from ocs_ci.ocs import constants +from ocs_ci.ocs.node import list_encrypted_rbd_devices_onnode +from ocs_ci.ocs.exceptions import ResourceNotFoundError log = logging.getLogger(__name__) @@ -101,12 +103,12 @@ def test_rbd_pv_encryption_kmip( # Verify whether encrypted device is present inside the pod and run IO for vol_handle, pod_obj in zip(vol_handles, pod_objs): - if pod_obj.exec_sh_cmd_on_pod( - command=f"lsblk | grep {vol_handle} | grep crypt" - ): - log.info(f"Encrypted device found in {pod_obj.name}") - else: - log.error(f"Encrypted device not found in {pod_obj.name}") + rbd_devices = list_encrypted_rbd_devices_onnode(pod_obj.get_node()) + crypt_device = [device for device in rbd_devices if vol_handle in device] + if not crypt_device: + raise ResourceNotFoundError( + f"Encrypted device not found in {pod_obj.name}" + ) pod_obj.run_io( storage_type="block", diff --git a/tests/manage/pv_services/pv_encryption/test_rbd_pv_encryption.py b/tests/manage/pv_services/pv_encryption/test_rbd_pv_encryption.py index 53d9935d9ef..0b9c4cd3686 100644 --- a/tests/manage/pv_services/pv_encryption/test_rbd_pv_encryption.py +++ b/tests/manage/pv_services/pv_encryption/test_rbd_pv_encryption.py @@ -21,6 +21,7 @@ ) from ocs_ci.utility import kms from semantic_version import Version +from ocs_ci.ocs.node import list_encrypted_rbd_devices_onnode log = logging.getLogger(__name__) @@ -159,12 +160,12 @@ def test_rbd_pv_encryption( # Verify whether encrypted device is present inside the pod and run IO for vol_handle, pod_obj in zip(vol_handles, pod_objs): - if pod_obj.exec_sh_cmd_on_pod( - command=f"lsblk | grep {vol_handle} | grep crypt" - ): - log.info(f"Encrypted device found in {pod_obj.name}") - else: - log.error(f"Encrypted device not found in {pod_obj.name}") + rbd_devices = list_encrypted_rbd_devices_onnode(pod_obj.get_node()) + crypt_device = [device for device in rbd_devices if vol_handle in device] + if not crypt_device: + raise ResourceNotFoundError( + f"Encrypted device not found in {pod_obj.name}" + ) pod_obj.run_io( storage_type="block", diff --git a/tests/manage/pv_services/pv_encryption/test_rbd_pv_encryption_vaulttenantsa.py b/tests/manage/pv_services/pv_encryption/test_rbd_pv_encryption_vaulttenantsa.py index 38fe089327d..2fcbdf2cddd 100644 --- a/tests/manage/pv_services/pv_encryption/test_rbd_pv_encryption_vaulttenantsa.py +++ b/tests/manage/pv_services/pv_encryption/test_rbd_pv_encryption_vaulttenantsa.py @@ -21,6 +21,7 @@ ResourceNotFoundError, ) from ocs_ci.utility import kms +from ocs_ci.ocs.node import list_encrypted_rbd_devices_onnode log = logging.getLogger(__name__) @@ -146,11 +147,9 @@ def test_rbd_pv_encryption_vaulttenantsa( # Verify whether encrypted device is present inside the pod and run IO for vol_handle, pod_obj in zip(vol_handles, pod_objs): - if pod_obj.exec_sh_cmd_on_pod( - command=f"lsblk | grep {vol_handle} | grep crypt" - ): - log.info(f"Encrypted device found in {pod_obj.name}") - else: + rbd_devices = list_encrypted_rbd_devices_onnode(pod_obj.get_node()) + crypt_device = [device for device in rbd_devices if vol_handle in device] + if not crypt_device: raise ResourceNotFoundError( f"Encrypted device not found in {pod_obj.name}" ) diff --git a/tests/ui/test_pv_encryption_ui.py b/tests/ui/test_pv_encryption_ui.py index e34d10cff99..033e68b1a91 100644 --- a/tests/ui/test_pv_encryption_ui.py +++ b/tests/ui/test_pv_encryption_ui.py @@ -29,6 +29,7 @@ from ocs_ci.utility.utils import get_vault_cli, get_ocp_version from ocs_ci.ocs import constants from ocs_ci.utility import version +from ocs_ci.ocs.node import list_encrypted_rbd_devices_onnode logger = logging.getLogger(__name__) @@ -225,12 +226,12 @@ def test_for_encrypted_pv_ui( "Verify whether encrypted device is present inside the pod and run IO" ) for vol_handle, pod_obj in zip(vol_handles, pod_objs): - if pod_obj.exec_sh_cmd_on_pod( - command=f"lsblk | grep {vol_handle} | grep crypt" - ): - logger.info(f"Encrypted device found in {pod_obj.name}") - else: - logger.error(f"Encrypted device not found in {pod_obj.name}") + rbd_devices = list_encrypted_rbd_devices_onnode(pod_obj.get_node()) + crypt_device = [device for device in rbd_devices if vol_handle in device] + if not crypt_device: + raise ResourceNotFoundError( + f"Encrypted device not found in {pod_obj.name}" + ) logger.info(f"Running FIO on Pod '{pod_obj.name}'") pod_obj.run_io( From ee41bc85a6398277708e4a75adde15ac3dfa9376 Mon Sep 17 00:00:00 2001 From: Parag Kamble Date: Thu, 18 Jan 2024 15:29:07 +0530 Subject: [PATCH 2/5] Incorporated review comments Signed-off-by: Parag Kamble --- ocs_ci/ocs/node.py | 20 +++++++++++++++++ .../test_encrypted_rbd_pvc_clone.py | 22 ++++++++----------- .../test_encrypted_rbd_pvc_snapshot.py | 22 ++++++++----------- .../test_kmip_rbd_pv_encryption.py | 13 +++++------ .../pv_encryption/test_rbd_pv_encryption.py | 12 +++++----- .../test_rbd_pv_encryption_vaulttenantsa.py | 12 +++++----- tests/ui/test_pv_encryption_ui.py | 12 +++++----- 7 files changed, 58 insertions(+), 55 deletions(-) diff --git a/ocs_ci/ocs/node.py b/ocs_ci/ocs/node.py index a3e2f3d5060..f5d4765f9b4 100644 --- a/ocs_ci/ocs/node.py +++ b/ocs_ci/ocs/node.py @@ -2803,3 +2803,23 @@ def list_encrypted_rbd_devices_onnode(node): ).split("\n") crypt_devices = [device.strip() for device in crypt_devices_out if device != ""] return crypt_devices + + +def verify_crypt_device_present_onnode(node, vol_handle): + """ + Find the crypt device maching for given volume handle. + + Args: + node : node name + vol_handle : volumen handle name. + """ + device_list = list_encrypted_rbd_devices_onnode(node) + crypt_device = [device for device in device_list if vol_handle in device] + if not crypt_device: + log.error( + f"crypt device for volume handle {vol_handle} not present on node : {node}" + ) + return False + + log.info(f"Crypt device for volume handle {vol_handle} present on the node: {node}") + return True diff --git a/tests/manage/pv_services/pv_encryption/test_encrypted_rbd_pvc_clone.py b/tests/manage/pv_services/pv_encryption/test_encrypted_rbd_pvc_clone.py index bd09e6d596d..e1b557292ea 100644 --- a/tests/manage/pv_services/pv_encryption/test_encrypted_rbd_pvc_clone.py +++ b/tests/manage/pv_services/pv_encryption/test_encrypted_rbd_pvc_clone.py @@ -23,7 +23,7 @@ ) from ocs_ci.utility import kms from semantic_version import Version -from ocs_ci.ocs.node import list_encrypted_rbd_devices_onnode +from ocs_ci.ocs.node import verify_crypt_device_present_onnode log = logging.getLogger(__name__) @@ -161,12 +161,10 @@ def test_pvc_to_pvc_clone(self, kv_version, kms_provider, pod_factory): log.info("Checking for encrypted device and running IO on all pods") for vol_handle, pod_obj in zip(self.vol_handles, self.pod_objs): - rbd_devices = list_encrypted_rbd_devices_onnode(pod_obj.get_node()) - crypt_device = [device for device in rbd_devices if vol_handle in device] - if not crypt_device: - raise ResourceNotFoundError( - f"Encrypted device not found in {pod_obj.name}" - ) + node = pod_obj.get_node() + assert verify_crypt_device_present_onnode( + node, vol_handle + ), f"Crypt devicve {vol_handle} not found on node:{node}" log.info(f"File created during IO {pod_obj.name}") pod_obj.run_io( @@ -242,12 +240,10 @@ def test_pvc_to_pvc_clone(self, kv_version, kms_provider, pod_factory): ) # Verify encrypted device is present and md5sum on all pods for vol_handle, pod_obj in zip(cloned_vol_handles, cloned_pod_objs): - rbd_devices = list_encrypted_rbd_devices_onnode(pod_obj.get_node()) - crypt_device = [device for device in rbd_devices if vol_handle in device] - if not crypt_device: - raise ResourceNotFoundError( - f"Encrypted device not found in {pod_obj.name}" - ) + node = pod_obj.get_node() + assert verify_crypt_device_present_onnode( + node, vol_handle + ), f"Crypt devicve {vol_handle} not found on node:{node}" log.info(f"Verifying md5sum on pod {pod_obj.name}") pod.verify_data_integrity( diff --git a/tests/manage/pv_services/pv_encryption/test_encrypted_rbd_pvc_snapshot.py b/tests/manage/pv_services/pv_encryption/test_encrypted_rbd_pvc_snapshot.py index c83f8db0af4..5ccfe3ac782 100644 --- a/tests/manage/pv_services/pv_encryption/test_encrypted_rbd_pvc_snapshot.py +++ b/tests/manage/pv_services/pv_encryption/test_encrypted_rbd_pvc_snapshot.py @@ -25,7 +25,7 @@ ) from ocs_ci.utility import kms from semantic_version import Version -from ocs_ci.ocs.node import list_encrypted_rbd_devices_onnode +from ocs_ci.ocs.node import verify_crypt_device_present_onnode log = logging.getLogger(__name__) @@ -170,12 +170,10 @@ def test_encrypted_rbd_block_pvc_snapshot( ) for vol_handle, pod_obj in zip(self.vol_handles, self.pod_objs): - rbd_devices = list_encrypted_rbd_devices_onnode(pod_obj.get_node()) - crypt_device = [device for device in rbd_devices if vol_handle in device] - if not crypt_device: - raise ResourceNotFoundError( - f"Encrypted device not found in {pod_obj.name}" - ) + node = pod_obj.get_node() + assert verify_crypt_device_present_onnode( + node, vol_handle + ), f"Crypt devicve {vol_handle} not found on node:{node}" # Find initial md5sum pod_obj.md5sum_before_io = cal_md5sum( @@ -327,12 +325,10 @@ def test_encrypted_rbd_block_pvc_snapshot( # Verify encrypted device is present and md5sum on all pods for vol_handle, pod_obj in zip(restore_vol_handles, restore_pod_objs): - rbd_devices = list_encrypted_rbd_devices_onnode(pod_obj.get_node()) - crypt_device = [device for device in rbd_devices if vol_handle in device] - if not crypt_device: - raise ResourceNotFoundError( - f"Encrypted device not found in {pod_obj.name}" - ) + node = pod_obj.get_node() + assert verify_crypt_device_present_onnode( + node, vol_handle + ), f"Crypt devicve {vol_handle} not found on node:{node}" log.info(f"Verifying md5sum on pod {pod_obj.name}") verify_data_integrity( diff --git a/tests/manage/pv_services/pv_encryption/test_kmip_rbd_pv_encryption.py b/tests/manage/pv_services/pv_encryption/test_kmip_rbd_pv_encryption.py index 3e635fefbdc..81dcbef0495 100644 --- a/tests/manage/pv_services/pv_encryption/test_kmip_rbd_pv_encryption.py +++ b/tests/manage/pv_services/pv_encryption/test_kmip_rbd_pv_encryption.py @@ -16,8 +16,7 @@ create_pods, ) from ocs_ci.ocs import constants -from ocs_ci.ocs.node import list_encrypted_rbd_devices_onnode -from ocs_ci.ocs.exceptions import ResourceNotFoundError +from ocs_ci.ocs.node import verify_crypt_device_present_onnode log = logging.getLogger(__name__) @@ -103,12 +102,10 @@ def test_rbd_pv_encryption_kmip( # Verify whether encrypted device is present inside the pod and run IO for vol_handle, pod_obj in zip(vol_handles, pod_objs): - rbd_devices = list_encrypted_rbd_devices_onnode(pod_obj.get_node()) - crypt_device = [device for device in rbd_devices if vol_handle in device] - if not crypt_device: - raise ResourceNotFoundError( - f"Encrypted device not found in {pod_obj.name}" - ) + node = pod_obj.get_node() + assert verify_crypt_device_present_onnode( + node, vol_handle + ), f"Crypt devicve {vol_handle} not found on node:{node}" pod_obj.run_io( storage_type="block", diff --git a/tests/manage/pv_services/pv_encryption/test_rbd_pv_encryption.py b/tests/manage/pv_services/pv_encryption/test_rbd_pv_encryption.py index 0b9c4cd3686..765a60a9d16 100644 --- a/tests/manage/pv_services/pv_encryption/test_rbd_pv_encryption.py +++ b/tests/manage/pv_services/pv_encryption/test_rbd_pv_encryption.py @@ -21,7 +21,7 @@ ) from ocs_ci.utility import kms from semantic_version import Version -from ocs_ci.ocs.node import list_encrypted_rbd_devices_onnode +from ocs_ci.ocs.node import verify_crypt_device_present_onnode log = logging.getLogger(__name__) @@ -160,12 +160,10 @@ def test_rbd_pv_encryption( # Verify whether encrypted device is present inside the pod and run IO for vol_handle, pod_obj in zip(vol_handles, pod_objs): - rbd_devices = list_encrypted_rbd_devices_onnode(pod_obj.get_node()) - crypt_device = [device for device in rbd_devices if vol_handle in device] - if not crypt_device: - raise ResourceNotFoundError( - f"Encrypted device not found in {pod_obj.name}" - ) + node = pod_obj.get_node() + assert verify_crypt_device_present_onnode( + node, vol_handle + ), f"Crypt devicve {vol_handle} not found on node:{node}" pod_obj.run_io( storage_type="block", diff --git a/tests/manage/pv_services/pv_encryption/test_rbd_pv_encryption_vaulttenantsa.py b/tests/manage/pv_services/pv_encryption/test_rbd_pv_encryption_vaulttenantsa.py index 2fcbdf2cddd..7ae9e7d2380 100644 --- a/tests/manage/pv_services/pv_encryption/test_rbd_pv_encryption_vaulttenantsa.py +++ b/tests/manage/pv_services/pv_encryption/test_rbd_pv_encryption_vaulttenantsa.py @@ -21,7 +21,7 @@ ResourceNotFoundError, ) from ocs_ci.utility import kms -from ocs_ci.ocs.node import list_encrypted_rbd_devices_onnode +from ocs_ci.ocs.node import verify_crypt_device_present_onnode log = logging.getLogger(__name__) @@ -147,12 +147,10 @@ def test_rbd_pv_encryption_vaulttenantsa( # Verify whether encrypted device is present inside the pod and run IO for vol_handle, pod_obj in zip(vol_handles, pod_objs): - rbd_devices = list_encrypted_rbd_devices_onnode(pod_obj.get_node()) - crypt_device = [device for device in rbd_devices if vol_handle in device] - if not crypt_device: - raise ResourceNotFoundError( - f"Encrypted device not found in {pod_obj.name}" - ) + node = pod_obj.get_node() + assert verify_crypt_device_present_onnode( + node, vol_handle + ), f"Crypt devicve {vol_handle} not found on node:{node}" pod_obj.run_io( storage_type="block", diff --git a/tests/ui/test_pv_encryption_ui.py b/tests/ui/test_pv_encryption_ui.py index 033e68b1a91..395dcdac28d 100644 --- a/tests/ui/test_pv_encryption_ui.py +++ b/tests/ui/test_pv_encryption_ui.py @@ -29,7 +29,7 @@ from ocs_ci.utility.utils import get_vault_cli, get_ocp_version from ocs_ci.ocs import constants from ocs_ci.utility import version -from ocs_ci.ocs.node import list_encrypted_rbd_devices_onnode +from ocs_ci.ocs.node import verify_crypt_device_present_onnode logger = logging.getLogger(__name__) @@ -226,12 +226,10 @@ def test_for_encrypted_pv_ui( "Verify whether encrypted device is present inside the pod and run IO" ) for vol_handle, pod_obj in zip(vol_handles, pod_objs): - rbd_devices = list_encrypted_rbd_devices_onnode(pod_obj.get_node()) - crypt_device = [device for device in rbd_devices if vol_handle in device] - if not crypt_device: - raise ResourceNotFoundError( - f"Encrypted device not found in {pod_obj.name}" - ) + node = pod_obj.get_node() + assert verify_crypt_device_present_onnode( + node, vol_handle + ), f"Crypt devicve {vol_handle} not found on node:{node}" logger.info(f"Running FIO on Pod '{pod_obj.name}'") pod_obj.run_io( From cc1e0ff363571b4aeeeb542e1f45c789dc8687a2 Mon Sep 17 00:00:00 2001 From: Parag Kamble Date: Thu, 18 Jan 2024 17:38:20 +0530 Subject: [PATCH 3/5] Corrected the function doc string Signed-off-by: Parag Kamble --- ocs_ci/ocs/node.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ocs_ci/ocs/node.py b/ocs_ci/ocs/node.py index f5d4765f9b4..155cb36ff21 100644 --- a/ocs_ci/ocs/node.py +++ b/ocs_ci/ocs/node.py @@ -2812,6 +2812,10 @@ def verify_crypt_device_present_onnode(node, vol_handle): Args: node : node name vol_handle : volumen handle name. + + Returns: + True: if volume handle device found on the node. + False: if volume handle device not found on the node. """ device_list = list_encrypted_rbd_devices_onnode(node) crypt_device = [device for device in device_list if vol_handle in device] From c7d701a3751c21e62cc0f93eec2a706fb13ada33 Mon Sep 17 00:00:00 2001 From: Parag Kamble Date: Tue, 9 Jul 2024 15:43:55 +0530 Subject: [PATCH 4/5] Incorporated review Comments. Signed-off-by: Parag Kamble --- ocs_ci/ocs/node.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ocs_ci/ocs/node.py b/ocs_ci/ocs/node.py index 155cb36ff21..77c7aca7424 100644 --- a/ocs_ci/ocs/node.py +++ b/ocs_ci/ocs/node.py @@ -2786,7 +2786,7 @@ def is_node_rack_or_zone_exist(failure_domain, node_name): return get_node_rack_or_zone(failure_domain, node_obj) is not None -def list_encrypted_rbd_devices_onnode(node): +def list_encrypted_rbd_devices_on_node(node): """ Get rbd crypt devices from the node @@ -2814,10 +2814,9 @@ def verify_crypt_device_present_onnode(node, vol_handle): vol_handle : volumen handle name. Returns: - True: if volume handle device found on the node. - False: if volume handle device not found on the node. + bool: True if volume handle device found on the node, False otherwise """ - device_list = list_encrypted_rbd_devices_onnode(node) + device_list = list_encrypted_rbd_devices_on_node(node) crypt_device = [device for device in device_list if vol_handle in device] if not crypt_device: log.error( From 018c98c01ee6f5fe2e4994c6cf3ca8f7db9043ee Mon Sep 17 00:00:00 2001 From: Parag Kamble Date: Tue, 9 Jul 2024 16:04:39 +0530 Subject: [PATCH 5/5] Incorporated review Comments. Signed-off-by: Parag Kamble --- ocs_ci/ocs/node.py | 2 +- .../pv_encryption/test_encrypted_rbd_pvc_clone.py | 6 +++--- .../pv_encryption/test_encrypted_rbd_pvc_snapshot.py | 6 +++--- .../pv_encryption/test_kmip_rbd_pv_encryption.py | 4 ++-- .../pv_services/pv_encryption/test_rbd_pv_encryption.py | 4 ++-- .../pv_encryption/test_rbd_pv_encryption_vaulttenantsa.py | 4 ++-- tests/ui/test_pv_encryption_ui.py | 4 ++-- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/ocs_ci/ocs/node.py b/ocs_ci/ocs/node.py index 77c7aca7424..f9ce0a4639f 100644 --- a/ocs_ci/ocs/node.py +++ b/ocs_ci/ocs/node.py @@ -2805,7 +2805,7 @@ def list_encrypted_rbd_devices_on_node(node): return crypt_devices -def verify_crypt_device_present_onnode(node, vol_handle): +def verify_crypt_device_present_on_node(node, vol_handle): """ Find the crypt device maching for given volume handle. diff --git a/tests/manage/pv_services/pv_encryption/test_encrypted_rbd_pvc_clone.py b/tests/manage/pv_services/pv_encryption/test_encrypted_rbd_pvc_clone.py index e1b557292ea..33b45f22ece 100644 --- a/tests/manage/pv_services/pv_encryption/test_encrypted_rbd_pvc_clone.py +++ b/tests/manage/pv_services/pv_encryption/test_encrypted_rbd_pvc_clone.py @@ -23,7 +23,7 @@ ) from ocs_ci.utility import kms from semantic_version import Version -from ocs_ci.ocs.node import verify_crypt_device_present_onnode +from ocs_ci.ocs.node import verify_crypt_device_present_on_node log = logging.getLogger(__name__) @@ -162,7 +162,7 @@ def test_pvc_to_pvc_clone(self, kv_version, kms_provider, pod_factory): log.info("Checking for encrypted device and running IO on all pods") for vol_handle, pod_obj in zip(self.vol_handles, self.pod_objs): node = pod_obj.get_node() - assert verify_crypt_device_present_onnode( + assert verify_crypt_device_present_on_node( node, vol_handle ), f"Crypt devicve {vol_handle} not found on node:{node}" @@ -241,7 +241,7 @@ def test_pvc_to_pvc_clone(self, kv_version, kms_provider, pod_factory): # Verify encrypted device is present and md5sum on all pods for vol_handle, pod_obj in zip(cloned_vol_handles, cloned_pod_objs): node = pod_obj.get_node() - assert verify_crypt_device_present_onnode( + assert verify_crypt_device_present_on_node( node, vol_handle ), f"Crypt devicve {vol_handle} not found on node:{node}" diff --git a/tests/manage/pv_services/pv_encryption/test_encrypted_rbd_pvc_snapshot.py b/tests/manage/pv_services/pv_encryption/test_encrypted_rbd_pvc_snapshot.py index 5ccfe3ac782..08257a20b27 100644 --- a/tests/manage/pv_services/pv_encryption/test_encrypted_rbd_pvc_snapshot.py +++ b/tests/manage/pv_services/pv_encryption/test_encrypted_rbd_pvc_snapshot.py @@ -25,7 +25,7 @@ ) from ocs_ci.utility import kms from semantic_version import Version -from ocs_ci.ocs.node import verify_crypt_device_present_onnode +from ocs_ci.ocs.node import verify_crypt_device_present_on_node log = logging.getLogger(__name__) @@ -171,7 +171,7 @@ def test_encrypted_rbd_block_pvc_snapshot( for vol_handle, pod_obj in zip(self.vol_handles, self.pod_objs): node = pod_obj.get_node() - assert verify_crypt_device_present_onnode( + assert verify_crypt_device_present_on_node( node, vol_handle ), f"Crypt devicve {vol_handle} not found on node:{node}" @@ -326,7 +326,7 @@ def test_encrypted_rbd_block_pvc_snapshot( # Verify encrypted device is present and md5sum on all pods for vol_handle, pod_obj in zip(restore_vol_handles, restore_pod_objs): node = pod_obj.get_node() - assert verify_crypt_device_present_onnode( + assert verify_crypt_device_present_on_node( node, vol_handle ), f"Crypt devicve {vol_handle} not found on node:{node}" diff --git a/tests/manage/pv_services/pv_encryption/test_kmip_rbd_pv_encryption.py b/tests/manage/pv_services/pv_encryption/test_kmip_rbd_pv_encryption.py index 81dcbef0495..666adea5014 100644 --- a/tests/manage/pv_services/pv_encryption/test_kmip_rbd_pv_encryption.py +++ b/tests/manage/pv_services/pv_encryption/test_kmip_rbd_pv_encryption.py @@ -16,7 +16,7 @@ create_pods, ) from ocs_ci.ocs import constants -from ocs_ci.ocs.node import verify_crypt_device_present_onnode +from ocs_ci.ocs.node import verify_crypt_device_present_on_node log = logging.getLogger(__name__) @@ -103,7 +103,7 @@ def test_rbd_pv_encryption_kmip( # Verify whether encrypted device is present inside the pod and run IO for vol_handle, pod_obj in zip(vol_handles, pod_objs): node = pod_obj.get_node() - assert verify_crypt_device_present_onnode( + assert verify_crypt_device_present_on_node( node, vol_handle ), f"Crypt devicve {vol_handle} not found on node:{node}" diff --git a/tests/manage/pv_services/pv_encryption/test_rbd_pv_encryption.py b/tests/manage/pv_services/pv_encryption/test_rbd_pv_encryption.py index 765a60a9d16..dd9471919b1 100644 --- a/tests/manage/pv_services/pv_encryption/test_rbd_pv_encryption.py +++ b/tests/manage/pv_services/pv_encryption/test_rbd_pv_encryption.py @@ -21,7 +21,7 @@ ) from ocs_ci.utility import kms from semantic_version import Version -from ocs_ci.ocs.node import verify_crypt_device_present_onnode +from ocs_ci.ocs.node import verify_crypt_device_present_on_node log = logging.getLogger(__name__) @@ -161,7 +161,7 @@ def test_rbd_pv_encryption( # Verify whether encrypted device is present inside the pod and run IO for vol_handle, pod_obj in zip(vol_handles, pod_objs): node = pod_obj.get_node() - assert verify_crypt_device_present_onnode( + assert verify_crypt_device_present_on_node( node, vol_handle ), f"Crypt devicve {vol_handle} not found on node:{node}" diff --git a/tests/manage/pv_services/pv_encryption/test_rbd_pv_encryption_vaulttenantsa.py b/tests/manage/pv_services/pv_encryption/test_rbd_pv_encryption_vaulttenantsa.py index 7ae9e7d2380..e21deb25ef5 100644 --- a/tests/manage/pv_services/pv_encryption/test_rbd_pv_encryption_vaulttenantsa.py +++ b/tests/manage/pv_services/pv_encryption/test_rbd_pv_encryption_vaulttenantsa.py @@ -21,7 +21,7 @@ ResourceNotFoundError, ) from ocs_ci.utility import kms -from ocs_ci.ocs.node import verify_crypt_device_present_onnode +from ocs_ci.ocs.node import verify_crypt_device_present_on_node log = logging.getLogger(__name__) @@ -148,7 +148,7 @@ def test_rbd_pv_encryption_vaulttenantsa( # Verify whether encrypted device is present inside the pod and run IO for vol_handle, pod_obj in zip(vol_handles, pod_objs): node = pod_obj.get_node() - assert verify_crypt_device_present_onnode( + assert verify_crypt_device_present_on_node( node, vol_handle ), f"Crypt devicve {vol_handle} not found on node:{node}" diff --git a/tests/ui/test_pv_encryption_ui.py b/tests/ui/test_pv_encryption_ui.py index 395dcdac28d..c602a369b19 100644 --- a/tests/ui/test_pv_encryption_ui.py +++ b/tests/ui/test_pv_encryption_ui.py @@ -29,7 +29,7 @@ from ocs_ci.utility.utils import get_vault_cli, get_ocp_version from ocs_ci.ocs import constants from ocs_ci.utility import version -from ocs_ci.ocs.node import verify_crypt_device_present_onnode +from ocs_ci.ocs.node import verify_crypt_device_present_on_node logger = logging.getLogger(__name__) @@ -227,7 +227,7 @@ def test_for_encrypted_pv_ui( ) for vol_handle, pod_obj in zip(vol_handles, pod_objs): node = pod_obj.get_node() - assert verify_crypt_device_present_onnode( + assert verify_crypt_device_present_on_node( node, vol_handle ), f"Crypt devicve {vol_handle} not found on node:{node}"