Best Python code snippet using lisa_python
sriov.py
Source:sriov.py  
...73            network_interface=features.Sriov(),74        ),75    )76    def sriov_basic_validation(self, environment: Environment) -> None:77        vm_nics = initialize_nic_info(environment)78        sriov_basic_test(environment, vm_nics)79    @TestCaseMetadata(80        description="""81        This case verifies module of sriov network interface is loaded and82         each synthetic nic is paired with one VF, and check rx statistics of source83         and tx statistics of dest increase after send 200 Mb file from source to dest.84        Steps,85        1. Check VF of synthetic nic is paired.86        2. Check module of sriov network device is loaded.87        3. Check VF counts listed from lspci is expected.88        4. Setup SSH connection between source and dest with key authentication.89        5. Ping the dest IP from the source machine to check connectivity.90        6. Generate 200Mb file, copy from source to dest.91        7. Check rx statistics of source VF and tx statistics of dest VF is increased.92        """,93        priority=1,94        requirement=simple_requirement(95            min_count=2,96            network_interface=features.Sriov(),97        ),98    )99    def verify_sriov_single_vf_connection(self, environment: Environment) -> None:100        vm_nics = initialize_nic_info(environment)101        sriov_basic_test(environment, vm_nics)102        sriov_vf_connection_test(environment, vm_nics)103    @TestCaseMetadata(104        description="""105        This case needs 2 nodes and 64 Vcpus. And it verifies module of sriov network106         interface is loaded and each synthetic nic is paired with one VF, and check107         rx statistics of source and tx statistics of dest increase after send 200 Mb108         file from source to dest.109        Steps,110        1. Check VF of synthetic nic is paired.111        2. Check module of sriov network device is loaded.112        3. Check VF counts listed from lspci is expected.113        4. Setup SSH connection between source and dest with key authentication.114        5. Ping the dest IP from the source machine to check connectivity.115        6. Generate 200Mb file, copy from source to dest.116        7. Check rx statistics of source VF and tx statistics of dest VF is increased.117        """,118        priority=2,119        requirement=simple_requirement(120            min_count=2,121            min_core_count=64,122            network_interface=features.Sriov(),123        ),124    )125    def verify_sriov_single_vf_connection_max_cpu(126        self, environment: Environment127    ) -> None:128        vm_nics = initialize_nic_info(environment)129        sriov_basic_test(environment, vm_nics)130        sriov_vf_connection_test(environment, vm_nics)131    @TestCaseMetadata(132        description="""133        This case needs 2 nodes and 8 nics. And it verifies module of sriov network134         interface is loaded and each synthetic nic is paired with one VF, and check135         rx statistics of source and tx statistics of dest increase after send 200 Mb136         file from source to dest.137        Steps,138        1. Check VF of synthetic nic is paired.139        2. Check module of sriov network device is loaded.140        3. Check VF counts listed from lspci is expected.141        4. Setup SSH connection between source and dest with key authentication.142        5. Ping the dest IP from the source machine to check connectivity.143        6. Generate 200Mb file, copy from source to dest.144        7. Check rx statistics of source VF and tx statistics of dest VF is increased.145        """,146        priority=2,147        requirement=simple_requirement(148            min_count=2,149            network_interface=schema.NetworkInterfaceOptionSettings(150                nic_count=8,151                data_path=schema.NetworkDataPath.Sriov,152            ),153        ),154    )155    def verify_sriov_max_vf_connection(self, environment: Environment) -> None:156        vm_nics = initialize_nic_info(environment)157        sriov_basic_test(environment, vm_nics)158        sriov_vf_connection_test(environment, vm_nics)159    @TestCaseMetadata(160        description="""161        This case needs 2 nodes, 8 nics and 64 Vcpus. And it verifies module of sriov162         network interface is loaded and each synthetic nic is paired with one VF, and163         check rx statistics of source and tx statistics of dest increase after send 200164         Mb file from source to dest.165        Steps,166        1. Check VF of synthetic nic is paired.167        2. Check module of sriov network device is loaded.168        3. Check VF counts listed from lspci is expected.169        4. Setup SSH connection between source and dest with key authentication.170        5. Ping the dest IP from the source machine to check connectivity.171        6. Generate 200Mb file, copy from source to dest.172        7. Check rx statistics of source VF and tx statistics of dest VF is increased.173        """,174        priority=2,175        requirement=simple_requirement(176            min_count=2,177            min_core_count=64,178            network_interface=schema.NetworkInterfaceOptionSettings(179                nic_count=8,180                data_path=schema.NetworkDataPath.Sriov,181            ),182        ),183    )184    def verify_sriov_max_vf_connection_max_cpu(self, environment: Environment) -> None:185        vm_nics = initialize_nic_info(environment)186        sriov_basic_test(environment, vm_nics)187        sriov_vf_connection_test(environment, vm_nics)188    @TestCaseMetadata(189        description="""190        This case verify VM works well after disable and enable accelerated network in191         network interface through sdk.192        Steps,193        1. Do the basic sriov check.194        2. Set enable_accelerated_networking as False to disable sriov.195        3. Set enable_accelerated_networking as True to enable sriov.196        4. Do the basic sriov check.197        5. Do step 2 ~ step 4 for 2 times.198        """,199        priority=2,200        requirement=simple_requirement(201            network_interface=features.Sriov(),202            supported_platform_type=[AZURE],203        ),204    )205    def verify_sriov_disable_enable(self, environment: Environment) -> None:206        sriov_disable_enable(environment)207    @TestCaseMetadata(208        description="""209        This case verify VM works well after disable and enable PCI device inside VM.210        Steps,211        1. Disable sriov PCI device inside the VM.212        2. Enable sriov PCI device inside the VM.213        3. Do the basic sriov check.214        4. Do VF connection test.215        """,216        priority=2,217        requirement=simple_requirement(218            min_count=2,219            network_interface=features.Sriov(),220        ),221    )222    def verify_sriov_disable_enable_pci(self, environment: Environment) -> None:223        for node in environment.nodes.list():224            lspci = node.tools[Lspci]225            lspci.disable_devices_by_type(constants.DEVICE_TYPE_SRIOV)226            lspci.enable_devices()227        vm_nics = initialize_nic_info(environment)228        sriov_basic_test(environment, vm_nics)229        sriov_vf_connection_test(environment, vm_nics)230    @TestCaseMetadata(231        description="""232        This case verify VM works well after down the VF nic and up VF nic inside VM.233        Steps,234        1. Do the basic sriov check.235        2. Do network connection test with bring down the VF nic.236        3. After copy 200Mb file from source to desc.237        4. Check rx statistics of source synthetic nic and tx statistics of dest238         synthetic nic is increased.239        5. Bring up VF nic.240        """,241        priority=2,242        requirement=simple_requirement(243            min_count=2,244            network_interface=features.Sriov(),245        ),246    )247    def verify_sriov_disable_enable_on_guest(self, environment: Environment) -> None:248        vm_nics = initialize_nic_info(environment)249        sriov_basic_test(environment, vm_nics)250        sriov_vf_connection_test(environment, vm_nics, turn_off_vf=True)251    @TestCaseMetadata(252        description="""253        This case verify VM works well after attached the max sriov nics after254         provision.255        Steps,256        1. Attach 7 extra sriov nic into the VM.257        2. Do the basic sriov testing.258        """,259        priority=2,260        use_new_environment=True,261        requirement=simple_requirement(262            network_interface=schema.NetworkInterfaceOptionSettings(263                data_path=schema.NetworkDataPath.Sriov,264                max_nic_count=8,265            ),266        ),267    )268    def verify_sriov_add_max_nics(269        self, log_path: Path, log: Logger, environment: Environment270    ) -> None:271        remove_extra_nics(environment)272        try:273            node = cast(RemoteNode, environment.nodes[0])274            network_interface_feature = node.features[NetworkInterface]275            network_interface_feature.attach_nics(extra_nic_count=7)276            is_ready, tcp_error_code = wait_tcp_port_ready(277                node.public_address, node.public_port, log=log, timeout=self.TIME_OUT278            )279            if is_ready:280                vm_nics = initialize_nic_info(environment)281                sriov_basic_test(environment, vm_nics)282            else:283                serial_console = node.features[SerialConsole]284                serial_console.check_panic(285                    saved_path=log_path, stage="after_attach_nics"286                )287                raise TcpConnectionException(288                    node.public_address,289                    node.public_port,290                    tcp_error_code,291                    "no panic found in serial log after attach nics",292                )293        finally:294            restore_extra_nics(environment)295    @TestCaseMetadata(296        description="""297        This case verify VM works well when provisioning with max (8) sriov nics.298        Steps,299        1. Provision VM with max network interfaces with enabling accelerated network.300        2. Do the basic sriov testing.301        """,302        priority=2,303        requirement=simple_requirement(304            min_nic_count=8,305            network_interface=features.Sriov(),306        ),307    )308    def verify_sriov_provision_with_max_nics(self, environment: Environment) -> None:309        vm_nics = initialize_nic_info(environment)310        sriov_basic_test(environment, vm_nics)311    @TestCaseMetadata(312        description="""313        This case verify VM works well when provisioning with max (8) sriov nics.314        Steps,315        1. Provision VM with max network interfaces with enabling accelerated network.316        2. Do the basic sriov testing.317        3. Reboot VM from guest.318        4. Do the basic sriov testing.319        """,320        priority=2,321        requirement=simple_requirement(322            min_nic_count=8,323            network_interface=features.Sriov(),324        ),325    )326    def verify_sriov_provision_with_max_nics_reboot(327        self, environment: Environment328    ) -> None:329        vm_nics = initialize_nic_info(environment)330        sriov_basic_test(environment, vm_nics)331        for node in environment.nodes.list():332            node.reboot()333        sriov_basic_test(environment, vm_nics)334    @TestCaseMetadata(335        description="""336        This case verify VM works well when provisioning with max (8) sriov nics.337        Steps,338        1. Provision VM with max network interfaces with enabling accelerated network.339        2. Do the basic sriov testing.340        3. Reboot VM from API.341        4. Do the basic sriov testing.342        """,343        priority=2,344        requirement=simple_requirement(345            min_nic_count=8,346            network_interface=features.Sriov(),347        ),348    )349    def verify_sriov_provision_with_max_nics_reboot_from_platform(350        self, environment: Environment351    ) -> None:352        vm_nics = initialize_nic_info(environment)353        sriov_basic_test(environment, vm_nics)354        for node in environment.nodes.list():355            start_stop = node.features[StartStop]356            start_stop.restart()357        sriov_basic_test(environment, vm_nics)358    @TestCaseMetadata(359        description="""360        This case verify VM works well when provisioning with max (8) sriov nics.361        Steps,362        1. Provision VM with max network interfaces with enabling accelerated network.363        2. Do the basic sriov testing.364        3. Stop and Start VM from API.365        4. Do the basic sriov testing.366        """,367        priority=2,368        requirement=simple_requirement(369            min_nic_count=8,370            network_interface=features.Sriov(),371        ),372    )373    def verify_sriov_provision_with_max_nics_stop_start_from_platform(374        self, environment: Environment375    ) -> None:376        vm_nics = initialize_nic_info(environment)377        sriov_basic_test(environment, vm_nics)378        for node in environment.nodes.list():379            start_stop = node.features[StartStop]380            start_stop.stop()381            start_stop.start()382        sriov_basic_test(environment, vm_nics)383    @TestCaseMetadata(384        description="""385        This case verify VM works well during remove and load sriov modules.386        Steps,387        1. Provision VM with max network interfaces with enabling accelerated network.388        2. Do the basic sriov testing.389        3. Remove sriov module, check network traffic through synthetic nic.390        4. Load sriov module, check network traffic through VF.391        """,392        priority=2,393        requirement=simple_requirement(394            min_count=2,395            min_nic_count=8,396            network_interface=features.Sriov(),397        ),398    )399    def verify_sriov_reload_modules(self, environment: Environment) -> None:400        for node in environment.nodes.list():401            if node.tools[KernelConfig].is_built_in(get_used_config(node)):402                raise SkippedException(403                    "current VM's mlx driver is built-in, can not reload."404                )405        vm_nics = initialize_nic_info(environment)406        sriov_basic_test(environment, vm_nics)407        module_in_used: Dict[str, str] = {}408        for node in environment.nodes.list():409            module_in_used[node.name] = remove_module(node)410        sriov_vf_connection_test(environment, vm_nics, remove_module=True)411        for node in environment.nodes.list():412            load_module(node, module_in_used[node.name])413        vm_nics = initialize_nic_info(environment)414        sriov_vf_connection_test(environment, vm_nics)415    @TestCaseMetadata(416        description="""417        This case verify below two kernel patches.418        1. hv_netvsc: Sync offloading features to VF NIC419           https://github.com/torvalds/linux/commit/68622d071e555e1528f3e7807f30f73311c1acae#diff-007213ba7199932efdb096be47d209a2f83e4d425c486b3adaba861d0a0c80c5 # noqa: E501420        2. hv_netvsc: Allow scatter-gather feature to be tunable421           https://github.com/torvalds/linux/commit/b441f79532ec13dc82d05c55badc4da1f62a6141#diff-007213ba7199932efdb096be47d209a2f83e4d425c486b3adaba861d0a0c80c5 # noqa: E501422        Steps,423        1. Change scatter-gather feature on synthetic nic,424         verify the the feature status sync to the VF dynamically.425        2. Disable and enable sriov,426         check the scatter-gather feature status keep consistent in VF.427        """,428        priority=2,429        requirement=simple_requirement(430            min_count=2,431            network_interface=schema.NetworkInterfaceOptionSettings(432                nic_count=search_space.IntRange(min=3, max=8),433                data_path=schema.NetworkDataPath.Sriov,434            ),435        ),436    )437    def verify_sriov_ethtool_offload_setting(self, environment: Environment) -> None:438        client_iperf3_log = "iperfResults.log"439        server_node = cast(RemoteNode, environment.nodes[0])440        client_node = cast(RemoteNode, environment.nodes[1])441        client_ethtool = client_node.tools[Ethtool]442        vm_nics = initialize_nic_info(environment)443        # skip test if scatter-gather can't be updated444        for _, client_nic_info in vm_nics[client_node.name].items():445            device_sg_settings = client_ethtool.get_device_sg_settings(446                client_nic_info.upper, True447            )448            if device_sg_settings.sg_fixed:449                raise SkippedException(450                    "scatter-gather is fixed, it cannot be changed for device"451                    f" {client_nic_info.upper}. Skipping test."452                )453            else:454                break455        # save original enabled features456        device_enabled_features_origin = client_ethtool.get_all_device_enabled_features(457            True458        )459        # run iperf3 on server side and client side460        # iperfResults.log stored client side log461        source_iperf3 = server_node.tools[Iperf3]462        dest_iperf3 = client_node.tools[Iperf3]463        source_iperf3.run_as_server_async()464        dest_iperf3.run_as_client_async(465            server_ip=server_node.internal_address,466            log_file=client_iperf3_log,467            run_time_seconds=self.TIME_OUT,468        )469        # wait for a while then check any error shown up in iperfResults.log470        dest_cat = client_node.tools[Cat]471        iperf_log = dest_cat.read(client_iperf3_log, sudo=True, force_run=True)472        assert_that(iperf_log).does_not_contain("error")473        # disable and enable VF in pci level474        for node in environment.nodes.list():475            lspci = node.tools[Lspci]476            lspci.disable_devices_by_type(constants.DEVICE_TYPE_SRIOV)477            lspci.enable_devices()478        # check VF still paired with synthetic nic479        vm_nics = initialize_nic_info(environment)480        # get the enabled features after disable and enable VF481        # make sure there is not any change482        device_enabled_features_after = client_ethtool.get_all_device_enabled_features(483            True484        )485        assert_that(device_enabled_features_origin[0].enabled_features).is_equal_to(486            device_enabled_features_after[0].enabled_features487        )488        # set on for scatter-gather feature for synthetic nic489        # verify vf scatter-gather feature has value 'on'490        for _, client_nic_info in vm_nics[client_node.name].items():491            new_settings = client_ethtool.change_device_sg_settings(492                client_nic_info.upper, True493            )494            device_vf_sg_settings = client_ethtool.get_device_sg_settings(495                client_nic_info.lower, True496            )497            assert_that(498                new_settings.sg_setting,499                "sg setting is not sync into VF.",500            ).is_equal_to(device_vf_sg_settings.sg_setting)501        # set off for scatter-gather feature for synthetic nic502        # verify vf scatter-gather feature has value 'off'503        for _, client_nic_info in vm_nics[client_node.name].items():504            new_settings = client_ethtool.change_device_sg_settings(505                client_nic_info.upper, False506            )507            device_vf_sg_settings = client_ethtool.get_device_sg_settings(508                client_nic_info.lower, True509            )510            assert_that(511                new_settings.sg_setting,512                "sg setting is not sync into VF.",513            ).is_equal_to(device_vf_sg_settings.sg_setting)514        #  disable and enable VF in pci level515        for node in environment.nodes.list():516            lspci = node.tools[Lspci]517            lspci.disable_devices_by_type(constants.DEVICE_TYPE_SRIOV)518            lspci.enable_devices()519        # check VF still paired with synthetic nic520        vm_nics = initialize_nic_info(environment)521        # check VF's scatter-gather feature keep consistent with previous status522        for _, client_nic_info in vm_nics[client_node.name].items():523            device_vf_sg_settings = client_ethtool.get_device_sg_settings(524                client_nic_info.lower, True525            )526            assert_that(527                device_vf_sg_settings.sg_setting,528                "sg setting is not sync into VF.",529            ).is_equal_to(False)530        # disable and enable sriov in network interface level531        network_interface_feature = client_node.features[NetworkInterface]532        for _ in range(3):533            sriov_is_enabled = network_interface_feature.is_enabled_sriov()534            network_interface_feature.switch_sriov(enable=(not sriov_is_enabled))535        network_interface_feature.switch_sriov(enable=True)536        # check VF still paired with synthetic nic537        vm_nics = initialize_nic_info(environment)538        # check VF's scatter-gather feature keep consistent with previous status539        for _, client_nic_info in vm_nics[client_node.name].items():540            device_vf_sg_settings = client_ethtool.get_device_sg_settings(541                client_nic_info.lower, True542            )543            assert_that(544                device_vf_sg_settings.sg_setting,545                "sg setting is not sync into VF.",546            ).is_equal_to(False)547        # reload sriov modules548        module_in_used = ""549        for node in environment.nodes.list():550            module_in_used = remove_module(node)551        for node in environment.nodes.list():552            load_module(node, module_in_used)553        # check VF still paired with synthetic nic554        vm_nics = initialize_nic_info(environment)555        # check VF's scatter-gather feature keep consistent with previous status556        for _, client_nic_info in vm_nics[client_node.name].items():557            device_vf_sg_settings = client_ethtool.get_device_sg_settings(558                client_nic_info.lower, True559            )560            assert_that(561                device_vf_sg_settings.sg_setting,562                "sg setting is not sync into VF.",563            ).is_equal_to(False)564        # check there is no error happen in iperf3 log565        # after above operations566        dest_cat = client_node.tools[Cat]567        iperf_log = dest_cat.read(client_iperf3_log, sudo=True, force_run=True)568        assert_that(iperf_log).does_not_contain("error")569    @TestCaseMetadata(570        description="""571        This case is to verify interrupts count increased after network traffic572         went through the VF, if CPU is less than 8, it can't verify the interrupts573         spread to CPU evenly, when CPU is more than 16, the traffic is too light to574         make sure interrupts distribute to every CPU.575        Steps,576        1. Start iperf3 on server node.577        2. Get initial interrupts sum per irq and cpu number on client node.578        3. Start iperf3 for 120 seconds with 128 threads on client node.579        4. Get final interrupts sum per irq number on client node.580        5. Compare interrupts changes, expected to see interrupts increased.581        6. Get final interrupts sum per cpu on client node.582        7. Collect cpus which don't have interrupts count increased.583        8. Compare interrupts count changes, expected half of cpus' interrupts584         increased.585        """,586        priority=2,587        requirement=node_requirement(588            node=schema.NodeSpace(589                node_count=2,590                core_count=search_space.IntRange(min=8, max=16),591                network_interface=features.Sriov(),592            )593        ),594    )595    def verify_sriov_interrupts_change(self, environment: Environment) -> None:596        server_node = cast(RemoteNode, environment.nodes[0])597        client_node = cast(RemoteNode, environment.nodes[1])598        client_lscpu = client_node.tools[Lscpu]599        client_cpu_count = client_lscpu.get_core_count()600        vm_nics = initialize_nic_info(environment)601        server_iperf3 = server_node.tools[Iperf3]602        client_iperf3 = client_node.tools[Iperf3]603        # 1. Start iperf3 on server node.604        server_iperf3.run_as_server_async()605        client_interrupt_inspector = client_node.tools[InterruptInspector]606        for _, client_nic_info in vm_nics[client_node.name].items():607            # 2. Get initial interrupts sum per irq and cpu number on client node.608            # only collect 'Completion Queue Interrupts' irqs609            initial_pci_interrupts_by_irqs = (610                client_interrupt_inspector.sum_cpu_counter_by_irqs(611                    client_nic_info.pci_slot,612                    exclude_key_words=["pages", "cmd", "async"],613                )614            )...stress.py
Source:stress.py  
...53    )54    def verify_stress_sriov_iperf(self, environment: Environment) -> None:55        server_node = cast(RemoteNode, environment.nodes[0])56        client_node = cast(RemoteNode, environment.nodes[1])57        vm_nics = initialize_nic_info(environment)58        client_iperf3_log = "iperfResults.log"59        server_iperf3 = server_node.tools[Iperf3]60        # 1. Start iperf3 on server node.61        server_iperf3.run_as_server_async()62        # 2. Start iperf3 for 30 minutes on client node.63        client_nic_info_list = [64            x65            for _, x in vm_nics[client_node.name].items()66            if x.ip_addr == client_node.internal_address67        ]68        assert_that(client_nic_info_list).described_as(69            "not found the primary network interface."70        ).is_not_none()71        client_nic_info = client_nic_info_list[0]72        isinstance(client_nic_info, NicInfo)73        matched_server_nic_info: NicInfo74        for _, server_nic_info in vm_nics[server_node.name].items():75            if (76                server_nic_info.ip_addr.rsplit(".", maxsplit=1)[0]77                == client_nic_info.ip_addr.rsplit(".", maxsplit=1)[0]78            ):79                matched_server_nic_info = server_nic_info80                break81        assert matched_server_nic_info, (82            "not found the server nic has the same subnet of"83            f" {client_nic_info.ip_addr}"84        )85        client_iperf3 = client_node.tools[Iperf3]86        client_iperf3.run_as_client(87            server_ip=matched_server_nic_info.ip_addr,88            log_file=client_iperf3_log,89            run_time_seconds=1800,90            client_ip=client_nic_info.ip_addr,91        )92        client_cat = client_node.tools[Cat]93        iperf_log = client_cat.read(client_iperf3_log, sudo=True, force_run=True)94        assert_that(iperf_log).described_as(95            f"iperf client run failed on client node, {iperf_log}"96        ).does_not_contain("error")97        # 3. Do VF connection test.98        sriov_vf_connection_test(environment, vm_nics)99    @TestCaseMetadata(100        description="""101        This case verify VM works well after disable and enable accelerated network in102         network interface through sdk under stress.103        It is a regression test case to check the bug104         https://git.launchpad.net/~canonical-kernel/ubuntu/+source/linux-azure/+git/105         bionic/commit/id=16a3c750a78d8, which misses the second hunk of the upstream106         patch https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/107         commit/?id=877b911a5ba0. Details please check https://bugs.launchpad.net/108         ubuntu/+source/linux-azure/+bug/1965618109        Steps,110        1. Do the basic sriov check.111        2. Set enable_accelerated_networking as False to disable sriov.112        3. Set enable_accelerated_networking as True to enable sriov.113        4. Do the basic sriov check.114        5. Do step 2 ~ step 4 for 25 times.115        """,116        priority=3,117        timeout=4500,118        requirement=simple_requirement(119            min_core_count=4,120            network_interface=features.Sriov(),121            supported_platform_type=[AZURE],122        ),123    )124    def verify_stress_sriov_disable_enable(self, environment: Environment) -> None:125        sriov_disable_enable(environment, times=50)126    @TestCaseMetadata(127        description="""128        This case verify VM works well when provison with max (8) synthetic nics.129        Steps,130        1. Provision VM with max network interfaces with synthetic network.131        2. Check each nic has an ip address.132        3. Reboot VM from guest.133        4. Check each nic has an ip address.134        5. Repeat step 3 and 4 for 10 times.135        """,136        priority=2,137        requirement=simple_requirement(138            min_nic_count=8,139            network_interface=schema.NetworkInterfaceOptionSettings(140                data_path=schema.NetworkDataPath.Synthetic,141            ),142        ),143    )144    def verify_stress_synthetic_provision_with_max_nics_reboot(145        self, environment: Environment146    ) -> None:147        initialize_nic_info(environment, is_sriov=False)148        for _ in range(10):149            for node in environment.nodes.list():150                node.reboot()151            initialize_nic_info(environment, is_sriov=False)152    @TestCaseMetadata(153        description="""154        This case verify VM works well when provison with max (8) synthetic nics.155        Steps,156        1. Provision VM with max network interfaces with synthetic network.157        2. Check each nic has an ip address.158        3. Reboot VM from API.159        4. Check each nic has an ip address.160        5. Repeat step 3 and 4 for 10 times.161        """,162        priority=2,163        requirement=simple_requirement(164            min_nic_count=8,165            network_interface=schema.NetworkInterfaceOptionSettings(166                data_path=schema.NetworkDataPath.Synthetic,167            ),168        ),169    )170    def verify_stress_synthetic_with_max_nics_reboot_from_platform(171        self, environment: Environment172    ) -> None:173        initialize_nic_info(environment, is_sriov=False)174        for _ in range(10):175            for node in environment.nodes.list():176                start_stop = node.features[StartStop]177                start_stop.restart()178            initialize_nic_info(environment, is_sriov=False)179    @TestCaseMetadata(180        description="""181        This case verify VM works well when provison with max (8) synthetic nics.182        Steps,183        1. Provision VM with max network interfaces with synthetic network.184        2. Check each nic has an ip address.185        3. Stop and Start VM from API.186        4. Check each nic has an ip address.187        5. Repeat step 3 and 4 for 10 times.188        """,189        priority=2,190        requirement=simple_requirement(191            min_nic_count=8,192            network_interface=schema.NetworkInterfaceOptionSettings(193                data_path=schema.NetworkDataPath.Synthetic,194            ),195        ),196    )197    def verify_stress_synthetic_with_max_nics_stop_start_from_platform(198        self, environment: Environment199    ) -> None:200        initialize_nic_info(environment, is_sriov=False)201        for _ in range(10):202            for node in environment.nodes.list():203                start_stop = node.features[StartStop]204                start_stop.stop()205                start_stop.start()206            initialize_nic_info(environment, is_sriov=False)207    @TestCaseMetadata(208        description="""209        This case verify VM works well when provisioning with max (8) sriov nics.210        Steps,211        1. Provision VM with max network interfaces with enabling accelerated network.212        2. Do the basic sriov testing.213        3. Reboot VM from guest.214        4. Do the basic sriov testing.215        5. Repeat step 3 and 4 for 10 times.216        """,217        priority=2,218        requirement=simple_requirement(219            min_nic_count=8,220            network_interface=features.Sriov(),221        ),222    )223    def verify_stress_sriov_with_max_nics_reboot(224        self, environment: Environment225    ) -> None:226        vm_nics = initialize_nic_info(environment)227        sriov_basic_test(environment, vm_nics)228        for _ in range(10):229            for node in environment.nodes.list():230                node.reboot()231            sriov_basic_test(environment, vm_nics)232    @TestCaseMetadata(233        description="""234        This case verify VM works well when provisioning with max (8) sriov nics.235        Steps,236        1. Provision VM with max network interfaces with enabling accelerated network.237        2. Do the basic sriov testing.238        3. Reboot VM from API.239        4. Do the basic sriov testing.240        5. Repeat step 3 and 4 for 10 times.241        """,242        priority=2,243        requirement=simple_requirement(244            min_nic_count=8,245            network_interface=features.Sriov(),246        ),247    )248    def verify_sriov_with_max_nics_reboot_from_platform(249        self, environment: Environment250    ) -> None:251        vm_nics = initialize_nic_info(environment)252        sriov_basic_test(environment, vm_nics)253        for _ in range(10):254            for node in environment.nodes.list():255                start_stop = node.features[StartStop]256                start_stop.restart()257            sriov_basic_test(environment, vm_nics)258    @TestCaseMetadata(259        description="""260        This case verify VM works well when provisioning with max (8) sriov nics.261        Steps,262        1. Provision VM with max network interfaces with enabling accelerated network.263        2. Do the basic sriov testing.264        3. Stop and Start VM from API.265        4. Do the basic sriov testing.266        5. Repeat step 3 and 4 for 10 times.267        """,268        priority=2,269        requirement=simple_requirement(270            min_nic_count=8,271            network_interface=features.Sriov(),272        ),273    )274    def verify_sriov_with_max_nics_stop_start_from_platform(275        self, environment: Environment276    ) -> None:277        vm_nics = initialize_nic_info(environment)278        sriov_basic_test(environment, vm_nics)279        for _ in range(10):280            for node in environment.nodes.list():281                start_stop = node.features[StartStop]282                start_stop.stop()283                start_stop.start()284            sriov_basic_test(environment, vm_nics)285    def after_case(self, log: Logger, **kwargs: Any) -> None:286        environment: Environment = kwargs.pop("environment")...synthetic.py
Source:synthetic.py  
...36    )37    def synthetic_provision_with_max_nics_validation(38        self, environment: Environment39    ) -> None:40        initialize_nic_info(environment, is_sriov=False)41    @TestCaseMetadata(42        description="""43        This case verify VM works well when provison with max (8) synthetic nics.44        Steps,45        1. Provision VM with max network interfaces with synthetic network.46        2. Check each nic has an ip address.47        3. Reboot VM from guest.48        4. Check each nic has an ip address.49        """,50        priority=2,51        requirement=simple_requirement(52            min_nic_count=8,53            network_interface=schema.NetworkInterfaceOptionSettings(54                data_path=schema.NetworkDataPath.Synthetic,55            ),56        ),57    )58    def synthetic_provision_with_max_nics_reboot_validation(59        self, environment: Environment60    ) -> None:61        initialize_nic_info(environment, is_sriov=False)62        for node in environment.nodes.list():63            node.reboot()64        initialize_nic_info(environment, is_sriov=False)65    @TestCaseMetadata(66        description="""67        This case verify VM works well when provison with max (8) synthetic nics.68        Steps,69        1. Provision VM with max network interfaces with synthetic network.70        2. Check each nic has an ip address.71        3. Reboot VM from API.72        4. Check each nic has an ip address.73        """,74        priority=2,75        requirement=simple_requirement(76            min_nic_count=8,77            network_interface=schema.NetworkInterfaceOptionSettings(78                data_path=schema.NetworkDataPath.Synthetic,79            ),80        ),81    )82    def synthetic_provision_with_max_nics_reboot_from_platform_validation(83        self, environment: Environment84    ) -> None:85        initialize_nic_info(environment, is_sriov=False)86        for node in environment.nodes.list():87            start_stop = node.features[StartStop]88            start_stop.restart()89        initialize_nic_info(environment, is_sriov=False)90    @TestCaseMetadata(91        description="""92        This case verify VM works well when provison with max (8) synthetic nics.93        Steps,94        1. Provision VM with max network interfaces with synthetic network.95        2. Check each nic has an ip address.96        3. Stop and Start VM from API.97        4. Check each nic has an ip address.98        """,99        priority=2,100        requirement=simple_requirement(101            min_nic_count=8,102            network_interface=schema.NetworkInterfaceOptionSettings(103                data_path=schema.NetworkDataPath.Synthetic,104            ),105        ),106    )107    def synthetic_provision_with_max_nics_stop_start_from_platform_validation(108        self, environment: Environment109    ) -> None:110        initialize_nic_info(environment, is_sriov=False)111        for node in environment.nodes.list():112            start_stop = node.features[StartStop]113            start_stop.stop()114            start_stop.start()115        initialize_nic_info(environment, is_sriov=False)116    @TestCaseMetadata(117        description="""118        This case verify VM works well after attaching 7 extra synthetic nics119         in one time.120        Steps,121        1. Provision VM with 1 network interface with synthetic network.122        2. Add 7 extra network interfaces in one time.123        3. Check each nic has an ip address.124        """,125        priority=2,126        use_new_environment=True,127        requirement=simple_requirement(128            network_interface=schema.NetworkInterfaceOptionSettings(129                data_path=schema.NetworkDataPath.Synthetic,130                max_nic_count=8,131            ),132        ),133    )134    def synthetic_add_max_nics_one_time_after_provision_validation(135        self, environment: Environment136    ) -> None:137        remove_extra_nics(environment)138        try:139            for node in environment.nodes.list():140                network_interface_feature = node.features[NetworkInterface]141                network_interface_feature.attach_nics(142                    extra_nic_count=7, enable_accelerated_networking=False143                )144            initialize_nic_info(environment, is_sriov=False)145        finally:146            restore_extra_nics(environment)147    @TestCaseMetadata(148        description="""149        This case verify VM works well after attaching 7 extra synthetic nics150         one by one.151        Steps,152        1. Provision VM with 1 network interface with synthetic network.153        2. Add 7 extra network interfaces one by one.154        3. Check each nic has an ip address.155        """,156        priority=2,157        use_new_environment=True,158        requirement=simple_requirement(159            network_interface=schema.NetworkInterfaceOptionSettings(160                data_path=schema.NetworkDataPath.Synthetic,161                max_nic_count=8,162            ),163        ),164    )165    def synthetic_add_max_nics_one_by_one_after_provision_validation(166        self, environment: Environment167    ) -> None:168        remove_extra_nics(environment)169        try:170            for node in environment.nodes.list():171                network_interface_feature = node.features[NetworkInterface]172                for _ in range(7):173                    network_interface_feature.attach_nics(174                        extra_nic_count=1, enable_accelerated_networking=False175                    )176                    initialize_nic_info(environment, is_sriov=False)177        finally:...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!!
