From 3e780949ed3453ec45e75aba7114661d7ab74ac1 Mon Sep 17 00:00:00 2001 From: Arun Kumar Date: Tue, 23 Jun 2020 09:48:01 +0530 Subject: [Test] Add TC fill arbiter brick, shutdown data brick node and run io Change-Id: I36d44123db24154fe0aefc905ad2f5a5e5061558 Signed-off-by: Arun Kumar --- .../openshiftstoragelibs/baseclass.py | 17 ++++--- .../openshiftstoragelibs/gluster_ops.py | 6 ++- .../openshiftstoragelibs/openshift_ops.py | 59 ++++++++++++++++------ 3 files changed, 57 insertions(+), 25 deletions(-) (limited to 'openshift-storage-libs') diff --git a/openshift-storage-libs/openshiftstoragelibs/baseclass.py b/openshift-storage-libs/openshiftstoragelibs/baseclass.py index 99082ac9..52cbfcce 100644 --- a/openshift-storage-libs/openshiftstoragelibs/baseclass.py +++ b/openshift-storage-libs/openshiftstoragelibs/baseclass.py @@ -38,6 +38,7 @@ from openshiftstoragelibs.openshift_ops import ( get_pod_name_from_rc, get_pv_name_from_pvc, oc_create_app_dc_with_io, + oc_create_busybox_app_dc_with_io, oc_create_pvc, oc_create_sc, oc_create_secret, @@ -426,7 +427,7 @@ class BaseClass(unittest.TestCase): def create_dcs_with_pvc( self, pvc_names, timeout=600, wait_step=5, dc_name_prefix='autotests-dc', label=None, - skip_cleanup=False): + skip_cleanup=False, is_busybox=False): """Create bunch of DCs with app PODs which use unique PVCs. Args: @@ -435,7 +436,8 @@ class BaseClass(unittest.TestCase): timeout (int): timeout value, default value is 600 seconds. wait_step( int): wait step, default value is 5 seconds. dc_name_prefix(str): name prefix for deployement config. - lable (dict): keys and value for adding label into DC. + label (dict): keys and value for adding label into DC. + is_busybox (bool): True for busybox app pod else default is False Returns: dictionary with following structure: { "pvc_name_1": ("dc_name_1", "pod_name_1"), @@ -448,10 +450,11 @@ class BaseClass(unittest.TestCase): pvc_names if isinstance(pvc_names, (list, set, tuple)) else [pvc_names]) dc_and_pod_names, dc_names = {}, {} + function = (oc_create_busybox_app_dc_with_io if is_busybox else + oc_create_app_dc_with_io) for pvc_name in pvc_names: - dc_name = oc_create_app_dc_with_io( - self.ocp_client[0], pvc_name, dc_name_prefix=dc_name_prefix, - label=label) + dc_name = function(self.ocp_client[0], pvc_name, + dc_name_prefix=dc_name_prefix, label=label) dc_names[pvc_name] = dc_name if not skip_cleanup: self.addCleanup(oc_delete, self.ocp_client[0], 'dc', dc_name) @@ -472,11 +475,11 @@ class BaseClass(unittest.TestCase): def create_dc_with_pvc( self, pvc_name, timeout=300, wait_step=10, dc_name_prefix='autotests-dc', label=None, - skip_cleanup=False): + skip_cleanup=False, is_busybox=False): return self.create_dcs_with_pvc( pvc_name, timeout, wait_step, dc_name_prefix=dc_name_prefix, label=label, - skip_cleanup=skip_cleanup)[pvc_name] + skip_cleanup=skip_cleanup, is_busybox=is_busybox)[pvc_name] def create_heketi_volume_with_name_and_wait( self, name, size, raise_on_cleanup_error=True, diff --git a/openshift-storage-libs/openshiftstoragelibs/gluster_ops.py b/openshift-storage-libs/openshiftstoragelibs/gluster_ops.py index ccc1a055..1b2c295a 100644 --- a/openshift-storage-libs/openshiftstoragelibs/gluster_ops.py +++ b/openshift-storage-libs/openshiftstoragelibs/gluster_ops.py @@ -50,15 +50,17 @@ def wait_to_heal_complete( @podcmd.GlustoPod() -def get_gluster_vol_status(file_vol): +def get_gluster_vol_status(file_vol, is_detail=False): """Get Gluster vol status. Args: file_vol (str): file volume name. + is_detail (bool): True for detailed output else False """ # Get Gluster vol info + options = 'detail' if is_detail else '' gluster_volume_status = get_volume_status( - "auto_get_gluster_endpoint", file_vol) + "auto_get_gluster_endpoint", file_vol, options=options) if not gluster_volume_status: raise AssertionError("Failed to get volume status for gluster " "volume '%s'" % file_vol) diff --git a/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py b/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py index ccacfeb5..cf1e342b 100644 --- a/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py +++ b/openshift-storage-libs/openshiftstoragelibs/openshift_ops.py @@ -345,25 +345,12 @@ def oc_create_pvc(hostname, sc_name=None, pvc_name_prefix="autotests-pvc", return pvc_name -def oc_create_app_dc_with_io( - hostname, pvc_name, dc_name_prefix="autotests-dc-with-app-io", - replicas=1, space_to_use=1048576, label=None): - """Create DC with app PODs and attached PVC, constantly running I/O. - - Args: - hostname (str): Node on which 'oc create' command will be executed. - pvc_name (str): name of the Persistent Volume Claim to attach to - the application PODs where constant I/O will run. - dc_name_prefix (str): DC name will consist of this prefix and - random str. - replicas (int): amount of application POD replicas. - space_to_use (int): value in bytes which will be used for I/O. - label (dict): dict of keys and values to add labels in DC. - """ +def _oc_create_app_dc_with_io_image(hostname, pvc_name, dc_name_prefix, + replicas, space_to_use, label, image): dc_name = "%s-%s" % (dc_name_prefix, utils.get_random_str()) container_data = { "name": dc_name, - "image": "cirros", + "image": image, "volumeMounts": [{"mountPath": "/mnt", "name": dc_name}], "command": ["sh"], "args": [ @@ -419,6 +406,46 @@ def oc_create_app_dc_with_io( return dc_name +def oc_create_app_dc_with_io( + hostname, pvc_name, dc_name_prefix="autotests-dc-with-app-io", + replicas=1, space_to_use=1048576, label=None): + """Create DC with app PODs and attached PVC, constantly running I/O. + + Args: + hostname (str): Node on which 'oc create' command will be executed. + pvc_name (str): name of the Persistent Volume Claim to attach to + the application PODs where constant I/O will run. + dc_name_prefix (str): DC name will consist of this prefix and + random str. + replicas (int): amount of application POD replicas. + space_to_use (int): value in bytes which will be used for I/O. + label (dict): dict of keys and values to add labels in DC. + """ + return _oc_create_app_dc_with_io_image( + hostname, pvc_name, dc_name_prefix, replicas, space_to_use, + label, "cirros") + + +def oc_create_busybox_app_dc_with_io( + hostname, pvc_name, dc_name_prefix="autotests-dc-with-app-io", + replicas=1, space_to_use=1048576, label=None): + """Create DC with app PODs and attached PVC, constantly running I/O. + + Args: + hostname (str): Node on which 'oc create' command will be executed. + pvc_name (str): name of the Persistent Volume Claim to attach to + the application PODs where constant I/O will run. + dc_name_prefix (str): DC name will consist of this prefix and + random str. + replicas (int): amount of application POD replicas. + space_to_use (int): value in bytes which will be used for I/O. + label (dict): dict of keys and values to add labels in DC. + """ + return _oc_create_app_dc_with_io_image( + hostname, pvc_name, dc_name_prefix, replicas, space_to_use, + label, "busybox") + + def oc_create_tiny_pod_with_volume(hostname, pvc_name, pod_name_prefix='', mount_path='/mnt'): """Create tiny POD from image in 10Mb with attached volume at /mnt""" -- cgit