Best Python code snippet using lisa_python
cpu.py
Source:cpu.py
...117 def verify_vmbus_interrupts(self, node: Node, log: Logger) -> None:118 found_hyperv_interrupt = False119 cpu_count = node.tools[Lscpu].get_core_count()120 log.debug(f"{cpu_count} CPU cores detected...")121 self._create_stimer_interrupts(node, cpu_count)122 interrupt_inspector = node.tools[InterruptInspector]123 interrupts = interrupt_inspector.get_interrupt_data()124 for interrupt in interrupts:125 is_hyperv_interrupt = any(126 [(substr in interrupt.metadata) for substr in hyperv_interrupt_substr]127 )128 if not is_hyperv_interrupt:129 continue130 log.debug(f"Processing Hyper-V interrupt : {interrupt}")131 assert_that(132 len(interrupt.cpu_counter),133 "Hyper-v interrupts should have count for each cpu.",134 ).is_equal_to(cpu_count)135 if interrupt.irq_number == "HRE" or "reenlightenment" in interrupt.metadata:136 assert_that(137 all(138 [139 interrupt_count == 0140 for interrupt_count in interrupt.cpu_counter141 ]142 ),143 "Hyper-V reenlightenment interrupts should be 0 on each vCPU "144 "unless the VM is doing migration.",145 ).is_greater_than_or_equal_to(True)146 elif interrupt.irq_number == "HYP" or "callback" in interrupt.metadata:147 assert_that(148 sum(149 [150 interrupt_count > 0151 for interrupt_count in interrupt.cpu_counter152 ]153 ),154 "Hypervisor callback interrupt should be processed by "155 "atleast min(#vCPU, 4) vCPU's",156 ).is_greater_than_or_equal_to(min(cpu_count, 4))157 elif interrupt.irq_number == "HVS" or "stimer" in interrupt.metadata:158 assert_that(159 all(160 [161 interrupt_count > 0162 for interrupt_count in interrupt.cpu_counter163 ]164 ),165 "Hypervisor synthetic timer interrupt should be processed by "166 "all vCPU's",167 ).is_equal_to(True)168 else:169 continue170 found_hyperv_interrupt = True171 # Fail test execution if these hyper-v interrupts are not showing up172 if not found_hyperv_interrupt:173 raise LisaException("Hyper-V interrupts are not recorded.")174 def _create_stimer_interrupts(self, node: Node, cpu_count: int) -> None:175 # Run CPU intensive workload to create hyper-v synthetic timer176 # interrupts.177 # Steps :178 # 1. Run `yes` program on each vCPU in a subprocess.179 # 2. Wait for one second to allow enough time for processing interrupts.180 # 3. Kill the spawned subprocess.181 for i in range(1, cpu_count):182 process = node.tools[TaskSet].run_on_specific_cpu(i)183 time.sleep(1)...
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!!