def test_ft_system_verify_traffic_during_fast_reboot(): data.tg_handler["tg"].tg_traffic_config( mode='modify', stream_id=data.stream['stream_id'], transmit_mode='continuous', port_handle=data.tg_handler["tg_ph_1"]) st.log("performing Config save") rb_obj.config_save(vars.D1) data.tg_handler["tg"].tg_traffic_control( action='clear_stats', port_handle=[data.tg_handler["tg_ph_1"], data.tg_handler["tg_ph_2"]]) data.tg_handler["tg"].tg_traffic_control( action='run', stream_handle=data.stream['stream_id']) st.log("performing fast-reboot") st.reboot(vars.D1, 'fast') data.tg_handler["tg"].tg_traffic_control( action='stop', stream_handle=data.stream['stream_id']) loss_pkts_count = 26 * 100 stats_tg1 = tgapi.get_traffic_stats(data.tg_handler["tg"], mode="aggregate", port_handle=data.tg_handler["tg_ph_1"]) tx_pkts = stats_tg1.tx.total_packets stats_tg2 = tgapi.get_traffic_stats(data.tg_handler["tg"], mode="aggregate", port_handle=data.tg_handler["tg_ph_2"]) rx_pkts = stats_tg2.rx.total_packets st.log("Traffic sent from TGEN: {}".format(tx_pkts)) st.log("Traffic received on TGEN: {}".format(rx_pkts)) if not loss_pkts_count > int(tx_pkts) - int(rx_pkts): st.report_fail('data_traffic_loss_during_fast_reboot') st.report_pass("test_case_passed")
def verify_traffic(): ifapi.clear_interface_counters(vars.D1) ifapi.show_interface_counters_all(vars.D1) st.log("Starting of traffic from TGen") 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) ifapi.show_interface_counters_all(vars.D1) tg_1_stats = tgapi.get_traffic_stats(tg, mode='aggregate', port_handle=tg_handler["tg_ph_1"]) tg_2_stats = tgapi.get_traffic_stats(tg, mode='aggregate', port_handle=tg_handler["tg_ph_3"]) total_rx_tg2 = tg_2_stats.rx.total_packets total_tx_tg1 = tg_1_stats.tx.total_packets percentage_95_total_tx_tg1 = (95 * int(total_tx_tg1)) / 100 if not int(percentage_95_total_tx_tg1) <= int(total_rx_tg2): st.report_fail("traffic_transmission_failed", vars.T1D1P1) return True
def test_ft_system_verify_traffic_through_port_channel_during_fast_reboot(): [output, exceptions] = exec_all(True, [[ po_obj.verify_portchannel_member, vars.D1, data.portchannel_name, data.members_dut1 ], [ po_obj.verify_portchannel_member, vars.D2, data.portchannel_name, data.members_dut2 ]]) if False in output: st.report_fail('portchannel_member_verification_failed', data.portchannel_name, vars.D1, data.members_dut1) ensure_no_exception(exceptions) exceptions = exec_all(True, [[ vlan_obj.add_vlan_member, vars.D1, data.vlan, data.portchannel_name, True ], [ vlan_obj.add_vlan_member, vars.D2, data.vlan, data.portchannel_name, True ]])[1] ensure_no_exception(exceptions) data.tg_handler["tg"].tg_traffic_config( mode='modify', stream_id=data.stream['stream_id'], transmit_mode='continuous', port_handle=data.tg_handler["tg_ph_1"]) st.log("performing Config save") rb_obj.config_save(vars.D1) data.tg_handler["tg"].tg_traffic_control( action='clear_stats', port_handle=[data.tg_handler["tg_ph_1"], data.tg_handler["tg_ph_3"]]) data.tg_handler["tg"].tg_traffic_control( action='run', stream_handle=data.stream['stream_id']) st.log("performing fast-reboot") st.reboot(vars.D1, 'fast') data.tg_handler["tg"].tg_traffic_control( action='stop', stream_handle=data.stream['stream_id']) loss_pkts_count = 26 * 100 stats_tg1 = tgapi.get_traffic_stats(data.tg_handler["tg"], mode="aggregate", port_handle=data.tg_handler["tg_ph_1"]) tx_pkts = stats_tg1.tx.total_packets stats_tg2 = tgapi.get_traffic_stats(data.tg_handler["tg"], mode="aggregate", port_handle=data.tg_handler["tg_ph_3"]) rx_pkts = stats_tg2.rx.total_packets st.log("Traffic sent from TGEN: {}".format(tx_pkts)) st.log("Traffic received on TGEN: {}".format(rx_pkts)) if not loss_pkts_count > int(tx_pkts) - int(rx_pkts): st.report_fail('data_traffic_loss_during_fast_reboot') st.report_pass("test_case_passed")
def test_ft_stormcontrol_incremental_bps_max_vlan(): status = 1 counters_avg =0 msg_id = "storm_control_traffic_incremental_bps_max_vlan_successful" initial_kbps_value = 600 last_kbps_value = 1000 interface_list = [vars.D1T1P1, vars.D1T1P2] for kbps_value in range(initial_kbps_value, last_kbps_value, 200): for interf in interface_list: scapi.config(vars.D1, type="broadcast", action="add", interface_name=interf, bits_per_sec=kbps_value) if not scapi.verify_config(vars.D1, interface_name=interf, type="broadcast", rate=kbps_value): st.error("incremental kbps is not working") status = 0 sc_data.packets = (kbps_value * 1024) / (sc_data.frame_size * 8) sc_data.bum_deviation1 = int(0.10 * sc_data.packets) sc_data.lower_pkt_cnt = int(sc_data.packets - sc_data.bum_deviation1) sc_data.higher_pkt_cnt = int(sc_data.packets + sc_data.bum_deviation1) for _ in range(1,3,1): verify_bum_traffic_mode('broadcast', tg_info['tg1_stream_id'], skip_traffic_verify=True) st.log("Clearing interface counters") ifapi.clear_interface_counters(vars.D1) st.log("Starting of traffic from TGen") 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 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_2_stats = tgapi.get_traffic_stats(tg, mode='aggregate', port_handle=tg_handler["tg_ph_2"]) counter = tg_2_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_cnt)) st.log("Lower packet count value is : {}".format(sc_data.lower_pkt_cnt)) st.log("value of status is : {}".format(status)) if counters_avg <= sc_data.higher_pkt_cnt and counters_avg >= sc_data.lower_pkt_cnt: break if counters_avg > sc_data.higher_pkt_cnt or counters_avg < sc_data.lower_pkt_cnt: st.error("storm control traffic verification failed") status = 0 st.log("Unconfiguring back to previous config") for interf in interface_list: scapi.config(vars.D1, type="broadcast", action="add", interface_name=interf, bits_per_sec=sc_data.kbps) if not status: msg_id = "storm_control_traffic_incremental_bps_max_vlan_failed" report_result(status, msg_id)
def verify_bum_traffic_mode(mode, tg_stream, skip_traffic_verify=False, duration=10): """ :param mode: :param tg_stream: :param skip_traffic_verify: :param duration: :return: """ if mode not in ["unknown-unicast", "unknown-multicast", "broadcast"]: st.log("Unsupported mode provided") return False st.banner("verifying {} traffic ".format(mode)) st.log("Clearing stats before sending traffic ...") tg.tg_traffic_control(action="clear_stats", port_handle=tg_handler["tg_ph_list"]) st.wait(2) if mode == 'broadcast': st.log("Enabling {} traffic ".format(mode)) tg.tg_traffic_config(port_handle=tg_handler["tg_ph_1"], mode='modify',duration=10, stream_id=tg_stream, mac_src="00:00:00:00:00:01", mac_dst="ff:ff:ff:ff:ff:ff", rate_pps=5000) elif mode == 'unknown-multicast': st.log("Enabling {} traffic ".format(mode)) tg.tg_traffic_config(port_handle=tg_handler["tg_ph_1"], mode='modify', duration=10,stream_id=tg_stream, mac_src="00:00:00:00:00:01",mac_dst="01:00:5e:01:02:03",rate_pps=5000) elif mode == 'unknown-unicast': st.log("Enabling {} traffic ".format(mode)) tg.tg_traffic_config(port_handle=tg_handler["tg_ph_1"],duration=10, mode='modify', stream_id=tg_stream, mac_src="00:00:00:00:00:01", mac_dst="00:00:00:00:00:02", rate_pps=5000) if not skip_traffic_verify: ifapi.clear_interface_counters(vars.D1,interface_type="all") ifapi.show_interface_counters_all(vars.D1) st.log("Starting of traffic from TGen") tg.tg_traffic_control(action='run', stream_handle=tg_stream, 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_stream) st.wait(sc_data.wait_for_stats) ifapi.show_interface_counters_all(vars.D1) tg_1_stats = tgapi.get_traffic_stats(tg, mode='aggregate', port_handle=tg_handler["tg_ph_1"], direction='tx') tg_2_stats = tgapi.get_traffic_stats(tg, mode='aggregate', port_handle=tg_handler["tg_ph_2"]) counter = tg_2_stats.rx.total_packets counter2 = tg_1_stats.tx.total_packets if counter2 == 0: st.report_fail("storm_control_traffic_verification_failed") counters_avg = counter / duration 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)) if counters_avg > sc_data.higher_pkt_count or counters_avg < sc_data.lower_pkt_count: st.report_fail("storm_control_traffic_verification_failed") return True
def test_ft_system_verify_traffic_fast_reboot(): data.tg_handler["tg"].tg_traffic_control( action='clear_stats', port_handle=[data.tg_handler["tg_ph_1"], data.tg_handler["tg_ph_2"]]) data.tg_handler["tg"].tg_traffic_control( action='run', stream_handle=data.stream['stream_id']) st.log("Fetching TGEN statistics") stats_tg1 = tgapi.get_traffic_stats(data.tg_handler["tg"], mode="aggregate", port_handle=data.tg_handler["tg_ph_1"]) total_tx_tg1 = stats_tg1.tx.total_bytes stats_tg2 = tgapi.get_traffic_stats(data.tg_handler["tg"], mode="aggregate", port_handle=data.tg_handler["tg_ph_2"]) total_rx_tg2 = stats_tg2.rx.total_bytes percentage_98_total_tx_tg1 = (98 * int(total_tx_tg1)) / 100 st.log("###############") st.log("Sent bytes: {} and Received bytes : {}".format( percentage_98_total_tx_tg1, total_rx_tg2)) st.log("##############") if not int(percentage_98_total_tx_tg1) <= int(total_rx_tg2): st.report_fail("traffic_transmission_failed", vars.T1D1P1) data.tg.tg_traffic_control(action="clear_stats", port_handle=data.tg_handler["tg_ph_list"]) data.tg.tg_traffic_control(action='run', stream_handle=data.stream['stream_id']) st.reboot(vars.D1, 'fast') data.tg.tg_traffic_control(action='stop', stream_handle=data.stream['stream_id']) stats_tg1 = tgapi.get_traffic_stats(data.tg_handler["tg"], mode="aggregate", port_handle=data.tg_handler["tg_ph_1"]) total_tx_tg1 = stats_tg1.tx.total_bytes stats_tg2 = tgapi.get_traffic_stats(data.tg_handler["tg"], mode="aggregate", port_handle=data.tg_handler["tg_ph_2"]) total_rx_tg2 = stats_tg2.rx.total_bytes percentage_98_total_tx_tg1 = (98 * int(total_tx_tg1)) / 100 st.log("###############") st.log("Sent bytes: {} and Received bytes : {}".format( percentage_98_total_tx_tg1, total_rx_tg2)) st.log("##############") if not int(percentage_98_total_tx_tg1) <= int(total_rx_tg2): st.report_fail("traffic_transmission_failed", vars.T1D1P1) st.report_pass("test_case_passed")
def test_ft_port_frame_fwd_diff_mtu(): intfapi.get_interface_property(vars.D1, vars.D1T1P1, "mtu") intfapi.get_interface_property(vars.D1, vars.D1T1P2, "mtu") st.log("Configuring MTU values for each interface") intfapi.interface_properties_set(vars.D1, [vars.D1T1P1, vars.D1T1P2], 'mtu', intf_data.mtu1) intf_data.tg.tg_traffic_control(action='run', stream_handle=intf_data.streams['mtu1']) st.wait(intf_data.wait_sec) intf_data.tg.tg_traffic_control(action='stop', stream_handle=intf_data.streams['mtu1']) st.log("Fetching TGen statistics") stats_tg1 = tgapi.get_traffic_stats(intf_data.tg, mode="aggregate", port_handle=intf_data.tg_ph_1) total_tx_tg1 = stats_tg1.tx.total_bytes stats_tg2 = tgapi.get_traffic_stats(intf_data.tg, mode="aggregate", port_handle=intf_data.tg_ph_2) total_rx_tg2 = stats_tg2.rx.total_bytes percentage_98_total_tx_tg1 = (98 * int(total_tx_tg1)) / 100 st.banner("Sent bytes: {} and Received bytes : {}".format( percentage_98_total_tx_tg1, total_rx_tg2)) if int(percentage_98_total_tx_tg1) <= 0 and int( percentage_98_total_tx_tg1) <= int(total_rx_tg2): st.report_fail("traffic_transmission_failed", vars.T1D1P1) intf_data.tg.tg_traffic_control(action='run', stream_handle=intf_data.streams['mtu2']) st.wait(intf_data.wait_sec) intf_data.tg.tg_traffic_control(action='stop', stream_handle=intf_data.streams['mtu2']) st.log("Fetching TGen statistics") stats_tg2 = tgapi.get_traffic_stats(intf_data.tg, mode="aggregate", port_handle=intf_data.tg_ph_2) total_rx_tg2 = stats_tg2.rx.total_packets st.banner("Received packets : {}".format(total_rx_tg2)) if int(total_rx_tg2) >= 100: st.report_fail("traffic_transmission_failed", vars.T1D1P1) st.report_pass("test_case_passed")
def test_ft_bgp6_rr_traffic_check(self): TG_D1 = topo.tg_dut_list_name[0] TG_D2 = topo.tg_dut_list_name[1] tg_ob = topo['T1{}P1_tg_obj'.format(TG_D1)] bgp_handle = topo['T1{}P1_ipv6_tg_bh'.format(TG_D1)] tc_fail_flag = 0 spine_as = int(bgplib.data['spine_as']) st.log("Advertising Routes from one of the Leaf Router") bgp_route = tg_ob.tg_emulation_bgp_route_config( handle=bgp_handle['handle'], mode='add', ip_version='6', num_routes='100', prefix='1001::1', as_path='as_seq:1') tg_ob.tg_emulation_bgp_control(handle=bgp_handle['handle'], mode='start') # Sleep for some time and the check the route count in neighbour st.wait(10) bgp_summary = bgpapi.show_bgp_ipv6_summary(topo.dut_list[1]) rib_entries = bgp_summary[0]['ribentries'] st.log('RIB Entries : {}'.format(rib_entries)) # when route-reflector is not configured at server(spine), we should not learn anything at # route-reflector-client (leaf node), ideally, route count should be 0. if int(rib_entries) > 10: st.error( 'iBGP Routes are advertised to iBGP peer DUT, even when route-reflector-client is not configured' ) tc_fail_flag = 1 # now configure route-reflector-client at spine node result = bgpapi.create_bgp_route_reflector_client( topo.dut_list[0], spine_as, 'ipv6', 'spine_leaf6', 'yes') if not result: st.log( "Configuring client reflection on {} {} bgp {} Failed".format( topo.dut_list[0], 'ipv6', spine_as)) tc_fail_flag = 1 bgpapi.create_bgp_next_hop_self(topo.dut_list[0], spine_as, 'ipv6', 'spine_leaf6', 'yes', 'yes', cli_type=bgp_cli_type) st.wait(15) bgp_summary = bgpapi.show_bgp_ipv6_summary(topo.dut_list[1]) rib_entries = bgp_summary[0]['ribentries'] st.log('RIB Entries : {}'.format(rib_entries)) if int(rib_entries) < 100: st.error( 'iBGP Routes are not advertised to route-reflector-client') tc_fail_flag = 1 st.log( "Initiating the Ipv6 traffic for those Routes from another Leaf Router" ) tr1 = tg_ob.tg_traffic_config( port_handle=topo['T1{}P1_ipv6_tg_ph'.format(TG_D2)], emulation_src_handle=topo['T1{}P1_ipv6_tg_ih'.format( TG_D2)]['handle'], emulation_dst_handle=bgp_route['handle'], circuit_endpoint_type='ipv6', mode='create', transmit_mode='single_burst', pkts_per_burst='2000', length_mode='fixed', rate_pps=1000) stream_id1 = tr1['stream_id'] tg_ob.tg_traffic_control(action='run', handle=stream_id1) st.tg_wait(20) tg1_stats = tgapi.get_traffic_stats( tg_ob, port_handle=topo["T1{}P1_ipv6_tg_ph".format(TG_D1)]) tg2_stats = tgapi.get_traffic_stats( tg_ob, port_handle=topo["T1{}P1_ipv6_tg_ph".format(TG_D2)]) if not (int(tg2_stats.tx.total_packets) and int(tg1_stats.rx.total_packets)): st.error('Received ZERO stats.') tc_fail_flag = 1 else: percent_rx = float( int(tg2_stats.tx.total_packets) - int(tg1_stats.rx.total_packets)) / int( tg2_stats.tx.total_packets) * 100 st.log('tg1_stats.rx.total_packets : {}'.format( tg1_stats.rx.total_packets)) st.log('tg2_stats.tx.total_packets : {}'.format( tg2_stats.tx.total_packets)) st.log('percent_rx : {}'.format(percent_rx)) if percent_rx > 0.5: tc_fail_flag = 1 tg_ob.tg_emulation_bgp_control(handle=bgp_handle['handle'], mode='stop') if tc_fail_flag: st.report_fail("traffic_verification_failed") st.report_pass('test_case_passed')
def test_ft_ip_v4_v6_L2_L3_translation(): # Objective - Verify that L2 port to IPv4 L3 port transition and vice-versa is successful. st.log("Checking IPv4 ping from {} to {} over routing interface".format( vars.D1, vars.D2)) if not ipfeature.ping( vars.D1, data.ip4_addr[7], family=data.af_ipv4, count=1): st.report_fail("ping_fail", data.ip4_addr[6], data.ip4_addr[7]) st.log( "Checking IPv6 ping from {} to {} over vlan routing interface".format( vars.D1, vars.D2)) if not ipfeature.ping( vars.D2, data.ip6_addr[6], family=data.af_ipv6, count=1): st.report_fail("ping_fail", data.ip6_addr[7], data.ip6_addr[6]) st.log("L3 to L2 port transition") st.log("Removing ipv4,ipv6 address from interface") ipfeature.delete_ip_interface(vars.D1, vars.D1D2P4, data.ip4_addr[6], 24, family=data.af_ipv4) ipfeature.delete_ip_interface(vars.D2, vars.D2D1P4, data.ip4_addr[7], 24, family=data.af_ipv4) ipfeature.delete_ip_interface(vars.D1, vars.D1D2P4, data.ip6_addr[6], 96, family=data.af_ipv6) ipfeature.delete_ip_interface(vars.D2, vars.D2D1P4, data.ip6_addr[7], 96, family=data.af_ipv6) ipfeature.delete_ip_interface(vars.D1, vars.D1T1P1, data.ip4_addr[1], 24, family=data.af_ipv4) ipfeature.delete_ip_interface(vars.D2, vars.D2T1P1, data.ip4_addr[8], 24, family=data.af_ipv4) st.log("Removing the static routes") ipfeature.delete_static_route(vars.D1, data.ip4_addr[7], data.static_ip_rt, shell=data.shell_vtysh, family=data.af_ipv4) ipfeature.delete_static_route(vars.D1, data.static_ip6_rt_drop, data.static_ip6_rt, shell=data.shell_vtysh, family=data.af_ipv6) st.log("Vlan creation and port association configuration") vlan_obj.create_vlan(vars.D1, data.vlan_2) st.log("Adding back to back connecting ports to vlan {}".format( data.vlan_2)) vlan_obj.add_vlan_member(vars.D1, data.vlan_2, [vars.D1D2P4], tagging_mode=True) vlan_obj.create_vlan(vars.D2, data.vlan_2) vlan_obj.add_vlan_member(vars.D2, data.vlan_2, [vars.D2D1P4], tagging_mode=True) st.log("Adding TG connecting ports to vlan {}".format(data.vlan_1)) vlan_obj.add_vlan_member(vars.D1, data.vlan_2, vars.D1T1P1, tagging_mode=True) vlan_obj.add_vlan_member(vars.D2, data.vlan_2, vars.D2T1P1, tagging_mode=True) tg_handler = tgapi.get_handles_byname("T1D1P1", "T1D2P1") tg.tg_traffic_control(action="reset", port_handle=tg_handler["tg_ph_list"]) tg.tg_traffic_control(action="clear_stats", port_handle=tg_handler["tg_ph_list"]) tr2 = tg.tg_traffic_config(port_handle=tg_handler["tg_ph_2"], mode='create', rate_pps="2000", mac_src_mode="fixed", transmit_mode="single_burst", pkts_per_burst=2000, length_mode='fixed', l2_encap='ethernet_ii_vlan', vlan_id=data.vlan_2, mac_dst_mode="fixed", vlan="enable", mac_src="00:a1:bb:cc:dd:01", mac_dst="00:b1:bb:cc:dd:01") st.log("TRAFCONF: " + str(tr2)) res = tg.tg_traffic_control(action='run', stream_handle=tr2['stream_id']) tg.tg_traffic_control(action='stop', stream_handle=tr2['stream_id']) st.wait(data.wait_tgstats) st.log("TR_CTRL: " + str(res)) st.log("Fetching TGen statistics") stats_tg1 = tgapi.get_traffic_stats(tg_handler["tg"], mode="aggregate", port_handle=tg_handler["tg_ph_2"]) total_tx_tg1 = stats_tg1.tx.total_packets stats_tg2 = tgapi.get_traffic_stats(tg_handler["tg"], mode="aggregate", port_handle=tg_handler["tg_ph_1"]) total_rx_tg2 = stats_tg2.rx.total_packets st.log("total_tx_tg1 = {}".format(total_tx_tg1)) total_tx_tg1_95_percentage = int(total_tx_tg1) * 0.95 st.log("total_tx_tg1_95_percentage= {}".format(total_tx_tg1_95_percentage)) st.log("total_rx_tg2 = {}".format(total_rx_tg2)) if int(total_tx_tg1_95_percentage) > int(total_rx_tg2): st.report_fail("traffic_verification_failed") st.log("Removing vlan configuration") vlan_obj.delete_vlan_member(vars.D1, data.vlan_2, [vars.D1D2P4, vars.D1T1P1], True) vlan_obj.delete_vlan_member(vars.D2, data.vlan_2, [vars.D2D1P4, vars.D2T1P1], True) st.log("L2 to L3 port transition") ipfeature.config_ip_addr_interface(vars.D1, vars.D1D2P4, data.ip4_addr[6], 24, family=data.af_ipv4) ipfeature.config_ip_addr_interface(vars.D2, vars.D2D1P4, data.ip4_addr[7], 24, family=data.af_ipv4) ipfeature.create_static_route(vars.D1, data.ip4_addr[7], data.static_ip_rt, shell=data.shell_vtysh, family=data.af_ipv4) st.log("Checking IPv4 ping from {} to {} over routing interface".format( vars.D1, vars.D2)) if not ipfeature.ping( vars.D1, data.ip4_addr[7], family=data.af_ipv4, count=1): st.report_fail("ping_fail", data.ip4_addr[6], data.ip4_addr[7]) ipfeature.config_ip_addr_interface(vars.D1, vars.D1D2P4, data.ip6_addr[6], 96, family=data.af_ipv6) ipfeature.config_ip_addr_interface(vars.D2, vars.D2D1P4, data.ip6_addr[7], 96, family=data.af_ipv6) ipfeature.create_static_route(vars.D1, data.static_ip6_rt_drop, data.static_ip6_rt, shell=data.shell_vtysh, family=data.af_ipv6) st.log( "Checking IPv6 ping from {} to {} over vlan routing interface".format( vars.D1, vars.D2)) if not ipfeature.ping( vars.D2, data.ip6_addr[6], family=data.af_ipv6, count=1): st.report_fail("ping_fail", data.ip6_addr[7], data.ip6_addr[6]) st.report_pass("test_case_passed")
def test_ft_l3_performance_enhancements_v4_bgp_clos_topology_indirect_link_fail_convergence_time(fixture_v4): ################# Author Details ################ # Name: Rakesh Kumar Vooturi # Email: [email protected] ################################################# # # Objective - FtOpSoRtPerfFn034 : Measure convergence time with BGP routes (with ECMP paths) in case of indirectly connected link failure # ############### Test bed details ################ # TG --- DUT1 --- DUT2 --- DUT3 --- DUT4 --- TG ################################################# print_topology("Indirect link failover time", "D3 -> D1 Link") # Verify the total route count using bcmcmd if not check_bcmcmd_route_count(dut1, 50, "ipv4", def_v4_route_count_d1, data.test_bgp_route_count): st.report_fail("route_table_not_updated_by_advertise_from_tg") if not check_bcmcmd_route_count(dut4, 50, "ipv4", def_v4_route_count_d4, data.test_bgp_route_count): st.report_fail("route_table_not_updated_by_advertise_from_tg") # Configuring traffic stream on the TG interface tr1=tg.tg_traffic_config(port_handle=tg_handler["tg_ph_2"], emulation_src_handle=h2['handle'], emulation_dst_handle=bgp_rtr1['route'][0]['handle'], circuit_endpoint_type='ipv4', mode='create', transmit_mode='continuous', length_mode='fixed', rate_pps=data.traffic_rate_pps, enable_stream_only_gen='0') st.log("#######################################################################################################################################################") st.log("# Measuring convergence time with BGP v4 routes (with ECMP paths) in case of indirectly connected link failure") st.log("#######################################################################################################################################################") # Starting the TG traffic after clearing the DUT counters papi.clear_interface_counters(dut1) tgapi.traffic_action_control(tg_handler, actions=['clear_stats']) tg.tg_traffic_control(action="run",handle=tr1['stream_id']) # Shutdown the routing interface link. st.log("Shutdown the routing interface link.") if not interface_obj.interface_operation(dut3, dut3_to_dut1_port_1 , "shutdown"): st.report_fail('interface_admin_shut_down_fail', dut3_to_dut1_port_1) # Wait for traffic to reroute papi.get_interface_counters_all(dut1) st.wait(30) if not check_intf_traffic_counters(dut1, dut1_to_tg_port_1, 30): st.report_fail("ingress_traffic_rate_not_matching_with_egress_rate") # Stopping the TG traffic tg.tg_traffic_control(action='stop', handle=tr1['stream_id']) # Stats fetching st.log("Fetching the stats on TG ports") tg_1_stats = tgapi.get_traffic_stats(tg, mode='aggregate', port_handle=tg_handler["tg_ph_1"]) tg_2_stats = tgapi.get_traffic_stats(tg, mode='aggregate', port_handle=tg_handler["tg_ph_2"]) total_rx = tg_1_stats.rx.total_packets total_tx = tg_2_stats.tx.total_packets # Stats verification st.log("Sent Packets On TG2: {} and Received Packets On TG1: {}".format(total_tx, total_rx)) if (int(total_tx) == 0): st.log("Traffic verification failed : Failed to send traffic from TG2 to TG1.") st.report_fail("traffic_verification_failed") time_taken = round((int(total_tx)-int(total_rx))/(int(data.test_bgp_route_count)*1.0),1) # Time taken for convergence st.log("#######################################################################################################################################################") st.log(" Convergence time with BGP v4 routes (with ECMP paths) in case of indirectly connected link failure in secs = " +str(time_taken)) st.log("#######################################################################################################################################################") st.report_pass("test_case_passed")
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 test_ft_vlan_save_config_warm_and_fast_reboot(): ''' Author: Sai Durga <*****@*****.**> This script covers the below scenarios ft_max_vlan_save_reload Verify the save and reload functionality with max vlan configuration. ft_max_vlan_fast_reload Verify the max vlan configuration is retained after fast-reboot. FtOpSoSwVlFn026 Verify that VLAN is present and traffic is not disturbed during and after warm reboot FtOpSoSysFRFn005 Verify the Fast-Reboot must disrupt control plane not more than 90 seconds (from sonic test suite -configuration tests) ft_reboot_fdb_fast_reboot Verify that the FDB entry is retained after fast reboot. ''' status = True msg_id = "max_vlan_config_retain_after_save_fast_warm_reboot" vlan_module_epilog() vlan_module_config(config='yes') st.log("Device name is : {}".format(sc_data.dut_platform)) st.log("Saving the MAX VLAN config on the device") reboot.config_save(vars.D1) st.log("Performing reboot and checking the VLAN configuration") st.reboot(vars.D1) st.log("Checking VLAN config after reboot") max_vlan_verify() st.log( "Sending traffic with 100 MAC,Checking FDB table updated with 100 MAC addresses and performing reboot and checking the VLAN configuration" ) tg.tg_traffic_control(action="reset", port_handle=tg_handler["tg_ph_list"]) tg_1 = tg.tg_traffic_config(port_handle=tg_handler["tg_ph_1"], mode='create', length_mode='fixed', frame_size=72, mac_src='00:01:00:00:00:01', mac_src_step='00:00:00:00:00:01', mac_src_mode='increment', mac_src_count=sc_data.mac_count, mac_dst='00:02:00:00:00:02', rate_pps=2000, l2_encap='ethernet_ii_vlan', vlan="enable", vlan_id=sc_data.vlan, transmit_mode='continuous') tg_info['tg1_stream_id'] = tg_1['stream_id'] tg.tg_traffic_control(action='run', stream_handle=tg_info['tg1_stream_id']) st.wait(2) tg.tg_traffic_control(action='stop', stream_handle=tg_info['tg1_stream_id']) if not poll_wait(mac_verify, 300): st.error("mac_address_verification_fail") st.log("Performing fast-reboot and checking the VLAN configuration") st.reboot(vars.D1, 'fast') st.log("Checking VLAN config after fast-reboot") max_vlan_verify() st.log("Sending traffic after fast reboot and checking the FDB table") tg.tg_traffic_control(action='run', stream_handle=tg_info['tg1_stream_id']) st.wait(2) tg.tg_traffic_control(action='stop', stream_handle=tg_info['tg1_stream_id']) if not poll_wait(mac_verify, 300): st.error("mac_address_verification_fail") st.log("Performing warm reboot and checking the traffic") ifapi.clear_interface_counters(vars.D1) st.wait(2) ifapi.show_interface_counters_all(vars.D1) st.wait(2) tg.tg_traffic_control(action='run', stream_handle=tg_info['tg1_stream_id']) st.wait(2) st.reboot(vars.D1, 'warm') st.log("Checking VLAN config after warm-reboot") max_vlan_verify() tg.tg_traffic_control(action='stop', stream_handle=tg_info['tg1_stream_id']) st.log("Checking traffic is forwarded without any loss after warm-reboot") st.log("Fetching TGen statistics") st.wait(2) ifapi.show_interface_counters_all(vars.D1) stats_tg1 = tgapi.get_traffic_stats(tg, mode="aggregate", port_handle=tg_handler["tg_ph_1"]) total_tx_tg1 = stats_tg1.tx.total_bytes stats_tg2 = tgapi.get_traffic_stats(tg, mode="aggregate", port_handle=tg_handler["tg_ph_2"]) total_rx_tg2 = stats_tg2.rx.total_bytes percentage_95_total_tx_tg1 = (95 * int(total_tx_tg1)) / 100 st.log("###############") st.log("Sent bytes: {} and Received bytes : {}".format( percentage_95_total_tx_tg1, total_rx_tg2)) st.log("##############") if int(percentage_95_total_tx_tg1) > int(total_rx_tg2): st.report_fail("traffic_transmission_failed", vars.T1D1P1) report_result(status, msg_id)
def test_ft_l3_fwding(): """ Testcase : verify the basic L3 traffic validation Author : Praveen Kumar Kota <*****@*****.**> """ sub_intf = 0 operation_tg1 = { "openconfig-if-ip:config": { "ip": "192.168.1.1", "prefix-length": 24 } } operation_tg2 = { "openconfig-if-ip:config": { "ip": "192.168.2.1", "prefix-length": 24 } } rest_urls = st.get_datastore(vars.D1, "rest_urls") url = rest_urls['ip_config'].format(vars.D1T1P1, sub_intf, data.ip4_addr_t1) url2 = rest_urls['ip_config'].format(vars.D1T1P2, sub_intf, data.ip4_addr_t2) config_rest(vars.D1, http_method="rest-patch", rest_url=url, json_data=operation_tg1) get_rest(vars.D1, rest_url=url) config_rest(vars.D1, http_method="rest-patch", rest_url=url2, json_data=operation_tg2) get_rest(vars.D1, rest_url=url2) h1 = tg.tg_interface_config(port_handle=tg_handler["tg_ph_1"], mode='config', intf_ip_addr=data.ip4_addr_t1_tg, gateway=data.ip4_addr_t1, src_mac_addr=data.tg_mac1, arp_send_req='1') tg.tg_interface_config(port_handle=tg_handler["tg_ph_2"], mode='config', intf_ip_addr=data.ip4_addr_t2_tg, gateway=data.ip4_addr_t2, src_mac_addr=data.tg_mac2, arp_send_req='1') res = tgapi.verify_ping(src_obj=tg, port_handle=tg_handler["tg_ph_1"], dev_handle=h1['handle'], dst_ip=data.ip4_addr_t2_tg, ping_count='1', exp_count='1') if res: st.log("Ping succeeded.") else: st.warn("Ping failed.") dut_rt_int_mac1 = basic_obj.get_ifconfig_ether(vars.D1, vars.D1T1P1) tr1 = tg.tg_traffic_config(port_handle=tg_handler["tg_ph_1"], mode='create', transmit_mode='single_burst', pkts_per_burst=1000, length_mode='fixed', rate_pps=1000, l3_protocol='ipv4', mac_src=data.tg_mac1, \ mac_dst=dut_rt_int_mac1, ip_src_addr=data.ip4_addr_t1_tg, ip_dst_addr=data.ip4_addr_t2_tg) ifapi.clear_interface_counters(vars.D1, interface_type="all") ifapi.show_interface_counters_all(vars.D1) tg.tg_traffic_control(action='run', stream_handle=tr1['stream_id']) st.wait(2) tg.tg_traffic_control(action='stop', stream_handle=tr1['stream_id']) st.wait(2) ifapi.show_interface_counters_all(vars.D1) tg_1_stats = tgapi.get_traffic_stats(tg, mode='aggregate', port_handle=tg_handler["tg_ph_1"]) tg_2_stats = tgapi.get_traffic_stats(tg, mode='aggregate', port_handle=tg_handler["tg_ph_2"]) counter1 = tg_2_stats.rx.total_packets counter2 = tg_1_stats.tx.total_packets if not counter1 >= counter2: ifapi.show_interface_counters_all(vars.D1) st.report_fail("test_case_failed") st.report_pass("test_case_passed")