def check_intf_traffic_bo_counters():
    (dut1) = (data.dut)
    papi.clear_interface_counters(dut1)
    st.wait(5)
    output = papi.get_interface_counters_all(dut1)
    p1_tx = intf_traffic_stats(filter_and_select(output, ["tx_bps"], {'iface': vars.D1T1P1}))
    p2_tx = intf_traffic_stats(filter_and_select(output, ["tx_bps"], {'iface': vars.D1T1P2}))
    p3_tx = intf_traffic_stats(filter_and_select(output, ["tx_bps"], {'iface': vars.D1T1P3}))
    p4_tx = intf_traffic_stats(filter_and_select(output, ["tx_bps"], {'iface': vars.D1T1P4}))
    st.log("Inter Dut port stats  tx_ok xounter value on DUT Egress ports : {} {} {} {}".format(p1_tx, p2_tx, p3_tx, p4_tx))
    if (p2_tx == 0) | (p3_tx == 0) | (p4_tx == 0):
        st.log("Error:Inter Dut port stats  tx_ok xounter value on DUT Egress ports : {} {} {}".format(p2_tx, p3_tx, p4_tx))
    else:
        return True

    DUT_rx_value = papi.get_interface_counters(dut1, vars.D1T1P4, "rx_ok")
    for i in DUT_rx_value:
        p1_rcvd = i['rx_ok']
        p1_rcvd = p1_rcvd.replace(",","")

    st.log("rx_ok xounter value on DUT Inress port : {}".format(p1_rcvd))

    if (abs(int(float(p1_rcvd))) > 0):
        output = papi.get_interface_counters_all(dut1)
        entry1 = filter_and_select(output, ["tx_bps"], {'iface': vars.D1T1P1})
        entry2 = filter_and_select(output, ["tx_bps"], {'iface': vars.D1T1P2})
        entry3 = filter_and_select(output, ["tx_bps"], {'iface': vars.D1T1P3})
        entry4 = filter_and_select(output, ["tx_bps"], {'iface': vars.D1T1P4})
        for i in entry1:
            p1_txmt = i['tx_bps']
            p1_txmt = p1_txmt.replace(" MB/s","")
            p1_txmt = p1_txmt.replace(" KB/s","")
            p1_txmt = p1_txmt.replace(" B/s","")
        for i in entry2:
            p2_txmt = i['tx_bps']
            p2_txmt = p2_txmt.replace(" MB/s","")
            p2_txmt = p2_txmt.replace(" KB/s","")
            p2_txmt = p2_txmt.replace(" B/s","")
        for i in entry3:
            p3_txmt = i['tx_bps']
            p3_txmt = p3_txmt.replace(" MB/s","")
            p3_txmt = p3_txmt.replace(" KB/s","")
            p3_txmt = p3_txmt.replace(" B/s","")
        for i in entry4:
            p4_txmt = i['tx_bps']
            p4_txmt = p4_txmt.replace(" MB/s","")
            p4_txmt = p4_txmt.replace(" KB/s","")
            p4_txmt = p4_txmt.replace(" B/s","")

        st.log("RETRY tx_ok xounter value on DUT Egress ports : {} {} {} {}".format(p1_txmt, p2_txmt, p3_txmt, p4_txmt))
        if (abs(int(float(p2_txmt))) == 0) | (abs(int(float(p3_txmt))) == 0) | (abs(int(float(p4_txmt))) == 0):
            st.show(dut1, "show arp")
            return False
        else:
            return True
    else:
        return False
Example #2
0
def get_port_tx_rate_in_bps(dut, port, **kwargs):
    """
    This API is used to return the TX_BPS of a port
    :param dut:
    :type dut:
    :param port:
    :type port:
    """
    cli_type = st.get_ui_type(dut, **kwargs)
    CMD = 'show interfaces counters | grep "{}"'
    cli_type = 'klish' if cli_type in ['rest-put', 'rest-patch'] else cli_type
    output = st.show(dut, CMD.format(port), cli_type=cli_type
                     ) if cli_type == 'click' else get_interface_counters_all(
                         dut, port, cli_type=cli_type)
    entry = filter_and_select(output, ['tx_bps'], {'iface': port})
    rv = re.search(r"\d+\.\d+",
                   entry[0]['tx_bps']) if entry and 'tx_bps' in entry[0] else 0
    if cli_type == 'click':
        if rv:
            if 'GB/s' in entry[0]['tx_bps']:
                multiplier = 1000 * 1000 * 1000
            elif 'MB/s' in entry[0]['tx_bps']:
                multiplier = 1000 * 1000
            elif 'KB/s' in entry[0]['tx_bps']:
                multiplier = 1000
            else:
                multiplier = 1
        return round(float(rv.group()) * multiplier) if rv else 0
    elif cli_type == 'klish':
        return round(float(rv.group()) * 1000 * 1000) if rv else 0
    else:
        st.error("Unsupported CLI Type: {}".format(cli_type))
        return False
def check_intf_traffic_counters():
    (dut1) = (data.dut)
    papi.clear_interface_counters(dut1)
    st.wait(5)
    DUT_tx_value = papi.get_interface_counters(dut1, vars.D1T1P4, "tx_bps")

    for i in DUT_tx_value:
        p2_txmt = i['tx_bps']
        p2_txmt = p2_txmt.replace(" MB/s","")
        p2_txmt = p2_txmt.replace(" KB/s","")
        p2_txmt = p2_txmt.replace(" B/s","")

    st.log("tx_ok xounter value on DUT Egress port : {}".format(p2_txmt))

    if (abs(int(float(p2_txmt))) == 0):
        output = papi.get_interface_counters_all(dut1)
        entry1 = filter_and_select(output, ["tx_bps"], {'iface': vars.D1T1P4})
        for i in entry1:
            p2_txmt = i['tx_bps']
            p2_txmt = p2_txmt.replace(" MB/s","")
            p2_txmt = p2_txmt.replace(" KB/s","")
            p2_txmt = p2_txmt.replace(" B/s","")
        st.log("RETRY tx_ok xounter value on DUT Egress port : {}".format(p2_txmt))
        if (abs(int(float(p2_txmt))) == 0):
            st.show(dut1, "show arp")
            asicapi.dump_l3_egress(dut1)
            return False
        else:
            return True
    else:
        return True
def check_end_to_end_intf_traffic_counters():
    dut1 = vars.D1
    DUT_tx_value = papi.get_interface_counters(dut1, vars.D1T1P1, "tx_ok")
    for i in DUT_tx_value:
        p1_tx = i['tx_ok']
        p1_tx = p1_tx.replace(",","")
    st.log("tx_ok xounter value on DUT Inress port : {}".format(p1_tx))
    if (abs(int(float(p1_tx))) > 0):
        output = papi.get_interface_counters_all(dut1)
        entry1 = filter_and_select(output, ["tx_bps"], {'iface': vars.D1T1P1})
        for i in entry1:
            p1_txmt = i['tx_bps']
            p1_txmt = p1_txmt.replace(" MB/s","")
            p1_txmt = p1_txmt.replace(" KB/s","")
            p1_txmt = p1_txmt.replace(" B/s","")
        if (abs(int(float(p1_txmt))) == 0):
            st.show(dut1, "show arp")
            st.error("End to End traffic is Zero")
            return False
        else:
            st.log("End to End traffic is fine")
            return True
    else:
        st.error("End to End traffic is not fine")
        return False
Example #5
0
def check_intf_traffic_counters(dut, loopCnt, case):
    flag = 0
    iter = 1
    p1_rcvd = 0
    p2_txmt = 0

    while iter <= loopCnt:
        output = papi.get_interface_counters_all(dut)
        for entry in output:
            if entry["iface"] == dut_to_tg_port_2:
                DUT_rx_value = entry["rx_bps"]
            if entry["iface"] == dut_to_tg_port_1:
                DUT_tx_value = entry["tx_bps"]
        p1_rcvd = DUT_rx_value
        p1_rcvd = p1_rcvd.replace(" MB/s", "")
        p1_rcvd = p1_rcvd.replace(" B/s", "")
        p1_rcvd = p1_rcvd.replace(" KB/s", "")
        p1_rcvd = p1_rcvd.replace(" GB/s", "")
        p1_rcvd = 0.0 if p1_rcvd == "" else p1_rcvd
        p2_txmt = DUT_tx_value
        p2_txmt = p2_txmt.replace(" MB/s", "")
        p2_txmt = p2_txmt.replace(" B/s", "")
        p2_txmt = p2_txmt.replace(" KB/s", "")
        p2_txmt = p2_txmt.replace(" GB/s", "")
        p2_txmt = 0.0 if p2_txmt == "" else p2_txmt

        st.log(
            "rx_ok counter value on DUT Ingress port: {} and tx_ok xounter value on DUT Egress port : {}"
            .format(p1_rcvd, p2_txmt))
        if cli_type == "klish":
            st.log("Converting counters to bits by multiplying 1000000")
            p2_txmt = int(float(p2_txmt) * 1000000)
            p1_rcvd = int(float(p1_rcvd) * 1000000)
        if case == "install":
            if (int(float(p2_txmt)) == 0):
                flag = 0
                break

            if (abs(int(float(p1_rcvd)) -
                    int(float(p2_txmt))) == data.counters_threshold):
                flag = 1
                break
        elif case == "withdraw":
            if (int(float(p2_txmt))) == 0:
                flag = 1
                break
        iter = iter + 1

    if flag:
        return True
    else:
        return False
Example #6
0
def check_intf_traffic_counters(dut, port, loopCnt):
	flag = 0
	iter = 1
	p2_txmt = 0

	while iter <= loopCnt:
		output = papi.get_interface_counters_all(dut, port=port)
		for entry in iterable(output):
			if entry["iface"] == port:
				DUT_tx_value = entry["tx_pps"]
		p2_txmt = DUT_tx_value
		p2_txmt = p2_txmt.replace("/s","")

		st.log("tx_pps counter value on DUT {} Egress port {} : {}".format(dut,port,p2_txmt))

		if (int(float(p2_txmt)) >= data.traffic_rate_pps-1000):
			flag = 1
			break
		iter = iter+1

	if flag:
		return True
	else:
		return False
Example #7
0
def sf_collecting_debug_logs_when_test_fails():
    get_interface_counters_all(vars.D1)
Example #8
0
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")