Best Python code snippet using tempest_python
test_backends_capabilities.py
Source:test_backends_capabilities.py
...30 """Test getting backend capabilities"""31 # Check response schema32 self.admin_capabilities_client.show_backend_capabilities(self.hosts[0])33 @staticmethod34 def _change_capabilities_storage_protocol(capabilities):35 """Convert storage_protocol to its canonical version"""36 # List of storage protocols variants defined in cinder.common.constants37 # The canonical name for storage protocol comes first in the list38 VARIANTS = [['iSCSI', 'iscsi'], ['FC', 'fibre_channel', 'fc'],39 ['NFS', 'nfs'], ['NVMe-oF', 'NVMeOF', 'nvmeof']]40 capabilities = sorted(list(capabilities))41 # Cinder Bug #1966103: Some drivers were reporting different strings42 # to represent the same storage protocol. For backward compatibility,43 # the scheduler can handle the variants, but to standardize this for44 # operators (who may need to refer to the protocol in volume-type45 # extra-specs), the get-pools and get-capabilities response was changed46 # to only report the canonical name for a storage protocol, but these47 # 2 REST API call swere not changed simultaneously, so we may or may48 # not get canonical names, so just convert canonical names.49 for item in range(len(capabilities)):50 for variants in VARIANTS:51 if capabilities[item][2] in variants:52 capabilities[item] = (capabilities[item][0],53 capabilities[item][1],54 variants[0])55 return capabilities56 @decorators.idempotent_id('a9035743-d46a-47c5-9cb7-3c80ea16dea0')57 def test_compare_volume_stats_values(self):58 """Test comparing volume stats values59 Compare volume stats between show_backend_capabilities and show_pools.60 """61 VOLUME_STATS = ('vendor_name',62 'volume_backend_name',63 'storage_protocol')64 # Get list backend capabilities using show_pools65 cinder_pools = [66 pool['capabilities'] for pool in67 self.admin_scheduler_stats_client.list_pools(detail=True)['pools']68 ]69 # Get list backends capabilities using show_backend_capabilities70 capabilities = [71 self.admin_capabilities_client.show_backend_capabilities(72 host=host) for host in self.hosts73 ]74 # Returns a tuple of VOLUME_STATS values75 expected_list = self._change_capabilities_storage_protocol(76 map(operator.itemgetter(*VOLUME_STATS), cinder_pools))77 observed_list = self._change_capabilities_storage_protocol(78 map(operator.itemgetter(*VOLUME_STATS), capabilities))...
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!!