Ejemplo n.º 1
0
def vlan_module_prolog():
    """
    Module prolog for module configuration
    :return:
    """
    st.log("Creating vlan in device and adding members ...")
    vlan.create_vlan_and_add_members(sc_data.vlan_data)
    if st.is_feature_supported("strom-control", vars.D1):
        st.banner("Configuring BUM Storm control on interfaces")
        interface_list = [vars.D1T1P1, vars.D1T1P2]
        storm_control_type = [
            "broadcast", "unknown-multicast", "unknown-unicast"
        ]
        for interface in interface_list:
            for stc_type in storm_control_type:
                scapi.config(vars.D1,
                             type=stc_type,
                             action="add",
                             interface_name=interface,
                             bits_per_sec=sc_data.kbps)
                if not scapi.verify_config(vars.D1,
                                           interface_name=interface,
                                           type=stc_type,
                                           rate=sc_data.kbps):
                    st.report_fail("storm_control_config_verify_failed",
                                   stc_type, interface)
Ejemplo n.º 2
0
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])
Ejemplo n.º 3
0
def storm_control_func_hooks(request):
    bum_test_functions = [
        "test_ft_stormcontrol_verification",
        "test_ft_stormcontrol_portchannel_intf",
        "test_ft_stormcontrol_incremental_bps_max_vlan",
        "test_ft_stormcontrol_fast_reboot", "test_ft_stormcontrol_warm_reboot"
    ]
    if request.function.func_name in bum_test_functions:
        platform_check()
    yield
    if request.function.func_name == "test_ft_vlan_delete_with_member":
        if st.is_community_build(vars.D1):
            vlan.create_vlan_and_add_members(sc_data.vlan_data,
                                             cli_type=sc_data.cli_type)
Ejemplo n.º 4
0
def test_ft_vlan_delete_with_member():
    """
    Author: Surendra Kumar Vella ([email protected])

    Verify that user is not able to delete a valn till its members are deleted

    """
    vlan_data = [{"dut": [vars.D1], "vlan_id": sc_data.vlan_id, "tagged": [sc_data.free_port]}]
    st.log("checking whether vlan with member is deleted or not ")
    if not vlan.create_vlan_and_add_members(vlan_data):
        st.report_fail("vlan_tagged_member_fail", sc_data.free_port, sc_data.vlan_id)
    if st.is_feature_supported("prevent-delete-vlans-with-members", vars.D1):
        if sc_data.cli_type == "click":
            if vlan.delete_vlan(vars.D1, sc_data.vlan_id):
                st.report_fail("vlan_deletion_successfull_albiet_having_member", sc_data.vlan_id)
            if not vlan.delete_vlan_member(vars.D1, sc_data.vlan_id, sc_data.free_port, tagging_mode=True):
                st.report_fail("vlan_tagged_member_fail", sc_data.free_port, sc_data.vlan_id)
            if not vlan.delete_vlan(vars.D1, sc_data.vlan_id):
                st.report_fail("vlan_delete_fail", sc_data.vlan_id)
        else:
            if not vlan.delete_vlan(vars.D1, sc_data.vlan_id):
                st.report_fail("vlan_delete_fail", sc_data.vlan_id)
    else:
        if not vlan.delete_vlan(vars.D1, sc_data.vlan_id):
            st.report_fail("vlan_delete_fail", sc_data.vlan_id)
    st.report_pass("test_case_passed")
def storm_control_verify():
    status = 1
    platform_check()
    st.log(
        "Removing mirror session related information to ensure that BUM is unaffected due to mirror sessions"
    )
    mirror.delete_session(vars.D1, mirror_session=data.session_name_port)
    st.log("Creating vlan in device and adding members ...")
    vlan_data = [{
        "dut": [vars.D1],
        "vlan_id": data.vlan,
        "tagged": [vars.D1T1P1, vars.D1T1P2]
    }]
    vlan.create_vlan_and_add_members(vlan_data)
    msg_id = "storm_control_reboot_successful"
    interface_list = [vars.D1T1P1, vars.D1T1P2]
    storm_control_type = ["broadcast", "unknown-multicast", "unknown-unicast"]
    for interface_li in interface_list:
        for stc_type in storm_control_type:
            if not scapi.verify_config(vars.D1,
                                       interface_name=interface_li,
                                       type=stc_type,
                                       rate=data.kbps):
                st.report_fail("storm_control_config_verify_failed", stc_type,
                               interface_li)
    if not verify_bum_traffic_mode(
            'broadcast', tg_info['tg1_stream_id'], skip_traffic_verify=False):
        st.error("Broadcast traffic verification got failed")
        status = 0
    if not verify_bum_traffic_mode('unknown-unicast',
                                   tg_info['tg1_stream_id'],
                                   skip_traffic_verify=False):
        st.error("Unknown-unicast traffic verification got failed")
        status = 0
    if not verify_bum_traffic_mode('unknown-multicast',
                                   tg_info['tg1_stream_id'],
                                   skip_traffic_verify=False):
        st.error("Unknown-multicast traffic verification got failed")
        status = 0
    if not status:
        msg_id = "storm_control_reboot_failed"
    if status:
        st.report_tc_pass('ft_stormcontrol_cold_reboot', 'test_case_passed')
    else:
        st.report_tc_fail('ft_stormcontrol_cold_reboot', 'test_case_failed')
    report_result(status, msg_id)
Ejemplo n.º 6
0
def basic_dhcp_relay_config_addition():
    data.vlan1 = "Vlan{}".format(data.vlan)
    st.log("Create VLAN and participate client connected interface in vlan")
    vlan_obj.create_vlan_and_add_members([{
        "dut": [vars.D2],
        "vlan_id": data.vlan,
        "untagged": [vars.D2D3P1]
    }])
    st.log("About to add IP address in RA DUT")
    ip_obj.config_ip_addr_interface(vars.D2,
                                    data.vlan1,
                                    data.RA_ipaddress_2,
                                    data.subnet,
                                    family=data.family,
                                    config='add')
    st.log("Add DHCP server address to vlan")
    dhcp_relay_obj.dhcp_relay_config_add(vars.D2,
                                         vlan=data.vlan1,
                                         IP=data.dhcp_server_ip)
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())
Ejemplo n.º 8
0
def test_ft_stormcontrol_portchannel_intf():
    status = 1
    msg_id = "storm_control_portchannel_verification_successful"
    portchannel_name = 'PortChannel13'
    vlan_info = [{
        "dut": [vars.D2],
        "vlan_id": sc_data.vlan,
        "tagged": [vars.D2T1P1, vars.D2T1P2, portchannel_name]
    }]
    portchannel_interfaces_dut1 = [vars.D1D2P1, vars.D1D2P2]
    portchannel_interfaces_dut2 = [vars.D2D1P1, vars.D2D1P2]
    portchannel.config_portchannel(vars.D1,
                                   vars.D2,
                                   portchannel_name,
                                   portchannel_interfaces_dut1,
                                   portchannel_interfaces_dut2,
                                   config="add",
                                   thread=True)
    vlan.add_vlan_member(vars.D1,
                         sc_data.vlan,
                         portchannel_name,
                         tagging_mode=True)
    vlan.create_vlan_and_add_members(vlan_info)
    st.log(
        "Verifying whether stormcontrol config can be applied on portchannel {} interfaces"
        .format(portchannel_name))
    if scapi.config(vars.D1,
                    type="broadcast",
                    action="add",
                    interface_name=portchannel_name,
                    rate=sc_data.kbps,
                    skip_error_check=True):
        st.error(
            "storm-control config can be applied on portchannel interface")
        status = 0
    else:
        st.log(
            "storm-control config cannot be applied on portchannel interface.")
    if status:
        st.report_tc_pass('ft_stormcontrol_neg_config_vlan_portchannel',
                          'test_case_passed')
    else:
        st.report_tc_fail('ft_stormcontrol_neg_config_vlan_portchannel',
                          'test_case_failed')
    status = 1
    st.log("configuring bum stormcontrol on portchannel interfaces")
    scapi.config(vars.D1,
                 type="broadcast",
                 action="del",
                 interface_name=vars.D1T1P1,
                 bits_per_sec=sc_data.kbps)
    scapi.config(vars.D1,
                 type="broadcast",
                 action="del",
                 interface_name=vars.D1T1P2,
                 bits_per_sec=sc_data.kbps)
    scapi.config(vars.D2,
                 type="broadcast",
                 action="add",
                 interface_name=vars.D2D1P1,
                 bits_per_sec=sc_data.kbps)
    scapi.config(vars.D2,
                 type="broadcast",
                 action="add",
                 interface_name=vars.D2D1P2,
                 bits_per_sec=sc_data.kbps)
    verify_bum_traffic_mode('broadcast',
                            tg_info['tg1_stream_id'],
                            skip_traffic_verify=True)
    st.log("Clearing interface counters")
    ifapi.clear_interface_counters(vars.D2)
    tg.tg_traffic_control(action='run',
                          stream_handle=tg_info['tg1_stream_id'],
                          duration=10)
    st.wait(sc_data.wait_stream_run)
    st.log("Stopping of traffic from TGen to get interface counters")
    tg.tg_traffic_control(action='stop',
                          stream_handle=tg_info['tg1_stream_id'])
    st.wait(sc_data.wait_for_stats)
    tg_1_stats = tgapi.get_traffic_stats(tg,
                                         mode='aggregate',
                                         port_handle=tg_handler["tg_ph_1"])
    tg_3_stats = tgapi.get_traffic_stats(tg,
                                         mode='aggregate',
                                         port_handle=tg_handler["tg_ph_3"])
    counter = tg_3_stats.rx.total_packets
    counter2 = tg_1_stats.tx.total_packets
    try:
        time = int(counter2 / sc_data.rate_pps)
        counters_avg = counter / time
    except Exception:
        counters_avg = 0
    st.log("Average of counters are : {}".format(counters_avg))
    st.log("Higher packet count value is : {}".format(
        sc_data.higher_pkt_count))
    st.log("Lower packet count value is : {}".format(sc_data.lower_pkt_count))
    st.log("value of status is : {}".format(status))
    if counters_avg > sc_data.higher_pkt_count or counters_avg < sc_data.lower_pkt_count:
        st.error("storm control traffic verification failed")
        status = 0
    if status:
        st.report_tc_pass('ft_stormcontrol_portchannel_intf',
                          'test_case_passed')
    else:
        st.report_tc_fail('ft_stormcontrol_portchannel_intf',
                          'test_case_failed')
    status = 1
    st.log("Configuring stormcontrol without providing bps value")
    if scapi.config(vars.D1,
                    type="broadcast",
                    action="add",
                    interface_name=vars.D1T1P1,
                    skip_error_check=True):
        st.error("Storm-control config is accepting not throwing any error")
        status = 0
    else:
        st.log("Config is not accepted and thrown an error")
    if status:
        st.report_tc_pass('ft_stormcontrol_neg_config_without_bpsvalue',
                          'test_case_passed')
    else:
        st.report_tc_fail('ft_stormcontrol_neg_config_without_bpsvalue',
                          'test_case_failed')
    status = 1
    st.log("unconfiguring of bum stormcontrol type by providing bps value")
    if scapi.config(vars.D1,
                    type="broadcast",
                    action="del",
                    interface_name=vars.D1T1P1,
                    rate=sc_data.kbps,
                    skip_error_check=True):
        st.error("Storm-control config is removed and not throwing any error")
        status = 0
    else:
        st.log("Config is not accepted and thrown an error")
    if status:
        st.report_tc_pass('ft_stormcontrol_neg_unconfig_with_bpsvalue',
                          'test_case_passed')
    else:
        st.report_tc_fail('ft_stormcontrol_neg_unconfig_with_bpsvalue',
                          'test_case_failed')

    st.log("Back to module config")
    scapi.config(vars.D2,
                 type="broadcast",
                 action="del",
                 interface_name=vars.D2D1P1,
                 bits_per_sec=sc_data.kbps)
    scapi.config(vars.D2,
                 type="broadcast",
                 action="del",
                 interface_name=vars.D2D1P2,
                 bits_per_sec=sc_data.kbps)
    scapi.config(vars.D1,
                 type="broadcast",
                 action="add",
                 interface_name=vars.D1T1P1,
                 bits_per_sec=sc_data.kbps)
    scapi.config(vars.D1,
                 type="broadcast",
                 action="add",
                 interface_name=vars.D1T1P2,
                 bits_per_sec=sc_data.kbps)
    st.log(
        "Unconfiguring portchannel config in both devices and only vlan configuration in device2"
    )
    vlan.clear_vlan_configuration(vars.D2)
    vlan.delete_vlan_member(vars.D1,
                            sc_data.vlan,
                            portchannel_name,
                            tagging_mode=True)
    portchannel.clear_portchannel_configuration(st.get_dut_names(),
                                                thread=True)
    if not status:
        msg_id = "storm_control_portchannel_verification_failed"
    report_result(status, msg_id)