From 4de9d7dcec116b9bcfa8c45389cd40229539e0f5 Mon Sep 17 00:00:00 2001 From: sellappa Date: Tue, 24 Sep 2024 00:56:22 +0000 Subject: [PATCH 1/9] Fixed reboot and lacp cases --- .../lacp/files/lacp_dut_helper.py | 36 ++--- .../lacp/files/lacp_physical_helper.py | 53 +++--- .../lacp/test_add_remove_link_from_dut.py | 12 +- .../lacp/test_add_remove_link_physically.py | 12 +- .../lacp/test_lacp_timers_effect.py | 16 +- .../reboot/files/reboot_helper.py | 152 +++++++++--------- 6 files changed, 128 insertions(+), 153 deletions(-) diff --git a/tests/snappi_tests/lacp/files/lacp_dut_helper.py b/tests/snappi_tests/lacp/files/lacp_dut_helper.py index b4a63731f4d..42d691167b6 100755 --- a/tests/snappi_tests/lacp/files/lacp_dut_helper.py +++ b/tests/snappi_tests/lacp/files/lacp_dut_helper.py @@ -18,7 +18,7 @@ def run_lacp_add_remove_link_from_dut(api, iteration, port_count, number_of_routes, - port_speed,): + traffic_type): """ Run Local link failover test @@ -29,7 +29,7 @@ def run_lacp_add_remove_link_from_dut(api, iteration: number of iterations for running convergence test on a port port_count: total number of ports used in test number_of_routes: Number of IPv4/IPv6 Routes - port_speed: speed of the port used for test + traffic_type: IPv4 or IPv6 traffic flow """ """ Create bgp config on dut """ @@ -41,7 +41,7 @@ def run_lacp_add_remove_link_from_dut(api, tgen_bgp_config = __tgen_bgp_config(api, port_count, number_of_routes, - port_speed,) + traffic_type) """ Run the convergence test by flapping all the rx @@ -54,9 +54,6 @@ def run_lacp_add_remove_link_from_dut(api, port_count, number_of_routes,) - """ Cleanup the dut configs after getting the convergence numbers """ - cleanup_config(duthost) - def duthost_bgp_config(duthost, tgen_ports, @@ -133,7 +130,7 @@ def duthost_bgp_config(duthost, def __tgen_bgp_config(api, port_count, number_of_routes, - port_speed,): + traffic_type): """ Creating BGP config on TGEN @@ -141,7 +138,7 @@ def __tgen_bgp_config(api, api (pytest fixture): snappi API port_count: total number of ports used in test number_of_routes: Number of IPv4/IPv6 Routes - port_speed: speed of the port used for test + traffic_type: IPv4 or IPv6 traffic flow """ config = api.config() for i in range(1, port_count+1): @@ -171,7 +168,7 @@ def __tgen_bgp_config(api, layer1.ieee_media_defaults = False layer1.auto_negotiation.rs_fec = True layer1.auto_negotiation.link_training = False - layer1.speed = port_speed + layer1.speed = temp_tg_port[0]['speed'] layer1.auto_negotiate = False # Source @@ -249,8 +246,10 @@ def createTrafficItem(traffic_name, src, dest): flow1.rate.percentage = 50 flow1.metrics.enable = True flow1.metrics.loss = True - createTrafficItem("IPv4_1-IPv4_Routes", ipv4_1.name, route_range1.name) - createTrafficItem("IPv6_1-IPv6_Routes", ipv6_1.name, route_range2.name) + if traffic_type == 'IPv4': + createTrafficItem("IPv4_1-IPv4_Routes", ipv4_1.name, route_range1.name) + else: + createTrafficItem("IPv6_1-IPv6_Routes", ipv6_1.name, route_range2.name) return config @@ -373,18 +372,3 @@ def get_avg_cpdp_convergence_time(port_name, dut_port_name): columns = ['Event Name', 'No. of Routes', 'Iterations', 'Loss%'] logger.info("\n%s" % tabulate(table, headers=columns, tablefmt="psql")) - -def cleanup_config(duthost): - """ - Cleaning up dut config at the end of the test - - Args: - duthost (pytest fixture): duthost fixture - """ - logger.info('Cleaning up config') - duthost.command("sudo cp {} {}".format( - "/etc/sonic/config_db_backup.json", "/etc/sonic/config_db.json")) - duthost.shell("sudo config reload -y \n") - pytest_assert(wait_until(360, 10, 1, duthost.critical_services_fully_started), - "Not all critical services are fully started") - logger.info('Convergence Test Completed') diff --git a/tests/snappi_tests/lacp/files/lacp_physical_helper.py b/tests/snappi_tests/lacp/files/lacp_physical_helper.py index da122b469e1..7cfad39912b 100755 --- a/tests/snappi_tests/lacp/files/lacp_physical_helper.py +++ b/tests/snappi_tests/lacp/files/lacp_physical_helper.py @@ -21,7 +21,7 @@ def run_lacp_add_remove_link_physically(cvg_api, iteration, port_count, number_of_routes, - port_speed,): + traffic_type): """ Run Local link failover test @@ -32,7 +32,7 @@ def run_lacp_add_remove_link_physically(cvg_api, iteration: number of iterations for running convergence test on a port port_count: total number of ports used in test number_of_routes: Number of IPv4/IPv6 Routes - port_speed: speed of the port used for test + traffic_type: IPv4 or IPv6 traffic flow """ """ Create bgp config on dut """ @@ -44,7 +44,7 @@ def run_lacp_add_remove_link_physically(cvg_api, tgen_bgp_config = __tgen_bgp_config(cvg_api, port_count, number_of_routes, - port_speed,) + traffic_type) """ Run the convergence test by flapping all the rx @@ -56,9 +56,6 @@ def run_lacp_add_remove_link_physically(cvg_api, port_count, number_of_routes,) - """ Cleanup the dut configs after getting the convergence numbers """ - cleanup_config(duthost) - def run_lacp_timers_effect(cvg_api, duthost, @@ -66,9 +63,9 @@ def run_lacp_timers_effect(cvg_api, iteration, port_count, number_of_routes, - port_speed, lacpdu_interval_period, - lacpdu_timeout,): + lacpdu_timeout, + traffic_type): """ Run Local link failover test @@ -79,7 +76,7 @@ def run_lacp_timers_effect(cvg_api, iteration: number of iterations for running convergence test on a port port_count: total number of ports used in test number_of_routes: Number of IPv4/IPv6 Routes - port_speed: speed of the port used for test + traffic_type: IPv4 or IPv6 traffic flow """ """ Create bgp config on dut """ @@ -91,9 +88,10 @@ def run_lacp_timers_effect(cvg_api, tgen_bgp_config = __tgen_bgp_config(cvg_api, port_count, number_of_routes, - port_speed, + traffic_type, lacpdu_interval_period, - lacpdu_timeout,) + lacpdu_timeout, + ) """ Run the convergence test by flapping all the rx @@ -105,9 +103,6 @@ def run_lacp_timers_effect(cvg_api, port_count, number_of_routes,) - """ Cleanup the dut configs after getting the convergence numbers """ - cleanup_config(duthost) - def duthost_bgp_config(duthost, tgen_ports, @@ -184,9 +179,10 @@ def duthost_bgp_config(duthost, def __tgen_bgp_config(cvg_api, port_count, number_of_routes, - port_speed, + traffic_type, lacpdu_interval_period=0, - lacpdu_timeout=0,): + lacpdu_timeout=0, + ): """ Creating BGP config on TGEN @@ -194,9 +190,9 @@ def __tgen_bgp_config(cvg_api, cvg_api (pytest fixture): snappi API port_count: total number of ports used in test number_of_routes: Number of IPv4/IPv6 Routes - port_speed: speed of the port used for test lacpdu_interval_period: LACP update packet interval ( 0 - Auto, 1- Fast, 30 - Slow ) lacpdu_timeout: LACP Timeout value (0 - Auto, 3 - Short, 90 - Long) + traffic_type: IPv4 or IPv6 traffic flow """ conv_config = cvg_api.convergence_config() config = conv_config.config @@ -240,7 +236,7 @@ def __tgen_bgp_config(cvg_api, layer1.ieee_media_defaults = False layer1.auto_negotiation.rs_fec = True layer1.auto_negotiation.link_training = False - layer1.speed = port_speed + layer1.speed = temp_tg_port[0]['speed'] layer1.auto_negotiate = False # Source @@ -318,8 +314,10 @@ def createTrafficItem(traffic_name, src, dest): flow1.rate.percentage = 50 flow1.metrics.enable = True flow1.metrics.loss = True - createTrafficItem("IPv4_1-IPv4_Routes", ipv4_1.name, route_range1.name) - # createTrafficItem("IPv6_1-IPv6_Routes", ipv6_1.name, route_range2.name) + if traffic_type == 'IPv4': + createTrafficItem("IPv4_1-IPv4_Routes", ipv4_1.name, route_range1.name) + else: + createTrafficItem("IPv6_1-IPv6_Routes", ipv6_1.name, route_range2.name) return conv_config @@ -423,18 +421,3 @@ def get_avg_cpdp_convergence_time(port_name): 'Frames Delta', 'Avg Calculated Data Convergence Time (ms)'] logger.info("\n%s" % tabulate(table, headers=columns, tablefmt="psql")) - -def cleanup_config(duthost): - """ - Cleaning up dut config at the end of the test - - Args: - duthost (pytest fixture): duthost fixture - """ - logger.info('Cleaning up config') - duthost.command("sudo cp {} {}".format( - "/etc/sonic/config_db_backup.json", "/etc/sonic/config_db.json")) - duthost.shell("sudo config reload -y \n") - pytest_assert(wait_until(360, 10, 1, duthost.critical_services_fully_started), - "Not all critical services are fully started") - logger.info('Convergence Test Completed') diff --git a/tests/snappi_tests/lacp/test_add_remove_link_from_dut.py b/tests/snappi_tests/lacp/test_add_remove_link_from_dut.py index 6c8d9e40e89..26e39c014b6 100755 --- a/tests/snappi_tests/lacp/test_add_remove_link_from_dut.py +++ b/tests/snappi_tests/lacp/test_add_remove_link_from_dut.py @@ -9,10 +9,10 @@ pytestmark = [pytest.mark.topology('tgen')] -@pytest.mark.parametrize('port_count', [4]) +@pytest.mark.parametrize('port_count', [3]) @pytest.mark.parametrize('number_of_routes', [1000]) @pytest.mark.parametrize('iterations', [1]) -@pytest.mark.parametrize('port_speed', ['speed_100_gbps']) +@pytest.mark.parametrize('traffic_type', ['IPv4']) def test_lacp_add_remove_link_from_dut(snappi_api, # noqa F811 duthost, tgen_ports, # noqa F811 @@ -21,7 +21,7 @@ def test_lacp_add_remove_link_from_dut(snappi_api, # noqa F fanout_graph_facts, # noqa F811 port_count, number_of_routes, - port_speed,): + traffic_type): """ Topo: LAG1 --- DUT --- LAG2 (N-1 TGEN Ports) @@ -48,13 +48,13 @@ def test_lacp_add_remove_link_from_dut(snappi_api, # noqa F port_count: Total no of ports used in the test iterations: no of iterations to run the link flap test number_of_routes: Number of IPv4/IPv6 Routes - port_speed: speed of the port used for test + traffic_type: IPv4 or IPv6 traffic flow """ - # port_count, number_of_routes ,iterations and port_speed parameters can be modified as per user preference + # port_count, number_of_routes ,iterations parameters can be modified as per user preference run_lacp_add_remove_link_from_dut(snappi_api, duthost, tgen_ports, iterations, port_count, number_of_routes, - port_speed,) + traffic_type) diff --git a/tests/snappi_tests/lacp/test_add_remove_link_physically.py b/tests/snappi_tests/lacp/test_add_remove_link_physically.py index 313ec1c8d64..e81a132a145 100755 --- a/tests/snappi_tests/lacp/test_add_remove_link_physically.py +++ b/tests/snappi_tests/lacp/test_add_remove_link_physically.py @@ -9,10 +9,10 @@ pytestmark = [pytest.mark.topology('tgen')] -@pytest.mark.parametrize('port_count', [4]) +@pytest.mark.parametrize('port_count', [3]) @pytest.mark.parametrize('number_of_routes', [1000]) @pytest.mark.parametrize('iterations', [1]) -@pytest.mark.parametrize('port_speed', ['speed_100_gbps']) +@pytest.mark.parametrize('traffic_type', ['IPv4']) def test_lacp_add_remove_link_physically(cvg_api, # noqa F811 duthost, tgen_ports, # noqa F811 @@ -21,7 +21,7 @@ def test_lacp_add_remove_link_physically(cvg_api, # noqa F811 fanout_graph_facts, # noqa F811 port_count, number_of_routes, - port_speed,): + traffic_type): """ Topo: LAG1 --- DUT --- LAG2 (N-1 TGEN Ports) @@ -49,15 +49,15 @@ def test_lacp_add_remove_link_physically(cvg_api, # noqa F811 port_count: Total no of ports used in the test iterations: no of iterations to run the link flap test number_of_routes: Number of IPv4/IPv6 Routes - port_speed: speed of the port used for test lacpdu_interval_period: LACP update packet interval ( 0 - Auto, 1- Fast, 30 - Slow ) lacpdu_timeout: LACP Timeout value (0 - Auto, 3 - Short, 90 - Long) + traffic_type: IPv4 or IPv6 traffic flow """ - # port_count, number_of_routes ,iterations and port_speed parameters can be modified as per user preference + # port_count, number_of_routes ,iterations parameters can be modified as per user preference run_lacp_add_remove_link_physically(cvg_api, duthost, tgen_ports, iterations, port_count, number_of_routes, - port_speed,) + traffic_type) diff --git a/tests/snappi_tests/lacp/test_lacp_timers_effect.py b/tests/snappi_tests/lacp/test_lacp_timers_effect.py index 7ced05d159c..8b9187a1a2d 100644 --- a/tests/snappi_tests/lacp/test_lacp_timers_effect.py +++ b/tests/snappi_tests/lacp/test_lacp_timers_effect.py @@ -9,12 +9,12 @@ pytestmark = [pytest.mark.topology('tgen')] -@pytest.mark.parametrize('port_count', [4]) +@pytest.mark.parametrize('port_count', [3]) @pytest.mark.parametrize('number_of_routes', [1000]) @pytest.mark.parametrize('iterations', [1]) -@pytest.mark.parametrize('port_speed', ['speed_100_gbps']) @pytest.mark.parametrize('lacpdu_interval_period', [1]) @pytest.mark.parametrize('lacpdu_timeout', [90]) +@pytest.mark.parametrize('traffic_type', ['IPv4']) def test_lacp_timers(cvg_api, # noqa F811 duthost, tgen_ports, # noqa F811 @@ -23,9 +23,9 @@ def test_lacp_timers(cvg_api, # noqa F811 fanout_graph_facts, # noqa F811 port_count, number_of_routes, - port_speed, lacpdu_interval_period, - lacpdu_timeout,): + lacpdu_timeout, + traffic_type): """ Topo: LAG1 --- DUT --- LAG2 (N-1 TGEN Ports) @@ -54,11 +54,11 @@ def test_lacp_timers(cvg_api, # noqa F811 port_count: Total no of ports used in the test iterations: no of iterations to run the link flap test number_of_routes: Number of IPv4/IPv6 Routes - port_speed: speed of the port used for test lacpdu_interval_period: LACP update packet interval ( 0 - Auto, 1- Fast, 30 - Slow ) lacpdu_timeout: LACP Timeout value (0 - Auto, 3 - Short, 90 - Long) + traffic_type: IPv4 or IPv6 traffic flow """ - # port_count, number_of_routes ,iterations, port_speed, lacpdu_interval_period, + # port_count, number_of_routes ,iterations lacpdu_interval_period, # lacpdu_timeout parameters can be modified as per user preference run_lacp_timers_effect(cvg_api, duthost, @@ -66,6 +66,6 @@ def test_lacp_timers(cvg_api, # noqa F811 iterations, port_count, number_of_routes, - port_speed, lacpdu_interval_period, - lacpdu_timeout,) + lacpdu_timeout, + traffic_type) diff --git a/tests/snappi_tests/reboot/files/reboot_helper.py b/tests/snappi_tests/reboot/files/reboot_helper.py index afea3fb875e..fc76eb140fe 100644 --- a/tests/snappi_tests/reboot/files/reboot_helper.py +++ b/tests/snappi_tests/reboot/files/reboot_helper.py @@ -11,6 +11,7 @@ logger = logging.getLogger(__name__) TGEN_AS_NUM = 65200 +DUT_AS_NUM = 65100 TIMEOUT = 30 BGP_TYPE = 'ebgp' temp_tg_port = dict() @@ -52,8 +53,6 @@ def run_reboot_test(cvg_api, get_convergence_for_reboot_test(duthost, localhost, cvg_api, tgen_bgp_config, reboot_type, ) - cleanup_config(duthost) - def duthost_bgp_config(duthost, tgen_ports): """ @@ -62,11 +61,7 @@ def duthost_bgp_config(duthost, tgen_ports): duthost (pytest fixture): duthost fixture tgen_ports (pytest fixture): Ports mapping info of T0 testbed """ - start = time.time() global temp_tg_port - duthost.command("sudo config save -y") - duthost.command("sudo cp {} {}".format("/etc/sonic/config_db.json", - "/etc/sonic/config_db_backup.json")) temp_tg_port = tgen_ports for i in range(1, 4): intf_config = ( @@ -108,38 +103,81 @@ def duthost_bgp_config(duthost, tgen_ports): tgen_ports[1]['peer_ip'], tgen_ports[1]['peer_ipv6'])) duthost.shell(portchannel_config) loopback = ( - "sudo config interface ip add Loopback1 1.1.1.1/32\n" + "sudo config interface ip add Loopback0 1.1.1.1/32\n" ) logger.info('Configuring 1.1.1.1/32 on the loopback interface') duthost.shell(loopback) + logger.info('Saving Interface, Vlan and Portchannel configuration in config_db.json') + duthost.command('sudo config save -y \n') + logger.info('Configuring BGP in config_db.json') - bgp_neighbors = \ - {tgen_ports[1]['ipv6']: {"rrclient": "0", "name": "ARISTA08T0", - "local_addr": tgen_ports[1]['peer_ipv6'], - "nhopself": "0", "holdtime": "90", - "asn": TGEN_AS_NUM, "keepalive": "30"}, - tgen_ports[1]['ip']: {"rrclient": "0", "name": "ARISTA08T0", - "local_addr": tgen_ports[1]['peer_ip'], - "nhopself": "0", "holdtime": "90", - "asn": TGEN_AS_NUM, "keepalive": "30"}} - cdf = json.loads(duthost.shell("sonic-cfggen -d --print-data")['stdout']) - for neighbor, neighbor_info in list(bgp_neighbors.items()): - cdf["BGP_NEIGHBOR"][neighbor] = neighbor_info - - with open("/tmp/sconfig_db.json", 'w') as fp: - json.dump(cdf, fp, indent=4) - duthost.copy(src="/tmp/sconfig_db.json", dest="/tmp/config_db_temp.json") - cdf = json.loads(duthost.shell("sonic-cfggen -j /tmp/config_db_temp.json " - "--print-data")['stdout']) - print(cdf) - duthost.command("sudo cp {} {} \n".format("/tmp/config_db_temp.json", - "/etc/sonic/config_db.json")) - logger.info('Reloading config to apply BGP config') - duthost.shell("sudo config reload -y \n") - wait(TIMEOUT + 60, "For Config to reload \n") - end = time.time() - logger.info('duthost_bpg_config() took {}s to complete'.format( - end - start)) + config_db = json.loads(duthost.shell("sonic-cfggen -d --print-data")['stdout']) + bgp_neighbors = dict() + device_neighbors = dict() + device_neighbor_metadatas = dict() + bgp_neighbor = \ + { + tgen_ports[1]['ip']: + { + "asn": TGEN_AS_NUM, + "holdtime": "180", + "keepalive": "60", + "local_addr": tgen_ports[1]['peer_ip'], + "name": "snappi-sonic", + "nhopself": "0", + "rrclient": "0" + }, + tgen_ports[1]['ipv6']: + { + "asn": TGEN_AS_NUM, + "holdtime": "180", + "keepalive": "60", + "local_addr": tgen_ports[1]['peer_ipv6'], + "name": "snappi-sonic", + "nhopself": "0", + "rrclient": "0" + }, + } + bgp_neighbors.update(bgp_neighbor) + device_neighbor = { + 'Ethernet0': + { + "name": "snappi-sonic", + "port": "Ethernet1" + } + } + device_neighbors.update(device_neighbor) + device_neighbor_metadata = { + "snappi-sonic": + { + "hwsku": "Snappi", + "mgmt_addr": "172.16.149.206", + "type": "ToRRouter" + } + } + device_neighbor_metadatas.update(device_neighbor_metadata) + if "BGP_NEIGHBOR" not in config_db.keys(): + config_db["BGP_NEIGHBOR"] = bgp_neighbors + else: + config_db["BGP_NEIGHBOR"].update(bgp_neighbors) + + if "DEVICE_NEIGHBOR" not in config_db.keys(): + config_db["DEVICE_NEIGHBOR"] = device_neighbors + else: + config_db["DEVICE_NEIGHBOR"].update(device_neighbors) + + if 'DEVICE_NEIGHBOR_METADATA' not in config_db.keys(): + config_db["DEVICE_NEIGHBOR_METADATA"] = device_neighbor_metadatas + else: + config_db["DEVICE_NEIGHBOR_METADATA"].update(device_neighbor_metadatas) + + with open("/tmp/temp_config.json", 'w') as fp: + json.dump(config_db, fp, indent=4) + duthost.copy(src="/tmp/temp_config.json", dest="/etc/sonic/config_db.json") + logger.info('Reloading config_db.json to apply IP and BGP configuration on {}'.format(duthost.hostname)) + pytest_assert('Error' not in duthost.shell("sudo config reload -f -y \n")['stderr'], + 'Error while reloading config in {} !!!!!'.format(duthost.hostname)) + logger.info('Config Reload Successful in {} !!!'.format(duthost.hostname)) def get_flow_stats(cvg_api, name): @@ -198,7 +236,7 @@ def __tgen_bgp_config(cvg_api, ): ) lag3 = config.lags.lag(name="lag1")[-1] lp3 = lag3.ports.port(port_name=p1.name)[-1] - lp3.protocol.lacp.actor_system_id = "00:11:03:00:00:03" + lag3.protocol.lacp.actor_system_id = "00:11:03:00:00:03" lp3.ethernet.name = "lag_Ethernet 3" lp3.ethernet.mac = "00:13:01:00:00:01" @@ -294,9 +332,9 @@ def __tgen_bgp_config(cvg_api, ): bgpv6_int = bgpv6_stack.ipv6_interfaces.add() bgpv6_int.ipv6_name = ipv6_3.name bgpv6_peer = bgpv6_int.peers.add() - bgpv6_peer.name = 'BGP 3' + bgpv6_peer.name = 'BGP+ 3' bgpv6_peer.as_type = BGP_TYPE - bgpv6_peer.peer_address = temp_tg_port[1]['peer_ip'] + bgpv6_peer.peer_address = temp_tg_port[1]['peer_ipv6'] bgpv6_peer.as_number = int(TGEN_AS_NUM) route_range2 = bgpv4_peer.v6_routes.add(name="Network Group 2") route_range2.addresses.add(address='3000::1', prefix=128, count=3000) @@ -386,7 +424,7 @@ def wait_for_bgp_and_lb_soft(cvg_api, ping_req, ): if not found_lb_state and responses[-1].result in "success": loopback_up_start_timer = time.time() # found_lb_state = True - logger.info('!!!!!!! 2. loopback up end time {} !!!!!!'.format( + logger.info('\n Ping Successfull \n!!!!!!! 2. loopback up end time {} !!!!!!'.format( loopback_up_start_timer)) break @@ -440,12 +478,14 @@ def wait_for_bgp_and_lb(cvg_api, ping_req, ): if not found_bgp_state and bgpv4_metrics[-1].session_state in "up": bgp_up_start_timer = time.time() found_bgp_state = True + logger.info(' ') logger.info('^^ 2. bgp is up end time {} ^^^'.format( bgp_up_start_timer)) if not found_lb_state and responses[-1].result in "success": loopback_up_start_timer = time.time() found_lb_state = True - logger.info('!!! 2. loopback up end time {} !!!'.format( + logger.info(' ') + logger.info('2. loopback up end time {} !!!'.format( loopback_up_start_timer)) if bgpv4_metrics[-1].session_state in "up" and responses[-1].result \ in "success" and found_bgp_state and found_lb_state: @@ -488,20 +528,6 @@ def get_convergence_for_reboot_test(duthost, cvg_api.set_state(cs) wait(TIMEOUT - 10, "For Traffic To start") - def check_bgp_state(): - req = cvg_api.convergence_request() - req.bgpv4.peer_names = [] - bgpv4_metrics = cvg_api.get_results(req).bgpv4_metrics - assert bgpv4_metrics[-1].session_state == "up", \ - "BGP v4 Session State is not UP" - logger.info("BGP v4 Session State is UP") - req.bgpv6.peer_names = [] - bgpv6_metrics = cvg_api.get_results(req).bgpv6_metrics - assert bgpv6_metrics[-1].session_state == "up", \ - "BGP v6 Session State is not UP" - logger.info("BGP v6 Session State is UP") - - check_bgp_state() ping_req = cvg_api.ping_request() p1 = ping_req.endpoints.ipv4()[-1] p1.src_name = 'IPv4 3' @@ -524,7 +550,7 @@ def check_bgp_state(): request = cvg_api.convergence_request() request.convergence.flow_names = flow_names convergence_metrics = cvg_api.get_results(request).flow_convergence - for i, metrics in zip(cs.transmit.flow_names, convergence_metrics): + for i, metrics in zip(flow_names, convergence_metrics): if reboot_type == "warm": request.metrics.flow_names = [i] flow = cvg_api.get_results(request).flow_metric @@ -563,21 +589,3 @@ def check_bgp_state(): columns = ['Reboot Type', 'Traffic Item Name', 'Data Plane Convergence Time (ms)', 'Time (ms)'] logger.info("\n%s" % tabulate(table, headers=columns, tablefmt="psql")) - - -def cleanup_config(duthost): - """ - Cleaning up dut config at the end of the test - Args: - duthost (pytest fixture): duthost fixture - """ - logger.info('Cleaning up config') - duthost.command("sudo cp {} {}". - format("/etc/sonic/config_db_backup.json", - "/etc/sonic/config_db.json")) - duthost.shell("sudo config reload -y \n") - logger.info("Wait until all critical services are fully started") - pytest_assert(wait_until(360, 10, 1, - duthost.critical_services_fully_started), - "Not all critical services are fully started") - logger.info('Convergence Test Completed') From 25b77ef720957e7e786e1ff4ca5ce1bac7eb83d3 Mon Sep 17 00:00:00 2001 From: sellappa Date: Tue, 24 Sep 2024 18:00:48 +0000 Subject: [PATCH 2/9] Increasing the route step count to 5k --- tests/snappi_tests/bgp/test_bgp_convergence_performance.py | 4 ++-- tests/snappi_tests/bgp/test_bgp_rib_in_capacity.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/snappi_tests/bgp/test_bgp_convergence_performance.py b/tests/snappi_tests/bgp/test_bgp_convergence_performance.py index fa7ecdde38f..917a6260b52 100644 --- a/tests/snappi_tests/bgp/test_bgp_convergence_performance.py +++ b/tests/snappi_tests/bgp/test_bgp_convergence_performance.py @@ -9,8 +9,8 @@ @pytest.mark.parametrize('multipath', [2]) -@pytest.mark.parametrize('start_routes', [500]) -@pytest.mark.parametrize('routes_step', [500]) +@pytest.mark.parametrize('start_routes', [5000]) +@pytest.mark.parametrize('routes_step', [5000]) @pytest.mark.parametrize('stop_routes', [16000]) @pytest.mark.parametrize('route_type', ['IPv4']) def test_bgp_convergence_performance(cvg_api, # noqa F811 diff --git a/tests/snappi_tests/bgp/test_bgp_rib_in_capacity.py b/tests/snappi_tests/bgp/test_bgp_rib_in_capacity.py index 62581578d89..ae8b416be5a 100644 --- a/tests/snappi_tests/bgp/test_bgp_rib_in_capacity.py +++ b/tests/snappi_tests/bgp/test_bgp_rib_in_capacity.py @@ -10,7 +10,7 @@ @pytest.mark.parametrize('multipath', [2]) @pytest.mark.parametrize('start_value', [1000]) -@pytest.mark.parametrize('step_value', [1000]) +@pytest.mark.parametrize('step_value', [10000]) @pytest.mark.parametrize('route_type', ['IPv4']) @pytest.mark.parametrize('port_speed', ['speed_100_gbps']) def test_RIB_IN_capacity(cvg_api, # noqa F811 From 503f9f7b715db66a4f010ea53bc3d99eef883417 Mon Sep 17 00:00:00 2001 From: sellappa Date: Tue, 24 Sep 2024 18:10:00 +0000 Subject: [PATCH 3/9] Removing hardcoded port speed --- .../bgp/files/bgp_convergence_helper.py | 42 ++++++------------- .../bgp/test_bgp_local_link_failover.py | 6 +-- .../bgp/test_bgp_remote_link_failover.py | 8 ++-- .../bgp/test_bgp_rib_in_capacity.py | 8 ++-- .../bgp/test_bgp_rib_in_convergence.py | 8 ++-- 5 files changed, 23 insertions(+), 49 deletions(-) diff --git a/tests/snappi_tests/bgp/files/bgp_convergence_helper.py b/tests/snappi_tests/bgp/files/bgp_convergence_helper.py index 0d3222207b7..fc1a8dcc71d 100644 --- a/tests/snappi_tests/bgp/files/bgp_convergence_helper.py +++ b/tests/snappi_tests/bgp/files/bgp_convergence_helper.py @@ -21,7 +21,7 @@ def run_bgp_local_link_failover_test(cvg_api, multipath, number_of_routes, route_type, - port_speed,): + ): """ Run Local link failover test @@ -33,7 +33,6 @@ def run_bgp_local_link_failover_test(cvg_api, multipath: ecmp value for BGP config number_of_routes: Number of IPv4/IPv6 Routes route_type: IPv4 or IPv6 routes - port_speed: speed of the port used for test """ port_count = multipath+1 @@ -48,7 +47,7 @@ def run_bgp_local_link_failover_test(cvg_api, port_count, number_of_routes, route_type, - port_speed,) + ) """ Run the convergence test by flapping all the rx @@ -61,9 +60,6 @@ def run_bgp_local_link_failover_test(cvg_api, number_of_routes, route_type,) - """ Cleanup the dut configs after getting the convergence numbers """ - cleanup_config(duthost) - def run_bgp_remote_link_failover_test(cvg_api, duthost, @@ -72,7 +68,7 @@ def run_bgp_remote_link_failover_test(cvg_api, multipath, number_of_routes, route_type, - port_speed,): + ): """ Run Remote link failover test @@ -83,7 +79,6 @@ def run_bgp_remote_link_failover_test(cvg_api, iteration: number of iterations for running convergence test on a port multipath: ecmp value for BGP config route_type: IPv4 or IPv6 routes - port_speed: speed of the port used for test """ port_count = multipath+1 """ Create bgp config on dut """ @@ -97,7 +92,7 @@ def run_bgp_remote_link_failover_test(cvg_api, port_count, number_of_routes, route_type, - port_speed,) + ) """ Run the convergence test by withdrawing all the route ranges @@ -110,9 +105,6 @@ def run_bgp_remote_link_failover_test(cvg_api, number_of_routes, route_type,) - """ Cleanup the dut configs after getting the convergence numbers """ - cleanup_config(duthost) - def run_rib_in_convergence_test(cvg_api, duthost, @@ -121,7 +113,7 @@ def run_rib_in_convergence_test(cvg_api, multipath, number_of_routes, route_type, - port_speed,): + ): """ Run RIB-IN Convergence test @@ -133,7 +125,6 @@ def run_rib_in_convergence_test(cvg_api, multipath: ecmp value for BGP config number_of_routes: Number of IPv4/IPv6 Routes route_type: IPv4 or IPv6 routes - port_speed: speed of the port used for test """ port_count = multipath+1 @@ -148,7 +139,7 @@ def run_rib_in_convergence_test(cvg_api, port_count, number_of_routes, route_type, - port_speed,) + ) """ Run the convergence test by withdrawing all routes at once and @@ -161,9 +152,6 @@ def run_rib_in_convergence_test(cvg_api, number_of_routes, route_type,) - """ Cleanup the dut configs after getting the convergence numbers """ - cleanup_config(duthost) - def run_RIB_IN_capacity_test(cvg_api, duthost, @@ -172,7 +160,7 @@ def run_RIB_IN_capacity_test(cvg_api, start_value, step_value, route_type, - port_speed,): + ): """ Run RIB-IN Capacity test @@ -184,7 +172,6 @@ def run_RIB_IN_capacity_test(cvg_api, start_value: start value of number of routes step_value: step value of routes to be incremented at every iteration route_type: IPv4 or IPv6 routes - port_speed: speed of the port used for test """ port_count = multipath+1 """ Create bgp config on dut """ @@ -199,10 +186,7 @@ def run_RIB_IN_capacity_test(cvg_api, start_value, step_value, route_type, - port_speed,) - - """ Cleanup the dut configs after getting the convergence numbers """ - cleanup_config(duthost) + ) def duthost_bgp_config(duthost, @@ -295,7 +279,7 @@ def __tgen_bgp_config(cvg_api, port_count, number_of_routes, route_type, - port_speed,): + ): """ Creating BGP config on TGEN @@ -304,7 +288,6 @@ def __tgen_bgp_config(cvg_api, port_count: multipath + 1 number_of_routes: Number of IPv4/IPv6 Routes route_type: IPv4 or IPv6 routes - port_speed: speed of the port used for test """ global NG_LIST conv_config = cvg_api.convergence_config() @@ -331,7 +314,7 @@ def __tgen_bgp_config(cvg_api, layer1.ieee_media_defaults = False layer1.auto_negotiation.rs_fec = True layer1.auto_negotiation.link_training = False - layer1.speed = port_speed + layer1.speed = temp_tg_port[0]['speed'] layer1.auto_negotiate = False def create_v4_topo(): @@ -751,7 +734,7 @@ def get_RIB_IN_capacity(cvg_api, start_value, step_value, route_type, - port_speed,): + ): """ Args: cvg_api (pytest fixture): snappi API @@ -760,7 +743,6 @@ def get_RIB_IN_capacity(cvg_api, start_value: Start value of the number of BGP routes step_value: Step value of the number of BGP routes to be incremented route_type: IPv4 or IPv6 routes - port_speed: speed of the port used in test """ def tgen_capacity(routes): conv_config = cvg_api.convergence_config() @@ -787,7 +769,7 @@ def tgen_capacity(routes): layer1.ieee_media_defaults = False layer1.auto_negotiation.rs_fec = True layer1.auto_negotiation.link_training = False - layer1.speed = port_speed + layer1.speed = temp_tg_port[0]['speed'] layer1.auto_negotiate = False def create_v4_topo(): diff --git a/tests/snappi_tests/bgp/test_bgp_local_link_failover.py b/tests/snappi_tests/bgp/test_bgp_local_link_failover.py index 28eda635f55..4da929a7d7e 100644 --- a/tests/snappi_tests/bgp/test_bgp_local_link_failover.py +++ b/tests/snappi_tests/bgp/test_bgp_local_link_failover.py @@ -12,7 +12,6 @@ @pytest.mark.parametrize('convergence_test_iterations', [1]) @pytest.mark.parametrize('number_of_routes', [1000]) @pytest.mark.parametrize('route_type', ['IPv4']) -@pytest.mark.parametrize('port_speed', ['speed_100_gbps']) def test_bgp_convergence_for_local_link_failover(cvg_api, # noqa F811 duthost, tgen_ports, # noqa F811 @@ -22,7 +21,7 @@ def test_bgp_convergence_for_local_link_failover(cvg_api, # no convergence_test_iterations, number_of_routes, route_type, - port_speed,): + ): """ Topo: TGEN1 --- DUT --- TGEN(2..N) @@ -51,7 +50,6 @@ def test_bgp_convergence_for_local_link_failover(cvg_api, # no convergence_test_iterations: number of iterations the link failure test has to be run for a port number_of_routes: Number of IPv4/IPv6 Routes route_type: IPv4 or IPv6 routes - port_speed: speed of the port used for test """ # convergence_test_iterations, multipath, number_of_routes and # route_type parameters can be modified as per user preference @@ -62,4 +60,4 @@ def test_bgp_convergence_for_local_link_failover(cvg_api, # no multipath, number_of_routes, route_type, - port_speed,) + ) diff --git a/tests/snappi_tests/bgp/test_bgp_remote_link_failover.py b/tests/snappi_tests/bgp/test_bgp_remote_link_failover.py index d12726dc488..3ecf12f18b1 100755 --- a/tests/snappi_tests/bgp/test_bgp_remote_link_failover.py +++ b/tests/snappi_tests/bgp/test_bgp_remote_link_failover.py @@ -12,7 +12,6 @@ @pytest.mark.parametrize('convergence_test_iterations', [1]) @pytest.mark.parametrize('number_of_routes', [1000]) @pytest.mark.parametrize('route_type', ['IPv4']) -@pytest.mark.parametrize('port_speed', ['speed_100_gbps']) def test_bgp_convergence_for_remote_link_failover(cvg_api, # noqa F811 duthost, tgen_ports, # noqa F811 @@ -22,7 +21,7 @@ def test_bgp_convergence_for_remote_link_failover(cvg_api, # no convergence_test_iterations, number_of_routes, route_type, - port_speed,): + ): """ Topo: TGEN1 --- DUT --- TGEN(2..N) @@ -51,10 +50,9 @@ def test_bgp_convergence_for_remote_link_failover(cvg_api, # no convergence_test_iterations: number of iterations the cp/dp convergence test has to be run for a port number_of_routes: Number of IPv4/IPv6 Routes route_type: IPv4 or IPv6 routes - port_speed: speed of the port used for test """ # convergence_test_iterations, multipath, number_of_routes, - # port_speed and route_type parameters can be modified as per user preference + # route_type parameters can be modified as per user preference run_bgp_remote_link_failover_test(cvg_api, duthost, tgen_ports, @@ -62,4 +60,4 @@ def test_bgp_convergence_for_remote_link_failover(cvg_api, # no multipath, number_of_routes, route_type, - port_speed,) + ) diff --git a/tests/snappi_tests/bgp/test_bgp_rib_in_capacity.py b/tests/snappi_tests/bgp/test_bgp_rib_in_capacity.py index ae8b416be5a..a8b69f200eb 100644 --- a/tests/snappi_tests/bgp/test_bgp_rib_in_capacity.py +++ b/tests/snappi_tests/bgp/test_bgp_rib_in_capacity.py @@ -12,7 +12,6 @@ @pytest.mark.parametrize('start_value', [1000]) @pytest.mark.parametrize('step_value', [10000]) @pytest.mark.parametrize('route_type', ['IPv4']) -@pytest.mark.parametrize('port_speed', ['speed_100_gbps']) def test_RIB_IN_capacity(cvg_api, # noqa F811 duthost, tgen_ports, # noqa F811 @@ -22,7 +21,7 @@ def test_RIB_IN_capacity(cvg_api, # noqa F811 start_value, step_value, route_type, - port_speed,): + ): """ Topo: TGEN1 --- DUT --- TGEN(2..N) @@ -51,9 +50,8 @@ def test_RIB_IN_capacity(cvg_api, # noqa F811 start_value: Start value of the number of BGP routes step_value: Step value of the number of BGP routes to be incremented route_type: IPv4 or IPv6 routes - port_speed: speed of the port used for test """ - # multipath, start_value, step_value and route_type, port_speed parameters can be modified as per user preference + # multipath, start_value, step_value and route_type parameters can be modified as per user preference run_RIB_IN_capacity_test(cvg_api, duthost, tgen_ports, @@ -61,4 +59,4 @@ def test_RIB_IN_capacity(cvg_api, # noqa F811 start_value, step_value, route_type, - port_speed,) + ) diff --git a/tests/snappi_tests/bgp/test_bgp_rib_in_convergence.py b/tests/snappi_tests/bgp/test_bgp_rib_in_convergence.py index f114dfe1b8a..eeda7498cd4 100644 --- a/tests/snappi_tests/bgp/test_bgp_rib_in_convergence.py +++ b/tests/snappi_tests/bgp/test_bgp_rib_in_convergence.py @@ -12,7 +12,6 @@ @pytest.mark.parametrize('convergence_test_iterations', [1]) @pytest.mark.parametrize('number_of_routes', [1000]) @pytest.mark.parametrize('route_type', ['IPv4']) -@pytest.mark.parametrize('port_speed', ['speed_100_gbps']) def test_rib_in_convergence(cvg_api, # noqa F811 duthost, tgen_ports, # noqa F811 @@ -22,7 +21,7 @@ def test_rib_in_convergence(cvg_api, # noqa F811 convergence_test_iterations, number_of_routes, route_type, - port_speed,): + ): """ Topo: TGEN1 --- DUT --- TGEN(2..N) @@ -52,9 +51,8 @@ def test_rib_in_convergence(cvg_api, # noqa F811 convergence_test_iterations: number of iterations the link failure test has to be run for a port number_of_routes: Number of IPv4/IPv6 Routes route_type: IPv4 or IPv6 routes - port_speed: speed of the port used for test """ - # convergence_test_iterations, multipath, number_of_routes port_speed and + # convergence_test_iterations, multipath, number_of_routes and # route_type parameters can be modified as per user preference run_rib_in_convergence_test(cvg_api, duthost, @@ -63,4 +61,4 @@ def test_rib_in_convergence(cvg_api, # noqa F811 multipath, number_of_routes, route_type, - port_speed,) + ) From cd07a70b245ec15db778d0ba56c5bb493a2b1d55 Mon Sep 17 00:00:00 2001 From: sellappa Date: Tue, 24 Sep 2024 18:12:03 +0000 Subject: [PATCH 4/9] removing redundant cleanup function --- .../bgp/files/bgp_convergence_helper.py | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/tests/snappi_tests/bgp/files/bgp_convergence_helper.py b/tests/snappi_tests/bgp/files/bgp_convergence_helper.py index fc1a8dcc71d..de28ca08553 100644 --- a/tests/snappi_tests/bgp/files/bgp_convergence_helper.py +++ b/tests/snappi_tests/bgp/files/bgp_convergence_helper.py @@ -963,18 +963,3 @@ def run_traffic(routes): logger.info("\n%s" % tabulate( [['RIB-IN Capacity Test', max_routes]], headers=columns, tablefmt="psql")) - -def cleanup_config(duthost): - """ - Cleaning up dut config at the end of the test - - Args: - duthost (pytest fixture): duthost fixture - """ - duthost.command("sudo cp {} {}".format( - "/etc/sonic/config_db_backup.json", "/etc/sonic/config_db.json")) - duthost.shell("sudo config reload -y \n") - logger.info("Wait until all critical services are fully started") - pytest_assert(wait_until(360, 10, 1, duthost.critical_services_fully_started), - "Not all critical services are fully started") - logger.info('Convergence Test Completed') From c27e527653e128b0d26fe6936cd3ba7cf2a2191c Mon Sep 17 00:00:00 2001 From: selldinesh Date: Thu, 26 Sep 2024 18:15:29 +0000 Subject: [PATCH 5/9] Adding is_snappi_multidut() for mutidut rdam cases --- .../ecn/test_multidut_dequeue_ecn_with_snappi.py | 7 ++++--- .../ecn/test_multidut_red_accuracy_with_snappi.py | 6 ++++-- ...st_lossless_response_to_external_pause_storms.py | 7 ++++--- ..._lossless_response_to_throttling_pause_storms.py | 7 ++++--- .../multidut/pfc/test_m2o_fluctuating_lossless.py | 7 ++++--- .../multidut/pfc/test_m2o_oversubscribe_lossless.py | 8 +++++--- .../pfc/test_m2o_oversubscribe_lossless_lossy.py | 8 +++++--- .../multidut/pfc/test_m2o_oversubscribe_lossy.py | 8 +++++--- .../test_multidut_pfc_pause_lossless_with_snappi.py | 3 ++- .../test_multidut_pfc_pause_lossy_with_snappi.py | 7 ++++--- .../pfcwd/test_multidut_pfcwd_a2a_with_snappi.py | 9 ++++++--- .../pfcwd/test_multidut_pfcwd_basic_with_snappi.py | 13 ++++++++----- .../test_multidut_pfcwd_burst_storm_with_snappi.py | 9 ++++++--- .../pfcwd/test_multidut_pfcwd_m2o_with_snappi.py | 11 +++++++---- ...st_multidut_pfcwd_runtime_traffic_with_snappi.py | 7 +++++-- 15 files changed, 73 insertions(+), 44 deletions(-) diff --git a/tests/snappi_tests/multidut/ecn/test_multidut_dequeue_ecn_with_snappi.py b/tests/snappi_tests/multidut/ecn/test_multidut_dequeue_ecn_with_snappi.py index 299134eee23..cf1971dd114 100644 --- a/tests/snappi_tests/multidut/ecn/test_multidut_dequeue_ecn_with_snappi.py +++ b/tests/snappi_tests/multidut/ecn/test_multidut_dequeue_ecn_with_snappi.py @@ -3,10 +3,11 @@ import logging from tests.common.helpers.assertions import pytest_assert, pytest_require # noqa: F401 -from tests.common.fixtures.conn_graph_facts import conn_graph_facts, \ - fanout_graph_facts_multidut # noqa: F401 +from tests.common.fixtures.conn_graph_facts import conn_graph_facts, fanout_graph_facts_multidut, \ + fanout_graph_facts # noqa: F401 from tests.common.snappi_tests.snappi_fixtures import snappi_api_serv_ip, snappi_api_serv_port, \ - snappi_api, snappi_dut_base_config, get_snappi_ports, get_snappi_ports_for_rdma, cleanup_config # noqa: F401 + snappi_api, snappi_dut_base_config, get_snappi_ports, get_snappi_ports_for_rdma, cleanup_config, \ + is_snappi_multidut, get_snappi_ports_single_dut, get_snappi_ports_multi_dut # noqa: F401 from tests.common.snappi_tests.qos_fixtures import prio_dscp_map, lossless_prio_list # noqa F401 from tests.snappi_tests.variables import MULTIDUT_PORT_INFO, MULTIDUT_TESTBED diff --git a/tests/snappi_tests/multidut/ecn/test_multidut_red_accuracy_with_snappi.py b/tests/snappi_tests/multidut/ecn/test_multidut_red_accuracy_with_snappi.py index 27a8a6906ca..3f29c1232e8 100644 --- a/tests/snappi_tests/multidut/ecn/test_multidut_red_accuracy_with_snappi.py +++ b/tests/snappi_tests/multidut/ecn/test_multidut_red_accuracy_with_snappi.py @@ -4,9 +4,11 @@ import logging from tabulate import tabulate # noqa F401 from tests.common.helpers.assertions import pytest_assert, pytest_require # noqa: F401 -from tests.common.fixtures.conn_graph_facts import conn_graph_facts, fanout_graph_facts_multidut # noqa: F401 +from tests.common.fixtures.conn_graph_facts import conn_graph_facts, fanout_graph_facts_multidut, \ + fanout_graph_facts # noqa: F401 from tests.common.snappi_tests.snappi_fixtures import snappi_api_serv_ip, snappi_api_serv_port, \ - snappi_api, snappi_dut_base_config, get_snappi_ports, get_snappi_ports_for_rdma, cleanup_config # noqa: F401 + snappi_api, snappi_dut_base_config, get_snappi_ports, get_snappi_ports_for_rdma, cleanup_config, \ + is_snappi_multidut, get_snappi_ports_single_dut, get_snappi_ports_multi_dut # noqa: F401 from tests.common.snappi_tests.qos_fixtures import prio_dscp_map, \ lossless_prio_list # noqa F401 from tests.snappi_tests.variables import MULTIDUT_PORT_INFO, MULTIDUT_TESTBED diff --git a/tests/snappi_tests/multidut/pfc/test_lossless_response_to_external_pause_storms.py b/tests/snappi_tests/multidut/pfc/test_lossless_response_to_external_pause_storms.py index 2cb631b911d..27cf4e81664 100644 --- a/tests/snappi_tests/multidut/pfc/test_lossless_response_to_external_pause_storms.py +++ b/tests/snappi_tests/multidut/pfc/test_lossless_response_to_external_pause_storms.py @@ -1,10 +1,11 @@ import pytest import logging from tests.common.helpers.assertions import pytest_assert -from tests.common.fixtures.conn_graph_facts import conn_graph_facts, \ - fanout_graph_facts_multidut # noqa: F401 +from tests.common.fixtures.conn_graph_facts import conn_graph_facts, fanout_graph_facts_multidut, \ + fanout_graph_facts # noqa: F401 from tests.common.snappi_tests.snappi_fixtures import snappi_api_serv_ip, snappi_api_serv_port, \ - snappi_api, snappi_dut_base_config, get_snappi_ports, get_snappi_ports_for_rdma, cleanup_config # noqa: F401 + snappi_api, snappi_dut_base_config, get_snappi_ports, get_snappi_ports_for_rdma, cleanup_config, \ + is_snappi_multidut, get_snappi_ports_single_dut, get_snappi_ports_multi_dut # noqa: F401 from tests.common.snappi_tests.qos_fixtures import prio_dscp_map, \ lossless_prio_list # noqa: F401 from tests.snappi_tests.variables import MULTIDUT_PORT_INFO, MULTIDUT_TESTBED diff --git a/tests/snappi_tests/multidut/pfc/test_lossless_response_to_throttling_pause_storms.py b/tests/snappi_tests/multidut/pfc/test_lossless_response_to_throttling_pause_storms.py index 1fc579899cc..cbd14ade13f 100644 --- a/tests/snappi_tests/multidut/pfc/test_lossless_response_to_throttling_pause_storms.py +++ b/tests/snappi_tests/multidut/pfc/test_lossless_response_to_throttling_pause_storms.py @@ -1,10 +1,11 @@ import pytest import logging from tests.common.helpers.assertions import pytest_assert -from tests.common.fixtures.conn_graph_facts import conn_graph_facts, \ - fanout_graph_facts_multidut # noqa: F401 +from tests.common.fixtures.conn_graph_facts import conn_graph_facts, fanout_graph_facts_multidut, \ + fanout_graph_facts # noqa: F401 from tests.common.snappi_tests.snappi_fixtures import snappi_api_serv_ip, snappi_api_serv_port, \ - snappi_api, snappi_dut_base_config, get_snappi_ports, get_snappi_ports_for_rdma, cleanup_config # noqa: F401 + snappi_api, snappi_dut_base_config, get_snappi_ports, get_snappi_ports_for_rdma, cleanup_config, \ + is_snappi_multidut, get_snappi_ports_single_dut, get_snappi_ports_multi_dut # noqa: F401 from tests.common.snappi_tests.qos_fixtures import prio_dscp_map, \ lossless_prio_list # noqa: F401 from tests.snappi_tests.variables import MULTIDUT_PORT_INFO, MULTIDUT_TESTBED diff --git a/tests/snappi_tests/multidut/pfc/test_m2o_fluctuating_lossless.py b/tests/snappi_tests/multidut/pfc/test_m2o_fluctuating_lossless.py index c135ea3da39..22f8ce9a00c 100644 --- a/tests/snappi_tests/multidut/pfc/test_m2o_fluctuating_lossless.py +++ b/tests/snappi_tests/multidut/pfc/test_m2o_fluctuating_lossless.py @@ -1,10 +1,11 @@ import pytest import logging from tests.common.helpers.assertions import pytest_assert -from tests.common.fixtures.conn_graph_facts import conn_graph_facts, \ - fanout_graph_facts_multidut # noqa: F401 +from tests.common.fixtures.conn_graph_facts import conn_graph_facts, fanout_graph_facts_multidut, \ + fanout_graph_facts # noqa: F401 from tests.common.snappi_tests.snappi_fixtures import snappi_api_serv_ip, snappi_api_serv_port, \ - snappi_api, snappi_dut_base_config, get_snappi_ports, get_snappi_ports_for_rdma, cleanup_config # noqa: F401 + snappi_api, snappi_dut_base_config, get_snappi_ports, get_snappi_ports_for_rdma, cleanup_config, \ + is_snappi_multidut, get_snappi_ports_single_dut, get_snappi_ports_multi_dut # noqa: F401 from tests.common.snappi_tests.qos_fixtures import prio_dscp_map, \ lossless_prio_list # noqa: F401 from tests.snappi_tests.variables import MULTIDUT_PORT_INFO, MULTIDUT_TESTBED diff --git a/tests/snappi_tests/multidut/pfc/test_m2o_oversubscribe_lossless.py b/tests/snappi_tests/multidut/pfc/test_m2o_oversubscribe_lossless.py index ffcefc461c1..9c5a1ebd56c 100644 --- a/tests/snappi_tests/multidut/pfc/test_m2o_oversubscribe_lossless.py +++ b/tests/snappi_tests/multidut/pfc/test_m2o_oversubscribe_lossless.py @@ -1,10 +1,12 @@ import pytest import logging from tests.common.helpers.assertions import pytest_assert -from tests.common.fixtures.conn_graph_facts import conn_graph_facts, \ - fanout_graph_facts_multidut # noqa: F401 +from tests.common.fixtures.conn_graph_facts import conn_graph_facts, fanout_graph_facts_multidut, \ + fanout_graph_facts # noqa: F401 from tests.common.snappi_tests.snappi_fixtures import snappi_api_serv_ip, snappi_api_serv_port, \ - snappi_api, snappi_dut_base_config, get_snappi_ports, get_snappi_ports_for_rdma, cleanup_config # noqa: F401 + snappi_api, snappi_dut_base_config, get_snappi_ports, is_snappi_multidut, \ + get_snappi_ports_single_dut, get_snappi_ports_multi_dut, \ + get_snappi_ports_for_rdma, cleanup_config # noqa: F401 from tests.common.snappi_tests.qos_fixtures import prio_dscp_map, \ lossless_prio_list # noqa: F401 from tests.snappi_tests.variables import MULTIDUT_PORT_INFO, MULTIDUT_TESTBED diff --git a/tests/snappi_tests/multidut/pfc/test_m2o_oversubscribe_lossless_lossy.py b/tests/snappi_tests/multidut/pfc/test_m2o_oversubscribe_lossless_lossy.py index f681c5acdad..21f260efaf1 100644 --- a/tests/snappi_tests/multidut/pfc/test_m2o_oversubscribe_lossless_lossy.py +++ b/tests/snappi_tests/multidut/pfc/test_m2o_oversubscribe_lossless_lossy.py @@ -1,10 +1,12 @@ import pytest import logging from tests.common.helpers.assertions import pytest_assert -from tests.common.fixtures.conn_graph_facts import conn_graph_facts, \ - fanout_graph_facts_multidut # noqa: F401 +from tests.common.fixtures.conn_graph_facts import conn_graph_facts, fanout_graph_facts_multidut, \ + fanout_graph_facts # noqa: F401 from tests.common.snappi_tests.snappi_fixtures import snappi_api_serv_ip, snappi_api_serv_port, \ - snappi_api, snappi_dut_base_config, get_snappi_ports, get_snappi_ports_for_rdma, cleanup_config # noqa: F401 + snappi_api, snappi_dut_base_config, get_snappi_ports, \ + is_snappi_multidut, get_snappi_ports_single_dut, get_snappi_ports_multi_dut, \ + get_snappi_ports_for_rdma, cleanup_config # noqa: F401 from tests.common.snappi_tests.qos_fixtures import prio_dscp_map, \ lossless_prio_list # noqa: F401 from tests.snappi_tests.variables import MULTIDUT_PORT_INFO, MULTIDUT_TESTBED diff --git a/tests/snappi_tests/multidut/pfc/test_m2o_oversubscribe_lossy.py b/tests/snappi_tests/multidut/pfc/test_m2o_oversubscribe_lossy.py index 7b7e4bfe419..8b3c2fe146a 100644 --- a/tests/snappi_tests/multidut/pfc/test_m2o_oversubscribe_lossy.py +++ b/tests/snappi_tests/multidut/pfc/test_m2o_oversubscribe_lossy.py @@ -1,10 +1,12 @@ import pytest import logging from tests.common.helpers.assertions import pytest_assert -from tests.common.fixtures.conn_graph_facts import conn_graph_facts, \ - fanout_graph_facts_multidut # noqa: F401 +from tests.common.fixtures.conn_graph_facts import conn_graph_facts, fanout_graph_facts_multidut, \ + fanout_graph_facts # noqa: F401 from tests.common.snappi_tests.snappi_fixtures import snappi_api_serv_ip, snappi_api_serv_port, \ - snappi_api, snappi_dut_base_config, get_snappi_ports, get_snappi_ports_for_rdma, cleanup_config # noqa: F401 + snappi_api, snappi_dut_base_config, get_snappi_ports, is_snappi_multidut, \ + get_snappi_ports_single_dut, get_snappi_ports_multi_dut, \ + get_snappi_ports_for_rdma, cleanup_config # noqa: F401 from tests.common.snappi_tests.qos_fixtures import prio_dscp_map, \ lossless_prio_list # noqa: F401 from tests.snappi_tests.variables import MULTIDUT_PORT_INFO, MULTIDUT_TESTBED diff --git a/tests/snappi_tests/multidut/pfc/test_multidut_pfc_pause_lossless_with_snappi.py b/tests/snappi_tests/multidut/pfc/test_multidut_pfc_pause_lossless_with_snappi.py index c283e0c6721..1d3cd38a04f 100644 --- a/tests/snappi_tests/multidut/pfc/test_multidut_pfc_pause_lossless_with_snappi.py +++ b/tests/snappi_tests/multidut/pfc/test_multidut_pfc_pause_lossless_with_snappi.py @@ -3,7 +3,8 @@ from tests.common.fixtures.conn_graph_facts import conn_graph_facts, fanout_graph_facts, \ fanout_graph_facts_multidut # noqa: F401 from tests.common.snappi_tests.snappi_fixtures import snappi_api_serv_ip, snappi_api_serv_port, \ - snappi_api, snappi_dut_base_config, get_snappi_ports_for_rdma, cleanup_config, get_snappi_ports_multi_dut, \ + snappi_api, snappi_dut_base_config, is_snappi_multidut, \ + get_snappi_ports_for_rdma, cleanup_config, get_snappi_ports_multi_dut, \ snappi_testbed_config, get_snappi_ports_single_dut, \ get_snappi_ports, is_snappi_multidut # noqa: F401 from tests.common.snappi_tests.qos_fixtures import prio_dscp_map, all_prio_list, lossless_prio_list,\ diff --git a/tests/snappi_tests/multidut/pfc/test_multidut_pfc_pause_lossy_with_snappi.py b/tests/snappi_tests/multidut/pfc/test_multidut_pfc_pause_lossy_with_snappi.py index a5297a3988c..af83dc929be 100644 --- a/tests/snappi_tests/multidut/pfc/test_multidut_pfc_pause_lossy_with_snappi.py +++ b/tests/snappi_tests/multidut/pfc/test_multidut_pfc_pause_lossy_with_snappi.py @@ -1,10 +1,11 @@ import pytest from tests.common.helpers.assertions import pytest_require, pytest_assert # noqa: F401 -from tests.common.fixtures.conn_graph_facts import conn_graph_facts, \ - fanout_graph_facts_multidut # noqa: F401 +from tests.common.fixtures.conn_graph_facts import conn_graph_facts, fanout_graph_facts_multidut, \ + fanout_graph_facts # noqa: F401 from tests.common.snappi_tests.snappi_fixtures import snappi_api_serv_ip, snappi_api_serv_port, \ snappi_api, snappi_dut_base_config, get_snappi_ports_for_rdma, cleanup_config, \ - get_snappi_ports # noqa: F401 + get_snappi_ports, is_snappi_multidut, \ + get_snappi_ports_single_dut, get_snappi_ports_multi_dut # noqa F401 from tests.common.snappi_tests.qos_fixtures import prio_dscp_map, all_prio_list, lossless_prio_list,\ lossy_prio_list # noqa F401 from tests.snappi_tests.variables import MULTIDUT_PORT_INFO, MULTIDUT_TESTBED diff --git a/tests/snappi_tests/multidut/pfcwd/test_multidut_pfcwd_a2a_with_snappi.py b/tests/snappi_tests/multidut/pfcwd/test_multidut_pfcwd_a2a_with_snappi.py index bb9237fcbc2..c7f37fbd249 100644 --- a/tests/snappi_tests/multidut/pfcwd/test_multidut_pfcwd_a2a_with_snappi.py +++ b/tests/snappi_tests/multidut/pfcwd/test_multidut_pfcwd_a2a_with_snappi.py @@ -2,9 +2,12 @@ import random import logging from tests.common.helpers.assertions import pytest_assert # noqa F401 -from tests.common.fixtures.conn_graph_facts import conn_graph_facts, fanout_graph_facts_multidut # noqa: F401 +from tests.common.fixtures.conn_graph_facts import conn_graph_facts, fanout_graph_facts_multidut, \ + fanout_graph_facts # noqa: F401 from tests.common.snappi_tests.snappi_fixtures import snappi_api_serv_ip, snappi_api_serv_port, \ - snappi_api, snappi_dut_base_config, get_snappi_ports, get_snappi_ports_for_rdma, cleanup_config # noqa: F401 + snappi_api, snappi_dut_base_config, get_snappi_ports, is_snappi_multidut, \ + get_snappi_ports_single_dut, get_snappi_ports_multi_dut, \ + get_snappi_ports_for_rdma, cleanup_config # noqa: F401 from tests.common.snappi_tests.qos_fixtures import prio_dscp_map, all_prio_list,\ lossless_prio_list, lossy_prio_list # noqa F401 from tests.snappi_tests.variables import MULTIDUT_PORT_INFO, MULTIDUT_TESTBED @@ -71,7 +74,7 @@ def test_multidut_pfcwd_all_to_all(snappi_api, # noqa: F811 snappi_ports, snappi_api) - lossless_prio = random.sample(lossless_prio_list, 1) + lossless_prio = random.sample(lossless_prio_list, 1)[0] snappi_extra_params = SnappiTestParams() snappi_extra_params.multi_dut_params.multi_dut_ports = snappi_ports diff --git a/tests/snappi_tests/multidut/pfcwd/test_multidut_pfcwd_basic_with_snappi.py b/tests/snappi_tests/multidut/pfcwd/test_multidut_pfcwd_basic_with_snappi.py index f039f9b8971..956e1196c90 100644 --- a/tests/snappi_tests/multidut/pfcwd/test_multidut_pfcwd_basic_with_snappi.py +++ b/tests/snappi_tests/multidut/pfcwd/test_multidut_pfcwd_basic_with_snappi.py @@ -4,9 +4,12 @@ import re from collections import defaultdict from tests.common.helpers.assertions import pytest_require, pytest_assert # noqa: F401 -from tests.common.fixtures.conn_graph_facts import conn_graph_facts, fanout_graph_facts_multidut # noqa: F401 +from tests.common.fixtures.conn_graph_facts import conn_graph_facts, fanout_graph_facts_multidut, \ + fanout_graph_facts # noqa: F401 from tests.common.snappi_tests.snappi_fixtures import snappi_api_serv_ip, snappi_api_serv_port, \ - snappi_api, snappi_dut_base_config, get_snappi_ports, get_snappi_ports_for_rdma, cleanup_config # noqa: F401 + snappi_api, snappi_dut_base_config, get_snappi_ports, is_snappi_multidut, \ + get_snappi_ports_single_dut, get_snappi_ports_multi_dut, \ + get_snappi_ports_for_rdma, cleanup_config # noqa: F401 from tests.common.snappi_tests.qos_fixtures import prio_dscp_map, lossless_prio_list # noqa F401 from tests.snappi_tests.variables import MULTIDUT_PORT_INFO, MULTIDUT_TESTBED from tests.common.reboot import reboot # noqa: F401 @@ -71,7 +74,7 @@ def test_pfcwd_basic_single_lossless_prio(snappi_api, # noqa: skip_pfcwd_test(duthost=snappi_ports[0]['duthost'], trigger_pfcwd=trigger_pfcwd) skip_pfcwd_test(duthost=snappi_ports[1]['duthost'], trigger_pfcwd=trigger_pfcwd) - lossless_prio = random.sample(lossless_prio_list, 1) + lossless_prio = random.sample(lossless_prio_list, 1)[0] lossless_prio = int(lossless_prio) snappi_extra_params = SnappiTestParams() @@ -218,7 +221,7 @@ def test_pfcwd_basic_single_lossless_prio_reboot(snappi_api, # no snappi_ports, snappi_api) - lossless_prio = random.sample(lossless_prio_list, 1) + lossless_prio = random.sample(lossless_prio_list, 1)[0] lossless_prio = int(lossless_prio) snappi_extra_params = SnappiTestParams() snappi_extra_params.multi_dut_params.multi_dut_ports = snappi_ports @@ -380,7 +383,7 @@ def test_pfcwd_basic_single_lossless_prio_service_restart(snappi_api, testbed_config, port_config_list, snappi_ports = snappi_dut_base_config(duthosts, snappi_ports, snappi_api) - lossless_prio = random.sample(lossless_prio_list, 1) + lossless_prio = random.sample(lossless_prio_list, 1)[0] lossless_prio = int(lossless_prio) if (snappi_ports[0]['duthost'].is_multi_asic): diff --git a/tests/snappi_tests/multidut/pfcwd/test_multidut_pfcwd_burst_storm_with_snappi.py b/tests/snappi_tests/multidut/pfcwd/test_multidut_pfcwd_burst_storm_with_snappi.py index 612db2059c0..24e24f98bec 100644 --- a/tests/snappi_tests/multidut/pfcwd/test_multidut_pfcwd_burst_storm_with_snappi.py +++ b/tests/snappi_tests/multidut/pfcwd/test_multidut_pfcwd_burst_storm_with_snappi.py @@ -2,9 +2,12 @@ import random import logging from tests.common.helpers.assertions import pytest_require, pytest_assert # noqa: F401 -from tests.common.fixtures.conn_graph_facts import conn_graph_facts, fanout_graph_facts_multidut # noqa: F401 +from tests.common.fixtures.conn_graph_facts import conn_graph_facts, fanout_graph_facts_multidut, \ + fanout_graph_facts # noqa: F401 from tests.common.snappi_tests.snappi_fixtures import snappi_api_serv_ip, snappi_api_serv_port, \ - snappi_api, snappi_dut_base_config, get_snappi_ports, get_snappi_ports_for_rdma, cleanup_config # noqa: F401 + snappi_api, snappi_dut_base_config, get_snappi_ports, is_snappi_multidut, \ + get_snappi_ports_single_dut, get_snappi_ports_multi_dut, \ + get_snappi_ports_for_rdma, cleanup_config # noqa: F401 from tests.common.snappi_tests.qos_fixtures import prio_dscp_map, all_prio_list,\ lossless_prio_list, lossy_prio_list # noqa F401 from tests.snappi_tests.variables import MULTIDUT_PORT_INFO, MULTIDUT_TESTBED @@ -68,7 +71,7 @@ def test_pfcwd_burst_storm_single_lossless_prio(snappi_api, # noqa: snappi_ports, snappi_api) - lossless_prio = random.sample(lossless_prio_list, 1) + lossless_prio = random.sample(lossless_prio_list, 1)[0] snappi_extra_params = SnappiTestParams() snappi_extra_params.multi_dut_params.multi_dut_ports = snappi_ports diff --git a/tests/snappi_tests/multidut/pfcwd/test_multidut_pfcwd_m2o_with_snappi.py b/tests/snappi_tests/multidut/pfcwd/test_multidut_pfcwd_m2o_with_snappi.py index a6bbbf4446f..ce77c3b2fd2 100644 --- a/tests/snappi_tests/multidut/pfcwd/test_multidut_pfcwd_m2o_with_snappi.py +++ b/tests/snappi_tests/multidut/pfcwd/test_multidut_pfcwd_m2o_with_snappi.py @@ -2,9 +2,12 @@ import random import logging from tests.common.helpers.assertions import pytest_require, pytest_assert # noqa: F401 -from tests.common.fixtures.conn_graph_facts import conn_graph_facts, fanout_graph_facts_multidut # noqa: F401 +from tests.common.fixtures.conn_graph_facts import conn_graph_facts, fanout_graph_facts_multidut, \ + fanout_graph_facts # noqa: F401 from tests.common.snappi_tests.snappi_fixtures import snappi_api_serv_ip, snappi_api_serv_port, \ - snappi_api, snappi_dut_base_config, get_snappi_ports, get_snappi_ports_for_rdma, cleanup_config # noqa: F401 + snappi_api, snappi_dut_base_config, get_snappi_ports, is_snappi_multidut, \ + get_snappi_ports_single_dut, get_snappi_ports_multi_dut, \ + get_snappi_ports_for_rdma, cleanup_config # noqa: F401 from tests.common.snappi_tests.qos_fixtures import prio_dscp_map, all_prio_list,\ lossless_prio_list, lossy_prio_list # noqa F401 from tests.snappi_tests.variables import MULTIDUT_PORT_INFO, MULTIDUT_TESTBED @@ -18,6 +21,7 @@ @pytest.mark.parametrize("multidut_port_info", MULTIDUT_PORT_INFO[MULTIDUT_TESTBED]) def test_pfcwd_many_to_one(snappi_api, # noqa: F811 conn_graph_facts, # noqa: F811 + fanout_graph_facts, fanout_graph_facts_multidut, # noqa: F811 duthosts, lossless_prio_list, # noqa: F811 @@ -71,8 +75,7 @@ def test_pfcwd_many_to_one(snappi_api, # noqa: F811 snappi_ports, snappi_api) - lossless_prio = random.sample(lossless_prio_list, 1) - + lossless_prio = random.sample(lossless_prio_list, 1)[0] snappi_extra_params = SnappiTestParams() snappi_extra_params.multi_dut_params.multi_dut_ports = snappi_ports diff --git a/tests/snappi_tests/multidut/pfcwd/test_multidut_pfcwd_runtime_traffic_with_snappi.py b/tests/snappi_tests/multidut/pfcwd/test_multidut_pfcwd_runtime_traffic_with_snappi.py index fbe603b1095..b33b18e74ff 100644 --- a/tests/snappi_tests/multidut/pfcwd/test_multidut_pfcwd_runtime_traffic_with_snappi.py +++ b/tests/snappi_tests/multidut/pfcwd/test_multidut_pfcwd_runtime_traffic_with_snappi.py @@ -1,9 +1,12 @@ import pytest import logging from tests.common.helpers.assertions import pytest_require, pytest_assert # noqa: F401 -from tests.common.fixtures.conn_graph_facts import conn_graph_facts, fanout_graph_facts_multidut # noqa: F401 +from tests.common.fixtures.conn_graph_facts import conn_graph_facts, fanout_graph_facts_multidut, \ + fanout_graph_facts # noqa: F401 from tests.common.snappi_tests.snappi_fixtures import snappi_api_serv_ip, snappi_api_serv_port,\ - snappi_api, snappi_dut_base_config, get_snappi_ports, get_snappi_ports_for_rdma, cleanup_config # noqa: F401 + snappi_api, snappi_dut_base_config, get_snappi_ports, is_snappi_multidut, \ + get_snappi_ports_single_dut, get_snappi_ports_multi_dut, \ + get_snappi_ports_for_rdma, cleanup_config # noqa: F401 from tests.common.snappi_tests.qos_fixtures import prio_dscp_map # noqa: F401 from tests.snappi_tests.variables import MULTIDUT_PORT_INFO, MULTIDUT_TESTBED from tests.snappi_tests.multidut.pfcwd.files.\ From 375a70876c5f0d3f5662b398e32fe8c5f87b156b Mon Sep 17 00:00:00 2001 From: selldinesh Date: Wed, 16 Oct 2024 16:47:40 +0000 Subject: [PATCH 6/9] Adding try finally block for cleanup in PFC scripts --- ...multidut_pfc_pause_lossless_with_snappi.py | 142 ++++++++-------- ...st_multidut_pfc_pause_lossy_with_snappi.py | 152 +++++++++--------- 2 files changed, 150 insertions(+), 144 deletions(-) diff --git a/tests/snappi_tests/multidut/pfc/test_multidut_pfc_pause_lossless_with_snappi.py b/tests/snappi_tests/multidut/pfc/test_multidut_pfc_pause_lossless_with_snappi.py index 1d3cd38a04f..c81d988ae99 100644 --- a/tests/snappi_tests/multidut/pfc/test_multidut_pfc_pause_lossless_with_snappi.py +++ b/tests/snappi_tests/multidut/pfc/test_multidut_pfc_pause_lossless_with_snappi.py @@ -91,20 +91,21 @@ def test_pfc_pause_single_lossless_prio(snappi_api, # noqa: snappi_extra_params = SnappiTestParams() snappi_extra_params.multi_dut_params.multi_dut_ports = snappi_ports - - run_pfc_test(api=snappi_api, - testbed_config=testbed_config, - port_config_list=port_config_list, - conn_data=conn_graph_facts, - fanout_data=fanout_graph_facts_multidut, - global_pause=False, - pause_prio_list=pause_prio_list, - test_prio_list=test_prio_list, - bg_prio_list=bg_prio_list, - prio_dscp_map=prio_dscp_map, - test_traffic_pause=True, - snappi_extra_params=snappi_extra_params) - cleanup_config(duthosts, snappi_ports) + try: + run_pfc_test(api=snappi_api, + testbed_config=testbed_config, + port_config_list=port_config_list, + conn_data=conn_graph_facts, + fanout_data=fanout_graph_facts_multidut, + global_pause=False, + pause_prio_list=pause_prio_list, + test_prio_list=test_prio_list, + bg_prio_list=bg_prio_list, + prio_dscp_map=prio_dscp_map, + test_traffic_pause=True, + snappi_extra_params=snappi_extra_params) + finally: + cleanup_config(duthosts, snappi_ports) @pytest.mark.parametrize("multidut_port_info", MULTIDUT_PORT_INFO[MULTIDUT_TESTBED]) @@ -167,20 +168,21 @@ def test_pfc_pause_multi_lossless_prio(snappi_api, # noqa: F811 snappi_extra_params = SnappiTestParams() snappi_extra_params.multi_dut_params.multi_dut_ports = snappi_ports - - run_pfc_test(api=snappi_api, - testbed_config=testbed_config, - port_config_list=port_config_list, - conn_data=conn_graph_facts, - fanout_data=fanout_graph_facts_multidut, - global_pause=False, - pause_prio_list=pause_prio_list, - test_prio_list=test_prio_list, - bg_prio_list=bg_prio_list, - prio_dscp_map=prio_dscp_map, - test_traffic_pause=True, - snappi_extra_params=snappi_extra_params) - cleanup_config(duthosts, snappi_ports) + try: + run_pfc_test(api=snappi_api, + testbed_config=testbed_config, + port_config_list=port_config_list, + conn_data=conn_graph_facts, + fanout_data=fanout_graph_facts_multidut, + global_pause=False, + pause_prio_list=pause_prio_list, + test_prio_list=test_prio_list, + bg_prio_list=bg_prio_list, + prio_dscp_map=prio_dscp_map, + test_traffic_pause=True, + snappi_extra_params=snappi_extra_params) + finally: + cleanup_config(duthosts, snappi_ports) @pytest.mark.disable_loganalyzer @@ -255,27 +257,27 @@ def test_pfc_pause_single_lossless_prio_reboot(snappi_api, # no snappi_extra_params = SnappiTestParams() snappi_extra_params.multi_dut_params.multi_dut_ports = snappi_ports - - for duthost in [snappi_ports[0]['duthost'], snappi_ports[1]['duthost']]: - logger.info("Issuing a {} reboot on the dut {}".format(reboot_type, duthost.hostname)) - reboot(duthost, localhost, reboot_type=reboot_type) - logger.info("Wait until the system is stable") - wait_until(180, 20, 0, duthost.critical_services_fully_started) - - run_pfc_test(api=snappi_api, - testbed_config=testbed_config, - port_config_list=port_config_list, - conn_data=conn_graph_facts, - fanout_data=fanout_graph_facts_multidut, - global_pause=False, - pause_prio_list=pause_prio_list, - test_prio_list=test_prio_list, - bg_prio_list=bg_prio_list, - prio_dscp_map=prio_dscp_map, - test_traffic_pause=True, - snappi_extra_params=snappi_extra_params) - - cleanup_config(duthosts, snappi_ports) + try: + for duthost in [snappi_ports[0]['duthost'], snappi_ports[1]['duthost']]: + logger.info("Issuing a {} reboot on the dut {}".format(reboot_type, duthost.hostname)) + reboot(duthost, localhost, reboot_type=reboot_type) + logger.info("Wait until the system is stable") + wait_until(180, 20, 0, duthost.critical_services_fully_started) + + run_pfc_test(api=snappi_api, + testbed_config=testbed_config, + port_config_list=port_config_list, + conn_data=conn_graph_facts, + fanout_data=fanout_graph_facts_multidut, + global_pause=False, + pause_prio_list=pause_prio_list, + test_prio_list=test_prio_list, + bg_prio_list=bg_prio_list, + prio_dscp_map=prio_dscp_map, + test_traffic_pause=True, + snappi_extra_params=snappi_extra_params) + finally: + cleanup_config(duthosts, snappi_ports) @pytest.mark.disable_loganalyzer @@ -344,24 +346,24 @@ def test_pfc_pause_multi_lossless_prio_reboot(snappi_api, # noq snappi_extra_params = SnappiTestParams() snappi_extra_params.multi_dut_params.multi_dut_ports = snappi_ports - - for duthost in [snappi_ports[0]['duthost'], snappi_ports[1]['duthost']]: - logger.info("Issuing a {} reboot on the dut {}".format(reboot_type, duthost.hostname)) - reboot(duthost, localhost, reboot_type=reboot_type) - logger.info("Wait until the system is stable") - wait_until(180, 20, 0, duthost.critical_services_fully_started) - - run_pfc_test(api=snappi_api, - testbed_config=testbed_config, - port_config_list=port_config_list, - conn_data=conn_graph_facts, - fanout_data=fanout_graph_facts_multidut, - global_pause=False, - pause_prio_list=pause_prio_list, - test_prio_list=test_prio_list, - bg_prio_list=bg_prio_list, - prio_dscp_map=prio_dscp_map, - test_traffic_pause=True, - snappi_extra_params=snappi_extra_params) - - cleanup_config(duthosts, snappi_ports) + try: + for duthost in [snappi_ports[0]['duthost'], snappi_ports[1]['duthost']]: + logger.info("Issuing a {} reboot on the dut {}".format(reboot_type, duthost.hostname)) + reboot(duthost, localhost, reboot_type=reboot_type) + logger.info("Wait until the system is stable") + wait_until(180, 20, 0, duthost.critical_services_fully_started) + + run_pfc_test(api=snappi_api, + testbed_config=testbed_config, + port_config_list=port_config_list, + conn_data=conn_graph_facts, + fanout_data=fanout_graph_facts_multidut, + global_pause=False, + pause_prio_list=pause_prio_list, + test_prio_list=test_prio_list, + bg_prio_list=bg_prio_list, + prio_dscp_map=prio_dscp_map, + test_traffic_pause=True, + snappi_extra_params=snappi_extra_params) + finally: + cleanup_config(duthosts, snappi_ports) diff --git a/tests/snappi_tests/multidut/pfc/test_multidut_pfc_pause_lossy_with_snappi.py b/tests/snappi_tests/multidut/pfc/test_multidut_pfc_pause_lossy_with_snappi.py index af83dc929be..45fb6fffcf2 100644 --- a/tests/snappi_tests/multidut/pfc/test_multidut_pfc_pause_lossy_with_snappi.py +++ b/tests/snappi_tests/multidut/pfc/test_multidut_pfc_pause_lossy_with_snappi.py @@ -84,20 +84,21 @@ def test_pfc_pause_single_lossy_prio(snappi_api, # noqa: F811 snappi_extra_params = SnappiTestParams() snappi_extra_params.multi_dut_params.multi_dut_ports = snappi_ports - - run_pfc_test(api=snappi_api, - testbed_config=testbed_config, - port_config_list=port_config_list, - conn_data=conn_graph_facts, - fanout_data=fanout_graph_facts_multidut, - global_pause=False, - pause_prio_list=pause_prio_list, - test_prio_list=test_prio_list, - bg_prio_list=bg_prio_list, - prio_dscp_map=prio_dscp_map, - test_traffic_pause=False, - snappi_extra_params=snappi_extra_params) - cleanup_config(duthosts, snappi_ports) + try: + run_pfc_test(api=snappi_api, + testbed_config=testbed_config, + port_config_list=port_config_list, + conn_data=conn_graph_facts, + fanout_data=fanout_graph_facts_multidut, + global_pause=False, + pause_prio_list=pause_prio_list, + test_prio_list=test_prio_list, + bg_prio_list=bg_prio_list, + prio_dscp_map=prio_dscp_map, + test_traffic_pause=False, + snappi_extra_params=snappi_extra_params) + finally: + cleanup_config(duthosts, snappi_ports) @pytest.mark.parametrize("multidut_port_info", MULTIDUT_PORT_INFO[MULTIDUT_TESTBED]) @@ -158,20 +159,21 @@ def test_pfc_pause_multi_lossy_prio(snappi_api, # noqa: F811 snappi_extra_params = SnappiTestParams() snappi_extra_params.multi_dut_params.multi_dut_ports = snappi_ports - - run_pfc_test(api=snappi_api, - testbed_config=testbed_config, - port_config_list=port_config_list, - conn_data=conn_graph_facts, - fanout_data=fanout_graph_facts, - global_pause=False, - pause_prio_list=pause_prio_list, - test_prio_list=test_prio_list, - bg_prio_list=bg_prio_list, - prio_dscp_map=prio_dscp_map, - test_traffic_pause=False, - snappi_extra_params=snappi_extra_params) - cleanup_config(duthosts, snappi_ports) + try: + run_pfc_test(api=snappi_api, + testbed_config=testbed_config, + port_config_list=port_config_list, + conn_data=conn_graph_facts, + fanout_data=fanout_graph_facts, + global_pause=False, + pause_prio_list=pause_prio_list, + test_prio_list=test_prio_list, + bg_prio_list=bg_prio_list, + prio_dscp_map=prio_dscp_map, + test_traffic_pause=False, + snappi_extra_params=snappi_extra_params) + finally: + cleanup_config(duthosts, snappi_ports) @pytest.mark.disable_loganalyzer @@ -243,29 +245,30 @@ def test_pfc_pause_single_lossy_prio_reboot(snappi_api, # noqa: F811 test_prio_list = [lossy_prio] bg_prio_list = [p for p in all_prio_list] bg_prio_list.remove(lossy_prio) - - for duthost in [snappi_ports[0]['duthost'], snappi_ports[1]['duthost']]: - logger.info("Issuing a {} reboot on the dut {}".format(reboot_type, duthost.hostname)) - reboot(duthost, localhost, reboot_type=reboot_type) - logger.info("Wait until the system is stable") - wait_until(180, 20, 0, duthost.critical_services_fully_started) - - snappi_extra_params = SnappiTestParams() - snappi_extra_params.multi_dut_params.multi_dut_ports = snappi_ports - - run_pfc_test(api=snappi_api, - testbed_config=testbed_config, - port_config_list=port_config_list, - conn_data=conn_graph_facts, - fanout_data=fanout_graph_facts_multidut, - global_pause=False, - pause_prio_list=pause_prio_list, - test_prio_list=test_prio_list, - bg_prio_list=bg_prio_list, - prio_dscp_map=prio_dscp_map, - test_traffic_pause=False, - snappi_extra_params=snappi_extra_params) - cleanup_config(duthosts, snappi_ports) + try: + for duthost in [snappi_ports[0]['duthost'], snappi_ports[1]['duthost']]: + logger.info("Issuing a {} reboot on the dut {}".format(reboot_type, duthost.hostname)) + reboot(duthost, localhost, reboot_type=reboot_type) + logger.info("Wait until the system is stable") + wait_until(180, 20, 0, duthost.critical_services_fully_started) + + snappi_extra_params = SnappiTestParams() + snappi_extra_params.multi_dut_params.multi_dut_ports = snappi_ports + + run_pfc_test(api=snappi_api, + testbed_config=testbed_config, + port_config_list=port_config_list, + conn_data=conn_graph_facts, + fanout_data=fanout_graph_facts_multidut, + global_pause=False, + pause_prio_list=pause_prio_list, + test_prio_list=test_prio_list, + bg_prio_list=bg_prio_list, + prio_dscp_map=prio_dscp_map, + test_traffic_pause=False, + snappi_extra_params=snappi_extra_params) + finally: + cleanup_config(duthosts, snappi_ports) @pytest.mark.disable_loganalyzer @@ -332,26 +335,27 @@ def test_pfc_pause_multi_lossy_prio_reboot(snappi_api, # noqa: F811 pause_prio_list = lossy_prio_list test_prio_list = lossy_prio_list bg_prio_list = lossless_prio_list - - for duthost in [snappi_ports[0]['duthost'], snappi_ports[1]['duthost']]: - logger.info("Issuing a {} reboot on the dut {}".format(reboot_type, duthost.hostname)) - reboot(duthost, localhost, reboot_type=reboot_type) - logger.info("Wait until the system is stable") - wait_until(180, 20, 0, duthost.critical_services_fully_started) - - snappi_extra_params = SnappiTestParams() - snappi_extra_params.multi_dut_params.multi_dut_ports = snappi_ports - - run_pfc_test(api=snappi_api, - testbed_config=testbed_config, - port_config_list=port_config_list, - conn_data=conn_graph_facts, - fanout_data=fanout_graph_facts_multidut, - global_pause=False, - pause_prio_list=pause_prio_list, - test_prio_list=test_prio_list, - bg_prio_list=bg_prio_list, - prio_dscp_map=prio_dscp_map, - test_traffic_pause=False, - snappi_extra_params=snappi_extra_params) - cleanup_config(duthosts, snappi_ports) + try: + for duthost in [snappi_ports[0]['duthost'], snappi_ports[1]['duthost']]: + logger.info("Issuing a {} reboot on the dut {}".format(reboot_type, duthost.hostname)) + reboot(duthost, localhost, reboot_type=reboot_type) + logger.info("Wait until the system is stable") + wait_until(180, 20, 0, duthost.critical_services_fully_started) + + snappi_extra_params = SnappiTestParams() + snappi_extra_params.multi_dut_params.multi_dut_ports = snappi_ports + + run_pfc_test(api=snappi_api, + testbed_config=testbed_config, + port_config_list=port_config_list, + conn_data=conn_graph_facts, + fanout_data=fanout_graph_facts_multidut, + global_pause=False, + pause_prio_list=pause_prio_list, + test_prio_list=test_prio_list, + bg_prio_list=bg_prio_list, + prio_dscp_map=prio_dscp_map, + test_traffic_pause=False, + snappi_extra_params=snappi_extra_params) + finally: + cleanup_config(duthosts, snappi_ports) From a527026278dff7cd92498cf1d807e7d6293b289f Mon Sep 17 00:00:00 2001 From: sellappa Date: Wed, 23 Oct 2024 19:38:33 +0000 Subject: [PATCH 7/9] reboot and ip cleanup fix for pfc --- .../test_multidut_pfc_pause_lossless_with_snappi.py | 13 +++++++++---- .../test_multidut_pfc_pause_lossy_with_snappi.py | 13 +++++++++---- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/tests/snappi_tests/multidut/pfc/test_multidut_pfc_pause_lossless_with_snappi.py b/tests/snappi_tests/multidut/pfc/test_multidut_pfc_pause_lossless_with_snappi.py index c81d988ae99..053feca3812 100644 --- a/tests/snappi_tests/multidut/pfc/test_multidut_pfc_pause_lossless_with_snappi.py +++ b/tests/snappi_tests/multidut/pfc/test_multidut_pfc_pause_lossless_with_snappi.py @@ -13,6 +13,7 @@ from tests.snappi_tests.multidut.pfc.files.multidut_helper import run_pfc_test from tests.common.reboot import reboot from tests.common.utilities import wait_until +from tests.common.platform.processes_utils import wait_critical_processes import logging from tests.common.snappi_tests.snappi_test_params import SnappiTestParams from tests.snappi_tests.files.helper import skip_warm_reboot @@ -260,9 +261,11 @@ def test_pfc_pause_single_lossless_prio_reboot(snappi_api, # no try: for duthost in [snappi_ports[0]['duthost'], snappi_ports[1]['duthost']]: logger.info("Issuing a {} reboot on the dut {}".format(reboot_type, duthost.hostname)) - reboot(duthost, localhost, reboot_type=reboot_type) + reboot(duthost, localhost, reboot_type=reboot_type, safe_reboot=True) logger.info("Wait until the system is stable") - wait_until(180, 20, 0, duthost.critical_services_fully_started) + wait_critical_processes(duthost) + pytest_assert(wait_until(300, 20, 0, duthost.critical_services_fully_started), + "Not all critical services are fully started") run_pfc_test(api=snappi_api, testbed_config=testbed_config, @@ -349,9 +352,11 @@ def test_pfc_pause_multi_lossless_prio_reboot(snappi_api, # noq try: for duthost in [snappi_ports[0]['duthost'], snappi_ports[1]['duthost']]: logger.info("Issuing a {} reboot on the dut {}".format(reboot_type, duthost.hostname)) - reboot(duthost, localhost, reboot_type=reboot_type) + reboot(duthost, localhost, reboot_type=reboot_type, safe_reboot=True) logger.info("Wait until the system is stable") - wait_until(180, 20, 0, duthost.critical_services_fully_started) + wait_critical_processes(duthost) + pytest_assert(wait_until(300, 20, 0, duthost.critical_services_fully_started), + "Not all critical services are fully started") run_pfc_test(api=snappi_api, testbed_config=testbed_config, diff --git a/tests/snappi_tests/multidut/pfc/test_multidut_pfc_pause_lossy_with_snappi.py b/tests/snappi_tests/multidut/pfc/test_multidut_pfc_pause_lossy_with_snappi.py index 45fb6fffcf2..1b586eead46 100644 --- a/tests/snappi_tests/multidut/pfc/test_multidut_pfc_pause_lossy_with_snappi.py +++ b/tests/snappi_tests/multidut/pfc/test_multidut_pfc_pause_lossy_with_snappi.py @@ -12,6 +12,7 @@ from tests.snappi_tests.multidut.pfc.files.multidut_helper import run_pfc_test from tests.common.reboot import reboot from tests.common.utilities import wait_until +from tests.common.platform.processes_utils import wait_critical_processes import logging from tests.common.snappi_tests.snappi_test_params import SnappiTestParams from tests.snappi_tests.files.helper import skip_warm_reboot @@ -248,9 +249,11 @@ def test_pfc_pause_single_lossy_prio_reboot(snappi_api, # noqa: F811 try: for duthost in [snappi_ports[0]['duthost'], snappi_ports[1]['duthost']]: logger.info("Issuing a {} reboot on the dut {}".format(reboot_type, duthost.hostname)) - reboot(duthost, localhost, reboot_type=reboot_type) + reboot(duthost, localhost, reboot_type=reboot_type, safe_reboot=True) logger.info("Wait until the system is stable") - wait_until(180, 20, 0, duthost.critical_services_fully_started) + wait_critical_processes(duthost) + pytest_assert(wait_until(300, 20, 0, duthost.critical_services_fully_started), + "Not all critical services are fully started") snappi_extra_params = SnappiTestParams() snappi_extra_params.multi_dut_params.multi_dut_ports = snappi_ports @@ -338,9 +341,11 @@ def test_pfc_pause_multi_lossy_prio_reboot(snappi_api, # noqa: F811 try: for duthost in [snappi_ports[0]['duthost'], snappi_ports[1]['duthost']]: logger.info("Issuing a {} reboot on the dut {}".format(reboot_type, duthost.hostname)) - reboot(duthost, localhost, reboot_type=reboot_type) + reboot(duthost, localhost, reboot_type=reboot_type, safe_reboot=True) logger.info("Wait until the system is stable") - wait_until(180, 20, 0, duthost.critical_services_fully_started) + wait_critical_processes(duthost) + pytest_assert(wait_until(300, 20, 0, duthost.critical_services_fully_started), + "Not all critical services are fully started") snappi_extra_params = SnappiTestParams() snappi_extra_params.multi_dut_params.multi_dut_ports = snappi_ports From 1aa2c9f73a25a4600f5471c8c62c927f97164646 Mon Sep 17 00:00:00 2001 From: sellappa Date: Wed, 23 Oct 2024 19:40:21 +0000 Subject: [PATCH 8/9] fixing ecn random.sample()[0] --- tests/snappi_tests/multidut/ecn/files/multidut_helper.py | 4 ++-- .../multidut/ecn/test_multidut_dequeue_ecn_with_snappi.py | 2 +- .../multidut/ecn/test_multidut_red_accuracy_with_snappi.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/snappi_tests/multidut/ecn/files/multidut_helper.py b/tests/snappi_tests/multidut/ecn/files/multidut_helper.py index 76c27031316..5239e9e4069 100644 --- a/tests/snappi_tests/multidut/ecn/files/multidut_helper.py +++ b/tests/snappi_tests/multidut/ecn/files/multidut_helper.py @@ -84,8 +84,8 @@ def run_ecn_test(api, # Enable ECN marking logger.info("Enabling ECN markings") - pytest_assert(enable_ecn(host_ans=egress_duthost, prio=lossless_prio), 'Unable to enable ecn') - pytest_assert(enable_ecn(host_ans=ingress_duthost, prio=lossless_prio), 'Unable to enable ecn') + pytest_assert(enable_ecn(host_ans=egress_duthost, prio=lossless_prio, asic_value=rx_port['asic_value']), 'Unable to enable ecn') + pytest_assert(enable_ecn(host_ans=ingress_duthost, prio=lossless_prio, asic_value=tx_port['asic_value']), 'Unable to enable ecn') config_result = config_ingress_lossless_buffer_alpha(host_ans=egress_duthost, alpha_log2=3) diff --git a/tests/snappi_tests/multidut/ecn/test_multidut_dequeue_ecn_with_snappi.py b/tests/snappi_tests/multidut/ecn/test_multidut_dequeue_ecn_with_snappi.py index cf1971dd114..51324a614e7 100644 --- a/tests/snappi_tests/multidut/ecn/test_multidut_dequeue_ecn_with_snappi.py +++ b/tests/snappi_tests/multidut/ecn/test_multidut_dequeue_ecn_with_snappi.py @@ -76,7 +76,7 @@ def test_dequeue_ecn(request, snappi_ports, snappi_api) - lossless_prio = random.sample(lossless_prio_list, 1) + lossless_prio = random.sample(lossless_prio_list, 1)[0] skip_ecn_tests(snappi_ports[0]['duthost']) skip_ecn_tests(snappi_ports[1]['duthost']) lossless_prio = int(lossless_prio) diff --git a/tests/snappi_tests/multidut/ecn/test_multidut_red_accuracy_with_snappi.py b/tests/snappi_tests/multidut/ecn/test_multidut_red_accuracy_with_snappi.py index 3f29c1232e8..f12925e1272 100644 --- a/tests/snappi_tests/multidut/ecn/test_multidut_red_accuracy_with_snappi.py +++ b/tests/snappi_tests/multidut/ecn/test_multidut_red_accuracy_with_snappi.py @@ -80,7 +80,7 @@ def test_red_accuracy(request, snappi_api) skip_ecn_tests(snappi_ports[0]['duthost']) or skip_ecn_tests(snappi_ports[1]['duthost']) - lossless_prio = random.sample(lossless_prio_list, 1) + lossless_prio = random.sample(lossless_prio_list, 1)[0] snappi_extra_params = SnappiTestParams() snappi_extra_params.multi_dut_params.multi_dut_ports = snappi_ports From ac1b8bd0c3f5e57683f47c517cc5b49c7c50f0fa Mon Sep 17 00:00:00 2001 From: selldinesh Date: Mon, 11 Nov 2024 19:11:59 +0000 Subject: [PATCH 9/9] Modified pfc fluctuation test verification to use ceil --- .../multidut/pfc/files/m2o_fluctuating_lossless_helper.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/snappi_tests/multidut/pfc/files/m2o_fluctuating_lossless_helper.py b/tests/snappi_tests/multidut/pfc/files/m2o_fluctuating_lossless_helper.py index cb2d69d9c0c..fdf13bad315 100644 --- a/tests/snappi_tests/multidut/pfc/files/m2o_fluctuating_lossless_helper.py +++ b/tests/snappi_tests/multidut/pfc/files/m2o_fluctuating_lossless_helper.py @@ -1,5 +1,6 @@ import logging # noqa: F401 import random +import math from tests.common.helpers.assertions import pytest_assert, pytest_require # noqa: F401 from tests.common.fixtures.conn_graph_facts import conn_graph_facts, fanout_graph_facts # noqa: F401 from tests.common.snappi_tests.snappi_helpers import get_dut_port_id # noqa: F401 @@ -375,4 +376,4 @@ def verify_m2o_fluctuating_lossless_result(rows, pytest_assert(int(row.loss) == 0, "FAIL: {} must have 0% loss".format(row.name)) elif 'Background Flow' in row.name: background_loss += float(row.loss) - pytest_assert(int(background_loss/4) == 10, "Each Background Flow must have an avg of 10% loss ") + pytest_assert(math.ceil(background_loss/4) == 10 or math.floor(background_loss/4) == 10, "Each Background Flow must have an avg of 10% loss ")