def bgp_rst_prologue():
    global vars
    vars = st.ensure_min_topology("D1D2:4")
    st.banner("Routing interface configuration in both DUTs")
    [_, exceptions] = exec_all(
        True, [[dut1_routing_int_cfg, "add"], [dut2_routing_int_cfg, "add"]])
    ensure_no_exception(exceptions)
def ipv6_link_local_config(action="add"):
    if action == "add":
        st.log("Creating VLAN and participating interfaces ...")
        vlan_data = [{
            "dut": [vars.D1],
            "vlan_id": bgp_rst_data.vlan_id[0],
            "tagged": [vars.D1D2P2]
        }, {
            "dut": [vars.D2],
            "vlan_id": bgp_rst_data.vlan_id[0],
            "tagged": [vars.D2D1P2]
        }]
        create_vlan_and_add_members(vlan_data)
        st.log("Creating PortChannel and participating interfaces ...")
        config_portchannel(vars.D1, vars.D2, bgp_rst_data.portchannel_name,
                           [vars.D1D2P3, vars.D1D2P4],
                           [vars.D2D1P3, vars.D2D1P4])
        st.log("Enable IPV6 on physical interface on both the devices")
        [_, exceptions] = exec_all(True, [[config_interface_ip6_link_local, vars.D1, ["Vlan{}".format(bgp_rst_data.vlan_id[0]), bgp_rst_data.portchannel_name]], \
                                            [config_interface_ip6_link_local, vars.D2, ["Vlan{}".format(bgp_rst_data.vlan_id[0]), bgp_rst_data.portchannel_name]]])
        ensure_no_exception(exceptions)
    else:
        [_, exceptions] = exec_all(True, [
            [config_interface_ip6_link_local, vars.D1, [vars.D1D2P1, "Vlan{}".format(bgp_rst_data.vlan_id[0]), bgp_rst_data.portchannel_name], "disable"], \
            [config_interface_ip6_link_local, vars.D2, [vars.D2D1P1, "Vlan{}".format(bgp_rst_data.vlan_id[0]), bgp_rst_data.portchannel_name], "disable"]])
        ensure_no_exception(exceptions)
        clear_portchannel_configuration([vars.D1, vars.D2])
        clear_vlan_configuration([vars.D1, vars.D2])
def bgp_rst_epilogue():
    st.banner("Routing interface un-configuration in both DUTs")
    [_, exceptions] = exec_all(
        True, [[dut1_routing_int_cfg, "del"], [dut2_routing_int_cfg, "del"]])
    ensure_no_exception(exceptions)
    [_, exceptions] = exec_all(True, [[config_bgp_router_rst, vars.D1, bgp_rst_data.dut1_asn, "del"], \
                                      [config_bgp_router_rst, vars.D2, bgp_rst_data.dut2_asn, "del"]])
    ensure_no_exception(exceptions)
def verify_traffic_hashed_or_not(dut,
                                 port_list,
                                 pkts_per_port,
                                 traffic_loss_verify=False,
                                 rx_port='',
                                 tx_port='',
                                 dut2=''):
    if traffic_loss_verify is True:
        [output,
         exceptions] = exec_all(True,
                                [[intfobj.show_interface_counters_all, dut],
                                 [intfobj.show_interface_counters_all, dut2]])
        ensure_no_exception(exceptions)
        static_data.intf_counters_1, static_data.intf_counters_2 = output
    else:
        static_data.intf_counters_1 = intfobj.show_interface_counters_all(dut)
    static_data.intf_count_dict = {}
    for port in port_list:
        for counter_dict in static_data.intf_counters_1:
            if counter_dict['iface'] == port:
                try:
                    tx_ok_counter = counter_dict['tx_ok'].replace(',', '')
                    static_data.intf_count_dict[port] = int(
                        tx_ok_counter) if tx_ok_counter.isdigit() else 0
                except Exception:
                    st.report_fail('invalid_traffic_stats')
                if not (static_data.intf_count_dict[port] >= pkts_per_port):
                    intfobj.show_interface_counters_detailed(
                        vars.D1, vars.D1T1P1)
                    st.report_fail("traffic_not_hashed", dut)
    if traffic_loss_verify is True:
        for counter_dict in static_data.intf_counters_1:
            if counter_dict['iface'] == rx_port:
                try:
                    rx_ok_counter = counter_dict['rx_ok'].replace(',', '')
                    static_data.rx_traffic = int(
                        rx_ok_counter) if rx_ok_counter.isdigit() else 0
                except Exception:
                    st.report_fail('invalid_traffic_stats')
                break
        for counter_dict in static_data.intf_counters_2:
            if counter_dict['iface'] == tx_port:
                try:
                    tx_ok_counter = counter_dict['tx_ok'].replace(',', '')
                    static_data.tx_traffic = int(
                        tx_ok_counter) if tx_ok_counter.isdigit() else 0
                except Exception:
                    st.report_fail('invalid_traffic_stats')
                break
        if not (static_data.tx_traffic >= 0.95 * static_data.rx_traffic):
            st.log("data.tx_traffic:{}".format(static_data.tx_traffic))
            st.log("data.rx_traffic:{}".format(static_data.rx_traffic))
            intfobj.show_interface_counters_detailed(vars.D1, vars.D1T1P1)
            st.report_fail('traffic_loss_observed')
    return True
Beispiel #5
0
def vlan_module_hooks(request):
    global vars
    vars = st.ensure_min_topology("D1D2:2", "D1T1:2", "D2T1:2")
    sc_data.version_data = basic_obj.show_version(vars.D1)
    vlan_variables()
    if not st.is_feature_supported("vlan-range", vars.D1):
        sc_data.max_vlan = 100
    [_, exceptions] = exec_all(True, [[config_tg_stream], [vlan_module_prolog]], first_on_main=True)
    ensure_no_exception(exceptions)
    yield
    vlan.clear_vlan_configuration(st.get_dut_names(), thread=False)
Beispiel #6
0
def test_ft_system_verify_traffic_through_port_channel_during_fast_reboot():
    [output,
     exceptions] = exec_all(True,
                            [[
                                po_obj.verify_portchannel_member, vars.D1,
                                data.portchannel_name, data.members_dut1
                            ],
                             [
                                 po_obj.verify_portchannel_member, vars.D2,
                                 data.portchannel_name, data.members_dut2
                             ]])
    if False in output:
        st.report_fail('portchannel_member_verification_failed',
                       data.portchannel_name, vars.D1, data.members_dut1)
    ensure_no_exception(exceptions)
    exceptions = exec_all(True, [[
        vlan_obj.add_vlan_member, vars.D1, data.vlan, data.portchannel_name,
        True
    ],
                                 [
                                     vlan_obj.add_vlan_member, vars.D2,
                                     data.vlan, data.portchannel_name, True
                                 ]])[1]
    ensure_no_exception(exceptions)
    data.tg_handler["tg"].tg_traffic_config(
        mode='modify',
        stream_id=data.stream['stream_id'],
        transmit_mode='continuous',
        port_handle=data.tg_handler["tg_ph_1"])
    st.log("performing Config save")
    rb_obj.config_save(vars.D1)
    data.tg_handler["tg"].tg_traffic_control(
        action='clear_stats',
        port_handle=[data.tg_handler["tg_ph_1"], data.tg_handler["tg_ph_3"]])
    data.tg_handler["tg"].tg_traffic_control(
        action='run', stream_handle=data.stream['stream_id'])
    st.log("performing fast-reboot")
    st.reboot(vars.D1, 'fast')
    data.tg_handler["tg"].tg_traffic_control(
        action='stop', stream_handle=data.stream['stream_id'])
    loss_pkts_count = 26 * 100
    stats_tg1 = tgapi.get_traffic_stats(data.tg_handler["tg"],
                                        mode="aggregate",
                                        port_handle=data.tg_handler["tg_ph_1"])
    tx_pkts = stats_tg1.tx.total_packets
    stats_tg2 = tgapi.get_traffic_stats(data.tg_handler["tg"],
                                        mode="aggregate",
                                        port_handle=data.tg_handler["tg_ph_3"])
    rx_pkts = stats_tg2.rx.total_packets
    st.log("Traffic sent from TGEN: {}".format(tx_pkts))
    st.log("Traffic received on TGEN: {}".format(rx_pkts))
    if not loss_pkts_count > int(tx_pkts) - int(rx_pkts):
        st.report_fail('data_traffic_loss_during_fast_reboot')
    st.report_pass("test_case_passed")
def test_ft_verify_static_portchannel_with_l2_traffic():
    '''
    Author: Venkatesh Terli <*****@*****.**>
    Scenario - 3.1.2 Verify that l2 traffic is forwarded Through the Static Port Channel.
    '''
    st.log(
        'Scenario - 3.1.2 Verify that l2 traffic is forwarded Through the Static Port Channel.'
    )
    exceptions = exec_all(True,
                          [[intfobj.clear_interface_counters, vars.D1],
                           [intfobj.clear_interface_counters, vars.D2]])[1]
    ensure_no_exception(exceptions)
    static_data.tg.tg_traffic_control(
        action='run',
        stream_handle=[
            static_data.streams['D1T1_SD_Mac_Hash1'],
            static_data.streams['D2T1_SD_Mac_Hash1']
        ])
    st.wait(5)
    static_data.tg.tg_traffic_control(
        action='stop',
        stream_handle=[
            static_data.streams['D1T1_SD_Mac_Hash1'],
            static_data.streams['D2T1_SD_Mac_Hash1']
        ])

    verify_traffic_hashed_or_not(
        vars.D1, [vars.D1D2P1, vars.D1D2P2, vars.D1D2P3, vars.D1D2P4],
        20,
        traffic_loss_verify=True,
        rx_port=vars.D1T1P1,
        tx_port=vars.D2T1P1,
        dut2=vars.D2)
    verify_traffic_hashed_or_not(
        vars.D2, [vars.D2D1P1, vars.D2D1P2, vars.D2D1P3, vars.D2D1P4],
        20,
        traffic_loss_verify=True,
        rx_port=vars.D2T1P1,
        tx_port=vars.D1T1P1,
        dut2=vars.D1)
    [output, exceptions] = exec_all(
        True,
        [[get_mac_address_count, vars.D1, None, static_data.portchannel_name],
         [get_mac_address_count, vars.D2, None, static_data.portchannel_name]])

    ensure_no_exception(exceptions)
    mac_count1, mac_count2 = output
    if int(mac_count1) < 100:
        st.report_fail('traffic_verification_fail', vars.D1)
    if int(mac_count2) < 100:
        st.report_fail('traffic_verification_fail', vars.D2)
    st.log('verified that traffic is successfully passing')
    st.report_pass('portchannel_l2_forwarding_success')
Beispiel #8
0
def dut_vlan_config():
    st.log("creating vlan and participating TGEN ports")
    data.vlan = str(random_vlan_list()[0])
    exceptions = exec_all(True,
                          [[vlan_obj.create_vlan, vars.D1, data.vlan],
                           [vlan_obj.create_vlan, vars.D2, data.vlan]])[1]
    ensure_no_exception(exceptions)
    exceptions = exec_all(True, [[
        vlan_obj.add_vlan_member, vars.D1, data.vlan,
        [vars.D1T1P1, vars.D1T1P2], True
    ], [vlan_obj.add_vlan_member, vars.D2, data.vlan, [vars.D2T1P1], True]])[1]
    ensure_no_exception(exceptions)
def bgp_rst_func_hooks(request):
    yield
    if st.get_func_name(request) == "test_ft_bgp_rst002":
        [_, exceptions] = exec_all(
            True, [[
                config_ip_addr_rst, vars.D1, bgp_rst_data.dut1_ip6_l[0],
                bgp_rst_data.ip6_pre_len, vars.D1D2P1, "ipv6", "del"
            ],
                   [
                       config_ip_addr_rst, vars.D2, bgp_rst_data.dut2_ip6_l[0],
                       bgp_rst_data.ip6_pre_len, vars.D2D1P1, "ipv6", "del"
                   ]])
        ensure_no_exception(exceptions)
Beispiel #10
0
def storm_control_module_hooks(request):
    global vars
    vars = st.ensure_min_topology("D1D2:2", "D1T1:2", "D2T1:2")
    sc_data.version_data = basic_obj.show_version(vars.D1)
    vlan_variables()
    [out, exceptions] = exec_all(True,
                                 [[config_tg_stream], [vlan_module_prolog]],
                                 first_on_main=True)
    ensure_no_exception(exceptions)
    yield
    vlan.clear_vlan_configuration(st.get_dut_names(),
                                  thread=False,
                                  cli_type="click")
Beispiel #11
0
def config_stp_root_bridge_by_vlan(stp_data):
    """
    :param stp_data: {dut1: {"vlan":10, "priority": "0"}, dut2: {"vlan":20, "priority": "0"}, dut3: {"vlan":30, "priority": "0"}}
    """
    params = list()
    for dut, data in stp_data.items():
        params.append(
            utility.ExecAllFunc(config_stp_vlan_parameters,
                                dut,
                                data["vlan"],
                                priority=data["priority"]))
    [out, exceptions] = exec_all(True, params)
    ensure_no_exception(exceptions)
Beispiel #12
0
def pvst_elastic_module_hooks(request):
    global vars
    vars = st.ensure_min_topology("D1D2:4", "D1T1:2", "D2T1:2")
    vlan_variables()
    vlan.clear_vlan_configuration(st.get_dut_names(), thread=False)
    [_, exceptions] = exec_all(True,
                               [[config_tg_stream], [looguard_module_prolog]],
                               first_on_main=True)
    ensure_no_exception(exceptions)
    yield
    stp.config_stp_in_parallel(sc_data.dut_list,
                               feature="rpvst",
                               mode="disable",
                               vlan=None)
    vlan.clear_vlan_configuration(st.get_dut_names(), thread=False)
def test_ft_bgp_rst001():
    #     """
    #     Validate the BGP IPv4 neighborship when configured through REST
    #     :return:
    #     """
    [out, exceptions] = exec_all(True, [[config_bgp_router_rst, vars.D1, bgp_rst_data.dut1_asn, "add"], \
                                      [config_bgp_router_rst, vars.D2, bgp_rst_data.dut2_asn, "add"]])
    ensure_no_exception(exceptions)
    for each in out:
        if not each:
            st.report_fail("bgp_router_create_delete", "Creation", "REST",
                           "FAILED")
    st.wait(5)
    dut1_data = {
        'neigh_ip': bgp_rst_data.dut2_ip_l[0],
        'local_asn': bgp_rst_data.dut1_asn,
        'remote_asn': bgp_rst_data.dut2_asn,
        'peer_type': "EXTERNAL",
        'family': "ipv4",
        'config': "add"
    }
    dut2_data = {
        'neigh_ip': bgp_rst_data.dut1_ip_l[0],
        'local_asn': bgp_rst_data.dut2_asn,
        'remote_asn': bgp_rst_data.dut1_asn,
        'peer_type': "EXTERNAL",
        'family': "ipv4",
        'config': "add"
    }
    exec_parallel(True, [vars.D1, vars.D2], config_bgp_neighbor_rst,
                  [dut1_data, dut2_data])
    for each in out:
        if not each:
            st.report_fail("bgp_neighbor_create_delete", "v4", "Creation",
                           "REST", "FAILED")
    if not poll_wait(verify_bgp_neighbor_rst, 60, vars.D1,
                     bgp_rst_data.dut2_ip_l[0]):
        st.report_fail("bgp_neighbor_create_delete", "v4", "Creation", "REST",
                       "FAILED")
    [out, exceptions] = exec_all(True, [[bgp_neighbor_del_rst, vars.D1, bgp_rst_data.dut2_ip_l[0]] , \
                                      [bgp_neighbor_del_rst, vars.D2, bgp_rst_data.dut1_ip_l[0]]])
    ensure_no_exception(exceptions)
    for each in out:
        if not each:
            st.report_fail("bgp_neighbor_create_delete", "v4", "Delrtion",
                           "REST", "FAILED")
    st.report_pass("bgp_neighbor_status", "v4", "Successful", "REST")
Beispiel #14
0
def clear_vlan_configuration(dut_list, thread=True, cli_type="click"):
    """
    Find and clear VLAN and its Members on list of DUTs
    Author : Prudvi Mangadu ([email protected])

    :param dut_list:
    :param thread: True(Default) / False
    :param cli_type:
    :return:
    """
    dut_li = list(dut_list) if isinstance(dut_list, list) else [dut_list]
    [out, exceptions] = exec_foreach(thread,
                                     dut_li,
                                     _clear_vlan_configuration_helper,
                                     cli_type=cli_type)
    ensure_no_exception(exceptions)
    return False if False in out else True
def test_ft_del_ip_assigned_portchannel():
    '''
    Author: Venkatesh Terli <*****@*****.**>
    Scenario - 3.2.2 Verify that deletion of a Static Port Channel with IP address is assigned on it is not Successful.
    '''
    st.log(
        'Scenario - 3.2.2 Verify that deletion of a Static Port Channel with IP address is assigned on it is not Successful.'
    )
    portchannelobj.delete_portchannel_member(vars.D1,
                                             static_data.portchannel_name,
                                             static_data.members_dut1)
    exceptions = exec_all(True, [
        ExecAllFunc(delete_vlan_member,
                    vars.D1,
                    static_data.vid,
                    static_data.portchannel_name,
                    tagging_mode=True),
        ExecAllFunc(delete_vlan_member,
                    vars.D2,
                    static_data.vid,
                    static_data.portchannel_name,
                    tagging_mode=True)
    ])[1]
    ensure_no_exception(exceptions)
    ipobj.config_ip_addr_interface(vars.D1, static_data.portchannel_name,
                                   static_data.ip41, static_data.ip_mask)

    result = portchannelobj.delete_portchannel(vars.D1,
                                               static_data.portchannel_name,
                                               skip_error=True)
    cli_type = st.get_ui_type(vars.D1)
    if cli_type == 'click':
        if result:
            st.report_fail(
                'msg',
                'Allowed to delete PortChannel which is configured with IP address'
            )
    else:
        if not result:
            st.report_fail(
                'msg',
                'Delete PortChannel which is configured with IP address is not allowed'
            )
    st.report_pass('portchannel_delete_with_ip_configured_portchannel')
def verify_traffic_hash(dut, port_list, pkts_per_port, traffic_loss_verify=False, rx_port = '',
                                 tx_port = '', dut2 =''):
    if traffic_loss_verify:
        sub_list = []
        sub_list.append([intf_obj.show_interface_counters_all, dut])
        sub_list.append([intf_obj.show_interface_counters_all, dut2])
        [output, exceptions] = utils.exec_all(True, sub_list)
        utils.ensure_no_exception(exceptions)
        data.int_cntr_1, data.int_cntr_2 = output
    else:
        data.int_cntr_1 = intf_obj.show_interface_counters_all(dut)
    data.intf_count_dict = {}
    for port in port_list:
        for counter_dict in iterable(data.int_cntr_1):
            if counter_dict['iface'] == port:
                try:
                    data.intf_count_dict[port] = int(counter_dict['tx_ok'].replace(',',''))
                except Exception:
                    st.report_fail('invalid_traffic_stats')
                if not (data.intf_count_dict[port] >= pkts_per_port):
                    intf_obj.show_interface_counters_detailed(vars.D1, vars.D1T1P1)
                    st.report_fail("traffic_not_hashed", dut)
    if traffic_loss_verify:
        for counter_dict in data.int_cntr_1:
            if counter_dict['iface'] == rx_port:
                try:
                    data.rx_traffic = int(counter_dict['rx_ok'].replace(',', ''))
                except Exception:
                    st.report_fail('invalid_traffic_stats')
                break
        for counter_dict in data.int_cntr_2:
            if counter_dict['iface'] == tx_port:
                try:
                    data.tx_traffic = int(counter_dict['tx_ok'].replace(',', ''))
                except Exception:
                    st.report_fail('invalid_traffic_stats')
                break
        if not (data.tx_traffic >= 0.95* data.rx_traffic):
            st.log("data.tx_traffic:{}".format(data.tx_traffic))
            st.log("data.rx_traffic:{}".format(data.rx_traffic))
            intf_obj.show_interface_counters_detailed(vars.D1, vars.D1T1P1)
            st.report_fail('traffic_loss_observed')
    return data.intf_count_dict
def scheduling_module_config(config='yes'):
    if config == 'yes':
        st.debug("Configuring MAC age out time")
        [output, exceptions] = exec_all(
            True, [[config_mac_agetime, vars.D1, scheduling_data.ageout_time],
                   [config_mac_agetime, vars.D2, scheduling_data.ageout_time]])
        ensure_no_exception(exceptions)
        if not all(output):
            st.report_fail("mac_aging_time_failed_config")
        st.debug("Verifying MAC age out time")
        [output, exceptions
         ] = exec_all(True,
                      [[get_mac_agetime, vars.D1], [get_mac_agetime, vars.D2]])
        ensure_no_exception(exceptions)
        if not ((int(output[0]) == scheduling_data.ageout_time) and
                (int(output[1]) == scheduling_data.ageout_time)):
            st.report_fail(
                "msg", "MAC age out time is not configured as: {}".format(
                    scheduling_data.ageout_time))
        st.debug("Create a vlan and add ports as tagged members to it")
        if not create_vlan_and_add_members(
            [{
                "dut": [vars.D1],
                "vlan_id": scheduling_data.vlan,
                "tagged": [vars.D1T1P1, vars.D1T1P2, vars.D1D2P1]
            }, {
                "dut": [vars.D2],
                "vlan_id": scheduling_data.vlan,
                "tagged": [vars.D2T1P1, vars.D2T1P2, vars.D2D1P1]
            }]):
            st.report_fail(
                "msg",
                "Failed to add port as tagged members of VLAN: {}".format(
                    scheduling_data.vlan))
    else:
        # clearing scheduling and vlan config
        clear_port_shaper(vars.D1,
                          port=vars.D1D2P1,
                          shaper_data=scheduling_data.policy_name,
                          qos_clear=True)
        clear_vlan_configuration([vars.D1, vars.D2], thread=True)
        scheduling_data.tg.tg_traffic_control(
            action='stop', stream_handle=scheduling_data.streams.values())
Beispiel #18
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)
def test_ft_verify_static_portchannel_funtionality_after_save_and_reboot():
    '''
    Author: Venkatesh Terli <*****@*****.**>
    Scenario - 3.3.1 Verify that the Static LAG configuration should be retained after save and reboot.
    '''
    st.log(
        'Scenario - 3.3.1 Verify that the Static LAG configuration should be retained after save and reboot.'
    )
    st.log("performing Config save and reboot")
    rbobj.config_save_reload([vars.D1, vars.D2])
    st.wait(10)
    exceptions = exec_all(True,
                          [[
                              portchannelobj.verify_portchannel_state, vars.D1,
                              static_data.portchannel_name, "up"
                          ],
                           [
                               portchannelobj.verify_portchannel_state,
                               vars.D2, static_data.portchannel_name, "up"
                           ]])[1]
    ensure_no_exception(exceptions)
    exceptions = exec_all(True,
                          [[intfobj.clear_interface_counters, vars.D1],
                           [intfobj.clear_interface_counters, vars.D2]])[1]
    ensure_no_exception(exceptions)
    static_data.tg.tg_traffic_control(
        action='run', stream_handle=[static_data.streams['D1T1_SD_Mac_Hash1']])
    st.wait(5)
    static_data.tg.tg_traffic_control(
        action='stop',
        stream_handle=[static_data.streams['D1T1_SD_Mac_Hash1']])
    verify_traffic_hashed_or_not(
        vars.D1, [vars.D1D2P1, vars.D1D2P2, vars.D1D2P3, vars.D1D2P4],
        20,
        traffic_loss_verify=True,
        rx_port=vars.D1T1P1,
        tx_port=vars.D2T1P1,
        dut2=vars.D2)
    st.report_pass('portchannel_functionality_after_save_and_reboot')
def test_ft_bgp_rst005():
    dut1_data = {
        'neigh_ip': bgp_rst_data.portchannel_name,
        'local_asn': bgp_rst_data.dut1_asn,
        'remote_asn': bgp_rst_data.dut2_asn,
        'peer_type': "EXTERNAL",
        'family': "ipv6",
        'config': "add"
    }
    dut2_data = {
        'neigh_ip': bgp_rst_data.portchannel_name,
        'local_asn': bgp_rst_data.dut2_asn,
        'remote_asn': bgp_rst_data.dut1_asn,
        'peer_type': "EXTERNAL",
        'family': "ipv6",
        'config': "add"
    }
    [out, exceptions] = exec_parallel(True, [vars.D1, vars.D2],
                                      config_bgp_neighbor_rst,
                                      [dut1_data, dut2_data])
    ensure_no_exception(exceptions)
    for each in out:
        if not each:
            st.report_fail("bgp_neighbor_create_delete", "v6", "Creation",
                           "REST", "FAILED")
    if not poll_wait(verify_bgp_neighbor_rst, 60, vars.D1,
                     bgp_rst_data.portchannel_name):
        st.report_fail("bgp_neighbor_create_delete", "v6", "Creation", "REST",
                       "FAILED")
    [out, exceptions] = exec_all(True, [[bgp_neighbor_del_rst, vars.D1, bgp_rst_data.portchannel_name], \
                                        [bgp_neighbor_del_rst, vars.D2, bgp_rst_data.portchannel_name]])
    ensure_no_exception(exceptions)
    for each in out:
        if not each:
            st.report_fail("bgp_neighbor_create_delete", "v6", "Delrtion",
                           "REST", "FAILED")
    st.report_pass("bgp_neighbor_status", "v6", "Successful", "REST")
def static_port_channel_dut_config():
    static_data.dut1_rt_int_mac = get_ifconfig_ether(vars.D1, vars.D1T1P1)
    static_data.members_dut1 = [
        vars.D1D2P1, vars.D1D2P2, vars.D1D2P3, vars.D1D2P4
    ]
    static_data.members_dut2 = [
        vars.D2D1P1, vars.D2D1P2, vars.D2D1P3, vars.D2D1P4
    ]
    st.log('Creating port-channel and adding members in both DUTs')
    dict1 = {
        'portchannel_list': [static_data.portchannel_name],
        'static': True
    }
    dict2 = {
        'portchannel_list': [static_data.portchannel_name],
        'static': True
    }
    exceptions = exec_parallel(True, [vars.D1, vars.D2],
                               portchannelobj.create_portchannel,
                               [dict1, dict2])[1]
    ensure_no_exception(exceptions)
    dict1 = {
        'portchannel': static_data.portchannel_name,
        'members': static_data.members_dut1
    }
    dict2 = {
        'portchannel': static_data.portchannel_name,
        'members': static_data.members_dut2
    }
    exceptions = exec_parallel(True, [vars.D1, vars.D2],
                               portchannelobj.add_del_portchannel_member,
                               [dict1, dict2])[1]
    ensure_no_exception(exceptions)
    st.log('Creating random VLAN in both the DUTs')
    exceptions = exec_all(True, [[create_vlan, vars.D1, static_data.vid],
                                 [create_vlan, vars.D2, static_data.vid]])[1]
    ensure_no_exception(exceptions)
    st.log(
        'Adding Port-Channel and TGen connected ports as tagged members to the random VLAN'
    )
    exceptions = \
        exec_all(True, [[add_vlan_member, vars.D1, static_data.vid, [static_data.portchannel_name, vars.D1T1P1], True],
                        [add_vlan_member, vars.D2, static_data.vid, [static_data.portchannel_name, vars.D2T1P1], True]])[1]
    ensure_no_exception(exceptions)
def test_ft_qos_scheduling_functionality():
    '''
     Author: Sai Durga <*****@*****.**>
	 This test script covers below scenarios

     FtOpSoQsDwrrFn001: Verify that traffic is forwarded based on the ratio calculated with configured weight when scheduling is enabled on egress port when congestion is happened

    Setup:
    =======
    2 TGen(IX1 and IX2)====DUT1-----DUT2=====2 TGen(IX3 and IX4)

    Procedure:
    ============
    1) Create a VLAN 555 in both the devices and include all the TGen and back to back interfaces to the VLAN
    2) Create a DWRR profiles with weights 50 and 40 and apply them on back to back interface on 1st device with queus 5 and 2
    3) Learn the MAC entries of 2 TGen connected ports on DUT2
    4) Start sending traffic from IX1 to IX3 and IX2 to IX4 with VLAN user priority 5 and 2 respectively

    Expected Result:
    ================
    1) Verify that VLAN created and all the ports included in that VLAN
    2) VLAN that strict priority is applied
    3) Verify that FDB table updated with the MAC entries
    4) Verify that traffic is forwarded  based on the ratio calsulated with configured weight

    In this case 55.5% IX1 and 44.5% from IX2

	 FtOpSoQsStPrFn001 : Verify that traffic is forwarded from highest prority queue when strict priority and DWRR is enabled on egress port when congestion is happened

    Setup:
    =======
    2 TGen(IX1 and IX2)====DUT1-----DUT2=====2 TGen(IX3 and IX4)

    Procedure:
    ============
    1) Create a VLAN 555 in both the devices and include all the TGen and back to back interfaces to the VLAN
    2) Create a strict priority profilewith one strict and weight 40(DWRR) and apply them on back to back interface on 1st device with queus 1 and 3 respectively
    3) Learn the MAC entries of 2 TGen connected ports on DUT2
    4) Start sending traffic from IX1 to IX3 and IX2 to IX4 with VLAN user priority 1 and 2 respectively

    Expected Result:
    ================
    1) Verify that VLAN created and all the ports included in that VLAN
    2) VLAN that strict priority is applied
    3) Verify that FDB table updated with the MAC entries
    4) Verify that traffic is forwarded from highest priority queue i.e., from IX1 to IX3 and also verify that IX4 receives very mimimal traffic or 0 traffic from IX2
    '''
    st.debug(
        "Applying and verifying DWRR and strict config reflecting in running config or not"
    )
    if not apply_queue_shcheduling_config(vars.D1,
                                          scheduling_data.json_content):
        get_debug_info()
        st.report_fail("msg", "Failed to configure scheduler")
    if not sconf_obj.verify_running_config(
            vars.D1, "SCHEDULER", "{}@{}".format(scheduling_data.policy_name,
                                                 scheduling_data.dwrr_queue2),
            "type", "DWRR"):
        get_debug_info()
        st.report_fail("content_not_found")
    if not sconf_obj.verify_running_config(
            vars.D1, "SCHEDULER", "{}@{}".format(scheduling_data.policy_name,
                                                 scheduling_data.strict_queue),
            "type", "STRICT"):
        get_debug_info()
        st.report_fail("content_not_found")
    mac_learning()
    exceptions = exec_all(True, [[clear_interface_counters, vars.D1],
                                 [clear_interface_counters, vars.D2]])[1]
    ensure_no_exception(exceptions)
    st.debug("Sending traffic from ingress ports")
    scheduling_data.tg.tg_traffic_control(
        action='run',
        stream_handle=[
            scheduling_data.streams['scheduling_port_dwrr_ingress1'],
            scheduling_data.streams['scheduling_port_dwrr_ingress2']
        ],
        enable_arp=0)
    if not sched_verify_queue_rate_ratio_dwrr(
            scheduling_data.dwrr_queue1,
            scheduling_data.get_percent(scheduling_data.weight_1),
            scheduling_data.dwrr_queue2,
            scheduling_data.get_percent(scheduling_data.weight_2)):
        get_debug_info()
        st.report_fail("msg", "Traffic is not schedules as configured")
    scheduling_data.tg.tg_traffic_control(
        action='stop', stream_handle=scheduling_data.streams.values())

    st.debug("Checking strict priority functionality")
    scheduling_data.tg.tg_traffic_config(
        mode='modify',
        stream_id=scheduling_data.streams['scheduling_port_dwrr_ingress1'],
        vlan_user_priority=scheduling_data.strict_queue)
    exceptions = exec_all(True, [[clear_interface_counters, vars.D1],
                                 [clear_interface_counters, vars.D2]])[1]
    ensure_no_exception(exceptions)
    st.debug("Sending traffic from ingress ports")
    scheduling_data.tg.tg_traffic_control(
        action='run',
        stream_handle=[
            scheduling_data.streams['scheduling_port_dwrr_ingress1'],
            scheduling_data.streams['scheduling_port_dwrr_ingress2']
        ],
        enable_arp=0)
    st.wait(5, "Sending traffic for 5 seconds")
    scheduling_data.tg.tg_traffic_control(
        action='stop', stream_handle=scheduling_data.streams.values())
    st.wait(2, "Waiting to stabilize the interface counters")
    [output, exceptions] = exec_all(True,
                                    [[show_interface_counters_all, vars.D1],
                                     [show_interface_counters_all, vars.D2]])
    ensure_no_exception(exceptions)
    if not all(output):
        get_debug_info()
        st.report_fail("msg", "Failed to get interface counters")
    dut1_counters, dut2_counters = output
    ingress_rx_cnt = filter_and_select(dut1_counters, ['rx_ok'],
                                       {'iface': vars.D1T1P1})
    egress_tx_cnt = filter_and_select(dut2_counters, ['tx_ok'],
                                      {'iface': vars.D2T1P1})
    if not (ingress_rx_cnt and egress_tx_cnt):
        get_debug_info()
        st.report_fail("msg", "Failed to get interface counters")
    ingress_rx_cnt = ingress_rx_cnt[0]['rx_ok']
    egress_tx_cnt = egress_tx_cnt[0]['tx_ok']
    if not ((0.99 * int(ingress_rx_cnt.replace(',', ''))) <= int(
            egress_tx_cnt.replace(',', ''))):
        st.debug("Traffic sent: {} and Traffic received: {}".format(
            ingress_rx_cnt.replace(',', ''), egress_tx_cnt.replace(',', '')))
        get_debug_info()
        st.report_fail("msg",
                       "Traffic is not scheduled as per strict priority")
    st.report_pass('test_case_passed')
def ipv6_link_local_pre_config():
    global vars
    vars = st.ensure_min_topology("D1D2:4", "D1T1:1", "D2T1:1")
    global tg_handler, tg1, tg2, tg_ph_1, tg_ph_2, tg_str_data, dut1_rt_int_mac, dut2_rt_int_mac, \
        tg_rt_int_handle, d1_prt_link_local, d2_prt_link_local, d1_int_ipv6_list, d2_int_ipv6_list
    tg_handler = util_tg_init(vars, [vars.T1D1P1, vars.T1D2P1])
    tg1 = tg_handler["tg"]
    tg2 = tg_handler["tg"]
    tg_ph_1 = tg_handler["tg_ph_1"]
    tg_ph_2 = tg_handler["tg_ph_2"]

    st.log("For debugging purpose, checking 'running config' before proceeding for module config")
    utils.exec_all(True, [[sc_obj.get_running_config, vars.D1], [sc_obj.get_running_config, vars.D2]])

    st.log("For debugging purpose, checking 'routing interfaces' before proceeding for module config")
    utils.exec_all(True, [[ip_obj.get_interface_ip_address, vars.D1, None, "ipv6"], [ip_obj.get_interface_ip_address, vars.D2, None, "ipv6"]])
    pc_obj.config_portchannel(vars.D1, vars.D2, data.prt_chnl, [vars.D1D2P3, vars.D1D2P4],
                              [vars.D2D1P3, vars.D2D1P4], config='add', thread=True)

    st.log("Vlan config")
    utils.exec_all(True, [[vlan_obj.create_vlan, vars.D1, [data.vlan_li[0], data.vlan_li[1]]],
                          [vlan_obj.create_vlan, vars.D2, [data.vlan_li[0], data.vlan_li[1]]]])
    utils.exec_all(True, [
        [vlan_mem_cfg, vars.D1, [[data.vlan_li[0], vars.D1D2P2, True], [data.vlan_li[1], vars.D1D2P2, True]]],
        [vlan_mem_cfg, vars.D2, [[data.vlan_li[0], vars.D2D1P2, True], [data.vlan_li[1], vars.D2D1P2, True]]]])
    st.log("VRF Config and binding 2nd vlan routing interface to that VRF")
    vrf_obj.config_vrf(vars.D1, vrf_name=data.vrf_name, config='yes')
    vrf_obj.bind_vrf_interface(vars.D1, vrf_name=data.vrf_name, intf_name=data.vlan_in_2, config='yes', skip_error=True)
    st.log("Enabling ipv6 link local")
    d1_int_ipv6_list =[vars.D1D2P1, data.vlan_in_1, data.vlan_in_2,data.prt_chnl]
    d2_int_ipv6_list = [vars.D2D1P1, data.vlan_in_1, data.vlan_in_2, data.prt_chnl]
    utils.exec_all(True, [[ip_obj.config_interface_ip6_link_local, vars.D1,d1_int_ipv6_list, 'enable'],
                          [ip_obj.config_interface_ip6_link_local, vars.D2,d2_int_ipv6_list, 'enable']])

    st.log("TG connected int ipv6 address config")
    utils.exec_all(True, [[ip_obj.config_ip_addr_interface, vars.D1, vars.D1T1P1, data.tgd_ip6_addr_l[0],
                           data.tg_ip6_addr_mask_l[0],"ipv6",'add'], [ip_obj.config_ip_addr_interface, vars.D2,
                                                                      vars.D2T1P1, data.tgd_ip6_addr_l[1],
                           data.tg_ip6_addr_mask_l[1],"ipv6",'add']])

    st.log("Get DUT mac address")
    [rt_int_mac, exceptions] = utils.exec_all(True, [[basic_obj.get_ifconfig_ether, vars.D1, vars.D1D2P1],
                                                     [basic_obj.get_ifconfig_ether, vars.D2, vars.D2D1P1]])
    utils.ensure_no_exception(exceptions)
    dut1_rt_int_mac = rt_int_mac[0]
    dut2_rt_int_mac = rt_int_mac[1]


    st.log("Get DUT link local addresses")
    [rt_link_local_addr, exceptions] = utils.exec_all(True, [[ip_obj.get_link_local_addresses, vars.D1, vars.D1D2P1],
                                                     [ip_obj.get_link_local_addresses, vars.D2, vars.D2D1P1]])
    utils.ensure_no_exception(exceptions)
    d1_prt_link_local = rt_link_local_addr[0]
    d2_prt_link_local = rt_link_local_addr[1]

    if not d1_prt_link_local or not d2_prt_link_local:
        st.log("DUT Link Local Address are empty")
        st.report_fail("link_local_address_not_found")

    st.log("Routing interface config in TG")
    tg_rt_int_handle = util_tg_routing_int_config(vars, tg1, tg2, tg_ph_1, tg_ph_2)

    st.log("Doing ping to the TG ipv6 address to resolve the next hop")
    utils.exec_all(True, [[ip_obj.ping, vars.D1, data.tgd_ip6_addr_l[0], 'ipv6'],[ip_obj.ping, vars.D2, data.tgd_ip6_addr_l[1], 'ipv6']])

    st.log("Get show ndp output")
    utils.exec_all(True, [[arp_obj.show_ndp, vars.D1, None],[arp_obj.show_ndp, vars.D2, None]])

    st.log("Static route config")
    utils.exec_all(True, [[ip_obj.create_static_route, vars.D1, d2_prt_link_local[0], data.static_rt, "vtysh", 'ipv6', vars.D1D2P1],
                          [ip_obj.create_static_route, vars.D2, data.tg_ip6_addr_l[1], data.static_rt, "vtysh", 'ipv6', vars.D2T1P1]])
    ip_obj.create_static_route(vars.D1, d2_prt_link_local[0], data.static_rt, "vtysh", 'ipv6', data.vlan_in_1)
    ip_obj.create_static_route(vars.D1, d2_prt_link_local[0], data.static_rt, "vtysh", 'ipv6', data.prt_chnl)
    ip_obj.create_static_route(vars.D1, d2_prt_link_local[0], data.static_rt, "vtysh", 'ipv6', data.vlan_in_2, vrf=data.vrf_name)
    st.log("Get show ipv6 route output")
    utils.exec_all(True, [[ip_obj.show_ip_route, vars.D1, "ipv6", "sonic", None],[ip_obj.show_ip_route, vars.D2, "ipv6", "sonic", None]])
    ip_obj.show_ip_route(vars.D1, "ipv6", "sonic", data.vrf_name)

    st.log("TG Stream config")
    tg_str_data = util_tg_stream_config(tg1, tg2, tg_ph_1, tg_ph_2)

    st.log("Clearing all interface counters for debugging purpose")
    utils.exec_all(True, [[intf_obj.clear_interface_counters, vars.D1], [intf_obj.clear_interface_counters, vars.D2]])
def portchannel_func_hooks(request):
    yield
    if st.get_func_name(
            request
    ) == 'test_ft_verify_static_portchannel_is_up_or_not_with_one_active_member':
        portchannelobj.add_del_portchannel_member(vars.D1,
                                                  static_data.portchannel_name,
                                                  static_data.members_dut1[1:])
    if st.get_func_name(
            request
    ) == 'test_ft_verify_static_portchannel_is_up_with_active_members_when_no_lag_in_partner':
        portchannelobj.create_portchannel(vars.D2,
                                          static_data.portchannel_name,
                                          static=True)
        portchannelobj.add_del_portchannel_member(vars.D2,
                                                  static_data.portchannel_name,
                                                  static_data.members_dut2)
        add_vlan_member(vars.D2,
                        static_data.vid,
                        static_data.portchannel_name,
                        tagging_mode=True)
    if st.get_func_name(
            request
    ) == 'test_ft_verify_fallback_is_configure_or_not_on_static_portchannel':
        if portchannelobj.get_portchannel(vars.D1,
                                          static_data.portchannel_name2):
            portchannelobj.delete_portchannel(vars.D1,
                                              static_data.portchannel_name2)
    if st.get_func_name(
            request
    ) == 'test_ft_verify_static_portchannel_del_from_ip_assigned_vlan':
        st.wait(2)
        ipobj.config_ip_addr_interface(vars.D1,
                                       'Vlan{}'.format(static_data.vid),
                                       static_data.ip41,
                                       static_data.ip_mask,
                                       config='remove')
        portchannelobj.add_del_portchannel_member(vars.D1,
                                                  static_data.portchannel_name,
                                                  static_data.members_dut1)
    if st.get_func_name(request) == 'test_ft_del_ip_assigned_portchannel':
        if not portchannelobj.get_portchannel(vars.D1,
                                              static_data.portchannel_name):
            portchannelobj.create_portchannel(vars.D1,
                                              static_data.portchannel_name,
                                              static=True)
        ipobj.delete_ip_interface(vars.D1,
                                  static_data.portchannel_name,
                                  static_data.ip41,
                                  static_data.ip_mask,
                                  skip_error=True)
        portchannelobj.add_del_portchannel_member(vars.D1,
                                                  static_data.portchannel_name,
                                                  static_data.members_dut1)
        exceptions = exec_all(True,
                              [[
                                  add_vlan_member, vars.D1, static_data.vid,
                                  static_data.portchannel_name, True
                              ],
                               [
                                   add_vlan_member, vars.D2, static_data.vid,
                                   static_data.portchannel_name, True
                               ]])[1]
        ensure_no_exception(exceptions)
    if st.get_func_name(
            request
    ) == 'test_ft_verify_static_portchannel_l3_hash_sip_dip_l4port':
        arpobj.delete_static_arp(vars.D2,
                                 static_data.ip42,
                                 interface=vars.D2T1P1,
                                 mac=static_data.remote_mac2)
        ipobj.clear_ip_configuration([vars.D1, vars.D2],
                                     family='ipv4',
                                     thread=True)
        exceptions = exec_all(
            True, [[
                add_vlan_member, vars.D1, static_data.vid,
                [static_data.portchannel_name, vars.D1T1P1], True
            ],
                   [
                       add_vlan_member, vars.D2, static_data.vid,
                       [static_data.portchannel_name, vars.D2T1P1], True
                   ]])[1]
        ensure_no_exception(exceptions)
    if st.get_func_name(
            request
    ) == 'test_ft_verify_static_portchannel_vlan_routing_l3_traffic':
        arpobj.delete_static_arp(vars.D2,
                                 static_data.ip42,
                                 interface=vars.D2T1P1,
                                 mac=static_data.remote_mac2)
        ipobj.clear_ip_configuration([vars.D1, vars.D2],
                                     family='ipv4',
                                     thread=True)
        exceptions = exec_all(True, [[
            add_vlan_member, vars.D1, static_data.vid, vars.D1T1P1, True
        ], [add_vlan_member, vars.D2, static_data.vid, vars.D2T1P1, True]])[1]
        ensure_no_exception(exceptions)
def test_ft_verify_static_portchannel_func_when_dis_en_mem_ports():
    '''
    Author: Venkatesh Terli <*****@*****.**>
    Scenario - 3.1.2 Verify that l2 traffic is forwarded Through the Static Port Channel.
    '''
    count = 0
    st.log(
        'Scenari - 3.1.5 Verify that traffic flow is fine through LAG after LAG member shut/no-shut.'
    )
    exceptions = exec_all(True,
                          [[intfobj.clear_interface_counters, vars.D1],
                           [intfobj.clear_interface_counters, vars.D2]])[1]
    ensure_no_exception(exceptions)
    st.wait(3)
    intfobj.interface_operation(vars.D1, vars.D1D2P1, operation="shutdown")
    st.wait(3)

    static_data.tg.tg_traffic_control(
        action='run',
        stream_handle=[
            static_data.streams['D1T1_SD_Mac_Hash1'],
            static_data.streams['D2T1_SD_Mac_Hash1']
        ])
    st.wait(3)
    intfobj.interface_operation(vars.D1, vars.D1D2P1, operation="startup")
    st.wait(3)
    if not intfobj.poll_for_interface_status(vars.D1,
                                             vars.D1D2P1,
                                             property='oper',
                                             value='up',
                                             iteration='2',
                                             delay=2):
        count += 1
        st.log("Interface is not UP after performing a Flap")
    portchannelobj.get_portchannel_members(
        vars.D1, portchannel=static_data.portchannel_name)
    static_data.tg.tg_traffic_control(
        action='stop',
        stream_handle=[
            static_data.streams['D1T1_SD_Mac_Hash1'],
            static_data.streams['D2T1_SD_Mac_Hash1']
        ])
    verify_traffic_hashed_or_not(
        vars.D1, [vars.D1D2P1, vars.D1D2P2, vars.D1D2P3, vars.D1D2P4],
        20,
        traffic_loss_verify=True,
        rx_port=vars.D1T1P1,
        tx_port=vars.D2T1P1,
        dut2=vars.D2)
    verify_traffic_hashed_or_not(
        vars.D2, [vars.D2D1P1, vars.D2D1P2, vars.D2D1P3, vars.D2D1P4],
        20,
        traffic_loss_verify=True,
        rx_port=vars.D2T1P1,
        tx_port=vars.D1T1P1,
        dut2=vars.D1)

    if count == 0:
        st.report_pass('portchannel_member_en_dis_success')
    else:
        st.report_fail('portchannel_member_en_dis_failed')
def test_ft_verify_static_portchannel_funtionality_during_warm_reboot():
    '''
    Author: Venkatesh Terli <*****@*****.**>
    Scenario - 3.3.2 Verify that port-channel is up and no traffic loss is observed during and after warm reboot.
    '''
    st.log(
        'Scenario - 3.3.2 Verify that port-channel is up and no traffic loss is observed during and after warm reboot.'
    )
    static_data.tg.tg_traffic_control(action='reset',
                                      port_handle=static_data.tg_ph_1)
    stream = static_data.tg.tg_traffic_config(port_handle=static_data.tg_ph_1,
                                              mode='create',
                                              length_mode='fixed',
                                              frame_size=72,
                                              mac_src='00:00:01:00:00:01',
                                              mac_src_step='00:00:00:00:00:01',
                                              mac_src_mode='increment',
                                              mac_src_count=1000,
                                              mac_dst='00:00:02:00:00:02',
                                              mac_dst_step='00:00:00:00:00:01',
                                              mac_dst_mode='increment',
                                              mac_dst_count=1000,
                                              rate_percent=100,
                                              l2_encap='ethernet_ii_vlan',
                                              vlan="enable",
                                              vlan_id=static_data.vid,
                                              transmit_mode='continuous')
    static_data.streams['D1T1_SD_Mac_Hash1'] = stream['stream_id']

    st.log("performing Config save")
    exceptions = exec_all(
        True, [[rbobj.config_save, vars.D1], [rbobj.config_save, vars.D2]])[1]
    ensure_no_exception(exceptions)
    st.reboot(vars.D2, 'warm')
    st.wait(10)
    exceptions = exec_all(True,
                          [[
                              portchannelobj.verify_portchannel_state, vars.D1,
                              static_data.portchannel_name, "up"
                          ],
                           [
                               portchannelobj.verify_portchannel_state,
                               vars.D2, static_data.portchannel_name, "up"
                           ]])[1]
    ensure_no_exception(exceptions)

    exceptions = exec_all(True,
                          [[intfobj.clear_interface_counters, vars.D1],
                           [intfobj.clear_interface_counters, vars.D2]])[1]
    ensure_no_exception(exceptions)
    static_data.tg.tg_traffic_control(
        action='run', stream_handle=[static_data.streams['D1T1_SD_Mac_Hash1']])
    st.wait(5)
    static_data.tg.tg_traffic_control(
        action='stop',
        stream_handle=[static_data.streams['D1T1_SD_Mac_Hash1']])
    if not verify_traffic_hashed_or_not(
            vars.D1, [vars.D1D2P1, vars.D1D2P2, vars.D1D2P3, vars.D1D2P4],
            20,
            traffic_loss_verify=True,
            rx_port=vars.D1T1P1,
            tx_port=vars.D2T1P1,
            dut2=vars.D2):
        st.report_fail('portchannel_functionality_during_warmreboot_failed')
    else:
        st.report_pass('portchannel_functionality_during_warmreboot')
Beispiel #27
0
def test_ft_control_plane_acl_icmp():
    result = True
    [output, exceptions] = parallel.exec_all(
        True, [[st.get_mgmt_ip, vars.D1], [st.get_mgmt_ip, vars.D2]])
    parallel.ensure_no_exception(exceptions)
    d1_ipaddress, d2_ipaddress = output
    d1_ipv6address = ip_obj.get_link_local_addresses(
        vars.D1, "eth0", cli_type='click'
    )  ##Passing parameter cli_type as click until the SONIC-32291 fixed
    if not d1_ipv6address:
        st.report_fail('dut_not_getting_ip_address')
    d1_ipv6address = d1_ipv6address[0]
    st.log("Creating acl rules to drop icmp packets")
    acl_config = acl_data.acl_json_config_control_plane_v2
    st.log("ACL_DATA: {}".format(acl_config))
    acl_obj.apply_acl_config(vars.D1, acl_config)
    acl_obj.show_acl_table(vars.D1)
    acl_obj.show_acl_rule(vars.D1)
    if ip_obj.ping(dut=vars.D2, addresses=d1_ipaddress):
        st.error(
            "ICMP ipv4 packets are not dropped with applied control plane acl rules."
        )
        result = False
        st.report_tc_fail("ft_controlplane_acl_ipv4_icmp", "test_case_failed")
    if ip_obj.ping(dut=vars.D1,
                   addresses=d1_ipv6address,
                   interface="eth0",
                   family="ipv6"):
        st.error(
            "ICMP ipv6 packets are not dropped with applied control plane acl rules."
        )
        result = False
        st.report_tc_fail("ft_controlplane_acl_ipv6_icmp", "test_case_failed")
    change_acl_rules(acl_config, "L3_IPV4_ICMP|rule1", "SRC_IP",
                     "{}/32".format(d2_ipaddress))
    change_acl_rules(acl_config, "L3_IPV6_ICMP|rule1", "SRC_IPV6",
                     "{}/128".format(d1_ipv6address))
    acl_obj.acl_delete(vars.D1)
    acl_obj.apply_acl_config(vars.D1, acl_config)
    if not ip_obj.ping(dut=vars.D2, addresses=d1_ipaddress):
        st.error(
            "ICMP ipv4 packets are dropped with applied control plane acl rules."
        )
        result = False
        st.report_tc_fail("ft_controlplane_acl_seq_priority",
                          "test_case_failed")
        st.report_tc_fail("ft_controlplane_acl_ipv4_icmp_permit",
                          "test_case_failed")
    if not ip_obj.ping(
            dut=vars.D1, addresses=d1_ipv6address, interface="eth0",
            family="ipv6"):
        st.error(
            "ICMP ipv6 packets are dropped with applied control plane acl rules."
        )
        result = False
        st.report_tc_fail("ft_controlplane_acl_ipv6_icmp_permit",
                          "test_case_failed")
    config_save(vars.D1)
    st.log('rebooting the device.')
    st.reboot(vars.D1, 'fast')
    if not ip_obj.ping(dut=vars.D2, addresses=d1_ipaddress):
        st.error(
            "control plane ipv4 acl functionality is failed after reboot.")
        st.report_tc_fail("ft_controlplane_acl_reboot", "test_case_failed")
        result = False
    if not ip_obj.ping(
            dut=vars.D1, addresses=d1_ipv6address, interface="eth0",
            family="ipv6"):
        st.error(
            "control plane ipv6 acl functionality is failed after reboot.")
        st.report_tc_fail("ft_controlplane_acl_reboot", "test_case_failed")
        result = False
    if not result:
        st.report_fail("test_case_failed")
    else:
        st.report_pass("test_case_passed")
def test_ft_verify_static_portchannel_vlan_routing_l3_traffic():
    """
    Author: Venkatesh Terli <*****@*****.**>
    3.1.6 Verify that LAG can forward traffic when participating in VLAN Routing.
    """
    st.log(
        "verify that scenario - 3.1.6 Verify that LAG can forward traffic when participating in VLAN Routing."
    )

    exceptions = exec_all(
        True,
        [[
            ipobj.config_ip_addr_interface, vars.D1, 'Vlan{}'.format(
                static_data.vid), static_data.ip_addr_pc1, static_data.subnet
        ],
         [
             ipobj.config_ip_addr_interface, vars.D2, 'Vlan{}'.format(
                 static_data.vid), static_data.ip_addr_pc2, static_data.subnet
         ]])[1]
    ensure_no_exception(exceptions)

    exceptions = exec_all(
        True,
        [[delete_vlan_member, vars.D1, static_data.vid, vars.D1T1P1, True],
         [delete_vlan_member, vars.D2, static_data.vid, vars.D2T1P1, True]])[1]
    ensure_no_exception(exceptions)

    exceptions = exec_all(
        True, [[
            ipobj.config_ip_addr_interface, vars.D1, vars.D1T1P1,
            static_data.ip_addr_po1, static_data.subnet
        ],
               [
                   ipobj.config_ip_addr_interface, vars.D2, vars.D2T1P1,
                   static_data.ip_addr_po2, static_data.subnet
               ]])[1]
    ensure_no_exception(exceptions)

    static_data.tg.tg_traffic_control(action='reset',
                                      port_handle=static_data.tg_ph_1)
    static_data.tg.tg_traffic_control(action='reset',
                                      port_handle=static_data.tg_ph_3)
    stream = static_data.tg.tg_traffic_config(
        port_handle=static_data.tg_ph_1,
        mode='create',
        length_mode='fixed',
        mac_dst=static_data.dut1_rt_int_mac,
        mac_src='00:05:00:00:00:01',
        mac_src_mode='increment',
        mac_src_step='00:00:00:00:00:01',
        mac_dst_mode='fixed',
        ip_src_addr=static_data.ip41,
        ip_src_mode='increment',
        ip_src_count=static_data.ip_src_count,
        ip_src_step='0.0.0.1',
        mac_src_count=1000,
        ip_dst_addr=static_data.ip42,
        ip_dst_mode='fixed',
        pkts_per_burst=1000,
        l3_protocol='ipv4',
        transmit_mode='single_burst')
    static_data.streams['D1T1_SD_ip_Hash1'] = stream['stream_id']

    if not ipobj.verify_interface_ip_address(
            vars.D1, vars.D1T1P1, "{}/8".format(static_data.ip_addr_po1),
            static_data.ipv4):
        st.report_fail('ip_routing_int_create_fail', static_data.ip_addr_po1)
    if not ipobj.verify_interface_ip_address(
            vars.D2, vars.D2T1P1, "{}/8".format(static_data.ip_addr_po2),
            static_data.ipv4):
        st.report_fail('ip_routing_int_create_fail', static_data.ip_addr_po2)

    exceptions = exec_all(True,
                          [[
                              ipobj.create_static_route, vars.D1,
                              static_data.ip_addr_pc2, static_data.static_ip2
                          ],
                           [
                               ipobj.create_static_route, vars.D2,
                               static_data.ip_addr_pc1, static_data.static_ip1
                           ]])[1]
    ensure_no_exception(exceptions)
    st.wait(5)

    if not arpobj.add_static_arp(vars.D2,
                                 static_data.ip42,
                                 static_data.remote_mac2,
                                 interface=vars.D2T1P1):
        st.report_fail("msg", "Failed to configure static ARP")
    # ping from dut to partner
    ipobj.ping(vars.D1, static_data.ip_addr_pc2, family='ipv4', count=3)

    exceptions = exec_all(True,
                          [[intfobj.clear_interface_counters, vars.D1],
                           [intfobj.clear_interface_counters, vars.D2]])[1]
    ensure_no_exception(exceptions)
    static_data.tg.tg_traffic_control(
        action='run', stream_handle=static_data.streams['D1T1_SD_ip_Hash1'])
    st.wait(2)
    static_data.tg.tg_traffic_control(
        action='stop', stream_handle=static_data.streams['D1T1_SD_ip_Hash1'])
    st.log("Verify that traffic is forwarding over portchannel members")
    verify_traffic_hashed_or_not(
        vars.D1, [vars.D1D2P1, vars.D1D2P2, vars.D1D2P3, vars.D1D2P4],
        200,
        traffic_loss_verify=True,
        rx_port=vars.D1T1P1,
        tx_port=vars.D2T1P1,
        dut2=vars.D2)
    static_data.tg.tg_traffic_control(action='reset',
                                      port_handle=static_data.tg_ph_1)
    st.report_pass('portchannel_l3_vlan_routing_success',
                   static_data.portchannel_name)