def setup(self): """ Setting up the test environment : Calculating the amount of storage which available for the test Creating namespace (project) for the test """ log.info("Setting up the test environment") super(TestPvcMultiSnapshotPerformance, self).setup() # Getting the total Storage capacity try: self.ceph_capacity = int(self.ceph_cluster.get_ceph_capacity()) except Exception as err: err_msg = f"Failed to get Storage capacity : {err}" log.error(err_msg) raise Exception(err_msg) # Use 70% of the storage capacity in the test self.capacity_to_use = int(self.ceph_capacity * 0.7) # Creating new namespace for the test self.nss_name = "pas-test-namespace" log.info(f"Creating new namespace ({self.nss_name}) for the test") try: self.proj = helpers.create_project(project_name=self.nss_name) except CommandFailed as ex: if str(ex).find("(AlreadyExists)"): log.warning("The Namespace is Already Exists !") log.error("Can not create new project") raise CommandFailed(f"{self.nss_name} was not created") # Initialize a general Snapshot object to use in the test self.snapshot = OCP(kind="volumesnapshot", namespace=self.nss_name)
def test_capacity_breakdown_ui( self, setup_ui_class, project_name, pod_name, sc_type, teardown_project_factory ): """ Test Capacity Breakdown UI project_name (str): the project name pod_name (str): pod name sc_type (str): storage class [fs, block] """ project_obj = helpers.create_project(project_name=project_name) teardown_project_factory(project_obj) logger.info( f"Created new pvc sc_name={sc_type} namespace={project_name}, " f"size=6Gi, access_mode={constants.ACCESS_MODE_RWO}" ) pvc_obj = helpers.create_pvc( sc_name=sc_type, namespace=project_name, size="6Gi", do_reload=False, access_mode=constants.ACCESS_MODE_RWO, ) logger.info( f"Create new pod. Pod name={pod_name}," f"interface_type={constants.CEPHBLOCKPOOL}" ) pod_obj = helpers.create_pod( pvc_name=pvc_obj.name, namespace=project_obj.namespace, interface_type=constants.CEPHBLOCKPOOL, pod_name=pod_name, ) logger.info(f"Wait for pod {pod_name} move to Running state") helpers.wait_for_resource_state( pod_obj, state=constants.STATUS_RUNNING, timeout=300 ) logger.info("Run fio workload") pod_obj.run_io( storage_type=constants.WORKLOAD_STORAGE_TYPE_FS, size="4GB", ) fio_result = pod_obj.get_fio_results() logger.info("IOPs after FIO:") reads = fio_result.get("jobs")[0].get("read").get("iops") writes = fio_result.get("jobs")[0].get("write").get("iops") logger.info(f"Read: {reads}") logger.info(f"Write: {writes}") validation_ui_obj = ValidationUI(setup_ui_class) assert validation_ui_obj.check_capacity_breakdown( project_name=project_name, pod_name=pod_name ), "The Project/Pod not created on Capacity Breakdown"
def create_test_project(self): """ Creating new project (namespace) for performance test """ self.namespace = helpers.create_unique_resource_name("pas-test", "namespace") log.info(f"Creating new namespace ({self.namespace}) for the test") try: self.proj = helpers.create_project(project_name=self.namespace) except CommandFailed as ex: if str(ex).find("(AlreadyExists)"): log.warning("The namespace already exists !") log.error("Cannot create new project") raise CommandFailed(f"{self.namespace} was not created")
def create_and_set_namespace(self): """ Create and set namespace for the pods to be created Create sa_name if Kind if DeploymentConfig """ self.namespace_list.append(helpers.create_project()) self.namespace = self.namespace_list[-1].namespace if self.dc_deployment: self.sa_name = helpers.create_serviceaccount(self.namespace) self.sa_name = self.sa_name.name helpers.add_scc_policy(sa_name=self.sa_name, namespace=self.namespace) else: self.sa_name = None
def create_project(request): """ Create a new project """ class_instance = request.node.cls def finalizer(): """ Delete the project """ ocp.switch_to_default_rook_cluster_project() class_instance.project_obj.delete( resource_name=class_instance.namespace) class_instance.project_obj.wait_for_delete(class_instance.namespace) request.addfinalizer(finalizer) class_instance.project_obj = helpers.create_project() class_instance.namespace = class_instance.project_obj.namespace