def initialize_topology():
    st.log(
        "Script Starts Here!. Initialize.........................................................................................."
    )
    vars = st.ensure_min_topology("D1D2:4", "D2D3:4", "D1T1:2", "D3T1:2")
    data.dut_list = st.get_dut_names()
    data.dut1 = data.dut_list[0]
    data.dut2 = data.dut_list[1]
    data.dut3 = data.dut_list[2]
    utils.exec_all(True,
                   [[bgp_obj.enable_docker_routing_config_mode, data.dut1],
                    [bgp_obj.enable_docker_routing_config_mode, data.dut2],
                    [bgp_obj.enable_docker_routing_config_mode, data.dut3]])
    data.d1_d2_ports = [vars.D1D2P1, vars.D1D2P2, vars.D1D2P3, vars.D1D2P4]
    data.d2_d1_ports = [vars.D2D1P1, vars.D2D1P2, vars.D2D1P3, vars.D2D1P4]
    data.d2_d3_ports = [vars.D2D3P1, vars.D2D3P2, vars.D2D3P3, vars.D2D3P4]
    data.d3_d2_ports = [vars.D3D2P1, vars.D3D2P2, vars.D3D2P3, vars.D3D2P4]
    data.dut1_tg_ports = [vars.D1T1P1, vars.D1T1P2]
    data.dut3_tg_ports = [vars.D3T1P1, vars.D3T1P2]
    data.tg_dut1_ports = [vars.T1D1P1, vars.T1D1P2]
    data.tg_dut3_ports = [vars.T1D3P1, vars.T1D3P2]
    data.tg = tgen_obj_dict[vars['tgen_list'][0]]
    data.tg_dut1_p1 = data.tg.get_port_handle(vars.T1D1P1)
    data.tg_dut3_p1 = data.tg.get_port_handle(vars.T1D3P1)
    data.tg_dut1_p2 = data.tg.get_port_handle(vars.T1D1P2)
    data.tg_dut3_p2 = data.tg.get_port_handle(vars.T1D3P2)
    data.d1_stream_list = {}
    data.d1_stream_list_vrf = {}
    data.d3_stream_list = {}
    if 'ixia' in vars['tgen_list'][0]:
        data.tgen_type = 'ixia'
        data.delay_factor = 2
    else:
        data.tgen_type = 'stc'
        data.delay_factor = 1
Ejemplo n.º 2
0
def nat_pre_config():
    global vars
    vars = st.ensure_min_topology("D1D2:1", "D2D3:1")
    platform = basic_obj.get_hwsku(vars.D2)
    common_constants = st.get_datastore(vars.D2, "constants", "default")
    if platform.lower() in common_constants['TH3_PLATFORMS']:
        st.error("NAT is not supported for this platform {}".format(platform))
        st.report_unsupported('NAT_unsupported_platform',platform)
    ip_obj.config_ip_addr_interface(vars.D1, vars.D1D2P1, data.d1d2_ip_addr, data.ip_addr_mask, family=data.af_ipv4)
    ip_obj.config_ip_addr_interface(vars.D2, vars.D2D1P1, data.d2d1_ip_addr, data.ip_addr_mask, family=data.af_ipv4)
    ip_obj.config_ip_addr_interface(vars.D2, vars.D2D3P1, data.d2d3_ip_addr, data.ip_addr_mask, family=data.af_ipv4)
    ip_obj.config_ip_addr_interface(vars.D3, vars.D3D2P1, data.d3d2_ip_addr, data.ip_addr_mask, family=data.af_ipv4)
    ip_obj.create_static_route(vars.D1, data.d2d1_ip_addr,"{}/{}".format(data.d1_static_nw, data.ip_addr_mask),
                               shell=data.shell_vtysh, family=data.af_ipv4)
    ip_obj.create_static_route(vars.D3, data.d2d3_ip_addr, "{}/{}".format(data.d3_static_nw, data.ip_addr_mask),
                               shell=data.shell_vtysh, family=data.af_ipv4)
    st.log("NAT Configuration")
    nat_obj.config_nat_feature(vars.D2, 'enable')
    util_nat_zone_config(vars.D2, [vars.D2D1P1, vars.D2D3P1], [data.zone_1, data.zone_2], config=data.config_add)
    st.log("Creating NAT Pool")
    nat_obj.config_nat_pool(vars.D2, pool_name=data.pool_name[0], global_ip_range=data.d2d1_ip_addr,
                            global_port_range=data.global_port_range, config=data.config_add)
    st.log("Creating NAT Pool binding")
    nat_obj.config_nat_pool_binding(vars.D2, binding_name=data.bind_name[0], pool_name=data.pool_name[0],
                                    config=data.config_add)
    utils.exec_all(True, [[ip_obj.show_ip_route, vars.D1], [ip_obj.show_ip_route, vars.D2]])
    ip_obj.show_ip_route(vars.D3)
Ejemplo n.º 3
0
def debug_bgp_bfd(dut):
    dut_list = make_list(dut)
    st.banner("********* Dubug commands starts ************")
    func_list = [clear_interface_counters, show_arp, show_ndp, show_interface_counters_all,
                 asicapi.dump_l3_ip6route, asicapi.dump_l3_defip]
    for func in func_list:
        api_list = [[func, dut] for dut in dut_list]
        exec_all(True, api_list)
    st.banner(" ******** End of Dubug commands ************")
Ejemplo n.º 4
0
def apply_module_configuration():
    print_log("Applying module configuration")

    data.dut1_lag_members = [vars.D1D2P1, vars.D1D2P2]
    data.dut2_lag_members = [vars.D2D1P1, vars.D2D1P2]

    # create portchannel
    utils.exec_all(True, [
        utils.ExecAllFunc(pc_obj.create_portchannel, vars.D1, data.portChannelName),
        utils.ExecAllFunc(pc_obj.create_portchannel, vars.D2, data.portChannelName),
    ])

    # add portchannel members
    utils.exec_all(True, [
        utils.ExecAllFunc(pc_obj.add_portchannel_member, vars.D1, data.portChannelName, data.dut1_lag_members),
        utils.ExecAllFunc(pc_obj.add_portchannel_member, vars.D2, data.portChannelName, data.dut2_lag_members),
    ])
def module_config():
    result = True
    result = utils.exec_all(True, [[dut1_config], [dut2_config]])
    if result is False:
        st.error(
            "Module config Failed - IP address/Portchannel/Vlan configuration failed"
        )
        pytest.skip()
Ejemplo n.º 6
0
def prologue_epilogue(request):
    initialize_topology_vars()
    [res, _] = utils.exec_all(True, [[create_tg_hosts], [ecmp_base_config]],
                              True)
    create_tg_streams()
    if res[1] is False:
        more_debugs(duts=dut_list)
        st.report_fail("module_config_verification_failed")
    yield
    ecmp_base_unconfig()
Ejemplo n.º 7
0
def clear_module_configuration():
    print_log("Clearing module configuration")
    # delete Ipv4 address
    print_log("Delete ip address configuration:")
    ip_obj.clear_ip_configuration([vars.D1, vars.D2], family='ipv4')
    # delete Ipv6 address
    ip_obj.clear_ip_configuration([vars.D1, vars.D2], family='ipv6')
    # delete ipv4 static routes
    ip_obj.delete_static_route(vars.D1, data.ipv4_portchannel_D2, data.ipv4_network_D2, shell="vtysh",
                               family="ipv4")
    ip_obj.delete_static_route(vars.D2, data.ipv4_portchannel_D1, data.ipv4_network_D1, shell="vtysh",
                               family="ipv4")
    # delete ipv6 static routes
    ip_obj.delete_static_route(vars.D1, data.ipv6_portchannel_D2, data.ipv6_network_D2, shell="vtysh",
                               family="ipv6")
    ip_obj.delete_static_route(vars.D2, data.ipv6_portchannel_D1, data.ipv6_network_D1, shell="vtysh",
                               family="ipv6")
    # delete port channel members
    print_log("Deleting members from port channel:")
    utils.exec_all(True, [
        utils.ExecAllFunc(pc_obj.delete_portchannel_member, vars.D1, data.portChannelName, data.dut1_lag_members),
        utils.ExecAllFunc(pc_obj.delete_portchannel_member, vars.D2, data.portChannelName, data.dut2_lag_members),
    ])
    # delete port channel
    print_log("Deleting port channel configuration:")
    utils.exec_all(True, [
        utils.ExecAllFunc(pc_obj.delete_portchannel, vars.D1, data.portChannelName),
        utils.ExecAllFunc(pc_obj.delete_portchannel, vars.D2, data.portChannelName),
    ])
    # delete acl tables and rules
    print_log("Deleting ACLs:")

    [_, exceptions] = utils.exec_all(True, [[acl_obj.acl_delete, vars.D1], [acl_obj.acl_delete, vars.D2]])
    ensure_no_exception(exceptions)
    #Clear static arp entries
    print_log("Clearing ARP entries")
    arp_obj.clear_arp_table(vars.D1)
    arp_obj.clear_arp_table(vars.D2)
    #Clear static ndp entries
    print_log("Clearing NDP entries")
    arp_obj.clear_ndp_table(vars.D1)
    arp_obj.clear_ndp_table(vars.D2)
Ejemplo n.º 8
0
def udld_module_config():
    '''
    - Configure vlans 10 on DUT1 to DUT2 to DUT3
    - Configure the ports to add in acess vlan 10
    - Configure UDLD global and interface

    '''
    ver_flag = True
    print_log("Starting UDLD Module Configurations...\n\
    STEPS:\n\
    - Configure vlans 10 on DUT1 to DUT2 to DUT3\n\
    - Configure the ports to add in acess vlan 10\n\
    - Configure UDLD global and interface.", "HIGH")

    ### Create Access VLAN on all DUTs
    utils.exec_all(True,[[vlan.create_vlan, dut, trunk_base_vlan] for dut in dut_list])


    ### Add Access ports between DUT1<->DUT2<->DUT3<->DUT1 in vlan 10
    api_list = []
    api_list.append([vlan.add_vlan_member, dut1, trunk_base_vlan, [vars.D1D2P1]])
    api_list.append([vlan.add_vlan_member, dut2, trunk_base_vlan, [vars.D2D1P1,vars.D2D3P1,vars.D2D3P2]])
    api_list.append([vlan.add_vlan_member, dut3, trunk_base_vlan, [vars.D3D2P1,vars.D3D2P2]])
    utils.exec_all(True, api_list)

    [result, exceptions] = pll.exec_parallel(True, [dut2, dut3], udld.udld_cfg_ebtables_rule, [{'add': False}, {'add': False}])
    if not all(i is None for i in exceptions):
        result.append(False)
        print_log(exceptions)
    if False in result:
        print_log('UDLD Delete ebtables rule FAILED','ERROR')
        ver_flag = False

    ###Enable UDLD global
    dict1 = {'udld_enable': udld_global[dut1]['udld_enable'], 'config': udld_global[dut1]['config']}
    pll.exec_parallel(True,[dut1],udld.config_udld_global, [dict1])

    ###Enable UDLD on Interfaces
    dict1 = {'intf': udld_int[dut1]['udld_int'],'udld_enable': udld_int[dut1]['udld_enable'], 'config': udld_int[dut1]['config']}
    pll.exec_parallel(True,[dut1],udld.config_intf_udld, [dict1])
    return ver_flag
Ejemplo n.º 9
0
def validate_topology():
    # Enable all links in the topology and verify links up
    dut_port_dict = {}
    for dut in dut_list:
        port_list = st.get_dut_links_local(dut, peer=None, index=None)
        dut_port_dict[dut] = port_list
    #Usage: exec_all(use_threads, list_of_funcs)
    [result, exceptions] = utils.exec_all(True, [[intf.interface_operation, dut, dut_port_dict[dut], 'startup',False]
                                          for dut in dut_port_dict.keys()])
    if not all(i is None for i in exceptions):
        print_log(exceptions)
    return False if False in result else True
Ejemplo n.º 10
0
def udld_module_unconfig():
    ver_flag = True
    print_log("Starting UDLD Module UnConfigurations...", "HIGH")

    ### Remove the trunk ports between DUT1<->DUT2<->DUT3 in vlan 10
    api_list = []
    api_list.append([vlan.delete_vlan_member, dut1, trunk_base_vlan, [vars.D1D2P1]])
    api_list.append([vlan.delete_vlan_member, dut2, trunk_base_vlan, [vars.D2D1P1]])
    utils.exec_all(True, api_list)

    ### delete Access VLAN on all DUTs
    utils.exec_all(True,[[vlan.delete_vlan, dut, trunk_base_vlan] for dut in dut_list])

    [result, exceptions] = pll.exec_parallel(True, [dut2, dut3], udld.udld_cfg_ebtables_rule, [{'add': True}, {'add': True}])
    if not all(i is None for i in exceptions):
        result.append(False)
        print_log(exceptions)
    if False in result:
        print_log('UDLD Add ebtables rule FAILED','ERROR')
        ver_flag = False
    return ver_flag
Ejemplo n.º 11
0
def initialize_topology():
    # code for ensuring min topology
    st.log(
        "Initialize............................................................................................................."
    )
    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]
    utils.exec_all(True,
                   [[bgp_api.enable_docker_routing_config_mode, data.dut1],
                    [bgp_api.enable_docker_routing_config_mode, data.dut2]])
    data.d1_dut_ports = [vars.D1D2P1]
    data.d2_dut_ports = [vars.D2D1P1]
    data.dut1_tg1_ports = [vars.D1T1P1]
    data.dut2_tg1_ports = [vars.D2T1P1]
    data.tg_dut1_hw_port = vars.T1D1P1
    data.tg_dut2_hw_port = vars.T1D2P1
    data.tg1 = tgapi.get_chassis(vars)
    data.tg2 = data.tg1
    data.tg_dut1_p1 = data.tg1.get_port_handle(vars.T1D1P1)
    data.tg_dut2_p1 = data.tg2.get_port_handle(vars.T1D2P1)
    data.d1_p1_intf_v4 = {}
    data.d1_p1_intf_v6 = {}
    data.d2_p1_intf_v4 = {}
    data.d2_p1_intf_v6 = {}
    data.stream_list_scale = {}
    data.stream = []
    data.dut1_dut2_ip_list = ip_range('5.0.0.1', 2, 1000)
    data.dut2_dut1_ip_list = ip_range('5.0.0.2', 2, 1000)
    data.dut1_tg_host = '6.0.0.1'
    data.tg_dut1_host = '6.0.0.2'
    data.dut2_tg_host = '7.0.0.1'
    data.tg_dut2_host = '7.0.0.2'
    data.tg_dut1_stream_start = ip_range('6.0.0.3', 3, 1000)
    data.tg_dut2_stream_start = ip_range('7.0.0.3', 3, 1000)
    data.intf_list = []
    for vlan in dut1_dut2_vlan_scale:
        data.intf_list.append('Vlan' + vlan)
Ejemplo n.º 12
0
def prologue_epilogue():
    print_log("Starting to initialize and validate topology...",'MED')
    initialize_topology()
    validate_topology()
    api_list = []
    api_list.append([udld_module_config])
    [result, exceptions] = utils.exec_all(True, api_list, True)
    if not all(i is None for i in exceptions):
        result.append(False)
        print_log(exceptions)
    if False in result:
        st.report_fail("module_config_failed", "prolog")
        return

    yield
    api_list = []
    api_list.append([udld_module_unconfig])
    [result, exceptions] = utils.exec_all(True, api_list, True)
    if not all(i is None for i in exceptions):
        result.append(False)
        print_log(exceptions)
    if False in result:
        st.report_fail("module_unconfig_failed", "epilog")
Ejemplo n.º 13
0
def qos_save_reboot_module_hooks(request):
    # add things at the start of this module
    global vars
    st.log("Ensuring minimum topology")
    vars = st.ensure_min_topology("D1T1:1")

    st.log("Configuring supported QoS features")
    wred_data = wred_config.init_vars(vars)
    st.log('Creating WRED and ECN table')
    utils.exec_all(True, [
        utils.ExecAllFunc(apply_wred_ecn_config, vars.D1,
                          wred_data['wred_ecn_json_config'])
    ])
    st.log("Checking for wred config before save and reboot")
    wred_verify()
    st.log("checking for ecn config before save and reboot")
    ecn_verify()
    st.log("Configuring IPV4 ACL with rule")
    ipv4_acl_config()
    st.log("Configuring IPV6 ACL with rule")
    ipv6_acl_config()
    st.log("Checking for IPV4 ACL config before save and reboot")
    ipv4_acl_verify()
    st.log("Checking for IPV6 ACL config before save and reboot")
    ipv6_acl_verify()
    st.log("Configuring COS")
    cos_config()
    st.log("Checking for COS config before save and reboot")
    cos_config_verify()

    yield
    # add things at the end of this module"
    #Below step will clear COS, WRED and ECN config from the device.
    qos_obj.clear_qos_config(vars.D1)
    #Below step will clear all ACL config from the device.
    acl_obj.clear_acl_config(vars.D1)
Ejemplo n.º 14
0
def interface_operation_parallel(input, operation='startup', thread=True):
    """
    Author : Chaitanya Lohith Bollapragada
    This will perform the shutdown and noshutdown of given ports in given DUTs parallel.
    :param input: dic keys = dut, values = list of interfaces
    :param operation: shutdown | startup(default)
    :param thread:
    :return:

    Ex: interface_operation_parallel({vars:D1:[vars.D1D2P1,vars.D1D2P2], vars.D2:[vars.D2D1P1,vars.D2T1P1]},)
    """
    [out, exceptions
     ] = exec_all(thread, [[interface_operation, duts, input[duts], operation]
                           for duts in input.keys()])
    st.log(exceptions)
    return False if False in out else True
Ejemplo n.º 15
0
def links_status(threads, check_type):
    header = [
        'DUT', 'Local', "LStatus (A/O)", "Partner", "Remote", "RStatus (A/O)"
    ]
    funcs = [[tg_links_status, check_type], [duts_links_status, threads]]
    [[v1, v2], [e1, e2]] = utils.exec_all(threads, funcs, True)
    if v1 is None or v2 is None or e1 is not None or e2 is not None:
        print(v1, v2, e1, e2)
        return [True, header, []]

    v1_default = "?2?" if v1 else "NA"
    (results, exclude, alias) = ([], [], fill_alias())
    for dut in st.get_dut_names():
        for local, partner, remote in st.get_tg_links(dut):
            res = []
            res.append(alias.get(dut, "?"))
            res.append(local)
            res.append(v2.get("{}--{}".format(dut, local), "?1?"))
            res.append(alias.get(partner, "?"))
            res.append(remote)
            res.append(v1.get("{}--{}".format(partner, remote), v1_default))
            results.append(res)
        for local, partner, remote in st.get_dut_links(dut):
            name = "{}--{}".format(dut, local)
            if name in exclude:
                continue
            res = []
            res.append(alias.get(dut, "?"))
            res.append(local)
            res.append(v2.get("{}--{}".format(dut, local), "?3?"))
            res.append(alias.get(partner, "?"))
            res.append(remote)
            res.append(v2.get("{}--{}".format(partner, remote), "?4?"))
            exclude.append("{}--{}".format(partner, remote))
            results.append(res)
    return [True, header, results]
def test_unnumvrf_basic(fixture_test_unnumvrf_basic):
    tc_list = [
        'FtOpSoRoIPnumvrfFun001', 'FtOpSoRoIPnumvrfFun002',
        'FtOpSoRoIPnumvrfFun003'
    ]
    final_result = 0
    error_list = []
    st.banner('FtOpSoRoIPnumvrfFun001 -- to -- FtOpSoRoIPnumvrfFun003')

    st.banner(
        'Configure and verify IP unnumbered over non-default vrf and default-vrf on a physical interface '
    )
    tc_result = True
    result = utils.exec_all(True,
                            [[loc_lib.dut1_config_unnumbered, 'phy', ''],
                             [loc_lib.dut2_config_unnumbered, 'phy', '']])
    if result is False:
        error = "IP unnumbered configuration on a physical interface failed"
        tc_result = False
        error_list.append(error)
    result = utils.exec_all(True, [[loc_lib.dut1_verify_unnumbered, 'phy'],
                                   [loc_lib.dut2_verify_unnumbered, 'phy']])
    if result is False:
        error = "IP unnumbered verification on a physical interface failed"
        tc_result = False
        error_list.append(error)
    st.log('On DUT1 verify routes on non default vrf use physical interface')
    result = retry_api(ip_obj.verify_ip_route,
                       data.dut1,
                       vrf_name=data.dut1_vrf[0],
                       type='O',
                       nexthop=data.dut2_loopback_ip[0],
                       interface=data.d1_d2_ports[0],
                       ip_address=data.dut2_loopback_ip[0] + '/' +
                       data.ip_loopback_prefix,
                       family="ipv4",
                       retry_count=7,
                       delay=5)
    if result is False:
        error = "IP routes on non-default vrf failed"
        tc_result = False
        error_list.append(error)
    result = loc_lib.send_verify_traffic(type='ipv4')
    if result is False:
        error = 'IPv4 traffic with IPv4 unnumbered over physical interface on a non-default vrf failed'
        tc_result = False
        error_list.append(error)
    if tc_result:
        st.report_tc_pass(tc_list[0], 'tc_passed')
    else:
        final_result += 1
        st.report_tc_fail(tc_list[0], 'test_case_failure_message', error)

    st.banner(
        'Configure and verify IP unnumbered over non-default vrf and default-vrf on a portchannel interface '
    )
    st.log(
        'On DUT1 disable physical interface for the routes to be learnt from portchannel'
    )
    port_obj.shutdown(data.dut1, data.d1_d2_ports[0])
    tc_result = True
    result = utils.exec_all(True, [[loc_lib.dut1_config_unnumbered, 'pc', ''],
                                   [loc_lib.dut2_config_unnumbered, 'pc', '']])
    if result is False:
        error = "IP unnumbered configuration on a portchannel interface failed"
        tc_result = False
        error_list.append(error)
    result = utils.exec_all(True, [[loc_lib.dut1_verify_unnumbered, 'pc'],
                                   [loc_lib.dut2_verify_unnumbered, 'pc']])
    if result is False:
        error = "IP unnumbered verification on a portchannel interface failed"
        tc_result = False
        error_list.append(error)
    st.log('On DUT1 verify routes on non default vrf use portchannel')
    result = retry_api(ip_obj.verify_ip_route,
                       data.dut1,
                       vrf_name=data.dut1_vrf[0],
                       type='O',
                       nexthop=data.dut2_loopback_ip[2],
                       interface=data.portchannel,
                       ip_address=data.dut2_loopback_ip[2] + '/' +
                       data.ip_loopback_prefix,
                       family="ipv4",
                       retry_count=7,
                       delay=5)
    if result is False:
        error = "IP routes on non-default vrf using portchannel failed"
        tc_result = False
        error_list.append(error)
    result = loc_lib.send_verify_traffic(type='ipv4')
    if result is False:
        error = 'IPv4 traffic with IPv4 unnumbered over portchannel on a non-default vrf failed'
        tc_result = False
        error_list.append(error)
    if tc_result:
        st.report_tc_pass(tc_list[1], 'tc_passed')
    else:
        final_result += 1
        st.report_tc_fail(tc_list[1], 'test_case_failure_message', error)

    st.log(
        'Configure and verify IP unnumbered over non-default vrf and default-vrf on a vlan interface '
    )
    st.log(
        'On DUT1 disable physical interface for the routes to be learnt from portchannel'
    )
    port_obj.shutdown(data.dut1, [data.d1_d2_ports[2], data.d1_d2_ports[3]])
    tc_result = True
    result = utils.exec_all(True,
                            [[loc_lib.dut1_config_unnumbered, 'vlan', ''],
                             [loc_lib.dut2_config_unnumbered, 'vlan', '']])
    if result is False:
        error = "IP unnumbered configuration on a vlan interface failed"
        tc_result = False
        error_list.append(error)
    result = utils.exec_all(True, [[loc_lib.dut1_verify_unnumbered, 'vlan'],
                                   [loc_lib.dut2_verify_unnumbered, 'vlan']])
    if result is False:
        error = "IP unnumbered verification on a vlan interface failed"
        tc_result = False
        error_list.append(error)
    st.log('On DUT1 verify routes on non default vrf use vlan')
    result = retry_api(ip_obj.verify_ip_route,
                       data.dut1,
                       vrf_name=data.dut1_vrf[0],
                       type='O',
                       nexthop=data.dut2_loopback_ip[1],
                       interface='Vlan' + data.dut1_dut2_vlan[0],
                       ip_address=data.dut2_loopback_ip[1] + '/' +
                       data.ip_loopback_prefix,
                       family="ipv4",
                       retry_count=7,
                       delay=5)
    if result is False:
        error = "IP routes on non-default vrf using vlan failed"
        tc_result = False
        error_list.append(error)
    result = loc_lib.send_verify_traffic(type='ipv4')
    if result is False:
        error = 'IPv4 traffic with IPv4 unnumbered over vlan interface on a non-default vrf failed'
        tc_result = False
        error_list.append(error)
    if tc_result:
        st.report_tc_pass(tc_list[2], 'tc_passed')
    else:
        final_result += 1
        st.report_tc_fail(tc_list[2], 'test_case_failure_message', error)

    if final_result != 0:
        st.report_fail('test_case_failure_message', error_list)
    else:
        st.report_pass('test_case_passed')
def test_dynamic_unnumbered_scale():

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

    result = 0
    st.banner('FtOpSoRoAutoSc001 - Verify maximum BGP unnumbered sessions')
    st.banner('FtOpSoRoAutoSc002 - Verify maximum sessions with listen range')
    vlan_list_d1_d2 = ['%s' % x for x in range(1, 101)]
    ip_list_dut2 = loc_lib.ip_range('2.0.0.1', 2, 100)
    ip_list_dut3 = loc_lib.ip_range('2.0.0.2', 2, 100)
    loc_lib.bgp_router_id()
    loc_lib.redistribute_routes()
    st.log(
        'Configure BGP unnumbered sessions or 100 vlans between DUT1 and DUT2')
    for vlan in vlan_list_d1_d2:
        dict1 = {
            'addr_family': 'ipv6',
            'local_as': dut1_as,
            'remote_as': dut2_as,
            'config_type_list': ['remote-as', 'activate'],
            'interface': 'Vlan' + vlan,
            'neighbor': 'Vlan' + vlan
        }
        dict2 = {
            'addr_family': 'ipv6',
            'local_as': dut2_as,
            'remote_as': dut1_as,
            'config_type_list': ['remote-as', 'activate'],
            'interface': 'Vlan' + vlan,
            'neighbor': 'Vlan' + vlan
        }
        putils.exec_parallel(True, [data.dut1, data.dut2], bgp_obj.config_bgp,
                             [dict1, dict2])
    st.log('Configure IPv4 peer groups on DUT2 and DUT3')
    utils.exec_all(True, [[
        bgp_obj.create_bgp_peergroup, data.dut2, dut2_as, 'd2d3_v4_peer',
        dut3_as
    ],
                          [
                              bgp_obj.create_bgp_peergroup, data.dut3, dut3_as,
                              'd2d3_v4_peer', dut2_as
                          ]])
    st.log('Configure listen range on DUT2')
    bgp_obj.config_bgp_listen_range(dut=data.dut2,
                                    local_asn=dut2_as,
                                    neighbor_address='2.0.0.0',
                                    subnet=16,
                                    peer_grp_name='d2d3_v4_peer',
                                    limit=100,
                                    config='yes')
    st.log('Configure IPv4 and IPv6 BGP sessions on DUT2 and DUT3')
    st.log('Configure neighbors on DUT3')
    for ip in ip_list_dut2:
        bgp_obj.create_bgp_neighbor_use_peergroup(dut=data.dut3,
                                                  local_asn=dut3_as,
                                                  peer_grp_name='d2d3_v4_peer',
                                                  neighbor_ip=ip,
                                                  family="ipv4")
        bgp_obj.activate_bgp_neighbor(data.dut3,
                                      dut3_as,
                                      ip,
                                      'ipv4',
                                      remote_asn=dut2_as)
        bgp_obj.activate_bgp_neighbor(data.dut3,
                                      dut3_as,
                                      ip,
                                      'ipv6',
                                      remote_asn=dut2_as)

    st.log('Configure 100 BGP sessions with listen range')
    if not loc_lib.retry_api(bgp_obj.verify_bgp_summary,
                             data.dut2,
                             family='ipv4',
                             shell=bgp_cli_type,
                             neighbor=['Vlan2', '*' + ip_list_dut3[0]],
                             state='Established',
                             retry_count=10,
                             delay=15):
        st.error(
            "Failed to form BGP unnumbered session using IPv6 link local address over vlan"
        )
        result += 1
    ip_obj.show_ip_route(data.dut1, family="ipv4")
    if not loc_lib.retry_api(ip_obj.ping,
                             data.dut1,
                             addresses=dut3_tg_ip[0],
                             retry_count=10,
                             delay=10,
                             source_ip=dut1_tg_ip[0]):
        st.error('IPv4 Ping from DUT1 to DUT3 failed')
        result += 1
    aggrResult = loc_lib.send_verify_traffic()
    if not aggrResult:
        st.error(
            'IPv4 and IPv6 traffic over vlan with BGP unnumbered and Dynamic Discovery failed'
        )
        result += 1
    st.log("Reduce the limit and verify the neighbor is removed")
    bgp_obj.config_bgp_listen_range(dut=data.dut2, local_asn=dut2_as, limit=1)
    bgp_obj.clear_ip_bgp_vtysh(data.dut2, value="*")
    bgp_obj.config_bgp_listen_range(dut=data.dut2,
                                    local_asn=dut2_as,
                                    limit=100)
    bgp_obj.clear_ip_bgp_vtysh(data.dut2, value="*")
    st.wait(2)
    if not loc_lib.retry_api(bgp_obj.verify_bgp_summary,
                             data.dut2,
                             family='ipv4',
                             shell=bgp_cli_type,
                             neighbor=['Vlan2', '*' + ip_list_dut3[0]],
                             state='Established',
                             retry_count=10,
                             delay=15):
        st.error(
            "Failed to form BGP unnumbered session using IPv6 link local address over vlan"
        )
        result += 1
    if result == 0:
        st.report_tc_pass('FtOpSoRoAutoSc001', 'test_case_passed')
    else:
        st.report_tc_fail('FtOpSoRoAutoSc001', 'test_case_failed')

    if result == 0:
        st.report_tc_pass('FtOpSoRoAutoSc002', 'test_case_passed')
    else:
        st.report_tc_fail('FtOpSoRoAutoSc002', 'test_case_failed')

    if result == 0:
        st.report_pass('test_case_passed')
    else:
        st.report_fail('test_case_failed')
Ejemplo n.º 18
0
def test_ecmp_vxlan_func003():
    tc_list = ['FtOpSoRoLBFunc004', 'FtOpSoRoLBFunc008', 'FtOpSoRoLBFunc010']
    st.banner(
        "Testcase: Verify IPv4 and IPv6 ECMP Loadbalance and Hash polarization in VxLAN topology.\n TCs:{}."
        .format(tc_list))
    retvar = True
    fail_msgs = ''
    tc_res = {}
    for tc in tc_list:
        tc_res[tc] = True

    spine1 = data.dut1
    spine2 = data.dut2
    leaf1 = data.dut3
    leaf2 = data.dut4
    leaf3 = data.dut5
    vxlan_tolerance = 30

    st.banner("Step T1: Verify default show cli.")

    def f3_t1_1():
        res1 = ip.verify_ip_loadshare(spine1,
                                      ip=ecmpv4,
                                      ipv6=ecmpv6,
                                      seed=data.seed_def)
        if res1 is False:
            fail_msg = "ERROR: Step T1 Default show failed on spine1."
            st.log(fail_msg)
            return False
        return True

    def f3_t1_2():
        res1 = ip.verify_ip_loadshare(spine2,
                                      ip=ecmpv4,
                                      ipv6=ecmpv6,
                                      seed=data.seed_def)
        if res1 is False:
            fail_msg = "ERROR: Step T1 Default show failed on spine2."
            st.log(fail_msg)
            return False
        return True

    def f3_t1_3():
        res1 = ip.verify_ip_loadshare(leaf1,
                                      ip=ecmpv4,
                                      ipv6=ecmpv6,
                                      seed=data.seed_def)
        if res1 is False:
            fail_msg = "ERROR: Step T1 Default show failed on leaf1."
            st.log(fail_msg)
            return False
        return True

    def f3_t1_4():
        res1 = ip.verify_ip_loadshare(leaf2,
                                      ip=ecmpv4,
                                      ipv6=ecmpv6,
                                      seed=data.seed_def)
        if res1 is False:
            fail_msg = "ERROR: Step T1 Default show failed on leaf2."
            st.log(fail_msg)
            return False
        return True

    def f3_t1_5():
        res1 = ip.verify_ip_loadshare(leaf3,
                                      ip=ecmpv4,
                                      ipv6=ecmpv6,
                                      seed=data.seed_def)
        if res1 is False:
            fail_msg = "ERROR: Step T1 Default show failed on leaf3."
            st.log(fail_msg)
            return False
        return True

    [res, _] = utils.exec_all(
        True, [[f3_t1_1], [f3_t1_2], [f3_t1_3], [f3_t1_4], [f3_t1_5]])
    if False in set(res):
        fail_msg = "ERROR: Step T1 show cli for default values failed."
        fail_msgs += fail_msg
        st.log(fail_msg)
        tc_res[tc_list[0]] = False
        retvar = False
    '''
    st.log("Step T1a: Fine tuning the config and verification.")
    f3_f2_1=lambda x: intf.interface_shutdown(spine1, [vars.D1D3P2, vars.D1D4P2, vars.D1D5P2])
    f3_f2_2=lambda x: intf.interface_shutdown(spine2, [vars.D2D3P2, vars.D2D4P2, vars.D2D5P2])
    [res, _] = utils.exec_all(True, [[f3_f2_1, 1], [f3_f2_2, 1]])
    st.wait(waitvar)
    '''
    st.banner("Step T2: Start all IPv4 and IPv6 Streams.")
    tg_v4s = [tg_l3l1_1['stream_id']]
    tg_v6s = [tg_l3l1_6_1['stream_id']]
    tg_strs = tg_v4s + tg_v6s
    f3_f1_1 = lambda x: intf.clear_interface_counters(spine1)
    f3_f1_2 = lambda x: intf.clear_interface_counters(spine2)
    f3_f1_3 = lambda x: intf.clear_interface_counters(leaf1)
    f3_f1_4 = lambda x: intf.clear_interface_counters(leaf2)
    f3_f1_5 = lambda x: intf.clear_interface_counters(leaf3)
    [res, _] = utils.exec_all(
        True,
        [[f3_f1_1, 1], [f3_f1_2, 1], [f3_f1_3, 1], [f3_f1_4, 1], [f3_f1_5, 1]])
    tg.tg_traffic_control(action='clear_stats', port_handle=tg_all)
    res = tg.tg_traffic_control(action='run', handle=tg_strs)
    st.wait(waitvar)
    res = tg.tg_traffic_control(action='stop', handle=tg_strs)
    st.wait(waitvar / 2)

    st.banner("Step T3: Verify ECMP.")
    leaf_tg_ports = [[leaf1, vars.D3T1P1], [leaf1, vars.D3T1P2],
                     [leaf2, vars.D4T1P1], [leaf2, vars.D4T1P2]]
    l3_spine_ports = [[leaf3, vars.D5D1P1], [leaf3, vars.D5D1P2],
                      [leaf3, vars.D5D2P1], [leaf3, vars.D5D2P2]]
    spine_leaf_ports = [[spine1, vars.D1D3P1], [spine1, vars.D1D3P2],
                        [spine1, vars.D1D4P1], [spine1, vars.D1D4P2],
                        [spine2, vars.D2D3P1], [spine2, vars.D2D3P2],
                        [spine2, vars.D2D4P1], [spine2, vars.D2D4P2]]
    res1 = verify_intf_counters(rx=[[leaf3, vars.D5T1P1]],
                                tx=leaf_tg_ports,
                                ratio=[[1], [0.25, 0.25, 0.25, 0.25]],
                                clear_save=True,
                                tolerance=vxlan_tolerance)
    res2 = verify_intf_counters(rx=[[leaf3, vars.D5T1P1]],
                                tx=l3_spine_ports,
                                ratio=[[1], [0.25, 0.25, 0.25, 0.25]],
                                saved_flag=True,
                                tolerance=vxlan_tolerance)
    res3 = verify_intf_counters(
        rx=[[leaf3, vars.D5T1P1]],
        tx=spine_leaf_ports,
        ratio=[[1], [0.125, 0.125, 0.125, 0.125, 0.125, 0.125, 0.125, 0.125]],
        saved_flag=True,
        tolerance=vxlan_tolerance)
    st.log("Step T3: res1={}, res2={}, res3={} - all should be True".format(
        res1, res2, res3))
    if res1 is False or res2 is False or res3 is False:
        fail_msg = "ERROR: Step T3 Initial ECMP failed."
        fail_msgs += fail_msg
        st.log(fail_msg)
        tc_res[tc_list[0]] = tc_res[tc_list[1]] = False
        retvar = False
        gen_tech_supp(filename='f3_t3_')
        more_debugs(duts=dut_list)

    st.banner("Step T4: Remove dst-ip on leaf3, src-l4-port from other duts.")

    def f3_t4_1():
        ip.config_ip_loadshare_hash(spine1,
                                    key='ip',
                                    val=ecmpv4[3],
                                    config='no')
        ip.config_ip_loadshare_hash(spine1,
                                    key='ipv6',
                                    val=ecmpv6[3],
                                    config='no')
        res1 = ip.verify_ip_loadshare(spine1, ip=ecmpv4[3], ipv6=ecmpv6[3])
        if res1 is True:
            fail_msg = "ERROR: Step T4 show failed on spine1."
            st.log(fail_msg)
            return False
        return True

    def f3_t4_2():
        ip.config_ip_loadshare_hash(spine2,
                                    key='ip',
                                    val=ecmpv4[3],
                                    config='no')
        ip.config_ip_loadshare_hash(spine2,
                                    key='ipv6',
                                    val=ecmpv6[3],
                                    config='no')
        res1 = ip.verify_ip_loadshare(spine2, ip=ecmpv4[3], ipv6=ecmpv6[3])
        if res1 is True:
            fail_msg = "ERROR: Step T4 show failed on spine2."
            st.log(fail_msg)
            return False
        return True

    def f3_t4_3():
        ip.config_ip_loadshare_hash(leaf1,
                                    key='ip',
                                    val=ecmpv4[3],
                                    config='no')
        ip.config_ip_loadshare_hash(leaf1,
                                    key='ipv6',
                                    val=ecmpv6[3],
                                    config='no')
        res1 = ip.verify_ip_loadshare(leaf1, ip=ecmpv4[3], ipv6=ecmpv6[3])
        if res1 is True:
            fail_msg = "ERROR: Step T4 show failed on leaf1."
            st.log(fail_msg)
            return False
        return True

    def f3_t4_4():
        ip.config_ip_loadshare_hash(leaf2,
                                    key='ip',
                                    val=ecmpv4[3],
                                    config='no')
        ip.config_ip_loadshare_hash(leaf2,
                                    key='ipv6',
                                    val=ecmpv6[3],
                                    config='no')
        res1 = ip.verify_ip_loadshare(leaf2, ip=ecmpv4[3], ipv6=ecmpv6[3])
        if res1 is True:
            fail_msg = "ERROR: Step T4 show failed on leaf2."
            st.log(fail_msg)
            return False
        return True

    def f3_t4_5():
        ip.config_ip_loadshare_hash(leaf3,
                                    key='ip',
                                    val=ecmpv4[1],
                                    config='no')
        ip.config_ip_loadshare_hash(leaf3,
                                    key='ipv6',
                                    val=ecmpv6[1],
                                    config='no')
        res1 = ip.verify_ip_loadshare(leaf3, ip=ecmpv4[1], ipv6=ecmpv6[1])
        if res1 is True:
            fail_msg = "ERROR: Step T4 show failed on leaf3."
            st.log(fail_msg)
            return False
        return True

    [res, _] = utils.exec_all(
        True, [[f3_t4_1], [f3_t4_2], [f3_t4_3], [f3_t4_4], [f3_t4_5]])
    if False in set(res):
        fail_msg = "ERROR: Step T4 show cli failed."
        fail_msgs += fail_msg
        st.log(fail_msg)
        tc_res[tc_list[0]] = tc_res[tc_list[1]] = False
        retvar = False
    st.wait(waitvar, "Waiting for hardware programming to complete.")

    st.banner("Step T5: Start the Streams - IPv4.")
    [res, _] = utils.exec_all(
        True,
        [[f3_f1_1, 1], [f3_f1_2, 1], [f3_f1_3, 1], [f3_f1_4, 1], [f3_f1_5, 1]])
    tg.tg_traffic_control(action='clear_stats', port_handle=tg_all)
    res = tg.tg_traffic_control(action='run', handle=tg_v4s)
    st.wait(waitvar)
    res = tg.tg_traffic_control(action='stop', handle=tg_v4s)
    st.wait(waitvar / 2)

    st.banner("Step T6: Verify no ECMP at leaf1 and leaf2 - IPv4.")
    res1a = verify_intf_counters(rx=[[leaf3, vars.D5T1P1]],
                                 tx=leaf_tg_ports,
                                 ratio=[[1], [1, 0, 0, 0]],
                                 clear_save=True)
    res1b = verify_intf_counters(rx=[[leaf3, vars.D5T1P1]],
                                 tx=leaf_tg_ports,
                                 ratio=[[1], [0, 1, 0, 0]],
                                 saved_flag=True)
    res1c = verify_intf_counters(rx=[[leaf3, vars.D5T1P1]],
                                 tx=leaf_tg_ports,
                                 ratio=[[1], [0, 0, 1, 0]],
                                 saved_flag=True)
    res1d = verify_intf_counters(rx=[[leaf3, vars.D5T1P1]],
                                 tx=leaf_tg_ports,
                                 ratio=[[1], [0, 0, 0, 1]],
                                 saved_flag=True)
    st.log(
        "Step T6: tx11={}, tx12={}, tx21={}, tx22={} - only one of these should be True"
        .format(res1a, res1b, res1c, res1d))
    res1 = len([r for r in [res1a, res1b, res1c, res1d] if r is True])
    ratio_list = [[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]
    res2_list = []
    for r_l in ratio_list:
        res = verify_intf_counters(rx=[[leaf3, vars.D5T1P1]],
                                   tx=l3_spine_ports,
                                   ratio=[[1], r_l],
                                   saved_flag=True)
        res2_list.append(res)
    st.log(
        "Step T6: L3S1P1,L3S1P2,L3S2P1,L3S2P2={} - only one of these should be True"
        .format(res2_list))
    res2 = len([r for r in res2_list if r is True])
    ratio_list3 = [[1, 0, 0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0, 0, 0],
                   [0, 0, 1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0, 0],
                   [0, 0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 0, 0, 1, 0, 0],
                   [0, 0, 0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0, 0, 1]]
    res3_list = []
    for r_l in ratio_list3:
        res = verify_intf_counters(rx=[[leaf3, vars.D5T1P1]],
                                   tx=spine_leaf_ports,
                                   ratio=[[1], r_l],
                                   saved_flag=True)
        res3_list.append(res)
    st.log(
        "Step T6: S1L1P1,S1L1P2,S1L2P1,S1L2P2,S2L1P1,S2L1P2,S2L2P1,S2L2P2={} - only one of these should be True"
        .format(res3_list))
    res3 = len([r for r in res3_list if r is True])
    st.log("Step T8: res1={}, res2={}, res3={} - all should be 1".format(
        res1, res2, res3))
    if res1 != 1 or res2 != 1 or res3 != 1:
        st.log("Step T6: res1={}, res2={}, res3={} - all should be 1".format(
            res1, res2, res3))
        st.log(
            "Step T6: tx11={}, tx12={}, tx21={}, tx22={} - only one of these should be True"
            .format(res1a, res1b, res1c, res1d))
        st.log(
            "Step T6: L3S1P1,L3S1P2,L3S2P1,L3S2P2={} - only one of these should be True"
            .format(res2_list))
        st.log(
            "Step T6: S1L1P1,S1L1P2,S1L2P1,S1L2P2,S2L1P1,S2L1P2,S2L2P1,S2L2P2={} - only one of these should be True"
            .format(res3_list))
        fail_msg = "ERROR: Step T6 IPv4 - ECMP still working even after disabling."
        fail_msgs += fail_msg
        st.log(fail_msg)
        tc_res[tc_list[0]] = False
        retvar = False

    st.banner("Step T7: Start the Streams - IPv6.")
    [res, _] = utils.exec_all(
        True,
        [[f3_f1_1, 1], [f3_f1_2, 1], [f3_f1_3, 1], [f3_f1_4, 1], [f3_f1_5, 1]])
    tg.tg_traffic_control(action='clear_stats', port_handle=tg_all)
    res = tg.tg_traffic_control(action='run', handle=tg_v6s)
    st.wait(waitvar)
    res = tg.tg_traffic_control(action='stop', handle=tg_v6s)
    st.wait(waitvar / 2)

    st.banner("Step T8: Verify no ECMP at leaf1 and leaf2 - IPv6.")
    res1a = verify_intf_counters(rx=[[leaf3, vars.D5T1P1]],
                                 tx=leaf_tg_ports,
                                 ratio=[[1], [1, 0, 0, 0]],
                                 clear_save=True)
    res1b = verify_intf_counters(rx=[[leaf3, vars.D5T1P1]],
                                 tx=leaf_tg_ports,
                                 ratio=[[1], [0, 1, 0, 0]],
                                 saved_flag=True)
    res1c = verify_intf_counters(rx=[[leaf3, vars.D5T1P1]],
                                 tx=leaf_tg_ports,
                                 ratio=[[1], [0, 0, 1, 0]],
                                 saved_flag=True)
    res1d = verify_intf_counters(rx=[[leaf3, vars.D5T1P1]],
                                 tx=leaf_tg_ports,
                                 ratio=[[1], [0, 0, 0, 1]],
                                 saved_flag=True)
    st.log(
        "Step T8: tx11={}, tx12={}, tx21={}, tx22={} - only one of these should be True"
        .format(res1a, res1b, res1c, res1d))
    res1 = len([r for r in [res1a, res1b, res1c, res1d] if r is True])
    res2_list = []
    for r_l in ratio_list:
        res = verify_intf_counters(rx=[[leaf3, vars.D5T1P1]],
                                   tx=l3_spine_ports,
                                   ratio=[[1], r_l],
                                   saved_flag=True)
        res2_list.append(res)
    st.log(
        "Step T8: L3S1P1,L3S1P2,L3S2P1,L3S2P2={} - only one of these should be True"
        .format(res2_list))
    res2 = len([r for r in res2_list if r is True])
    res3_list = []
    for r_l in ratio_list3:
        res = verify_intf_counters(rx=[[leaf3, vars.D5T1P1]],
                                   tx=spine_leaf_ports,
                                   ratio=[[1], r_l],
                                   saved_flag=True)
        res3_list.append(res)
    st.log(
        "Step T8: S1L1P1,S1L1P2,S1L2P1,S1L2P2,S2L1P1,S2L1P2,S2L2P1,S2L2P2={} - only one of these should be True"
        .format(res3_list))
    res3 = len([r for r in res3_list if r is True])
    st.log("Step T8: res1={}, res2={}, res3={} - all should be 1".format(
        res1, res2, res3))
    if res1 != 1 or res2 != 1 or res3 != 1:
        st.log("Step T8: res1={}, res2={}, res3={} - all should be 1".format(
            res1, res2, res3))
        st.log(
            "Step T8: tx11={}, tx12={}, tx21={}, tx22={} - only one of these should be True"
            .format(res1a, res1b, res1c, res1d))
        st.log(
            "Step T8: L3S1P1,L3S1P2,L3S2P1,L3S2P2={} - only one of these should be True"
            .format(res2_list))
        st.log(
            "Step T8: S1L1P1,S1L1P2,S1L2P1,S1L2P2,S2L1P1,S2L1P2,S2L2P1,S2L2P2={} - only one of these should be True"
            .format(res3_list))
        fail_msg = "ERROR: Step T8 IPv6 - ECMP still working even after disabling."
        fail_msgs += fail_msg
        st.log(fail_msg)
        tc_res[tc_list[1]] = False
        retvar = False
    if retvar is False:
        gen_tech_supp(filename='f3_t8_')
        more_debugs(duts=dut_list)

    st.banner("Step T10: Reconfigure the ECMP params.")

    def f3_t10_1():
        ip.config_ip_loadshare_hash(spine1, key='ip', val=ecmpv4[3])
        ip.config_ip_loadshare_hash(spine1, key='ipv6', val=ecmpv6[3])
        res1 = ip.verify_ip_loadshare(spine1,
                                      ip=ecmpv4,
                                      ipv6=ecmpv6,
                                      seed=data.seed_def)
        if res1 is False:
            fail_msg = "ERROR: Step T10 show failed on spine1."
            st.log(fail_msg)
            return False
        return True

    def f3_t10_2():
        ip.config_ip_loadshare_hash(spine2, key='ip', val=ecmpv4[3])
        ip.config_ip_loadshare_hash(spine2, key='ipv6', val=ecmpv6[3])
        res1 = ip.verify_ip_loadshare(spine2,
                                      ip=ecmpv4,
                                      ipv6=ecmpv6,
                                      seed=data.seed_def)
        if res1 is False:
            fail_msg = "ERROR: Step T10 show failed on spine2."
            st.log(fail_msg)
            return False
        return True

    def f3_t10_3():
        ip.config_ip_loadshare_hash(leaf1, key='ip', val=ecmpv4[3])
        ip.config_ip_loadshare_hash(leaf1, key='ipv6', val=ecmpv6[3])
        res1 = ip.verify_ip_loadshare(leaf1,
                                      ip=ecmpv4,
                                      ipv6=ecmpv6,
                                      seed=data.seed_def)
        if res1 is False:
            fail_msg = "ERROR: Step T10 show failed on leaf1."
            st.log(fail_msg)
            return False
        return True

    def f3_t10_4():
        ip.config_ip_loadshare_hash(leaf2, key='ip', val=ecmpv4[3])
        ip.config_ip_loadshare_hash(leaf2, key='ipv6', val=ecmpv6[3])
        res1 = ip.verify_ip_loadshare(leaf2,
                                      ip=ecmpv4,
                                      ipv6=ecmpv6,
                                      seed=data.seed_def)
        if res1 is False:
            fail_msg = "ERROR: Step T10 show failed on leaf2."
            st.log(fail_msg)
            return False
        return True

    def f3_t10_5():
        ip.config_ip_loadshare_hash(leaf3, key='ip', val=ecmpv4[1])
        ip.config_ip_loadshare_hash(leaf3, key='ipv6', val=ecmpv6[1])
        res1 = ip.verify_ip_loadshare(leaf3,
                                      ip=ecmpv4,
                                      ipv6=ecmpv6,
                                      seed=data.seed_def)
        if res1 is False:
            fail_msg = "ERROR: Step T10 show failed on leaf3."
            st.log(fail_msg)
            return False
        return True

    [res, _] = utils.exec_all(
        True, [[f3_t10_1], [f3_t10_2], [f3_t10_3], [f3_t10_4], [f3_t10_5]])
    if False in set(res):
        fail_msg = "ERROR: Step T10 show cli failed."
        fail_msgs += fail_msg
        st.log(fail_msg)
        tc_res[tc_list[0]] = tc_res[tc_list[1]] = tc_res[tc_list[2]] = False
        retvar = False
    st.wait(waitvar, "Waiting for hardware programming to complete.")

    st.banner("Step T11: Start the Streams.")
    [res, _] = utils.exec_all(
        True,
        [[f3_f1_1, 1], [f3_f1_2, 1], [f3_f1_3, 1], [f3_f1_4, 1], [f3_f1_5, 1]])
    tg.tg_traffic_control(action='clear_stats', port_handle=tg_all)
    res = tg.tg_traffic_control(action='run', handle=tg_strs)
    st.wait(waitvar)
    res = tg.tg_traffic_control(action='stop', handle=tg_strs)
    st.wait(waitvar / 2)

    st.banner("Step T12: Verify ECMP is restored.")
    res1 = verify_intf_counters(rx=[[leaf3, vars.D5T1P1]],
                                tx=leaf_tg_ports,
                                ratio=[[1], [0.25, 0.25, 0.25, 0.25]],
                                clear_save=True,
                                tolerance=vxlan_tolerance)
    res2 = verify_intf_counters(rx=[[leaf3, vars.D5T1P1]],
                                tx=l3_spine_ports,
                                ratio=[[1], [0.25, 0.25, 0.25, 0.25]],
                                saved_flag=True,
                                tolerance=vxlan_tolerance)
    res3 = verify_intf_counters(
        rx=[[leaf3, vars.D5T1P1]],
        tx=spine_leaf_ports,
        ratio=[[1], [0.125, 0.125, 0.125, 0.125, 0.125, 0.125, 0.125, 0.125]],
        saved_flag=True,
        tolerance=vxlan_tolerance)
    st.log("Step T12: res1={}, res2={}, res3={} - all should be True".format(
        res1, res2, res3))
    if res1 is False or res2 is False or res3 is False:
        fail_msg = "ERROR: Step T12 ECMP restoration failed."
        fail_msgs += fail_msg
        st.log(fail_msg)
        tc_res[tc_list[0]] = tc_res[tc_list[1]] = tc_res[tc_list[2]] = False
        retvar = False
        gen_tech_supp(filename='f3_t12_')
        more_debugs(duts=dut_list)

    for tc in tc_list:
        if tc_res[tc]:
            st.report_tc_pass(tc, "tc_passed")

    if retvar is False:
        st.report_fail("test_case_failure_message", fail_msgs)

    st.report_pass("test_case_passed")
Ejemplo n.º 19
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)
Ejemplo n.º 20
0
def thread_call(thread_info, first_on_main=False):
    [out, exceptions] = utils.exec_all(eh_data.thread_mode,
                                       thread_info,
                                       first_on_main=first_on_main)
    st.log([out, exceptions])
Ejemplo n.º 21
0
def l3_ipv4v6_address_config_unconfig(config='yes',
                                      vrf_type='all',
                                      config_type='all'):
    """

    :param config:
    :param vrf_type:
    :param config_type:
    :return:
    """
    st.banner(
        "{}Configuring IP Addresses between linear topology nodes.".format(
            'Un' if config != 'yes' else ''))
    tb_vars = st.get_testbed_vars()
    st.log("TestBed Vars => {}\n".format(tb_vars))

    topo['dut_list'] = tb_vars.dut_list
    st.log("topo dut_list {}".format(topo['dut_list']))

    config = 'add' if config == 'yes' else 'remove'
    ipv4_adr = '11'
    ipv6_adr = '67fe'
    result = True
    k = 1

    i = 0
    while i < (len(topo['dut_list']) - 1):
        dut = topo['dut_list'][i]
        peer_dut = topo['dut_list'][i + 1]
        link = 1
        for local, _, remote in st.get_dut_links(dut, peer_dut):
            if config_type == 'ipv4' or config_type == 'all':
                ipaddr1 = "{}.{}.0.1".format(ipv4_adr, k)
                ipaddr2 = "{}.{}.0.2".format(ipv4_adr, k)
                topo['D{}D{}P{}'.format(i + 1, i + 2, link)] = local
                topo['D{}D{}P{}_ipv4'.format(i + 1, i + 2, link)] = ipaddr1
                topo['D{}D{}P{}_neigh_ipv4'.format(i + 1, i + 2,
                                                   link)] = ipaddr2
                topo['D{}D{}P{}'.format(i + 2, i + 1, link)] = remote
                topo['D{}D{}P{}_ipv4'.format(i + 2, i + 1, link)] = ipaddr2
                topo['D{}D{}P{}_neigh_ipv4'.format(i + 2, i + 1,
                                                   link)] = ipaddr1
                [out, exceptions] = utils.exec_all(
                    bgplib.fast_start,
                    [[
                        ipapi.config_ip_addr_interface, dut, local, ipaddr1,
                        '24', "ipv4", config
                    ],
                     [
                         ipapi.config_ip_addr_interface, peer_dut, remote,
                         ipaddr2, '24', "ipv4", config
                     ]])
                st.log([out, exceptions])

            if config_type == 'ipv6' or config_type == 'all':
                ip6addr1 = "{}:{}::1".format(ipv6_adr, k)
                ip6addr2 = "{}:{}::2".format(ipv6_adr, k)
                topo['D{}D{}P{}'.format(i + 1, i + 2, link)] = local
                topo['D{}D{}P{}_ipv6'.format(i + 1, i + 2, link)] = ip6addr1
                topo['D{}D{}P{}_neigh_ipv6'.format(i + 1, i + 2,
                                                   link)] = ip6addr2
                topo['D{}D{}P{}'.format(i + 2, i + 1, link)] = remote
                topo['D{}D{}P{}_ipv6'.format(i + 2, i + 1, link)] = ip6addr2
                topo['D{}D{}P{}_neigh_ipv6'.format(i + 2, i + 1,
                                                   link)] = ip6addr1
                [out, exceptions] = utils.exec_all(
                    bgplib.fast_start,
                    [[
                        ipapi.config_ip_addr_interface, dut, local, ip6addr1,
                        '64', "ipv6", config
                    ],
                     [
                         ipapi.config_ip_addr_interface, peer_dut, remote,
                         ip6addr2, '64', "ipv6", config
                     ]])
                st.log([out, exceptions])
            link += 1
            break
        k += 1
        i += 1
    return result
Ejemplo n.º 22
0
def base_unconfig():
    ###############################################################################################################################

    st.log('######------Unconfigure static routes on 900 VRFs-----######')
    for vrf, dut1_as, dut2_as in zip(vrf_list[899:1000], dut1_as_scale[0:100],
                                     dut2_as_scale[0:100]):
        dict1 = {
            'vrf_name': vrf,
            'local_as': dut1_as,
            'config': 'no',
            'removeBGP': 'yes',
            'config_type_list': ['removeBGP']
        }
        dict2 = {
            'vrf_name': vrf,
            'local_as': dut2_as,
            'config': 'no',
            'removeBGP': 'yes',
            'config_type_list': ['removeBGP']
        }
        parallel.exec_parallel(True, [data.dut1, data.dut2],
                               bgp_api.config_bgp, [dict1, dict2])

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

    st.log('######------Unconfigure static routes on 900 VRFs-----######')
    dict1 = {
        'dest_list': data.tg_dut2_stream_start[0:425],
        'next_hop_list': data.dut2_dut1_ip_list[0:425],
        'vrf_list': vrf_list[0:425],
        'config': 'no'
    }
    dict2 = {
        'dest_list': data.tg_dut2_stream_start[0:425],
        'vrf_list': vrf_list[0:425],
        'config': 'no'
    }
    parallel.exec_parallel(True, [data.dut1, data.dut2], vrf_static_route,
                           [dict1, dict2])
    st.wait(30)

    st.log('######----- UnConfigure 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', 'remove'
        ],
         [
             ip_api.config_ip_addr_interface, data.dut2,
             data.dut2_tg1_ports[0], data.dut2_tg_host, '16', 'ipv4', 'remove'
         ]])

    dict1 = {
        'dest_list': data.tg_dut2_stream_start[425:899],
        'next_hop_list': data.dut2_dut1_ip_list[425:899],
        'vrf_list': vrf_list[425:899],
        'config': 'no'
    }
    dict2 = {
        'dest_list': data.tg_dut2_stream_start[425:899],
        'vrf_list': vrf_list[425:899],
        'config': 'no'
    }
    parallel.exec_parallel(True, [data.dut1, data.dut2], vrf_static_route,
                           [dict1, dict2])
    st.wait(30)

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

    st.log('###### ----- Laoding back the config_db file ------######')
    #cmd = 'cp /etc/sonic/default.json /etc/sonic/config_db.json'
    src_path = "/etc/sonic/default.json"
    dst_path = "/etc/sonic/config_db.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]])
    utils.exec_all(
        True, [[st.reboot, data.dut1, 'fast'], [st.reboot, data.dut2, 'fast']])

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

    host_config(config='no')
Ejemplo n.º 23
0
def exec_all(use_threads, entries, first_on_main=False):
    return base.exec_all(use_threads, entries, first_on_main)
Ejemplo n.º 24
0
def acl_v4_module_hooks(request):
    # initialize topology
    initialize_topology()

    # apply module configuration
    apply_module_configuration()

    acl_config1 = acl_data.acl_json_config_v4_l3_traffic
    add_port_to_acl_table(acl_config1, 'L3_IPV4_INGRESS', vars.D1T1P1)


    acl_config2 = acl_data.acl_json_config_v6_l3_traffic
    add_port_to_acl_table(acl_config2, 'L3_IPV6_INGRESS', vars.D2T1P1)


    # creating ACL tables and rules
    print_log('Creating ACL tables and rules')
    utils.exec_all(True, [
        utils.ExecAllFunc(acl_obj.apply_acl_config, vars.D1, acl_config1),
        utils.ExecAllFunc(acl_obj.apply_acl_config, vars.D2, acl_config2),
    ])

    # create streams
    data.mac1 = basic_obj.get_ifconfig_ether(vars.D1, vars.D1T1P1)
    data.mac2 = basic_obj.get_ifconfig_ether(vars.D2, vars.D2T1P1)
    print_log('Creating streams')
    create_streams("tg1", "tg2", acl_config1['ACL_RULE'], "L3_IPV4_INGRESS", \
                   mac_src="00:0a:01:00:00:01", mac_dst=data.mac1)
    create_streams("tg1", "tg2", acl_config2['ACL_RULE'], "L3_IPV6_EGRESS", \
                   mac_src="00:0a:01:00:00:01", mac_dst="00:0a:01:00:11:02")
    create_streams("tg2", "tg1", acl_config2['ACL_RULE'], "L3_IPV6_INGRESS", \
                   mac_src="00:0a:01:00:11:02", mac_dst=data.mac2)
    create_streams("tg2", "tg1", acl_config1['ACL_RULE'], "L3_IPV4_EGRESS", \
                   mac_src="00:0a:01:00:11:02", mac_dst="00:0a:01:00:00:01")
    print_log('Completed module configuration')

    st.log("Configuring ipv4 address on ixia connected interfaces and portchannels present on both the DUTs")
    ip_obj.config_ip_addr_interface(vars.D1, vars.D1T1P1, data.ipv4_address_D1, 24, family="ipv4", config='add')
    ip_obj.config_ip_addr_interface(vars.D2, vars.D2T1P1, data.ipv4_address_D2, 24, family="ipv4", config='add')
    ip_obj.config_ip_addr_interface(vars.D1, data.portChannelName, data.ipv4_portchannel_D1, 24, family="ipv4",
                                    config='add')
    ip_obj.config_ip_addr_interface(vars.D2, data.portChannelName, data.ipv4_portchannel_D2, 24, family="ipv4",
                                    config='add')

    st.log("Configuring ipv6 address on ixia connected interfaces and portchannels present on both the DUTs")
    ip_obj.config_ip_addr_interface(vars.D1, vars.D1T1P1, data.ipv6_address_D1, 64, family="ipv6", config='add')
    ip_obj.config_ip_addr_interface(vars.D2, vars.D2T1P1, data.ipv6_address_D2, 64, family="ipv6", config='add')
    ip_obj.config_ip_addr_interface(vars.D1, data.portChannelName, data.ipv6_portchannel_D1, 64, family="ipv6",
                                    config='add')
    ip_obj.config_ip_addr_interface(vars.D2, data.portChannelName, data.ipv6_portchannel_D2, 64, family="ipv6",
                                    config='add')

    st.log("configuring ipv4 static routes on both the DUTs")
    ip_obj.create_static_route(vars.D1, data.ipv4_portchannel_D2, data.ipv4_network_D2, shell="vtysh",
                               family="ipv4")
    ip_obj.create_static_route(vars.D2, data.ipv4_portchannel_D1, data.ipv4_network_D1, shell="vtysh",
                               family="ipv4")

    st.log("configuring ipv6 static routes on both the DUTs")
    ip_obj.create_static_route(vars.D1, data.ipv6_portchannel_D2, data.ipv6_network_D2, shell="vtysh",
                               family="ipv6")
    ip_obj.create_static_route(vars.D2, data.ipv6_portchannel_D1, data.ipv6_network_D1, shell="vtysh",
                               family="ipv6")

    st.log("configuring static arp entries")
    arp_obj.add_static_arp(vars.D1, "1.1.1.2", "00:0a:01:00:00:01", vars.D1T1P1)
    arp_obj.add_static_arp(vars.D2, "2.2.2.2", "00:0a:01:00:11:02", vars.D2T1P1)
    arp_obj.add_static_arp(vars.D2, "2.2.2.4", "00:0a:01:00:11:02", vars.D2T1P1)
    arp_obj.add_static_arp(vars.D1, "1.1.1.4", "00:0a:01:00:00:01", vars.D1T1P1)
    arp_obj.add_static_arp(vars.D2, "2.2.2.5", "00:0a:01:00:11:02", vars.D2T1P1)
    arp_obj.add_static_arp(vars.D1, "1.1.1.5", "00:0a:01:00:00:01", vars.D1T1P1)
    arp_obj.add_static_arp(vars.D2, "2.2.2.6", "00:0a:01:00:11:02", vars.D2T1P1)
    arp_obj.add_static_arp(vars.D1, "1.1.1.6", "00:0a:01:00:00:01", vars.D1T1P1)
    arp_obj.show_arp(vars.D1)
    arp_obj.show_arp(vars.D2)

    st.log("configuring static ndp entries")
    arp_obj.config_static_ndp(vars.D1, "1001::2", "00:0a:01:00:00:01", vars.D1T1P1, operation="add")
    arp_obj.config_static_ndp(vars.D2, "2001::2", "00:0a:01:00:11:02", vars.D2T1P1, operation="add")
    arp_obj.show_ndp(vars.D1)
    arp_obj.show_ndp(vars.D2)

    yield
    clear_module_configuration()
Ejemplo n.º 25
0
def test_udld_loops_normal_aggressive():
    '''
        Verify  UDLD Tx/Rx loops in normal mode with out PVST/RPVST
        Verify  UDLD Tx/Rx loops in aggressive mode with out PVST/RPVST
    '''
    tc_list = ['FtOpSoSwudldloopnormal001', 'FtOpSoSwudldloopaggressive001']
    print_log("START of TC:test_pvst_udld_normal_aggressive ==>Sub-Test:Verify UDLD functionality with PVST\n TCs:<{}>".format(tc_list), "HIGH")
    final_result = True
    tc_result1 = 0
    tc_result2 = 0
    #udld_global_fail = 0
    udld_mode_fail = 0
    udld_interface_normal_loop_fail = 0
    udld_interface_no_normal_loop_fail = 0
    udld_interface_aggressive_loop_fail = 0
    udld_interface_no_aggressive_loop_fail = 0
    udld_neighbor_fail = 0
    udld_neighbor_warm_reboot_norm_fail = 0
    ##########################################NORMAL MODE UDLD RX/TX loop TESTS START#######################################
    st.wait(5)
    print_log("Verify that the port from DUT1 to DUT2 should go down in Normal Mode with UDLD TX/RX loop...",'MED')
    udld_interfaces = [vars.D1D2P1]
    state = 'down'
    if verify_udld_port_status(udld_interfaces,dut1,state):
        print_log("The ports from DUT1 to DUT3 is going to down state verification PASSED", "HIGH")
    else:
        print_log("The ports from DUT1 to DUT3 is not going to down state verification FAILED", "HIGH")
        udld_interface_normal_loop_fail += 1
        tc_result1 += 1
        final_result = False

    ###Disable UDLD on Interfaces
    dict1 = {'intf': udld_int[dut1]['udld_int'],'udld_enable': 'no', 'config': 'no'}
    pll.exec_parallel(True,[dut1],udld.config_intf_udld, [dict1])

    ###Disable UDLD global
    dict1 = {'udld_enable': 'no', 'config': 'no'}
    pll.exec_parallel(True,[dut1],udld.config_udld_global, [dict1])

    ###do shut and no shut on DUt1 to DUT2
    udld_interfaces = [vars.D1D2P1]
    for udld_interface in udld_interfaces:
        intf.interface_operation(dut1, udld_interface , "shutdown")
        intf.interface_operation(dut1, udld_interface , "startup")
    st.wait(5)

    print_log("Verify that the port from DUT1 to DUT2 should go up in Normal Mode with UDLD TX/RX loop...",'MED')
    udld_interfaces = [vars.D1D2P1]
    state = 'up'
    if verify_udld_port_status(udld_interfaces,dut1,state):
        print_log("The ports from DUT1 to DUT2 is going to up state verification PASSED", "HIGH")
    else:
        print_log("The ports from DUT1 to DUT2 is not going to up state verification FAILED", "HIGH")
        udld_interface_no_normal_loop_fail += 1
        tc_result1 += 1
        final_result = False

    if tc_result1 > 0:
       st.report_tc_fail("FtOpSoSwudldloopnormal001", "UDLD_TX_RX_loop_Normal_Failed", "test_udld_loops_normal_aggressive")
    else:
       st.report_tc_pass("FtOpSoSwudldloopnormal001", "UDLD_TX_RX_loop_Normal_Passed", "test_udld_loops_normal_aggressive")

    ###Enable UDLD global
    dict1 = {'udld_enable': udld_global[dut1]['udld_enable'], 'config': udld_global[dut1]['config']}
    pll.exec_parallel(True,[dut1],udld.config_udld_global, [dict1])

    ###Enable UDLD on Interfaces
    dict1 = {'intf': udld_int[dut1]['udld_int'],'udld_enable': udld_int[dut1]['udld_enable'], 'config': udld_int[dut1]['config']}
    pll.exec_parallel(True,[dut1],udld.config_intf_udld, [dict1])

    ###Enable UDLD mode Aggressive
    print_log("Enable the UDLD Mode Agrgressive on All DUTs...", 'MED')
    dict1 = {'udld_mode': udld_global[dut1]['udld_enable'], 'config': udld_global[dut1]['config']}
    pll.exec_parallel(True,[dut1],udld.config_udld_mode, [dict1])

    ### Verify UDLD mode
    if verify_udld_mode('Aggressive'):
        print_log("UDLD Mode Aggressive verification PASSED", "HIGH")
    else:
        print_log("UDLD Mode Aggressive verification FAILED", "HIGH")
        udld_mode_fail += 1
        tc_result2 += 1
        final_result = False

    st.wait(2)
    print_log("Verify that the port from DUT1 to DUT2 should go down in Aggressive Mode with UDLD TX/RX loop...",'MED')
    udld_interfaces = [vars.D1D2P1]
    state = 'down'
    if verify_udld_port_status(udld_interfaces,dut1,state):
        print_log("The ports from DUT1 to DUT2 is going to down state verification PASSED", "HIGH")
    else:
        print_log("The ports from DUT1 to DUT2 is not going to down state verification FAILED", "HIGH")
        udld_interface_aggressive_loop_fail += 1
        tc_result2 += 1
        final_result = False

    ###Disable UDLD on Interfaces
    dict1 = {'intf': udld_int[dut1]['udld_int'],'udld_enable': 'no', 'config': 'no'}
    pll.exec_parallel(True,[dut1],udld.config_intf_udld, [dict1])

    ###Disable UDLD global
    dict1 = {'udld_enable': 'no', 'config': 'no'}
    pll.exec_parallel(True,[dut1],udld.config_udld_global, [dict1])

    ###do shut and no shut on DUt1 to DUT2
    udld_interfaces = [vars.D1D2P1]
    for udld_interface in udld_interfaces:
        intf.interface_operation(dut1, udld_interface , "shutdown")
        intf.interface_operation(dut1, udld_interface , "startup")
    st.wait(5)

    print_log("Verify that the port from DUT1 to DUT2 should go up in Aggressive Mode with UDLD TX/RX loop...",'MED')
    udld_interfaces = [vars.D1D2P1]
    state = 'up'
    if verify_udld_port_status(udld_interfaces,dut1,state):
        print_log("The ports from DUT1 to DUT2 is going to up state verification PASSED", "HIGH")
    else:
        print_log("The ports from DUT1 to DUT2 is not going to up state verification FAILED", "HIGH")
        udld_interface_no_aggressive_loop_fail += 1
        tc_result2 += 1
        final_result = False

    api_list = []
    api_list.append([vlan.delete_vlan_member, dut2, trunk_base_vlan, [vars.D2D3P1,vars.D2D3P2]])
    api_list.append([vlan.delete_vlan_member, dut3, trunk_base_vlan, [vars.D3D2P1,vars.D3D2P2]])
    utils.exec_all(True, api_list)

    ###Enable UDLD global
    dict1 = {'udld_enable': udld_global[dut1]['udld_enable'], 'config': udld_global[dut1]['config']}
    dict2 = {'udld_enable': udld_global[dut2]['udld_enable'], 'config': udld_global[dut2]['config']}
    pll.exec_parallel(True,dut_list,udld.config_udld_global, [dict1, dict2])

    ###Enable UDLD on Interfaces
    dict1 = {'intf': udld_int[dut1]['udld_int'],'udld_enable': udld_int[dut1]['udld_enable'], 'config': udld_int[dut1]['config']}
    dict2 = {'intf': udld_int[dut2]['udld_int'],'udld_enable': udld_int[dut2]['udld_enable'], 'config': udld_int[dut2]['config']}
    pll.exec_parallel(True,dut_list,udld.config_intf_udld, [dict1, dict2])
    st.wait(2)

    ####################PDB will REMOVE after suite completion
    #import pdb;pdb.set_trace()

    if verify_udld_neighbor(udld_neighbor):
        print_log("UDLD neighbor verification PASSED", "HIGH")
    else:
        print_log("UDLD neighbor verification FAILED", "HIGH")
        udld_neighbor_fail += 1
        tc_result2 += 1
        final_result = False

    print_log("Do Warm Reboot in Aggressive Mode...", 'MED')
    utils.exec_foreach(True, dut_reload, reboot_api.config_warm_restart, oper="enable")
    utils.exec_all(True, [[st.reboot, dut, "warm"] for dut in dut_reload])
    st.wait(10)
    if verify_udld_neighbor(udld_neighbor):
        print_log("UDLD neighbor in normal mode after cold reboot verification PASSED", "HIGH")
    else:
        print_log("UDLD neighbor in normal mode after cold reboot verification FAILED", "HIGH")
        udld_neighbor_warm_reboot_norm_fail += 1
        tc_result2 += 1
        final_result = False

    ###Disable UDLD on Interfaces
    dict1 = {'intf': udld_int[dut1]['udld_int'],'udld_enable': 'no', 'config': 'no'}
    dict2 = {'intf': udld_int[dut2]['udld_int'],'udld_enable': 'no', 'config': 'no'}
    pll.exec_parallel(True,dut_list,udld.config_intf_udld, [dict1, dict2])

    ###Disable UDLD global
    dict1 = {'udld_enable': 'no', 'config': 'no'}
    dict2 = {'udld_enable': 'no', 'config': 'no'}
    pll.exec_parallel(True,dut_list,udld.config_udld_global, [dict1, dict2])


    if tc_result2 > 0:
       st.report_tc_fail("FtOpSoSwudldloopaggressive001", "UDLD_TX_RX_loop_Aggressive_Failed", "test_udld_loops_normal_aggressive")
    else:
       st.report_tc_pass("FtOpSoSwudldloopaggressive001", "UDLD_TX_RX_loop_Aggressive_Passed", "test_udld_loops_normal_aggressive")

    if final_result:
        st.report_pass("test_case_passed")
    else:
        fail_msg = ''
        if udld_interface_normal_loop_fail > 0:
            fail_msg += 'UDLD loop port down Failed in Normal mode:'
        if udld_interface_no_normal_loop_fail > 0:
            fail_msg += 'UDLD no loop port up Failed in Normal mode:'
        if udld_mode_fail > 0:
            fail_msg += 'UDLD mode Aggressive config Failed:'
        if udld_interface_aggressive_loop_fail > 0:
            fail_msg += 'UDLD loop port down Failed in Aggressive mode:'
        if udld_interface_no_aggressive_loop_fail > 0:
            fail_msg += 'UDLD no loop port up Failed in Aggressive mode:'
        if udld_neighbor_fail > 0:
            fail_msg += 'UDLD neighbor Failed:'
        if udld_neighbor_warm_reboot_norm_fail > 0:
            fail_msg += 'UDLD neighbor Failed after warm reboot:'
        st.report_fail("test_case_failure_message", fail_msg.strip(':'))
Ejemplo n.º 26
0
def wred_module_hooks(request):
    # add things at the start of this module
    global vars
    vars = st.ensure_min_topology("D1T1:3")
    wred_data = wred_config.init_vars(vars, apply_wred=True)
    st.log('Creating WRED table')
    utils.exec_all(True, [
        utils.ExecAllFunc(apply_wred_ecn_config, vars.D1,
                          wred_data['wred_config_json'])
    ])

    st.log("Getting TG handlers")
    data.tg1, data.tg_ph_1 = tgapi.get_handle_byname("T1D1P1")
    data.tg2, data.tg_ph_2 = tgapi.get_handle_byname("T1D1P2")
    data.tg3, data.tg_ph_3 = tgapi.get_handle_byname("T1D1P3")
    data.tg = data.tg1

    st.log("Reset and clear statistics of TG ports")
    data.tg.tg_traffic_control(
        action='reset', port_handle=[data.tg_ph_1, data.tg_ph_2, data.tg_ph_3])
    data.tg.tg_traffic_control(
        action='clear_stats',
        port_handle=[data.tg_ph_1, data.tg_ph_2, data.tg_ph_3])
    st.log("Creating TG streams")
    data.streams = {}
    stream = data.tg.tg_traffic_config(port_handle=data.tg_ph_3,
                                       mode='create',
                                       length_mode='fixed',
                                       frame_size=64,
                                       pkts_per_burst=10,
                                       l2_encap='ethernet_ii_vlan',
                                       transmit_mode='single_burst',
                                       vlan_id=data.vlan,
                                       mac_src=data.dscp_dest_mac,
                                       mac_dst='00:0a:12:00:00:01',
                                       vlan="enable")
    data.streams['vlan_tagged_egress'] = stream['stream_id']
    stream = data.tg.tg_traffic_config(
        port_handle=data.tg_ph_1,
        mode='create',
        transmit_mode='continuous',
        length_mode='fixed',
        rate_percent=10,
        l2_encap='ethernet_ii_vlan',
        vlan_id=data.vlan,
        vlan="enable",
        mac_src=data.dscp_src1,
        mac_dst=data.dscp_dest_mac,
        l3_protocol='ipv4',
        ip_src_addr='1.1.1.1',
        ip_dst_addr='5.5.5.5',
        ip_dscp="8",
        high_speed_result_analysis=0,
        track_by='trackingenabled0 ipv4DefaultPhb0',
        ip_dscp_tracking=1)
    data.streams['dscp1'] = stream['stream_id']
    stream = data.tg.tg_traffic_config(
        port_handle=data.tg_ph_1,
        mode='create',
        transmit_mode='continuous',
        length_mode='fixed',
        rate_percent=10,
        l2_encap='ethernet_ii_vlan',
        vlan_id=data.vlan,
        vlan="enable",
        mac_src=data.dscp_src2,
        mac_dst=data.dscp_dest_mac,
        l3_protocol='ipv4',
        ip_src_addr='1.1.1.1',
        ip_dst_addr='5.5.5.5',
        ip_dscp="24",
        high_speed_result_analysis=0,
        track_by='trackingenabled0 ipv4DefaultPhb0',
        ip_dscp_tracking=1)
    data.streams['dscp2'] = stream['stream_id']
    yield
    #clearing WRED config
    qos_obj.clear_qos_config(vars.D1)
    vlan_obj.clear_vlan_configuration(vars.D1, thread=True)