Best Python code snippet using tempest_python
test_qos.py
Source:test_qos.py  
...101        # test the deletion of a specs key from qos-specs102        keys = ['iops_bytes']103        self.volume_qos_client.unset_qos_key(self.created_qos['id'], keys)104        operation = 'qos-key-unset'105        self.volume_qos_client.wait_for_qos_operations(self.created_qos['id'],106                                                       operation, keys)107        body = self.volume_qos_client.show_qos(108            self.created_qos['id'])['qos_specs']109        self.assertNotIn(keys[0], body['specs'])110    @test.idempotent_id('1dd93c76-6420-485d-a771-874044c416ac')111    def test_associate_disassociate_qos(self):112        """Test the following operations :113        1. associate_qos114        2. get_association_qos115        3. disassociate_qos116        4. disassociate_all_qos117        """118        # create a test volume-type119        vol_type = []120        for _ in range(0, 3):121            vol_type.append(self._create_test_volume_type())122        # associate the qos-specs with volume-types123        for i in range(0, 3):124            self._test_associate_qos(vol_type[i]['id'])125        # get the association of the qos-specs126        associations = self._test_get_association_qos()127        for i in range(0, 3):128            self.assertIn(vol_type[i]['id'], associations)129        # disassociate a volume-type with qos-specs130        self.volume_qos_client.disassociate_qos(131            self.created_qos['id'], vol_type[0]['id'])132        operation = 'disassociate'133        self.volume_qos_client.wait_for_qos_operations(self.created_qos['id'],134                                                       operation,135                                                       vol_type[0]['id'])136        associations = self._test_get_association_qos()137        self.assertNotIn(vol_type[0]['id'], associations)138        # disassociate all volume-types from qos-specs139        self.volume_qos_client.disassociate_all_qos(140            self.created_qos['id'])141        operation = 'disassociate-all'142        self.volume_qos_client.wait_for_qos_operations(self.created_qos['id'],143                                                       operation)144        associations = self._test_get_association_qos()145        self.assertEmpty(associations)146class QosSpecsV1TestJSON(QosSpecsV2TestJSON):...test_qos_rbac.py
Source:test_qos_rbac.py  
...85        qos = self._create_test_qos_specs()86        self.qos_client.set_qos_key(qos['id'], iops_bytes='500')['qos_specs']87        with self.override_role():88            self.qos_client.unset_qos_key(qos['id'], ['iops_bytes'])89        waiters.wait_for_qos_operations(self.qos_client, qos['id'],90                                        'qos-key-unset', args=['iops_bytes'])91    @rbac_rule_validation.action(92        service="cinder", rules=["volume_extension:qos_specs_manage:update"])93    @decorators.idempotent_id('2047b347-8bbe-405e-bf5a-c75a0d7e3930')94    def test_associate_qos(self):95        qos = self._create_test_qos_specs()96        vol_type = self.create_volume_type()['id']97        with self.override_role():98            self.qos_client.associate_qos(qos['id'], vol_type)99        self.addCleanup(100            test_utils.call_and_ignore_notfound_exc,101            self.qos_client.disassociate_qos, qos['id'], vol_type)102    @rbac_rule_validation.action(103        service="cinder", rules=["volume_extension:qos_specs_manage:update"])104    @decorators.idempotent_id('f12aeca1-0c02-4f33-b805-014171e5b2d4')105    def test_disassociate_qos(self):106        qos = self._create_test_qos_specs()107        vol_type = self.create_volume_type()['id']108        self.qos_client.associate_qos(qos['id'], vol_type)109        self.addCleanup(test_utils.call_and_ignore_notfound_exc,110                        self.qos_client.disassociate_qos, qos['id'], vol_type)111        with self.override_role():112            self.qos_client.disassociate_qos(qos['id'], vol_type)113        waiters.wait_for_qos_operations(self.qos_client, qos['id'],114                                        'disassociate', args=vol_type)115    @rbac_rule_validation.action(116        service="cinder", rules=["volume_extension:qos_specs_manage:update"])117    @decorators.idempotent_id('9f6e664d-a5d9-4e71-b122-73a3086be1b9')118    def test_disassociate_all_qos(self):119        qos = self._create_test_qos_specs()120        vol_type = self.create_volume_type()['id']121        self.qos_client.associate_qos(qos['id'], vol_type)122        self.addCleanup(test_utils.call_and_ignore_notfound_exc,123                        self.qos_client.disassociate_qos, qos['id'], vol_type)124        with self.override_role():125            self.qos_client.disassociate_all_qos(qos['id'])126        waiters.wait_for_qos_operations(self.qos_client, qos['id'],...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!!
