def create_pvc_pod(self, rbd_sc_obj, cephfs_sc_obj, number_of_pvc, size, start_io): """ Function to create multiple PVC of different type and created pods on them. Args: rbd_sc_obj (obj_dict): rbd storageclass object cephfs_sc_obj (obj_dict): cephfs storageclass object number_of_pvc (int): pvc count to be created for each types size (str): size of each pvc to be created eg: '10Gi' start_io (boolean): Ture to start and False not to start IO """ log.info(f"Create {number_of_pvc} pvcs and pods") self.delete_pod_count = round(number_of_pvc / 2) cephfs_pvcs = helpers.create_multiple_pvc_parallel( cephfs_sc_obj, self.namespace, number_of_pvc, size, access_modes=[constants.ACCESS_MODE_RWO, constants.ACCESS_MODE_RWX] ) rbd_pvcs = helpers.create_multiple_pvc_parallel( rbd_sc_obj, self.namespace, number_of_pvc, size, access_modes=[constants.ACCESS_MODE_RWO, constants.ACCESS_MODE_RWX] ) # Appending all the pvc obj to base case param for cleanup and evaluation self.all_pvc_obj.extend(cephfs_pvcs + rbd_pvcs) # Create pods with above pvc list cephfs_pods = helpers.create_pods_parallel( cephfs_pvcs, self.namespace, constants.CEPHFS_INTERFACE ) rbd_rwo_pvc, rbd_rwx_pvc = ([] for i in range(2)) for pvc_obj in rbd_pvcs: if pvc_obj.get_pvc_access_mode == constants.ACCESS_MODE_RWX: rbd_rwx_pvc.append(pvc_obj) else: rbd_rwo_pvc.append(pvc_obj) rbd_rwo_pods = helpers.create_pods_parallel( rbd_rwo_pvc, self.namespace, constants.CEPHBLOCKPOOL ) rbd_rwx_pods = helpers.create_pods_parallel( rbd_rwx_pvc, self.namespace, constants.CEPHBLOCKPOOL, raw_block_pv=True ) temp_pod_objs = list() temp_pod_objs.extend(cephfs_pods + rbd_rwo_pods) # Appending all the pod obj to base case param for cleanup and evaluation self.all_pod_obj.extend(temp_pod_objs + rbd_rwx_pods) # IO will start based on TC requirement if start_io: threads = list() for pod_obj in temp_pod_objs: process = threading.Thread(target=pod_obj.run_io, args=('fs', '512M',)) process.start() threads.append(process) for pod_obj in rbd_rwx_pods: process = threading.Thread(target=pod_obj.run_io, args=('block', '512M',)) process.start() threads.append(process) for process in threads: process.join()
def create_pvc_pod(self, rbd_sc_obj, cephfs_sc_obj, number_of_pvc, size, start_io): """ Function to create multiple PVC of different type and created pods on them. Args: rbd_sc_obj (obj_dict): rbd storageclass object cephfs_sc_obj (obj_dict): cephfs storageclass object number_of_pvc (int): pvc count to be created for each types size (str): size of each pvc to be created eg: '10Gi' start_io (boolean): Ture to start and False not to start IO """ log.info(f"Create {number_of_pvc} pvcs and pods") self.delete_pod_count = round(number_of_pvc / 2) cephfs_pvcs = helpers.create_multiple_pvc_parallel( cephfs_sc_obj, self.namespace, number_of_pvc, size, access_modes=[constants.ACCESS_MODE_RWO, constants.ACCESS_MODE_RWX] ) rbd_pvcs = helpers.create_multiple_pvc_parallel( rbd_sc_obj, self.namespace, number_of_pvc, size, access_modes=[constants.ACCESS_MODE_RWO, constants.ACCESS_MODE_RWX] ) # Appending all the pvc obj to base case param for cleanup and evaluation self.all_pvc_obj.extend(cephfs_pvcs + rbd_pvcs) # Create pods with above pvc list cephfs_pods = helpers.create_pods_parallel( cephfs_pvcs, self.namespace, constants.CEPHFS_INTERFACE ) rbd_rwo_pods = list() # TODO: RBD RWX pod creation for pvc_obj in rbd_pvcs: if not pvc_obj.get_pvc_access_mode == constants.ACCESS_MODE_RWX: rbd_rwo_pods.append(pvc_obj) rbd_pods = helpers.create_pods_parallel( rbd_rwo_pods, self.namespace, constants.CEPHBLOCKPOOL ) temp_pod_objs = list() temp_pod_objs.extend(cephfs_pods + rbd_pods) # Appending all the pod obj to base case param for cleanup and evaluation self.all_pod_obj.extend(temp_pod_objs) # IO will start based on TC requirement if start_io: with ThreadPoolExecutor() as executor: for pod_obj in temp_pod_objs: executor.submit(pod_obj.run_io('fs', size='512M'))
def create_multi_pvc_pod( self, pods_per_iter=5, io_runtime=3600, start_io=False ): """ Function to create PVC of different type and attach them to PODs and start IO. Args: pods_per_iter (int): Number of PVC-POD to be created per PVC type Example, If 2 then 8 PVC+POD will be created with 2 each of 4 PVC types io_runtime (sec): Fio run time in seconds start_io (bool): If True start IO else don't Returns: pod_objs (obj): Objs of all the PODs created pvc_objs (obj): Objs of all the PVCs created """ rbd_sc = helpers.default_storage_class(constants.CEPHBLOCKPOOL) cephfs_sc = helpers.default_storage_class(constants.CEPHFILESYSTEM) pvc_size = f"{random.randrange(15, 105, 5)}Gi" fio_size = get_size_based_on_cls_usage() fio_rate = get_rate_based_on_cls_iops() logging.info(f"Create {pods_per_iter * 4} PVCs and PODs") # Create PVCs cephfs_pvcs = helpers.create_multiple_pvc_parallel( sc_obj=cephfs_sc, namespace=self.namespace, number_of_pvc=pods_per_iter, size=pvc_size, access_modes=[constants.ACCESS_MODE_RWO, constants.ACCESS_MODE_RWX] ) rbd_pvcs = helpers.create_multiple_pvc_parallel( sc_obj=rbd_sc, namespace=self.namespace, number_of_pvc=pods_per_iter, size=pvc_size, access_modes=[constants.ACCESS_MODE_RWO, constants.ACCESS_MODE_RWX] ) # Appending all the pvc_obj and pod_obj to list pvc_objs, pod_objs = ([] for i in range(2)) pvc_objs.extend(cephfs_pvcs + rbd_pvcs) # Create pods with above pvc list cephfs_pods = helpers.create_pods_parallel( cephfs_pvcs, self.namespace, constants.CEPHFS_INTERFACE, pod_dict_path=self.pod_dict_path, sa_name=self.sa_name, dc_deployment=self.dc_deployment, node_selector=self.node_selector ) rbd_rwo_pvc, rbd_rwx_pvc = ([] for i in range(2)) for pvc_obj in rbd_pvcs: if pvc_obj.get_pvc_access_mode == constants.ACCESS_MODE_RWX: rbd_rwx_pvc.append(pvc_obj) else: rbd_rwo_pvc.append(pvc_obj) rbd_rwo_pods = helpers.create_pods_parallel( rbd_rwo_pvc, self.namespace, constants.CEPHBLOCKPOOL, pod_dict_path=self.pod_dict_path, sa_name=self.sa_name, dc_deployment=self.dc_deployment, node_selector=self.node_selector ) rbd_rwx_pods = helpers.create_pods_parallel( rbd_rwx_pvc, self.namespace, constants.CEPHBLOCKPOOL, pod_dict_path=self.pod_dict_path, sa_name=self.sa_name, dc_deployment=self.dc_deployment, raw_block_pv=True, node_selector=self.node_selector ) temp_pod_objs = list() temp_pod_objs.extend(cephfs_pods + rbd_rwo_pods) # Appending all the pod_obj to list pod_objs.extend(temp_pod_objs + rbd_rwx_pods) # Start IO import time if start_io: threads = list() for pod_obj in temp_pod_objs: process = threading.Thread( target=pod_obj.run_io, kwargs={ 'storage_type': 'fs', 'size': fio_size, 'runtime': io_runtime, 'rate': fio_rate } ) process.start() threads.append(process) time.sleep(30) for pod_obj in rbd_rwx_pods: process = threading.Thread( target=pod_obj.run_io, kwargs={ 'storage_type': 'block', 'size': fio_size, 'runtime': io_runtime, 'rate': fio_rate } ) process.start() threads.append(process) time.sleep(30) for process in threads: process.join() return pod_objs, pvc_objs