Best Python code snippet using lisa_python
lscpu.py
Source:lscpu.py
...156 len(matched),157 f"cluster count should have exact one line, but got {matched}",158 ).is_equal_to(1)159 return int(matched[0])160 def calculate_vcpu_count(self, force_run: bool = False) -> int:161 # The concept of a "cluster" of CPUs was recently added in the Linux162 # 5.16 kernel in commit c5e22feffdd7. There is "Core(s) per cluster"163 # and "Cluster(s)" in the output of lscpu. If there is cluster topology,164 # calculate vCPU count by core_per_cluster_count * cluster_count *165 # thread_per_core_count, else by core_per_socket_count * socket_count *166 # thread_per_core_count.167 result = self.run(force_run=force_run)168 if "Core(s) per cluster" in result.stdout:169 calculated_cpu_count = (170 self.get_core_per_cluster_count()171 * self.get_cluster_count()172 * self.get_thread_per_core_count()173 )174 else:...
cpu.py
Source:cpu.py
...81 # 1. Get vCPU count.82 cpu_count = lscpu.get_core_count()83 log.debug(f"{cpu_count} CPU cores detected...")84 # 2. Calculate vCPU count85 calculated_cpu_count = lscpu.calculate_vcpu_count()86 # 3. Judge whether the actual vCPU count equals to expected value.87 assert_that(cpu_count).described_as(88 "The VM may end up being incorrectly configured on some Azure hosts,"89 " it is a known host bug, please check the host version."90 ).is_equal_to(calculated_cpu_count)91 @TestCaseMetadata(92 description="""93 This test will verify if the CPUs inside a Linux VM are processing VMBus94 interrupts by checking the /proc/interrupts file.95 There are 3 types of Hyper-v interrupts : Hypervisor callback96 interrupts, Hyper-V reenlightenment interrupts, and Hyper-V stimer097 interrupts.98 Hyper-V reenlightenment interrupts are 0 unless the VM is doing migration.99 Hypervisor callback interrupts are vmbus events that are generated on all...
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!!