How to use get_device_names_by_type method in lisa

Best Python code snippet using lisa_python

nvme.py

Source:nvme.py Github

copy

Full Screen

...357 before_pci_count = lspci.disable_devices_by_type(device_type)358 # 2. Enable PCI devices.359 lspci.enable_devices()360 # 3. Get PCI devices slots.361 after_devices_slots = lspci.get_device_names_by_type(device_type, True)362 # 4. Check PCI devices are back after rescan.363 assert_that(364 after_devices_slots,365 "After rescan, the disabled PCI devices should be back.",366 ).is_length(before_pci_count)367 def _validate_nvme_disk(self, environment: Environment, node: Node) -> None:368 # 1. Get nvme devices and nvme namespaces from /dev/ folder,369 # compare the count of nvme namespaces and nvme devices.370 nvme = node.features[Nvme]371 nvme_device = nvme.get_devices()372 nvme_namespace = nvme.get_namespaces()373 assert_that(nvme_device).described_as(374 "nvme devices count should be equal to namespace count by listing devices "375 "under folder /dev."...

Full Screen

Full Screen

common.py

Source:common.py Github

copy

Full Screen

...49 vm_nics[node.name] = node_nic_info.nics50 return vm_nics51def get_used_module(node: Node) -> str:52 lspci = node.tools[Lspci]53 devices_slots = lspci.get_device_names_by_type(54 constants.DEVICE_TYPE_SRIOV, force_run=True55 )56 # there will not be multiple Mellanox types in one VM57 # get the used module using any one of sriov device58 return lspci.get_used_module(devices_slots[0])59def get_used_config(node: Node) -> str:60 return modules_config_dict[get_used_module(node)]61def remove_module(node: Node) -> str:62 modprobe = node.tools[Modprobe]63 module_in_used = get_used_module(node)64 assert_that(reload_modules_dict).described_as(65 f"used modules {module_in_used} should be contained"66 f" in dict {reload_modules_dict}"67 ).contains(module_in_used)68 modprobe.remove(reload_modules_dict[module_in_used])69 return module_in_used70def load_module(node: Node, module_name: str) -> None:71 modprobe = node.tools[Modprobe]72 modprobe.load(module_name)73def get_packets(node: Node, nic_name: str, name: str = "tx_packets") -> int:74 cat = node.tools[Cat]75 return int(cat.read(f"/sys/class/net/{nic_name}/statistics/{name}", force_run=True))76@retry(exceptions=AssertionError, tries=150, delay=2)77def sriov_basic_test(78 environment: Environment, vm_nics: Dict[str, Dict[str, NicInfo]]79) -> None:80 for node in environment.nodes.list():81 # 1. Check module of sriov network device is loaded.82 used_module = get_used_module(node)83 if not node.tools[KernelConfig].is_built_in(modules_config_dict[used_module]):84 lsmod = node.tools[Lsmod]85 assert_that(lsmod.module_exists(used_module, force_run=True)).described_as(86 "The module of sriov network device isn't loaded."87 ).is_true()88 # 2. Check VF counts listed from lspci is expected.89 lspci = node.tools[Lspci]90 devices_slots = lspci.get_device_names_by_type(91 constants.DEVICE_TYPE_SRIOV, force_run=True92 )93 assert_that(devices_slots).described_as(94 "count of sriov devices listed from lspci is not expected,"95 " please check the driver works properly"96 ).is_length(len([x for x in vm_nics[node.name].values() if x.lower != ""]))97def sriov_vf_connection_test(98 environment: Environment,99 vm_nics: Dict[str, Dict[str, NicInfo]],100 turn_off_vf: bool = False,101 remove_module: bool = False,102) -> None:103 source_node = cast(RemoteNode, environment.nodes[0])104 dest_node = cast(RemoteNode, environment.nodes[1])...

Full Screen

Full Screen

lspci.py

Source:lspci.py Github

copy

Full Screen

...73 def _install(self) -> bool:74 if isinstance(self.node.os, Posix):75 self.node.os.install_packages("pciutils")76 return self._check_exists()77 def get_device_names_by_type(78 self, device_type: str, force_run: bool = False79 ) -> List[str]:80 if device_type.upper() not in DEVICE_TYPE_DICT.keys():81 raise LisaException(f"pci_type '{device_type}' is not recognized.")82 class_names = DEVICE_TYPE_DICT[device_type.upper()]83 devices_list = self.get_devices(force_run)84 devices_slots = [x.slot for x in devices_list if x.device_class in class_names]85 return devices_slots86 def get_devices_by_type(87 self, device_type: str, force_run: bool = False88 ) -> List[PciDevice]:89 if device_type.upper() not in DEVICE_TYPE_DICT.keys():90 raise LisaException(91 f"pci_type '{device_type}' is not supported to be searched."...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run lisa automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful