def pvst_elastic_function_hooks(request): if st.get_func_name(request) == "test_ft_stp_loopguard_lag_interfaces": vlan.clear_vlan_configuration(st.get_dut_names(), thread=False) st.log('Creating port-channel and adding members in both DUTs') portchannel.config_portchannel(vars.D1, vars.D2, sc_data.portchannel_name, sc_data.members_dut1, sc_data.members_dut2, "add") portchannel.config_portchannel(vars.D1, vars.D2, sc_data.portchannel_name2, sc_data.members_dut1_p2, sc_data.members_dut2_p2, "add") parallel.exec_all( True, [[vlan.create_vlan_and_add_members, sc_data.vlan_pc_d1], [vlan.create_vlan_and_add_members, sc_data.vlan_pc_d2]]) yield if st.get_func_name(request) == "test_ft_stp_loopguard_lag_interfaces": vlan.clear_vlan_configuration(st.get_dut_names(), thread=False) portchannel.clear_portchannel_configuration([vars.D1, vars.D2]) parallel.exec_all( True, [[vlan.create_vlan_and_add_members, sc_data.vlan_data_d1], [vlan.create_vlan_and_add_members, sc_data.vlan_data_d2]]) parallel.exec_all( True, [[vlan.create_vlan_and_add_members, sc_data.vlan1_data_d1], [vlan.create_vlan_and_add_members, sc_data.vlan1_data_d2]])
def ipv6_link_local_config(action="add"): if action == "add": st.log("Creating VLAN and participating interfaces ...") vlan_data = [{ "dut": [vars.D1], "vlan_id": bgp_rst_data.vlan_id[0], "tagged": [vars.D1D2P2] }, { "dut": [vars.D2], "vlan_id": bgp_rst_data.vlan_id[0], "tagged": [vars.D2D1P2] }] create_vlan_and_add_members(vlan_data) st.log("Creating PortChannel and participating interfaces ...") config_portchannel(vars.D1, vars.D2, bgp_rst_data.portchannel_name, [vars.D1D2P3, vars.D1D2P4], [vars.D2D1P3, vars.D2D1P4]) st.log("Enable IPV6 on physical interface on both the devices") [_, exceptions] = exec_all(True, [[config_interface_ip6_link_local, vars.D1, ["Vlan{}".format(bgp_rst_data.vlan_id[0]), bgp_rst_data.portchannel_name]], \ [config_interface_ip6_link_local, vars.D2, ["Vlan{}".format(bgp_rst_data.vlan_id[0]), bgp_rst_data.portchannel_name]]]) ensure_no_exception(exceptions) else: [_, exceptions] = exec_all(True, [ [config_interface_ip6_link_local, vars.D1, [vars.D1D2P1, "Vlan{}".format(bgp_rst_data.vlan_id[0]), bgp_rst_data.portchannel_name], "disable"], \ [config_interface_ip6_link_local, vars.D2, [vars.D2D1P1, "Vlan{}".format(bgp_rst_data.vlan_id[0]), bgp_rst_data.portchannel_name], "disable"]]) ensure_no_exception(exceptions) clear_portchannel_configuration([vars.D1, vars.D2]) clear_vlan_configuration([vars.D1, vars.D2])
def config_portchannel(): po_obj.config_portchannel(vars.D1, vars.D2, data.portchannel_name, data.members_dut1, data.members_dut2, "add")
def bgp_unnum_pre_config(): global vars vars = st.ensure_min_topology("D1D2:4", "D1T1:2", "D2T1:2") global dut1_rt_int_mac, dut2_rt_int_mac, d1_prt_link_local, \ d2_prt_link_local, d1_int_ipv6_list, d2_int_ipv6_list # For debugging purpose, checking 'running config' before proceeding for module config utils.exec_all(True, [[sc_obj.get_running_config, vars.D1], [sc_obj.get_running_config, vars.D2]]) # For debugging purpose, checking 'routing interfaces' before proceeding for module config # utils.exec_all(True, [[ip_obj.get_interface_ip_address, vars.D1, None, "ipv6"], # [ip_obj.get_interface_ip_address, vars.D2, None, "ipv6"]]) pc_obj.config_portchannel(vars.D1, vars.D2, data.portchannel_name, [vars.D1D2P3, vars.D1D2P4], [vars.D2D1P3, vars.D2D1P4], config='add', thread=True) # vlan config utils.exec_all( True, [[vlan_obj.create_vlan, vars.D1, [data.vlan_li[0], data.vlan_li[1]]], [vlan_obj.create_vlan, vars.D2, [data.vlan_li[0], data.vlan_li[1]]]]) utils.exec_all(True, [[ vlan_mem_cfg, vars.D1, [[data.vlan_li[0], vars.D1D2P2, True], [data.vlan_li[1], vars.D1D2P2, True]] ], [ vlan_mem_cfg, vars.D2, [[data.vlan_li[0], vars.D2D1P2, True], [data.vlan_li[1], vars.D2D1P2, True]] ]]) d1_int_ipv6_list = [ vars.D1D2P1, data.vlan_in_1, data.vlan_in_2, data.portchannel_name ] d2_int_ipv6_list = [ vars.D2D1P1, data.vlan_in_1, data.vlan_in_2, data.portchannel_name ] utils.exec_all( True, [[ip_obj.config_interface_ip6_link_local, vars.D1, d1_int_ipv6_list], [ip_obj.config_interface_ip6_link_local, vars.D2, d2_int_ipv6_list]]) # TG connected int ipv6 address config utils.exec_all( True, [[ ip_obj.config_ip_addr_interface, vars.D1, vars.D1T1P2, data.tgd_ip6_addr_l[0], data.tg_ip6_addr_mask_l[0], "ipv6", 'add' ], [ ip_obj.config_ip_addr_interface, vars.D2, vars.D2T1P2, data.tgd_ip6_addr_l[1], data.tg_ip6_addr_mask_l[1], "ipv6", 'add' ]]) utils.exec_all( True, [[ ip_obj.config_ip_addr_interface, vars.D1, vars.D1T1P1, data.tgd_ip4_addr_l[0], data.tg_ip4_addr_mask_l[0], "ipv4", 'add' ], [ ip_obj.config_ip_addr_interface, vars.D2, vars.D2T1P1, data.tgd_ip4_addr_l[1], data.tg_ip4_addr_mask_l[1], "ipv4", 'add' ]]) # Get DUT mac address [rt_int_mac, exceptions ] = utils.exec_all(True, [[basic_obj.get_ifconfig_ether, vars.D1, vars.D1D2P1], [basic_obj.get_ifconfig_ether, vars.D2, vars.D2D1P1]]) for value in exceptions: if value is not None: st.log("Exceptions observed {}".format(value)) st.error( "Exceptions observed while getting mac address of routing interface" ) dut1_rt_int_mac = rt_int_mac[0] dut2_rt_int_mac = rt_int_mac[1] # Get DUT link local addresses [rt_link_local_addr, exceptions] = utils.exec_all( True, [[ip_obj.get_link_local_addresses, vars.D1, vars.D1D2P1], [ip_obj.get_link_local_addresses, vars.D2, vars.D2D1P1]]) for value in exceptions: if value is not None: st.log("Exceptions observed {}".format(value)) st.error( "Exceptions observed while getting mac address of routing interface" ) d1_prt_link_local = rt_link_local_addr[0] d2_prt_link_local = rt_link_local_addr[1] st.log("######------Get show ndp output------######") utils.exec_all( True, [[arp_obj.show_ndp, vars.D1, None], [arp_obj.show_ndp, vars.D2, None]]) bgp_unnumbered_neighbour_config()
def test_ft_stormcontrol_portchannel_intf(): status = 1 msg_id = "storm_control_portchannel_verification_successful" portchannel_name = 'PortChannel13' vlan_info = [{ "dut": [vars.D2], "vlan_id": sc_data.vlan, "tagged": [vars.D2T1P1, vars.D2T1P2, portchannel_name] }] portchannel_interfaces_dut1 = [vars.D1D2P1, vars.D1D2P2] portchannel_interfaces_dut2 = [vars.D2D1P1, vars.D2D1P2] portchannel.config_portchannel(vars.D1, vars.D2, portchannel_name, portchannel_interfaces_dut1, portchannel_interfaces_dut2, config="add", thread=True) vlan.add_vlan_member(vars.D1, sc_data.vlan, portchannel_name, tagging_mode=True) vlan.create_vlan_and_add_members(vlan_info) st.log( "Verifying whether stormcontrol config can be applied on portchannel {} interfaces" .format(portchannel_name)) if scapi.config(vars.D1, type="broadcast", action="add", interface_name=portchannel_name, rate=sc_data.kbps, skip_error_check=True): st.error( "storm-control config can be applied on portchannel interface") status = 0 else: st.log( "storm-control config cannot be applied on portchannel interface.") if status: st.report_tc_pass('ft_stormcontrol_neg_config_vlan_portchannel', 'test_case_passed') else: st.report_tc_fail('ft_stormcontrol_neg_config_vlan_portchannel', 'test_case_failed') status = 1 st.log("configuring bum stormcontrol on portchannel interfaces") scapi.config(vars.D1, type="broadcast", action="del", interface_name=vars.D1T1P1, bits_per_sec=sc_data.kbps) scapi.config(vars.D1, type="broadcast", action="del", interface_name=vars.D1T1P2, bits_per_sec=sc_data.kbps) scapi.config(vars.D2, type="broadcast", action="add", interface_name=vars.D2D1P1, bits_per_sec=sc_data.kbps) scapi.config(vars.D2, type="broadcast", action="add", interface_name=vars.D2D1P2, bits_per_sec=sc_data.kbps) verify_bum_traffic_mode('broadcast', tg_info['tg1_stream_id'], skip_traffic_verify=True) st.log("Clearing interface counters") ifapi.clear_interface_counters(vars.D2) tg.tg_traffic_control(action='run', stream_handle=tg_info['tg1_stream_id'], duration=10) st.wait(sc_data.wait_stream_run) st.log("Stopping of traffic from TGen to get interface counters") tg.tg_traffic_control(action='stop', stream_handle=tg_info['tg1_stream_id']) st.wait(sc_data.wait_for_stats) tg_1_stats = tgapi.get_traffic_stats(tg, mode='aggregate', port_handle=tg_handler["tg_ph_1"]) tg_3_stats = tgapi.get_traffic_stats(tg, mode='aggregate', port_handle=tg_handler["tg_ph_3"]) counter = tg_3_stats.rx.total_packets counter2 = tg_1_stats.tx.total_packets try: time = int(counter2 / sc_data.rate_pps) counters_avg = counter / time except Exception: counters_avg = 0 st.log("Average of counters are : {}".format(counters_avg)) st.log("Higher packet count value is : {}".format( sc_data.higher_pkt_count)) st.log("Lower packet count value is : {}".format(sc_data.lower_pkt_count)) st.log("value of status is : {}".format(status)) if counters_avg > sc_data.higher_pkt_count or counters_avg < sc_data.lower_pkt_count: st.error("storm control traffic verification failed") status = 0 if status: st.report_tc_pass('ft_stormcontrol_portchannel_intf', 'test_case_passed') else: st.report_tc_fail('ft_stormcontrol_portchannel_intf', 'test_case_failed') status = 1 st.log("Configuring stormcontrol without providing bps value") if scapi.config(vars.D1, type="broadcast", action="add", interface_name=vars.D1T1P1, skip_error_check=True): st.error("Storm-control config is accepting not throwing any error") status = 0 else: st.log("Config is not accepted and thrown an error") if status: st.report_tc_pass('ft_stormcontrol_neg_config_without_bpsvalue', 'test_case_passed') else: st.report_tc_fail('ft_stormcontrol_neg_config_without_bpsvalue', 'test_case_failed') status = 1 st.log("unconfiguring of bum stormcontrol type by providing bps value") if scapi.config(vars.D1, type="broadcast", action="del", interface_name=vars.D1T1P1, rate=sc_data.kbps, skip_error_check=True): st.error("Storm-control config is removed and not throwing any error") status = 0 else: st.log("Config is not accepted and thrown an error") if status: st.report_tc_pass('ft_stormcontrol_neg_unconfig_with_bpsvalue', 'test_case_passed') else: st.report_tc_fail('ft_stormcontrol_neg_unconfig_with_bpsvalue', 'test_case_failed') st.log("Back to module config") scapi.config(vars.D2, type="broadcast", action="del", interface_name=vars.D2D1P1, bits_per_sec=sc_data.kbps) scapi.config(vars.D2, type="broadcast", action="del", interface_name=vars.D2D1P2, bits_per_sec=sc_data.kbps) scapi.config(vars.D1, type="broadcast", action="add", interface_name=vars.D1T1P1, bits_per_sec=sc_data.kbps) scapi.config(vars.D1, type="broadcast", action="add", interface_name=vars.D1T1P2, bits_per_sec=sc_data.kbps) st.log( "Unconfiguring portchannel config in both devices and only vlan configuration in device2" ) vlan.clear_vlan_configuration(vars.D2) vlan.delete_vlan_member(vars.D1, sc_data.vlan, portchannel_name, tagging_mode=True) portchannel.clear_portchannel_configuration(st.get_dut_names(), thread=True) if not status: msg_id = "storm_control_portchannel_verification_failed" report_result(status, msg_id)
def ipv6_link_local_pre_config(): global vars vars = st.ensure_min_topology("D1D2:4", "D1T1:1", "D2T1:1") global tg_handler, tg1, tg2, tg_ph_1, tg_ph_2, tg_str_data, dut1_rt_int_mac, dut2_rt_int_mac, \ tg_rt_int_handle, d1_prt_link_local, d2_prt_link_local, d1_int_ipv6_list, d2_int_ipv6_list tg_handler = util_tg_init(vars, [vars.T1D1P1, vars.T1D2P1]) tg1 = tg_handler["tg"] tg2 = tg_handler["tg"] tg_ph_1 = tg_handler["tg_ph_1"] tg_ph_2 = tg_handler["tg_ph_2"] st.log("For debugging purpose, checking 'running config' before proceeding for module config") utils.exec_all(True, [[sc_obj.get_running_config, vars.D1], [sc_obj.get_running_config, vars.D2]]) st.log("For debugging purpose, checking 'routing interfaces' before proceeding for module config") utils.exec_all(True, [[ip_obj.get_interface_ip_address, vars.D1, None, "ipv6"], [ip_obj.get_interface_ip_address, vars.D2, None, "ipv6"]]) pc_obj.config_portchannel(vars.D1, vars.D2, data.prt_chnl, [vars.D1D2P3, vars.D1D2P4], [vars.D2D1P3, vars.D2D1P4], config='add', thread=True) st.log("Vlan config") utils.exec_all(True, [[vlan_obj.create_vlan, vars.D1, [data.vlan_li[0], data.vlan_li[1]]], [vlan_obj.create_vlan, vars.D2, [data.vlan_li[0], data.vlan_li[1]]]]) utils.exec_all(True, [ [vlan_mem_cfg, vars.D1, [[data.vlan_li[0], vars.D1D2P2, True], [data.vlan_li[1], vars.D1D2P2, True]]], [vlan_mem_cfg, vars.D2, [[data.vlan_li[0], vars.D2D1P2, True], [data.vlan_li[1], vars.D2D1P2, True]]]]) st.log("VRF Config and binding 2nd vlan routing interface to that VRF") vrf_obj.config_vrf(vars.D1, vrf_name=data.vrf_name, config='yes') vrf_obj.bind_vrf_interface(vars.D1, vrf_name=data.vrf_name, intf_name=data.vlan_in_2, config='yes', skip_error=True) st.log("Enabling ipv6 link local") d1_int_ipv6_list =[vars.D1D2P1, data.vlan_in_1, data.vlan_in_2,data.prt_chnl] d2_int_ipv6_list = [vars.D2D1P1, data.vlan_in_1, data.vlan_in_2, data.prt_chnl] utils.exec_all(True, [[ip_obj.config_interface_ip6_link_local, vars.D1,d1_int_ipv6_list, 'enable'], [ip_obj.config_interface_ip6_link_local, vars.D2,d2_int_ipv6_list, 'enable']]) st.log("TG connected int ipv6 address config") utils.exec_all(True, [[ip_obj.config_ip_addr_interface, vars.D1, vars.D1T1P1, data.tgd_ip6_addr_l[0], data.tg_ip6_addr_mask_l[0],"ipv6",'add'], [ip_obj.config_ip_addr_interface, vars.D2, vars.D2T1P1, data.tgd_ip6_addr_l[1], data.tg_ip6_addr_mask_l[1],"ipv6",'add']]) st.log("Get DUT mac address") [rt_int_mac, exceptions] = utils.exec_all(True, [[basic_obj.get_ifconfig_ether, vars.D1, vars.D1D2P1], [basic_obj.get_ifconfig_ether, vars.D2, vars.D2D1P1]]) utils.ensure_no_exception(exceptions) dut1_rt_int_mac = rt_int_mac[0] dut2_rt_int_mac = rt_int_mac[1] st.log("Get DUT link local addresses") [rt_link_local_addr, exceptions] = utils.exec_all(True, [[ip_obj.get_link_local_addresses, vars.D1, vars.D1D2P1], [ip_obj.get_link_local_addresses, vars.D2, vars.D2D1P1]]) utils.ensure_no_exception(exceptions) d1_prt_link_local = rt_link_local_addr[0] d2_prt_link_local = rt_link_local_addr[1] if not d1_prt_link_local or not d2_prt_link_local: st.log("DUT Link Local Address are empty") st.report_fail("link_local_address_not_found") st.log("Routing interface config in TG") tg_rt_int_handle = util_tg_routing_int_config(vars, tg1, tg2, tg_ph_1, tg_ph_2) st.log("Doing ping to the TG ipv6 address to resolve the next hop") utils.exec_all(True, [[ip_obj.ping, vars.D1, data.tgd_ip6_addr_l[0], 'ipv6'],[ip_obj.ping, vars.D2, data.tgd_ip6_addr_l[1], 'ipv6']]) st.log("Get show ndp output") utils.exec_all(True, [[arp_obj.show_ndp, vars.D1, None],[arp_obj.show_ndp, vars.D2, None]]) st.log("Static route config") utils.exec_all(True, [[ip_obj.create_static_route, vars.D1, d2_prt_link_local[0], data.static_rt, "vtysh", 'ipv6', vars.D1D2P1], [ip_obj.create_static_route, vars.D2, data.tg_ip6_addr_l[1], data.static_rt, "vtysh", 'ipv6', vars.D2T1P1]]) ip_obj.create_static_route(vars.D1, d2_prt_link_local[0], data.static_rt, "vtysh", 'ipv6', data.vlan_in_1) ip_obj.create_static_route(vars.D1, d2_prt_link_local[0], data.static_rt, "vtysh", 'ipv6', data.prt_chnl) ip_obj.create_static_route(vars.D1, d2_prt_link_local[0], data.static_rt, "vtysh", 'ipv6', data.vlan_in_2, vrf=data.vrf_name) st.log("Get show ipv6 route output") utils.exec_all(True, [[ip_obj.show_ip_route, vars.D1, "ipv6", "sonic", None],[ip_obj.show_ip_route, vars.D2, "ipv6", "sonic", None]]) ip_obj.show_ip_route(vars.D1, "ipv6", "sonic", data.vrf_name) st.log("TG Stream config") tg_str_data = util_tg_stream_config(tg1, tg2, tg_ph_1, tg_ph_2) st.log("Clearing all interface counters for debugging purpose") utils.exec_all(True, [[intf_obj.clear_interface_counters, vars.D1], [intf_obj.clear_interface_counters, vars.D2]])