def initialize_topology():
    st.log(
        "Script Starts Here!. Initialize.........................................................................................."
    )

    #DUT topology variables
    vars = st.ensure_min_topology("D1D2:4", "D1T1:2", "D2T1:2")
    data.dut_list = st.get_dut_names()
    data.dut1 = data.dut_list[0]
    data.dut2 = data.dut_list[1]
    data.d1_d2_ports = [vars.D1D2P1, vars.D1D2P2, vars.D1D2P3, vars.D1D2P4]
    data.d2_d1_ports = [vars.D2D1P1, vars.D2D1P2, vars.D2D1P3, vars.D2D1P4]

    #DUT-TG topology variables
    data.dut1_tg_ports = [vars.D1T1P1, vars.D1T1P2]
    data.dut2_tg_ports = [vars.D2T1P1, vars.D2T1P2]
    data.tg_dut1_ports = [vars.T1D1P1, vars.T1D1P2]
    data.tg_dut2_ports = [vars.T1D2P1, vars.T1D2P2]
    data.tg = tgen_obj_dict[vars['tgen_list'][0]]
    data.tg_dut1_p1 = data.tg.get_port_handle(vars.T1D1P1)
    data.tg_dut2_p1 = data.tg.get_port_handle(vars.T1D2P1)
    data.tg_dut1_p2 = data.tg.get_port_handle(vars.T1D1P2)
    data.tg_dut2_p2 = data.tg.get_port_handle(vars.T1D2P2)
    data.d1_stream_list = {}
    data.d2_stream_list = {}
    data.d1_gateway_mac = mac_obj.get_sbin_intf_mac(data.dut1,
                                                    data.dut1_tg_ports[0])
    #TGEN delay
    if 'ixia' in vars['tgen_list'][0]:
        data.tgen_type = 'ixia'
        data.delay_factor = 2
    else:
        data.tgen_type = 'stc'
        data.delay_factor = 1
Example #2
0
def arp_module_hooks(request):
    global vars, tg_handler, tg, dut1, d1_mac_addr, h1, h2

    # Min topology verification
    vars = st.ensure_min_topology("D1T1:2")

    # Initialize TG and TG port handlers
    tg_handler = tgapi.get_handles_byname("T1D1P1", "T1D1P2")
    tg = tg_handler["tg"]

    # Test setup details
    data.my_dut_list = st.get_dut_names()
    dut1 = data.my_dut_list[0]

    # Test variables
    d1_mac_addr = mac.get_sbin_intf_mac(dut1, "eth0")

    # ARP module configuration
    st.log("ARP module configuration.")
    ip_obj.config_ip_addr_interface(dut1, vars.D1T1P1, data.d1t1_ip_addr,
                                    data.mask)
    vlan_obj.create_vlan(dut1, data.vlan_1)
    vlan_obj.add_vlan_member(dut1, data.vlan_1, vars.D1T1P2, True)
    ip_obj.config_ip_addr_interface(dut1, data.vlan_int_1, data.d1t2_ip_addr,
                                    data.mask)

    # TG ports reset
    st.log("Resetting the TG ports")
    tg.tg_traffic_control(action="reset", port_handle=tg_handler["tg_ph_list"])

    # 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.t1d1_ip_addr,
                                gateway=data.d1t1_ip_addr,
                                src_mac_addr=data.t1d1_mac_addr,
                                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.t2d1_ip_addr,
                                gateway=data.d1t2_ip_addr,
                                src_mac_addr=data.t2d1_mac_addr,
                                arp_send_req='1',
                                vlan_id=data.vlan_1,
                                vlan=1)
    st.log("INTFCONF: " + str(h2))

    yield
    # ARP module cleanup
    st.log("ARP module cleanup.")
    ip_obj.clear_ip_configuration(dut1,
                                  family="ipv4",
                                  thread=data.clear_parallel)
    vlan_obj.clear_vlan_configuration(dut1, thread=data.clear_parallel)
Example #3
0
    def get_vars(self, dut):

        # try to read the version info
        for _ in range(3):
            try:
                version_data = self.show_version(dut)
                break
            except Exception:
                st.error("Failed to read version info")
                version_data = ""
                st.wait(1)
                continue

        # use default values when the show _version is failed
        if not version_data:
            st.error("Failed to read version info even after retries")
            version_data = {
                'product': 'unknown',
                'hwsku': 'unknown',
                'version': 'unknown',
            }

        retval = dict()
        retval["product"] = version_data['product']
        retval["hwsku"] = version_data['hwsku']
        retval["version"] = version_data['version']
        retval["constants"] = st.get_datastore(dut, "constants")

        retval["redis_db_cli"] = redis.db_cli_init(dut)

        retval["mgmt_ifname"] = st.get_mgmt_ifname(dut)
        retval["mgmt_ipv4"] = st.get_mgmt_ip(dut)
        try:
            retval["mgmt_mac"] = mac.get_sbin_intf_mac(dut,
                                                       retval["mgmt_ifname"])
        except Exception:
            retval["mgmt_mac"] = "unknown"

        output = st.show(dut, 'ls /etc/sonic/bcmsim.cfg', skip_tmpl=True)
        is_vsonic = not bool(re.search(r'No such file or directory', output))
        retval["is_vsonic"] = is_vsonic

        output = st.config(dut, "fast-reboot -h", skip_error_check=True)
        if "skip the user confirmation" in output:
            retval["reboot-confirm"] = True
        else:
            retval["reboot-confirm"] = False

        return retval
def test_l3_ecmp_4paths_on_bo_tc():
    (dut) = (data.dut)
    #count = 0
    #intf_ip_addr = data.start_ip_addr
    #intf_ip_addr2 = data.start_ip_addr2
    #nexthop = data.nexthop_start_ip_addr
    nexthop = "10.2.101.10/32"
    member1 = vars.D1T1P1
    member2 = vars.D1T1P2
    member3 = vars.D1T1P3
    member4 = vars.D1T1P4
    apply_file = False

    ipfeature.clear_ip_configuration([dut])
    max_range = data.base_val+4
    base_range = data.base_val-1
    if apply_file is False:
        command = "config vlan range add 100 105"
        st.config(dut, command)
        command = "config vlan member add 100 {}".format(member4)
        st.config(dut, command)
        command = "config vlan member add 101 {}".format(member1)
        st.config(dut, command)
        command = "config vlan member add 102 {}".format(member2)
        st.config(dut, command)
        command = "config vlan member add 103 {}".format(member3)
        st.config(dut, command)
        command = "config vlan member add 104 {}".format(member4)
        st.config(dut, command)
        #ip_addr = data.start_ip_addr
        ip_addr = "10.2.100.1/24"
        for index in range(base_range, max_range):
            command = "config interface ip add "+ "Vlan" + str(index) + " " + ip_addr
            st.config(dut, command)
            (_, ip_addr) = ipfeature.increment_ip_addr(ip_addr, "network")


    base_range = data.base_val
    max_range = data.base_val+3
    for index in range(base_range, max_range):
      (_, nexthop) = ipfeature.increment_ip_addr(nexthop, "network")
      nexthop1 = nexthop
      formatted_next_hop = nexthop1.replace("/32","")
      ipfeature.create_static_route(dut, formatted_next_hop, data.static_route)


    data.my_dut_list = st.get_dut_names()
    #dut1 = data.my_dut_list[0]

    (tg1, tg_ph_1, tg2, tg_ph_2, tg3, tg_ph_3, tg4, tg_ph_4) = get_handles_1()

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

    h0=tg4.tg_interface_config(port_handle=tg_ph_4, mode='config',
         intf_ip_addr='10.2.100.10',  gateway='10.2.100.1',
         src_mac_addr='00:0d:01:00:00:01', vlan='1', vlan_id='100',
         arp_send_req='1', gateway_step='0.0.1.0', intf_ip_addr_step='0.0.1.0')

    h1=tg1.tg_interface_config(port_handle=tg_ph_1, mode='config',
         intf_ip_addr='10.2.101.10',  gateway='10.2.101.1',
         src_mac_addr='00:0d:02:00:00:01', vlan='1', vlan_id='101',
         arp_send_req='1', gateway_step='0.0.1.0', intf_ip_addr_step='0.0.1.0')

    h2=tg2.tg_interface_config(port_handle=tg_ph_2, mode='config',
         intf_ip_addr='10.2.102.10',  gateway='10.2.102.1',
         src_mac_addr='00:0c:01:00:00:01', vlan='1', vlan_id='102',
         arp_send_req='1', gateway_step='0.0.1.0', intf_ip_addr_step='0.0.1.0')

    h3=tg3.tg_interface_config(port_handle=tg_ph_3, mode='config',
         intf_ip_addr='10.2.103.10',  gateway='10.2.103.1',
         src_mac_addr='00:0c:02:00:00:01', vlan='1', vlan_id='103',
         arp_send_req='1', gateway_step='0.0.1.0', intf_ip_addr_step='0.0.1.0')

    h4=tg4.tg_interface_config(port_handle=tg_ph_4, mode='config',
         intf_ip_addr='10.2.104.10',  gateway='10.2.104.1',
         src_mac_addr='00:0a:02:00:00:01', vlan='1', vlan_id='104',
         arp_send_req='1', gateway_step='0.0.1.0', intf_ip_addr_step='0.0.1.0')

    mac_eth = macapi.get_sbin_intf_mac(vars.D1,'eth0')
    tr1=tg4.tg_traffic_config(port_handle=tg_ph_4, mac_src='00:11:01:00:00:01',
         mac_dst=mac_eth, ip_dst_mode='increment', ip_dst_count=200,
         ip_dst_step='0.0.0.1',ip_src_addr='10.2.100.10', ip_dst_addr='200.1.0.1',
         l3_protocol='ipv4', l2_encap='ethernet_ii_vlan', vlan_id='100',
         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'])
    #count = 0
    #Port Counters
    st.wait(20)
    st.show(dut, "show arp")
    #Port Counters
    ret = check_intf_traffic_bo_counters()
    if ret is True:
        st.log("Test Case PASSED")
    tg2.tg_traffic_control(action='stop', handle=tr1['stream_id'])
    tg1.tg_interface_config(port_handle=tg_ph_1, handle=h0['handle'], mode='destroy')
    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')
    tg3.tg_interface_config(port_handle=tg_ph_3, handle=h3['handle'], mode='destroy')
    tg4.tg_interface_config(port_handle=tg_ph_4, handle=h4['handle'], mode='destroy')

    if apply_file is False:
        base_range = data.base_val-1
        ip_addr = data.start_ip_addr
        max_range = data.base_val+4
        for index in range(base_range, max_range):
            command = "config interface ip remove "+ "Vlan" + str(index) + " " + ip_addr
            st.config(dut, command)
            (_, ip_addr) = ipfeature.increment_ip_addr(ip_addr, "network")
        command = "config vlan member del 100 {}".format(member4)
        st.config(dut, command)
        command = "config vlan member del 101 {}".format(member1)
        st.config(dut, command)
        command = "config vlan member del 102 {}".format(member2)
        st.config(dut, command)
        command = "config vlan member del 103 {}".format(member3)
        st.config(dut, command)
        command = "config vlan member del 104 {}".format(member4)
        st.config(dut, command)
        command = "config vlan range del 100 105"
        st.config(dut, command)

    if ret is True:
        st.log("Test Case PASSED")
        st.report_pass("operation_successful")
    else:
        st.log("Test Case FAILED")
        st.report_fail("operation_failed")
Example #5
0
def base_config():
    ###############################################################################################################################

    st.log('###### ----- Taking backup for unconfig ------######')
    src_path = "/etc/sonic/config_db.json"
    dst_path = "/etc/sonic/default.json"
    #cmd = 'cp /etc/sonic/config_db.json /etc/sonic/default.json'
    utils.exec_all(
        True,
        [[basic_obj.copy_file_to_local_path, data.dut1, src_path, dst_path],
         [basic_obj.copy_file_to_local_path, data.dut2, src_path, dst_path]])
    ###############################################################################################################################

    st.log(
        '###### ----- Loading json file with vrf and IP address config ------######'
    )
    curr_path = os.getcwd()
    json_file_dut1 = curr_path + "/routing/VRF/vrf_scale_dut1.json"
    st.apply_files(data.dut1, [json_file_dut1])

    json_file_dut2 = curr_path + "/routing/VRF/vrf_scale_dut2.json"
    st.apply_files(data.dut2, [json_file_dut2])

    utils.exec_all(True, [[st.apply_files, data.dut1, [json_file_dut1]],
                          [st.apply_files, data.dut2, [json_file_dut2]]])

    st.log('######------Configure vlans and add members------######')
    utils.exec_all(True,
                   [[vlan_api.config_vlan_range, data.dut1, '1 999', 'add'],
                    [vlan_api.config_vlan_range, data.dut2, '1 999', 'add']])
    utils.exec_all(True, [[
        vlan_api.config_vlan_range_members, data.dut1, '1 999',
        data.d1_dut_ports[0], 'add'
    ],
                          [
                              vlan_api.config_vlan_range_members, data.dut2,
                              '1 999', data.d2_dut_ports[0], 'add'
                          ]])

    ###############################################################################################################################

    st.log('######----- Configure IP on DUT--TG interface------######')
    utils.exec_all(True,
                   [[
                       ip_api.config_ip_addr_interface, data.dut1,
                       data.dut1_tg1_ports[0], data.dut1_tg_host, '16', 'ipv4'
                   ],
                    [
                        ip_api.config_ip_addr_interface, data.dut2,
                        data.dut2_tg1_ports[0], data.dut2_tg_host, '16', 'ipv4'
                    ]])

    ###############################################################################################################################

    st.log(
        '######----- Configure hosts and create traffic streams for all VRFs------######'
    )
    host_config()
    gateway_mac = mac_api.get_sbin_intf_mac(data.dut1, data.dut1_tg1_ports[0])

    data.stream = data.tg1.tg_traffic_config(
        port_handle=data.tg_dut1_p1,
        mode='create',
        duration='5',
        transmit_mode='continuous',
        length_mode='fixed',
        port_handle2=data.tg_dut2_p1,
        rate_pps=1000,
        mac_src='00.00.00.11.12.53',
        mac_dst=gateway_mac,
        ip_src_addr=data.tg_dut1_stream_start[0],
        ip_dst_addr=data.tg_dut2_stream_start[0],
        l3_protocol='ipv4',
        ip_src_mode='increment',
        ip_src_count=1000,
        ip_src_step='0.0.0.1')
    data.stream_list_scale.update({'pc_v4_stream': data.stream['stream_id']})
    st.wait(30)
Example #6
0
def common_config(request):
    global dut1, r1_tg_ports1, r1_tg_ports2
    global tg_r1_hw_port1, tg_r1_hw_port2
    global tg1, tg2, tg_dut1_p1_handle, tg_dut1_p2_handle
    global r1tg1_1_ipAddr, r1tg2_1_ipAddr
    global nextHop_ip, nextHop_ipv6
    global static_macAdd
    global r1tg1_1_ipv6Addr, r1tg2_1_ipv6Addr
    global subnetMask, subnetMaskv6
    global Vlan, maskACL
    global acl_table_name, acl_table_namev6
    global description, descriptionv6
    global type, typev6
    global stage, expCount, pktrate, pktAction
    global srpIP, dstIP, srpIPv6, dstIPv6
    global rule_list, priority_list
    vars = st.ensure_min_topology("D1T1:2")
    dut1 = vars.D1
    r1_tg_ports1 = vars.D1T1P1
    r1_tg_ports2 = vars.D1T1P2
    tg_r1_hw_port1 = vars.T1D1P1
    tg_r1_hw_port2 = vars.T1D1P2
    tg1, tg_dut1_p1_handle = tgapi.get_handle_byname("T1D1P1")
    tg2, tg_dut1_p2_handle = tgapi.get_handle_byname("T1D1P2")
    r1tg1_1_ipAddr = '30.30.30.1'
    r1tg2_1_ipAddr = '20.20.20.1'
    nextHop_ip = '20.20.20.100'
    nextHop_ipv6 = '3001::100'
    static_macAdd = '00:0a:01:00:11:02'
    r1tg1_1_ipv6Addr = '2001::10'
    r1tg2_1_ipv6Addr = '3001::10'
    subnetMask = '24'
    subnetMaskv6 = '64'
    Vlan = '100'
    maskACL = '32'
    acl_table_name = 'ACL0'
    acl_table_namev6 = 'ACL1'
    description = 'IPv4_ACL_redirect_port'
    descriptionv6 = 'IPv6_ACL_redirect_port'
    type = 'L3'
    typev6 = 'L3V6'
    stage = 'INGRESS'
    expCount = '1000'
    pktrate = '1000'
    pktAction = 'redirect:'
    srpIP = '1.1.1.3'
    dstIP = '3.3.3.1'
    srpIPv6 = '1234::1'
    dstIPv6 = '5001::1'
    rule_list = [
        'rule_1', 'rule_2', 'rule_3', 'rule_4', 'rule_5', 'rule_6', 'rule_7',
        'rule_8', 'rule_9', 'rule_10'
    ]
    priority_list = ['10', '9', '8', '7', '6', '5', '4', '3', '2', '1']

    st.log("Bring Up the required topology for the test to run")
    port.noshutdown(dut1, [r1_tg_ports1, r1_tg_ports2])
    ipfeature.config_ip_addr_interface(dut1,
                                       interface_name=r1_tg_ports1,
                                       ip_address=r1tg1_1_ipAddr,
                                       subnet=subnetMask,
                                       family="ipv4")
    ipfeature.config_ip_addr_interface(dut1,
                                       interface_name=r1_tg_ports2,
                                       ip_address=r1tg2_1_ipAddr,
                                       subnet=subnetMask,
                                       family="ipv4")
    ipfeature.config_ip_addr_interface(dut1,
                                       interface_name=r1_tg_ports1,
                                       ip_address=r1tg1_1_ipv6Addr,
                                       subnet=subnetMaskv6,
                                       family="ipv6")
    ipfeature.config_ip_addr_interface(dut1,
                                       interface_name=r1_tg_ports2,
                                       ip_address=r1tg2_1_ipv6Addr,
                                       subnet=subnetMaskv6,
                                       family="ipv6")

    st.log("Create static arp on dut1")
    arp_obj.add_static_arp(dut1, nextHop_ip, static_macAdd)
    st.log("Create static ndp on dut1")
    arp_obj.config_static_ndp(dut1, nextHop_ipv6, static_macAdd, r1_tg_ports2)

    st.log("Get the device MAC- dut1")
    routing_mac = mapi.get_sbin_intf_mac(dut1, r1_tg_ports1)

    st.log("Create host on the Traffic generator")
    create_trafficStreams(tg1,
                          tg2,
                          tg_dut1_p1_handle,
                          tg_dut1_p2_handle,
                          rate=pktrate,
                          rule='forward',
                          dstMAC=routing_mac)

    yield
    # add things at the end of this module"
    arp_obj.delete_static_arp(dut1, nextHop_ip, static_macAdd)
    arp_obj.clear_ndp_table(dut1)
    st.log("Delete  interface config on dut1")
    ipfeature.delete_ip_interface(dut1,
                                  interface_name=r1_tg_ports1,
                                  ip_address=r1tg1_1_ipAddr,
                                  subnet=subnetMask,
                                  family="ipv4")
    ipfeature.delete_ip_interface(dut1,
                                  interface_name=r1_tg_ports2,
                                  ip_address=r1tg2_1_ipAddr,
                                  subnet=subnetMask,
                                  family="ipv4")
    ipfeature.delete_ip_interface(dut1,
                                  interface_name=r1_tg_ports1,
                                  ip_address=r1tg1_1_ipv6Addr,
                                  subnet=subnetMaskv6,
                                  family="ipv6")
    ipfeature.delete_ip_interface(dut1,
                                  interface_name=r1_tg_ports2,
                                  ip_address=r1tg2_1_ipv6Addr,
                                  subnet=subnetMaskv6,
                                  family="ipv6")
    port.shutdown(dut1, [r1_tg_ports1, r1_tg_ports2])