Best Python code snippet using lisa_python
lagscope.py
Source:lagscope.py
...207 dump_csv,208 daemon,209 )210 result = process.wait_result()211 errors = find_groups_in_lines(result.stdout, self._client_failure_pattern)212 if errors:213 raise LisaException(214 f"lagscope client error: {[x['error'] for x in errors]}"215 )216 return result217 def get_average(self, result: ExecutableResult) -> Decimal:218 matched_results = self._average_pattern.match(result.stdout)219 if matched_results:220 return Decimal(matched_results.group("average_latency_us"))221 else:222 self._log.debug(f"no average latency found in {result.stdout}")223 return Decimal(-1.0)224 def create_latency_performance_messages(225 self,226 result: ExecutableResult,227 test_case_name: str,228 test_result: "TestResult",229 ) -> List[NetworkLatencyPerformanceMessage]:230 matched_results = self._result_pattern.match(result.stdout)231 assert (232 matched_results233 ), "not found matched latency statistics from lagscope results."234 all_matched_results = find_groups_in_lines(235 result.stdout, self._interval_frequency_pattern236 )237 perf_message_list: List[NetworkLatencyPerformanceMessage] = []238 for matched_result in all_matched_results:239 other_fields: Dict[str, Any] = {}240 other_fields["tool"] = constants.NETWORK_PERFORMANCE_TOOL_LAGSCOPE241 other_fields["min_latency_us"] = Decimal(242 matched_results.group("min_latency_us")243 )244 other_fields["max_latency_us"] = Decimal(245 matched_results.group("max_latency_us")246 )247 other_fields["average_latency_us"] = Decimal(248 matched_results.group("average_latency_us")...
xdptools.py
Source:xdptools.py
...51 run full test of xdp tools repo52 """53 result = self.node.execute("make test", sudo=True, cwd=self._code_path)54 abnormal_results: Dict[str, str] = {}55 for item in find_groups_in_lines(56 result.stdout, pattern=self._xdp_test_result_pattern57 ):58 if item["result"] not in ["PASS", "SKIPPED"]:59 abnormal_results[item["name"]] = item["result"]60 if abnormal_results:61 raise LisaException(f"found failed tests: {abnormal_results}")62 result.assert_exit_code(63 0, "unknown error on xdp tests, please check log for more details."64 )65 def _initialize(self, *args: Any, **kwargs: Any) -> None:66 super()._initialize(*args, **kwargs)67 self._command: PurePath = PurePath(self._default_command)68 self._gro_lro_settings: Dict[str, DeviceGroLroSettings] = {}69 def _install(self) -> bool:...
tcpdump.py
Source:tcpdump.py
...63 force_run=True,64 sudo=True,65 ).stdout66 packets: List[IpPacket] = []67 results = find_groups_in_lines(output, self._information_pattern)68 for item in results:69 packet = IpPacket(70 time=time.strptime(item["time"], "%H:%M:%S.%f"),71 source=item["source"],72 destination=item["destination"],73 extra=item["extra"],74 )75 packets.append(packet)76 self._log.debug(f"{len(packets)} packets loaded.")77 return packets78 def _install(self) -> bool:79 self.node.os.install_packages("tcpdump") # type: ignore...
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!!