Best Python code snippet using lemoncheesecake
test_pvc_creation_performance.py
Source:test_pvc_creation_performance.py  
...44            sc_name=self.sc_obj.name, size=self.pvc_size45        )46        helpers.wait_for_resource_state(pvc_obj, constants.STATUS_BOUND)47        pvc_obj.reload()48        teardown_factory(pvc_obj)49        create_time = helpers.measure_pvc_creation_time(50            self.interface, pvc_obj.name51        )52        if create_time > 1:53            raise ex.PerformanceException(54                f"PVC creation time is {create_time} and greater than 1 second"55            )56        logging.info("PVC creation took less than a 1 second")57    @pytest.mark.usefixtures(base_setup.__name__)58    @polarion_id('OCS-1620')59    @bugzilla('1741612')60    def test_multiple_pvc_creation_measurement_performance(61        self, teardown_factory62    ):63        """64        Measuring PVC creation time of 120 PVCs in 60 seconds65        """66        number_of_pvcs = 12067        log.info('Start creating new 120 PVCs')68        pvc_objs = helpers.create_multiple_pvcs(69            sc_name=self.sc_obj.name,70            namespace=defaults.ROOK_CLUSTER_NAMESPACE,71            number_of_pvc=number_of_pvcs,72            size=self.pvc_size,73        )74        for pvc_obj in pvc_objs:75            teardown_factory(pvc_obj)76        with ThreadPoolExecutor(max_workers=5) as executor:77            for pvc_obj in pvc_objs:78                executor.submit(79                    helpers.wait_for_resource_state, pvc_obj,80                    constants.STATUS_BOUND81                )82                executor.submit(pvc_obj.reload)83        start_time = helpers.get_start_creation_time(84            self.interface, pvc_objs[0].name85        )86        end_time = helpers.get_end_creation_time(87            self.interface, pvc_objs[number_of_pvcs - 1].name,88        )89        total = end_time - start_time90        total_time = total.total_seconds()91        if total_time > 60:92            raise ex.PerformanceException(93                f"{number_of_pvcs} PVCs creation time is {total_time} and "94                f"greater than 60 seconds"95            )96        logging.info(97            f"{number_of_pvcs} PVCs creation time took less than a 60 seconds"98        )99    @pytest.mark.usefixtures(base_setup.__name__)100    @polarion_id('OCS-1270')101    @bugzilla('1741612')102    def test_multiple_pvc_creation_after_deletion_performance(103        self, teardown_factory104    ):105        """106        Measuring PVC creation time of 75% of initial PVCs (120) in the same107        rate after deleting 75% of the initial PVCs108        """109        initial_number_of_pvcs = 120110        number_of_pvcs = math.ceil(initial_number_of_pvcs * 0.75)111        log.info('Start creating new 120 PVCs')112        pvc_objs = helpers.create_multiple_pvcs(113            sc_name=self.sc_obj.name,114            namespace=defaults.ROOK_CLUSTER_NAMESPACE,115            number_of_pvc=initial_number_of_pvcs,116            size=self.pvc_size,117        )118        for pvc_obj in pvc_objs:119            teardown_factory(pvc_obj)120        with ThreadPoolExecutor() as executor:121            for pvc_obj in pvc_objs:122                executor.submit(123                    helpers.wait_for_resource_state, pvc_obj,124                    constants.STATUS_BOUND125                )126                executor.submit(pvc_obj.reload)127        log.info('Deleting 75% of the PVCs - 90 PVCs')128        assert pvc.delete_pvcs(pvc_objs[:number_of_pvcs], True), (129            "Deletion of 75% of PVCs failed"130        )131        log.info('Re-creating the 90 PVCs')132        pvc_objs = helpers.create_multiple_pvcs(133            sc_name=self.sc_obj.name,...test_raw_block_pv.py
Source:test_raw_block_pv.py  
...102        Base function for creation of namespace, storageclass, pvcs and pods103        """104        pods, pvcs, pvs = self.raw_block_pv105        if self.reclaim_policy == constants.RECLAIM_POLICY_RETAIN:106            teardown_factory(pvs)107        teardown_factory(pvcs)...test_create_multiple_sc_with_different_pool_name.py
Source:test_create_multiple_sc_with_different_pool_name.py  
...50                f"StorageClass: {sc_obj.name} "51                f"created successfully using {cbp_obj.name}"52            )53            sc_list.append(sc_obj)54            teardown_factory(cbp_obj)55            teardown_factory(sc_obj)56        # Create PVCs using each SC57        pvc_list = []58        for i in range(3):59            log.info(f"Creating a PVC using {sc_list[i].name}")60            pvc_obj = helpers.create_pvc(sc_list[i].name)61            log.info(62                f"PVC: {pvc_obj.name} created successfully using "63                f"{sc_list[i].name}"64            )65            pvc_list.append(pvc_obj)66            teardown_factory(pvc_obj)67            helpers.wait_for_resource_state(pvc_obj, constants.STATUS_BOUND)68            pvc_obj.reload()69        # Create app pod and mount each PVC70        pod_list = []71        for i in range(3):72            log.info(f"Creating an app pod and mount {pvc_list[i].name}")73            pod_obj = helpers.create_pod(74                interface_type=constants.CEPHBLOCKPOOL,75                pvc_name=pvc_list[i].name,76            )77            log.info(78                f"{pod_obj.name} created successfully and "79                f"mounted {pvc_list[i].name}"80            )81            pod_list.append(pod_obj)82            teardown_factory(pod_obj)83            helpers.wait_for_resource_state(pod_obj, constants.STATUS_RUNNING)84            pod_obj.reload()85        # Run IO on each app pod for sometime86        for pod in pod_list:87            log.info(f"Running FIO on {pod.name}")88            pod.run_io('fs', size='2G')89        for pod in pod_list:...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
