Beispiel #1
0
def fixture_v4(request):
	global h1
	global h2
	global ctrl_start
	global ctrl_stop
	global bgp_rtr1
	st.log("Test Fixture Config.")
	# TG ports reset
	st.log("Resetting the TG ports")
	tgapi.traffic_action_control(tg_handler, actions=['reset'])

	# TG protocol interface creation
	st.log("TG protocol interface creation")
	h1 = tg.tg_interface_config(port_handle=tg_handler["tg_ph_1"], mode='config',intf_ip_addr=data.tg_to_dut1_port_1_ip,gateway=data.dut1_to_tg_port_1_ip,arp_send_req='1')
	st.log("INTFCONF: "+str(h1))
	h2 = tg.tg_interface_config(port_handle=tg_handler["tg_ph_2"], mode='config',intf_ip_addr=data.tg_to_dut4_port_1_ip,gateway=data.dut4_to_tg_port_1_ip,arp_send_req='1')
	st.log("INTFCONF: "+str(h2))

	# Configuring BGP on TG interface
	conf_var = {'mode':'enable', 'active_connect_enable':'1', 'local_as':data.remote_as_num1, 'remote_as':data.as_num_1, 'remote_ip_addr':data.dut1_to_tg_port_1_ip}
	route_var = {'mode':'add', 'num_routes':data.test_bgp_route_count, 'prefix':'121.1.1.0', 'as_path':'as_seq:1'}
	ctrl_start = {'mode':'start'}
	ctrl_stop = {'mode':'stop'}

	# Starting the BGP router on TG.
	bgp_rtr1 = tgapi.tg_bgp_config(tg=tg, handle=h1['handle'], conf_var=conf_var, route_var = route_var, ctrl_var=ctrl_start)
	st.log("BGP_HANDLE: "+str(bgp_rtr1))

	# Verifying the BGP neighborship
	st.wait(10)
	st.log("Verifying the BGP neighborships.")
	if not bgpfeature.verify_bgp_summary(dut1, neighbor=data.tg_to_dut1_port_1_ip, state='Established'):
		st.report_fail("bgp_ip_peer_establish_fail", data.tg_to_dut1_port_1_ip)

	yield
	st.log("Test Fixture Cleanup.")
	# Startup the routing interface link.
	if not interface_obj.interface_operation(dut2, dut2_to_dut4_port_1, "startup"):
		st.report_fail('interface_admin_startup_fail', dut2_to_dut4_port_1)
	if not interface_obj.interface_operation(dut3, dut3_to_dut1_port_1, "startup"):
		st.report_fail('interface_admin_startup_fail', dut3_to_dut1_port_1)

	tg.tg_interface_config(port_handle=tg_handler["tg_ph_1"], handle=h1['handle'], mode='destroy')
	tg.tg_interface_config(port_handle=tg_handler["tg_ph_2"], handle=h2['handle'], mode='destroy')
Beispiel #2
0
def fixture_v6(request):
    global h1, h2, bgp_rtr2

    st.log("Test Fixture Config.")
    # TG ports reset
    st.log("Resetting the TG ports")
    tgapi.traffic_action_control(tg_handler, actions=['reset'])

    # TG protocol interface creation
    st.log("TG protocol interface creation")
    h1 = tg.tg_interface_config(port_handle=tg_handler["tg_ph_1"],
                                mode='config',
                                ipv6_intf_addr=data.neigh_ipv6_addr,
                                ipv6_prefix_length=64,
                                ipv6_gateway=data.my_ipv6_addr,
                                arp_send_req='1')
    st.log("INTFCONF: " + str(h1))
    h2 = tg.tg_interface_config(port_handle=tg_handler["tg_ph_2"],
                                mode='config',
                                ipv6_intf_addr=data.neigh_ipv6_addr2,
                                ipv6_prefix_length=64,
                                ipv6_gateway=data.intf_ipv6_addr,
                                arp_send_req='1')
    st.log("INTFCONF: " + str(h2))

    # Configuring BGP on TG interface
    conf_var = {
        'mode': 'enable',
        'ip_version': '6',
        'active_connect_enable': '1',
        'local_as': data.remote_as_num,
        'remote_as': data.as_num,
        'remote_ipv6_addr': data.my_ipv6_addr
    }
    route_var = {
        'mode': 'add',
        'ip_version': '6',
        'num_routes': data.test_bgp_route_count,
        'prefix': '3300:1::',
        'as_path': 'as_seq:1'
    }

    # Starting the BGP router on TG.
    bgp_rtr2 = tgapi.tg_bgp_config(tg=tg,
                                   handle=h1['handle'],
                                   conf_var=conf_var,
                                   route_var=route_var,
                                   ctrl_var=ctrl_start)
    st.log("BGP_HANDLE: " + str(bgp_rtr2))

    # Verifying the BGP neighborship
    st.wait(10)
    st.log("Verifying the BGP neighborship.")
    if not bgpfeature.verify_bgp_summary(
            dut, family='ipv6', neighbor=data.neigh_ipv6_addr,
            state='Established'):
        st.report_fail("bgp_ip6_peer_establish_fail", data.neigh_ip_addr)

    yield
    st.log("Test Fixture Cleanup.")
    tg.tg_interface_config(port_handle=tg_handler["tg_ph_1"],
                           handle=h1['handle'],
                           mode='destroy')
    tg.tg_interface_config(port_handle=tg_handler["tg_ph_2"],
                           handle=h2['handle'],
                           mode='destroy')
Beispiel #3
0
def create_v4_route(route_count):
    vars = st.get_testbed_vars()
    dut = vars.D1

    ipfeature.show_ip_route(dut)
    ipfeature.get_interface_ip_address(dut)
    intf_obj.interface_status_show(dut)

    bgpfeature.create_bgp_router(dut, data.as_num, '')
    bgpfeature.create_bgp_neighbor(dut, data.as_num, data.ip4_addr[0],
                                   data.remote_as_num)

    tg_handler = tgapi.get_handles_byname("T1D1P1", "T1D2P1")
    tg = tg_handler["tg"]
    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"])

    dut_rt_int_mac1 = basic_obj.get_ifconfig_ether(vars.D1, vars.D1T1P1)
    h1 = tg.tg_interface_config(port_handle=tg_handler["tg_ph_1"], mode='config', intf_ip_addr=data.ip4_addr[0], \
                                gateway=data.ip4_addr[1], src_mac_addr=data.tg_mac1, arp_send_req='1')
    st.log("INTFCONF: " + str(h1))
    h2 = tg.tg_interface_config(port_handle=tg_handler["tg_ph_2"], mode='config', intf_ip_addr=data.ip4_addr[9], \
                                gateway=data.ip4_addr[8], src_mac_addr=data.tg_mac2, arp_send_req='1')
    st.log("INTFCONF: " + str(h2))
    # Ping from tgen to DUT.
    res = tgapi.verify_ping(src_obj=tg, port_handle=tg_handler["tg_ph_1"], dev_handle=h1['handle'], dst_ip=data.ip4_addr[1], \
                      ping_count='1', exp_count='1')
    if res:
        st.log("Ping succeeded.")
    else:
        st.warn("Ping failed.")

    conf_var = {
        'mode': 'enable',
        'active_connect_enable': '1',
        'local_as': '200',
        'remote_as': '100',
        'remote_ip_addr': data.ip4_addr[1]
    }
    route_var = {
        'mode': 'add',
        'num_routes': route_count,
        'prefix': '121.1.1.0',
        'as_path': 'as_seq:1'
    }
    ctrl_start = {'mode': 'start'}

    # Configuring the BGP router.
    bgp_rtr1 = tgapi.tg_bgp_config(tg=tg,
                                   handle=h1['handle'],
                                   conf_var=conf_var,
                                   route_var=route_var,
                                   ctrl_var=ctrl_start)

    st.log("BGP_HANDLE: " + str(bgp_rtr1))
    st.log(
        "waiting for 10 sec to get the BGP neighbor started before going for another TG operation"
    )
    st.wait(10)
    # Verified at neighbor.
    tr1 = tg.tg_traffic_config(port_handle=tg_handler["tg_ph_1"], mode='create', transmit_mode='single_burst',
                               pkts_per_burst=2000, \
                               length_mode='fixed', rate_pps=2000, l3_protocol='ipv4', mac_src=data.tg_mac1, \
                               mac_dst=dut_rt_int_mac1, ip_src_addr=data.ip4_addr[0],
                               ip_dst_addr=data.ip4_addr[9])
    st.log("TRAFCONF: " + str(tr1))
    res = tg.tg_traffic_control(action='run', stream_handle=tr1['stream_id'])
    st.log("TR_CTRL: " + str(res))
    tg.tg_traffic_control(action='stop', stream_handle=tr1['stream_id'])
    st.log("Checking the stats and verifying the traffic flow")
    traffic_details = {
        '1': {
            'tx_ports': [vars.T1D1P1],
            'tx_obj': [tg_handler["tg"]],
            'exp_ratio': [1],
            'rx_ports': [vars.T1D2P1],
            'rx_obj': [tg_handler["tg"]],
        }
    }
    #verify statistics
    aggrResult = tgapi.validate_tgen_traffic(traffic_details=traffic_details,
                                             mode='aggregate',
                                             comp_type='packet_count')
    if not aggrResult:
        return False

    return True
def l3_max_route_max_path_scaling_tc(max_paths, max_routes, use_config_file, family="ipv4"):
    (dut) = (data.dut)
    #count = 0
    data.my_dut_list = st.get_dut_names()
    dut1 = data.my_dut_list[0]
    dut2 = data.my_dut_list[1]
    #intf_ip_addr = data.dut1_start_ip_addr
    #intf_ip_addr2 = data.start_ip_addr2
    #nexthop = data.nexthop_start_ip_addr
    vrf_flag = False
    member_dut1 = vars.D1T1P1
    member_dut2 = vars.D2T1P1
    # L3 INTF SCALING TEST CASE 1.1 START
    #json_path = os.getcwd()
    apply_file = False

    if apply_file is False:
        ipfeature.clear_ip_configuration(st.get_dut_names())
        vapi.clear_vlan_configuration(st.get_dut_names())
        st.banner("Started doing the needed config.")
        cmd = "config vlan range add 2 129"
        st.config(dut, cmd)
        st.config(dut2, cmd)
        command = "config vlan member add 2 {}".format(member_dut1)
        st.config(dut, command)
        command = "config vlan member add 2 {}".format(member_dut2)
        st.config(dut2, command)
        max_vlan = max_paths/4
        base_vlan = 3
        max_vlan = max_vlan - base_vlan
        v_range_t = str(base_vlan) + " " + str(base_vlan + max_vlan )
        vapi.config_vlan_range_members(dut1, v_range_t, data.dut1_ports[0])
        vapi.config_vlan_range_members(dut2, v_range_t, data.dut2_ports[0])
        base_range = 1
        max_range = 4
        max_vlan = max_paths/4
        incr_vlan = max_paths/4
        for index in range(base_range, max_range):
            base_vlan = max_vlan + 1
            max_vlan = max_vlan + incr_vlan
            #max_vlan = max_vlan + 32
            v_range_t = str(base_vlan) + " " + str(max_vlan)
            vapi.config_vlan_range_members(dut1, v_range_t, data.dut1_ports[index])
            vapi.config_vlan_range_members(dut2, v_range_t, data.dut2_ports[index])

        ip_addr = data.dut1_start_ip_addr
        ip_addr2 = data.dut2_start_ip_addr
        v6_ip_addr = data.v6_start_ip_addr
        v6_ip_addr2 = data.v6_new_dut2_start_ip_addr
        ix_vlan_val = 2
        #command = "config interface ip add "+ "Vlan" + str(data.vlan_val) + " " + ip_addr+'/24'
        if family == "ipv4":
            command1 = "config interface ip add "+ "Vlan" + str(ix_vlan_val) + " " + ip_addr
            command2 = "config interface ip add "+ "Vlan" + str(ix_vlan_val) + " " + ip_addr2
        else:
            command1 = "config interface ip add "+ "Vlan" + str(ix_vlan_val) + " " + v6_ip_addr
            command2 = "config interface ip add "+ "Vlan" + str(ix_vlan_val) + " " + v6_ip_addr2
        st.config(dut1, command1)
        st.config(dut2, command2)
        ip_addr2 = data.dut2_start_ip_addr
        base_vlan = 3
        max_vlan = max_paths + 1
        #max_vlan = 130
        for index in range(base_vlan, max_vlan):
            if family == "ipv4":
                (_, ip_addr) = ipfeature.increment_ip_addr(ip_addr, "network")
                (_, ip_addr2) = ipfeature.increment_ip_addr(ip_addr2, "network")
                command = "config interface ip add "+ "Vlan" + str(index) + " " + ip_addr
                command_dut2 = "config interface ip add "+ "Vlan" + str(index) + " " + ip_addr2
            else:
                v6_tok = str(hex(index)[2:])
                v6_ip_addr = "2100:0:" + v6_tok + "::1/64"
                v6_ip_addr2 = "2100:0:" + v6_tok + "::2/64"
                command = "config interface ip add "+ "Vlan" + str(index) + " " + v6_ip_addr
                command_dut2 = "config interface ip add "+ "Vlan" + str(index) + " " + v6_ip_addr2
            st.config(dut, command)
            st.config(dut2, command_dut2)

    (tg1, tg_ph_1, tg2, tg_ph_2) = get_handles_2()

    tg1.tg_traffic_control(action='reset',port_handle=tg_ph_1)
    tg2.tg_traffic_control(action='reset',port_handle=tg_ph_2)

    #h1=tg1.tg_interface_config(port_handle=tg_ph_1, mode='config', intf_ip_addr='10.2.2.2', gateway='10.2.2.1', arp_send_req='1')
    #h1=tg1.tg_interface_config(port_handle=tg_ph_1, mode='config', intf_ip_addr='10.2.2.2',  gateway='10.2.2.1', src_mac_addr='00:0a:01:00:00:01', vlan='1', vlan_id='2', arp_send_req='1', gateway_step='0.0.1.0', intf_ip_addr_step='0.0.1.0', vlan_id_step='1')
    if family == "ipv4":
        h1=tg1.tg_interface_config(port_handle=tg_ph_1, mode='config', intf_ip_addr='10.2.2.3',
                  gateway='10.2.2.1', src_mac_addr='00:0a:01:00:00:01', vlan='1', vlan_id='2', arp_send_req='1')
        arp_obj.show_arp(dut)
        h2=tg1.tg_interface_config(port_handle=tg_ph_2, mode='config', intf_ip_addr='10.2.2.4',
                  gateway='10.2.2.2', src_mac_addr='00:0b:01:00:00:01', vlan='1', vlan_id='2', arp_send_req='1')
        arp_obj.show_arp(dut2)
    else:
        h1=tg1.tg_interface_config(port_handle=tg_ph_1, mode='config', ipv6_intf_addr='2100:0:2::3',
                  ipv6_gateway='2100:0:2::1', src_mac_addr='00:0a:01:00:00:01', vlan='1', vlan_id='2', arp_send_req='1')
        st.show(dut, "show ndp")
        arp_obj.show_arp(dut)
        h2=tg1.tg_interface_config(port_handle=tg_ph_2, mode='config', ipv6_intf_addr='2200:0:2::4',
                  ipv6_gateway='2200:0:2::2', src_mac_addr='00:0b:01:00:00:01', vlan='1', vlan_id='2', arp_send_req='1')
        st.show(dut2, "show ndp")
        arp_obj.show_arp(dut2)

    if family == "ipv4":
        bgpfeature.create_bgp_router(dut, data.as_num, '')
        bgpfeature.create_bgp_router(dut2, data.new_as_num, '')
        dut1_neigh_ip_addr = data.neigh_ip_addr
        dut2_neigh_ip_addr = data.dut1_start_ip_addr
        #formatted_dut1_neigh_ip_addr = dut1_neigh_ip_addr.replace("/24","")
        #formatted_dut2_neigh_ip_addr = dut2_neigh_ip_addr.replace("/24","")
        formatted_dut1_neigh_ip_addr = "10.2.2.3"
        bgpfeature.create_bgp_neighbor(dut, data.as_num, formatted_dut1_neigh_ip_addr, data.remote_as_num)

        (_, dut1_neigh_ip_addr) = ipfeature.increment_ip_addr(dut1_neigh_ip_addr, "network")
        (_, dut2_neigh_ip_addr) = ipfeature.increment_ip_addr(dut2_neigh_ip_addr, "network")
        base_vlan = 3
        max_vlan = max_paths + 1
        #max_vlan = 130
        # The below neighbor config is for inter dut links ibgp
        for index in range(base_vlan, max_vlan):
            formatted_dut1_neigh_ip_addr = dut1_neigh_ip_addr.replace("/24","")
            bgpfeature.create_bgp_neighbor(dut, data.as_num, formatted_dut1_neigh_ip_addr, data.new_as_num)
            (_, dut1_neigh_ip_addr) = ipfeature.increment_ip_addr(dut1_neigh_ip_addr, "network")
            formatted_dut2_neigh_ip_addr = dut2_neigh_ip_addr.replace("/24","")
            bgpfeature.create_bgp_neighbor(dut2, data.new_as_num, formatted_dut2_neigh_ip_addr, data.as_num)
            (_, dut2_neigh_ip_addr) = ipfeature.increment_ip_addr(dut2_neigh_ip_addr, "network")

        conf_var = { 'mode'                  : 'enable',
                     'active_connect_enable' : '1',
                     'local_as'              : '200',
                     'remote_as'             : '100',
                     'remote_ip_addr'        : '10.2.2.1'
                   }
        max_route_str = str(max_routes)
        route_var = { 'mode'       : 'add',
                      'num_routes' : max_route_str,
                      'prefix'     : '121.1.1.0',
                      'as_path'    : 'as_seq:1'
                    }
                    #'num_routes' : '30000',
        ctrl_start = { 'mode' : 'start'}
        ctrl_stop = { 'mode' : 'stop'}


        # Configuring the BGP router.
        bgp_rtr1 = tgapi.tg_bgp_config(tg = tg1,
            handle    = h1['handle'],
            conf_var  = conf_var,
            route_var = route_var,
            ctrl_var  = ctrl_start)

        st.log("BGP_HANDLE: "+str(bgp_rtr1))
        # Verified at neighbor.
        st.log("BGP neighborship established.")
        st.wait(10)

        def f1(d):
            st.show(d, "show bgp ipv4 summary", type='vtysh')
            st.show(d, "show interface status")
            st.show(d, "show ip route | head -1000")
            arp_obj.show_arp(d)

        st.banner("ARP entries before traffic is initiated on Dut1 and Dut2")
        st.exec_each([dut, dut2], f1)

        #Port Counters

        tr1=tg2.tg_traffic_config(port_handle=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=512000, enable_stream_only_gen='0')
    else:
        v6_dut1_neigh_ip_addr = "2100:0:2::3"
        create_bgp_neighbor_route_map_config(dut, data.as_num, v6_dut1_neigh_ip_addr, data.routemap, vrf_flag)
        create_bgp_neighbor_route_map_config(dut2, data.new_as_num, v6_dut1_neigh_ip_addr, data.routemap, vrf_flag)
        bgpfeature.create_bgp_router(dut, data.as_num, '')
        create_bgp_neighbor_config(dut, data.as_num, v6_dut1_neigh_ip_addr, data.remote_as_num, data.routemap)
        #link_bgp_neighbor_to_routemap(dut, data.as_num, v6_dut1_neigh_ip_addr, data.routemap, vrf_flag)
        bgpfeature.create_bgp_router(dut2, data.new_as_num, '')
        base_vlan = 3
        max_vlan = max_paths + 1
        for index in range(base_vlan, max_vlan):
            v6_tok = str(hex(index)[2:])
            v6_dut1_neigh_ip_addr = "2100:0:" + v6_tok + "::2"
            v6_dut2_neigh_ip_addr2 = "2100:0:" + v6_tok + "::1"
            create_bgp_neighbor_config(dut, data.as_num, v6_dut1_neigh_ip_addr, data.new_as_num, data.routemap)
            create_bgp_neighbor_config(dut2, data.new_as_num, v6_dut2_neigh_ip_addr2, data.as_num, data.routemap)
            #bgpfeature.create_bgp_neighbor(dut, data.as_num, v6_dut1_neigh_ip_addr, data.new_as_num, family="ipv6")
            #bgpfeature.create_bgp_neighbor(dut2, data.new_as_num, v6_dut2_neigh_ip_addr2, data.as_num, family="ipv6")

        bgp_conf=tg2.tg_emulation_bgp_config(handle=h1['handle'], mode='enable', ip_version='6',
            active_connect_enable='1', local_as='200', remote_as='100', remote_ipv6_addr='2100:0:2::1')
        max_route_str = str(max_routes)

        bgp_route=tg2.tg_emulation_bgp_route_config(handle=bgp_conf['handle'], mode='add', ip_version='6',
            num_routes=max_route_str, prefix='3300:0:0:2::1', as_path='as_seq:1')
        tg2.tg_emulation_bgp_control(handle=bgp_conf['handle'], mode='start')

        def f1(d):
            st.show(d, "show run bgp")
            st.show(d, "show ndp")
            st.show(d, "show bgp ipv6 summary", type='vtysh')
            st.show(d, "show ipv6 route | head -1000")
            arp_obj.show_arp(d)
        st.banner("ARP entries before traffic is initiated on Dut1 and Dut2")
        st.exec_each([dut, dut2], f1)

        tr1=tg2.tg_traffic_config(port_handle=tg_ph_2, emulation_src_handle=h2['handle'],
            emulation_dst_handle=bgp_route['handle'], circuit_endpoint_type='ipv6', mode='create',
            transmit_mode='continuous', length_mode='fixed', rate_pps=512000, enable_stream_only_gen='0')

        #tr1=tg1.tg_traffic_config(port_handle=tg_ph_2, mac_src='00:11:01:00:00:01', mac_dst='80:a2:35:97:eb:c1',
        # ipv6_dst_mode='increment', ipv6_dst_count=200, ipv6_dst_step='::1',ipv6_src_addr='2200:0:2::5',
        # ipv6_dst_addr='3300:0:0:2::1',  l3_protocol='ipv6', l2_encap='ethernet_ii_vlan', vlan_id='2',
        # vlan='enable', mode='create', transmit_mode='continuous', length_mode='fixed',
        # rate_pps=512000, enable_stream_only_gen='1')

    tg2.tg_traffic_control(action='run', handle=tr1['stream_id'])
    ret1 = check_inter_dut_intf_traffic_counters()
    ret2 = check_end_to_end_intf_traffic_counters()
    tg2.tg_traffic_control(action='stop', handle=tr1['stream_id'])

    st.banner("ARP entries in both DUT's after traffic is stopped")
    st.exec_each([dut, dut2], arp_obj.show_arp)

    tg1.tg_traffic_control(action='reset',port_handle=tg_ph_2)
    if family == "ipv4":
        tgapi.tg_bgp_config(tg = tg1, handle = bgp_rtr1['conf']['handle'], ctrl_var=ctrl_stop)
    else:
        tg1.tg_emulation_bgp_control(handle=bgp_conf['handle'], mode='stop')
    tg1.tg_interface_config(port_handle=tg_ph_1, handle=h1['handle'], mode='destroy')
    tg1.tg_interface_config(port_handle=tg_ph_2, handle=h2['handle'], mode='destroy')

    #import pdb;pdb.set_trace()
    if apply_file is False:
        ip_addr = data.dut1_start_ip_addr
        ip_addr2 = data.dut2_start_ip_addr
        st.log("Un-Config previously config")
        base_range = 2
        max_range = max_paths + 1
        for index in range(base_range, max_range):
            if family == "ipv4":
                command1 = "config interface ip remove "+ "Vlan" + str(index) + " " + ip_addr
                command2 = "config interface ip remove "+ "Vlan" + str(index) + " " + ip_addr2
                (_, ip_addr) = ipfeature.increment_ip_addr(ip_addr, "network")
                (_, ip_addr2) = ipfeature.increment_ip_addr(ip_addr2, "network")
            else:
                v6_tok = str(hex(index)[2:])
                if index == 2:
                    v6_ip_addr2 = "2200:0:" + v6_tok + "::2/64"
                else:
                    v6_ip_addr2 = "2100:0:" + v6_tok + "::2/64"
                v6_ip_addr = "2100:0:" + v6_tok + "::1/64"
                command1 = "config interface ip remove "+ "Vlan" + str(index) + " " + v6_ip_addr
                command2 = "config interface ip remove "+ "Vlan" + str(index) + " " + v6_ip_addr2
            st.config(dut, command1)
            st.config(dut2, command2)
        max_vlan = max_paths/4
        base_vlan = 3
        max_vlan = max_vlan - base_vlan

        v_range_t = str(base_vlan) + " " + str(base_vlan + max_vlan )
        vapi.config_vlan_range_members(dut1, v_range_t, data.dut1_ports[0], config='del')
        vapi.config_vlan_range_members(dut2, v_range_t, data.dut2_ports[0], config='del')
        base_range = 1
        max_range = 4
        max_vlan = max_paths/4
        incr_vlan = max_paths/4
        for index in range(base_range, max_range):
            base_vlan = max_vlan + 1
            #max_vlan = max_vlan + 32
            max_vlan = max_vlan + incr_vlan
            v_range_t = str(base_vlan) + " " + str(max_vlan)
            vapi.config_vlan_range_members(dut1, v_range_t, data.dut1_ports[index], config='del')
            vapi.config_vlan_range_members(dut2, v_range_t, data.dut2_ports[index], config='del')
        cmd = "config vlan range del 2 129"
        st.config(dut, cmd)
        my_cmd = "no router bgp {}".format(data.as_num)
        st.vtysh_config(dut, my_cmd)
        my_cmd = "no router bgp {}".format(data.new_as_num)
        st.vtysh_config(dut2, my_cmd)

    st.debug("ret1: {} , ret2: {}".format(ret1, ret2))
    if ret1 is True and ret2 is True:
        ret = True
        st.log("Test Case PASSED")
    else:
        ret = False
        st.log("Test Case FAILED")
    st.log("operation_successful")
    return ret
def measure_v4_route_scale_time(route_count, show_flag):
    vars = st.get_testbed_vars()
    dut = vars.D1
    default_route = 0
    #TG pumps 512k per sec so to make measure route install
    #time more accurate we start from 600k + route_count
    #base_route_count = 60000 + route_count
    base_route_count = route_count

    ipfeature.clear_ip_configuration(st.get_dut_names())
    ipfeature.clear_ip_configuration(st.get_dut_names(), 'ipv6')

    member3 = vars.D1T1P1
    member4 = vars.D1T1P2
    ipfeature.config_ip_addr_interface(dut,
                                       member3,
                                       data.my_ip_addr,
                                       data.ip_prefixlen,
                                       family="ipv4")
    ipfeature.config_ip_addr_interface(dut,
                                       member4,
                                       data.intf_ip_addr,
                                       data.ip_prefixlen,
                                       family="ipv4")

    ipfeature.get_interface_ip_address(dut, family="ipv4")
    ipfeature.show_ip_route(dut)
    interface_status_show(dut)

    bgpfeature.create_bgp_router(dut, data.as_num, '')
    bgpfeature.create_bgp_neighbor(dut, data.as_num, data.neigh_ip_addr,
                                   data.remote_as_num)

    (tg1, tg2, tg_ph_1, tg_ph_2) = get_handles()

    tg1.tg_traffic_control(action='reset', port_handle=tg_ph_1)
    tg2.tg_traffic_control(action='reset', port_handle=tg_ph_2)

    h1 = tg1.tg_interface_config(port_handle=tg_ph_1,
                                 mode='config',
                                 intf_ip_addr='10.10.10.2',
                                 gateway='10.10.10.1',
                                 src_mac_addr='00:0a:01:00:00:01',
                                 arp_send_req='1')
    st.log("INTFCONF: " + str(h1))
    h2 = tg2.tg_interface_config(port_handle=tg_ph_2,
                                 mode='config',
                                 intf_ip_addr='20.20.20.2',
                                 gateway='20.20.20.1',
                                 arp_send_req='1')
    st.log("INTFCONF: " + str(h2))

    conf_var = {
        'mode': 'enable',
        'active_connect_enable': '1',
        'local_as': '200',
        'remote_as': '100',
        'remote_ip_addr': '10.10.10.1'
    }
    route_var = {
        'mode': 'add',
        'num_routes': base_route_count,
        'prefix': '121.1.1.0',
        'as_path': 'as_seq:1'
    }
    ctrl_start = {'mode': 'start'}
    ctrl_stop = {'mode': 'stop'}

    # Configuring the BGP router.
    bgp_rtr1 = tgapi.tg_bgp_config(tg=tg1,
                                   handle=h1['handle'],
                                   conf_var=conf_var,
                                   route_var=route_var,
                                   ctrl_var=ctrl_start)

    st.log("BGP_HANDLE: " + str(bgp_rtr1))
    # Verified at neighbor.
    st.log("BGP neighborship established.")
    st.wait(10)

    tr1 = tg2.tg_traffic_config(
        port_handle=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=512000,
        enable_stream_only_gen='0')

    retval = bgpfeature.verify_bgp_summary(dut,
                                           neighbor=data.neigh_ip_addr,
                                           state='Established')

    if retval is True:
        output = bcm_show(dut, 'bcmcmd "l3 defip show" | wc -l')
        st.log(output)
        default_route = parse_route_output(output)

    route_count += default_route

    cmd = 'bcmcmd "l3 defip show" | wc -l'
    measure_route_learn_time(dut, default_route, route_count, cmd)

    if (show_flag):
        cmd = "time show ip route"
        bcm_show(dut, cmd)
        data.result_14_3 = True

    res = tg2.tg_traffic_control(action='stop', handle=tr1['stream_id'])
    st.log("TR_CTRL: " + str(res))
    tgapi.tg_bgp_config(tg=tg1,
                        handle=bgp_rtr1['conf']['handle'],
                        ctrl_var=ctrl_stop)
    ipfeature.delete_ip_interface(dut,
                                  member4,
                                  data.intf_ip_addr,
                                  data.ip_prefixlen,
                                  family="ipv4")
    ipfeature.delete_ip_interface(dut,
                                  member3,
                                  data.my_ip_addr,
                                  data.ip_prefixlen,
                                  family="ipv4")
    bgpfeature.delete_bgp_neighbor(dut, data.as_num, data.neigh_ip_addr,
                                   data.remote_as_num)
    delete_bgp_router(dut, '', data.as_num)

    tg2.tg_traffic_control(action='reset', port_handle=tg_ph_2)
    tg1.tg_interface_config(port_handle=tg_ph_1,
                            handle=h1['handle'],
                            mode='destroy')
    tg2.tg_interface_config(port_handle=tg_ph_2,
                            handle=h2['handle'],
                            mode='destroy')
    st.wait(20)