Best Python code snippet using lisa_python
testsuite.py
Source:testsuite.py  
...62    def can_run(self) -> bool:63        return self.status in [TestStatus.QUEUED, TestStatus.ASSIGNED]64    @property65    def is_completed(self) -> bool:66        return _is_completed_status(self.status)67    @property68    def name(self) -> str:69        return self.runtime_data.metadata.name70    @hookspec71    def update_test_result_message(self, message: TestResultMessage) -> None:72        ...73    def handle_exception(74        self, exception: Exception, log: Logger, phase: str = ""75    ) -> None:76        self.stacktrace = traceback.format_exc()77        if phase:78            phase = f"{phase} "79        if isinstance(exception, SkippedException):80            log.info(f"case skipped: {exception}")...messages.py
Source:messages.py  
...70    log_file: str = ""71    stacktrace: Optional[str] = None72    @property73    def is_completed(self) -> bool:74        return _is_completed_status(self.status)75@dataclass76class SubTestMessage(TestResultMessageBase):77    hardware_platform: str = ""78    type: str = "SubTestResult"79class NetworkProtocol(str, Enum):80    IPv4 = "IPv4"81    IPv6 = "IPv6"82class TransportProtocol(str, Enum):83    Tcp = "TCP"84    Udp = "UDP"85@dataclass86class PerfMessage(MessageBase):87    type: str = "Performance"88    tool: str = ""89    test_case_name: str = ""90    platform: str = ""91    location: str = ""92    host_version: str = ""93    guest_os_type: str = "Linux"94    distro_version: str = ""95    vmsize: str = ""96    kernel_version: str = ""97    lis_version: str = ""98    ip_version: str = NetworkProtocol.IPv499    protocol_type: str = TransportProtocol.Tcp100    data_path: str = ""101    test_date: datetime = datetime.utcnow()102    role: str = ""103    test_result_id: str = ""104T = TypeVar("T", bound=PerfMessage)105DiskSetupType = Enum(106    "DiskSetupType",107    [108        "raw",109        "raid0",110    ],111)112DiskType = Enum(113    "DiskType",114    [115        "nvme",116        "premiumssd",117    ],118)119@dataclass120class DiskPerformanceMessage(PerfMessage):121    disk_setup_type: DiskSetupType = DiskSetupType.raw122    block_size: int = 0123    disk_type: DiskType = DiskType.nvme124    core_count: int = 0125    disk_count: int = 0126    qdepth: int = 0127    iodepth: int = 0128    numjob: int = 0129    read_iops: Decimal = Decimal(0)130    read_lat_usec: Decimal = Decimal(0)131    randread_iops: Decimal = Decimal(0)132    randread_lat_usec: Decimal = Decimal(0)133    write_iops: Decimal = Decimal(0)134    write_lat_usec: Decimal = Decimal(0)135    randwrite_iops: Decimal = Decimal(0)136    randwrite_lat_usec: Decimal = Decimal(0)137@dataclass138class NetworkLatencyPerformanceMessage(PerfMessage):139    max_latency_us: Decimal = Decimal(0)140    average_latency_us: Decimal = Decimal(0)141    min_latency_us: Decimal = Decimal(0)142    latency95_percentile_us: Decimal = Decimal(0)143    latency99_percentile_us: Decimal = Decimal(0)144    interval_us: int = 0145    frequency: int = 0146@dataclass147class NetworkPPSPerformanceMessage(PerfMessage):148    test_type: str = ""149    rx_pps_minimum: Decimal = Decimal(0)150    rx_pps_average: Decimal = Decimal(0)151    rx_pps_maximum: Decimal = Decimal(0)152    tx_pps_minimum: Decimal = Decimal(0)153    tx_pps_average: Decimal = Decimal(0)154    tx_pps_maximum: Decimal = Decimal(0)155    rx_tx_pps_minimum: Decimal = Decimal(0)156    rx_tx_pps_average: Decimal = Decimal(0)157    rx_tx_pps_maximum: Decimal = Decimal(0)158    fwd_pps_maximum: Decimal = Decimal(0)159    fwd_pps_average: Decimal = Decimal(0)160    fwd_pps_minimum: Decimal = Decimal(0)161@dataclass162class NetworkTCPPerformanceMessage(PerfMessage):163    connections_num: int = 0164    throughput_in_gbps: Decimal = Decimal(0)165    latency_us: Decimal = Decimal(0)166    buffer_size: Decimal = Decimal(0)167    tx_packets: Decimal = Decimal(0)168    rx_packets: Decimal = Decimal(0)169    pkts_interrupts: Decimal = Decimal(0)170    number_of_receivers: int = 1171    number_of_senders: int = 1172    sender_cycles_per_byte: Decimal = Decimal(0)173    connections_created_time: int = 0174    retrans_segments: int = 0175    receiver_cycles_rer_byte: Decimal = Decimal(0)176    # iperf tcp fields177    buffer_size_bytes: Decimal = Decimal(0)178    tx_throughput_in_gbps: Decimal = Decimal(0)179    rx_throughput_in_gbps: Decimal = Decimal(0)180    retransmitted_segments: Decimal = Decimal(0)181    congestion_windowsize_kb: Decimal = Decimal(0)182@dataclass183class NetworkUDPPerformanceMessage(PerfMessage):184    connections_num: int = 0185    number_of_receivers: int = 1186    number_of_senders: int = 1187    connections_created_time: int = 0188    receiver_cycles_rer_byte: Decimal = Decimal(0)189    send_buffer_size: Decimal = Decimal(0)190    tx_throughput_in_gbps: Decimal = Decimal(0)191    rx_throughput_in_gbps: Decimal = Decimal(0)192    data_loss: Decimal = Decimal(0)193    packet_size_kbytes: Decimal = Decimal(0)194def _is_completed_status(status: TestStatus) -> bool:195    return status in [196        TestStatus.FAILED,197        TestStatus.PASSED,198        TestStatus.SKIPPED,199        TestStatus.ATTEMPTED,200    ]201def create_perf_message(202    message_type: Type[T],203    node: "Node",204    test_result: "TestResult",205    test_case_name: str = "",206    other_fields: Optional[Dict[str, Any]] = None,207) -> T:208    environment = test_result.environment...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!!
