Ejemplo n.º 1
0
def erspan_func_hooks(request):
    # add things at the start every test case
    # use 'request.node.name' to compare
    # if any thing specific a particular test case

    yield
    # add things at the end every test case
    # use 'request.node.name' to compare
    # if any thing specific a particular test case

    # Deleteing configured ACL rule at end of each test case
    if st.get_func_name(request) != 'test_ft_erspan_config_upload_save_reload_reboot':
        acl_dscp.config_flow_update_table(vars.D1, policy_name=data.acl_table_name, flow='del', policy_type=data.type,
                                          class_name=data.acl_rule)
        acl_dscp.config_classifier_table(dut=vars.D1, enable="del", class_name=data.acl_rule)

    if 'test_ft_erspan_action_ethertype_dscp_tcp_flags_l4range' in request.node.name:
        ip.delete_ip_interface(vars.D1, vars.D1T1P1, "2001:1::1", "64", family="ipv6")
        ip.delete_ip_interface(vars.D1, vars.D1T1P2, "2001:2::1", "64", family="ipv6")
        acl.delete_acl_rule(vars.D1, "L3_IPV6_INGRESS", "L3V6", "FWD_RULE1")
    if st.get_func_name(request) == 'test_ft_erspan_action_encapsulation':
        encap_list = ['0x88ee', '0x6558']
        for encap in encap_list:
            mirror.delete_session(vars.D1, "mirror_" + encap)
    if st.get_func_name(request) == 'test_ft_erspan_portchannel_shut_noshut':
        mirror.delete_session(vars.D1, data.mirror_session)
Ejemplo n.º 2
0
def erspan_post_config():
    """
    Author: Lakshminarayana D ([email protected])
    Using this post config at module level. So, applicable for all test cases which includes in this module.
    :return: None
    """

    # Unconfig ip address on DUT-1
    for port, ip_addr, in zip(data.port_list_d1, data.ip_list_d1):
        ip.delete_ip_interface(vars.D1, port, ip_addr, data.subnet_mask)

    # Unconfig ip address on DUT-2
    for port, ip_addr in zip(data.port_list_d2, data.ip_list_d2):
        ip.delete_ip_interface(vars.D2, port, ip_addr, data.subnet_mask)

    # Unconfig static route
    _, network = ip.get_network_addr("{}/{}".format(data.ip_T1D2P1, data.subnet_mask))
    ip.delete_static_route(vars.D1, data.ip_D2D1P1, network)
    _, network = ip.get_network_addr("{}/{}".format(data.ip_T1D1P1, data.subnet_mask))
    ip.delete_static_route(vars.D2, data.ip_D1D2P1, network)

    # Unconfig mirror session
    mirror.delete_session(vars.D1, data.session_name)

    # Unconfig acl rule
    acl_dscp.config_classifier_table(dut=vars.D1, enable="del", class_name=data.acl_rule)

    # Unconfig acl table
    acl_dscp.config_service_policy_table(dut=vars.D1, policy_kind='unbind', interface_name=vars.D1T1P1, stage='in',
                                         service_policy_name=data.acl_table_name, policy_type=data.type)
    acl_dscp.config_service_policy_table(dut=vars.D1, policy_kind='unbind', interface_name=vars.D1T1P2, stage='in',
                                         service_policy_name=data.acl_table_name, policy_type=data.type)
    acl_dscp.config_policy_table(dut=vars.D1, enable='del', policy_name=data.acl_table_name)

    acl.delete_acl_table(vars.D1, acl_table_name="L3_IPV6_INGRESS", acl_type="L3V6")
Ejemplo n.º 3
0
def system_fast_reboot_module_hooks(request):
    # add things at the start of this module
    global vars
    vars = st.ensure_min_topology("D1T1:2", 'D1D2:2', 'D2T1:1')
    initialize_variables()
    st.log("Configuring CRM")
    crm_config()
    st.log("Checking CRM config before save and fast-reboot")
    crm_config_verify()
    if st.is_feature_supported("interface-mtu", vars.D1):
        st.log("Configuring MTU on interface")
        mtu_config()
        st.log("Checking the configured MTU value before save and fast-reboot")
        mtu_verify()
    if st.is_feature_supported("threshold", vars.D1):
        st.log("configuring threshold values on interface")
        threshold_config()
        st.log("configured threshold values verification")
        threshold_verify()
    st.log("configure mirror session values")
    mirror_action_config()
    st.log("configured mirror session verification")
    mirror_action_verify()
    if st.is_feature_supported("span-mirror-session", vars.D1):
        st.log("Configuring port mirroring values")
        port_mirror_config()
        st.log("Checking port mirroring before save and reboot")
        port_mirror_verify()
    st.log("Configuring Port-Channel")
    config_portchannel()
    st.log("Configuring VLAN related configuration")
    dut_vlan_config()
    st.log("Configuring TGEN handlers and streams")
    tgen_config()
    yield
    # add things at the end of this module"
    #Setting the MTU value to default
    intf_obj.interface_properties_set(vars.D1, data.eth, data.property,
                                      data.mtu_default)
    #Below step will clear all CRM config from the device.
    crm_obj.set_crm_clear_config(vars.D1)
    #Below steps will clear all threshold values configured on the device
    tf_obj.clear_threshold(vars.D1, breach='all')
    tf_obj.clear_threshold(vars.D1,
                           threshold_type='priority-group',
                           buffer_type='all')
    tf_obj.clear_threshold(vars.D1, threshold_type='queue', buffer_type='all')
    mirror.delete_session(vars.D1, "Mirror_Ses")
    mirror.delete_session(vars.D1, mirror_session=data.session_name_port)
    rb_obj.config_save(vars.D1)
def system_save_reboot_module_hooks(request):
    # add things at the start of this module
    global vars, tg_stream
    vars = st.ensure_min_topology("D1T1:2")
    initialize_variables()
    st.log("Configuring CRM")
    crm_config()
    st.log("Checking CRM config before save and reboot")
    crm_config_verify()
    if st.is_feature_supported("interface-mtu", vars.D1):
        st.log("Configuring MTU on interface")
        mtu_config()
        st.log("Checking the configured MTU value before save and reboot")
        mtu_verify()
    if st.is_feature_supported("threshold", vars.D1):
        st.log("configuring threshold values on interface")
        threshold_config()
        st.log("configured threshold values verification")
        threshold_verify()
    st.log("Configuration of erspan")
    mirror_action_config()
    st.log("Checking ERSPAN config before save and reboot")
    mirror_action_verify()
    if st.is_feature_supported("span-mirror-session", vars.D1):
        st.log("Configuring port mirror session")
        port_mirror_config()
        st.log("Checking port mirroring(SPAN) before save and reboot")
        port_mirror_verify()
    if st.is_feature_supported("strom-control", vars.D1):
        st.log("Configuring BUM/Storm control")
        storm_control_config()
    tg_stream = config_tg_stream()

    yield
    # delete things at the end of this module"
    crm_obj.set_crm_clear_config(vars.D1)
    if st.is_feature_supported("interface-mtu", vars.D1):
        intf_obj.interface_properties_set(vars.D1, data.eth, data.property,
                                          data.mtu_default)
    if st.is_feature_supported("threshold", vars.D1):
        tf_obj.clear_threshold(vars.D1, breach='all')
        tf_obj.clear_threshold(vars.D1,
                               threshold_type='priority-group',
                               buffer_type='all')
        tf_obj.clear_threshold(vars.D1,
                               threshold_type='queue',
                               buffer_type='all')
    mirror.delete_session(vars.D1, mirror_session=data.session_name)
    bum_clear_config()
    reboot_obj.config_save(vars.D1)
Ejemplo n.º 5
0
def erspan_post_config():
    """
    Author: Anil Kumar Kacharla<*****@*****.**>
    Using this post config at module level. So, applicable for all test cases which includes in this module.
    :return: None
    """

    # Unconfig ip address on DUT-1
    for port, ip_addr, in zip(data.port_list_d1, data.ip_list_d1):
        ip.delete_ip_interface(data.dut1, port, ip_addr, data.subnet_mask)

    # Unconfig ip address on DUT-2
    for port, ip_addr in zip(data.port_list_d2, data.ip_list_d2):
        ip.delete_ip_interface(data.dut2, port, ip_addr, data.subnet_mask)

    # Unconfig static route
    _, network = ip.get_network_addr("{}/{}".format(data.ip_T1D2P1,
                                                    data.subnet_mask))
    ip.delete_static_route(data.dut1, data.ip_D2D1P1, network)
    _, network = ip.get_network_addr("{}/{}".format(data.ip_T1D1P1,
                                                    data.subnet_mask))
    ip.delete_static_route(data.dut2, data.ip_D1D2P1, network)

    # Unconfig acl classifier
    acl_dscp.config_flow_update_table(data.dut1,
                                      policy_name=data.acl_table_name,
                                      flow='del',
                                      policy_type=data.type,
                                      class_name=data.acl_rule)
    acl_dscp.config_classifier_table(dut=data.dut1,
                                     enable="del",
                                     class_name=data.acl_rule)

    # Unconfig acl policy
    acl_dscp.config_service_policy_table(
        dut=data.dut1,
        policy_kind='unbind',
        interface_name=vars.D1T1P1,
        stage='in',
        service_policy_name=data.acl_table_name,
        policy_type=data.type)
    acl_dscp.config_policy_table(dut=data.dut1,
                                 enable='del',
                                 policy_name=data.acl_table_name)

    # Unconfig mirror session
    mirror.delete_session(data.dut1, data.session_name)
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.º 7
0
def test_ft_erspan_config_upload_save_reload_reboot():
    """
    Author: Prudviraj kristipati ([email protected])
    Verify that ERSPAN configuration is stored to config_db file, after config save & reload and save & reboot.
    :return:
    """
    mirror.delete_session(vars.D1, data.session_name)
    mirror_args = {"session_name": data.session_name, "src_ip": data.ip_D1T1P1, "dst_ip": data.ip_T1D2P1,
                   "gre_type": data.gre_type, "dscp": data.dscp, "ttl": data.ttl, "queue": data.queue}
    retval = mirror.create_session_table(vars.D1, **mirror_args)

    if not retval:
        st.log("Failed to create mirror session using json file.")
        st.report_fail("mirror_session_fail", data.session_name)
    if not sconf.verify_running_config(vars.D1, "MIRROR_SESSION", "Mirror_Ses", "dst_ip", "15.1.1.2"):
        st.log("Failed to show mirror session details in running config.")
        st.report_fail("test_case_failure_message", "Failed to display mirror session details in running-config.")
    reboot_obj.config_save_reload(vars.D1)

    if not mirror.verify_session(vars.D1, **mirror_args):
        st.log("Failed to show mirror session details after reload.")
        st.report_fail("mirror_session_fail", data.session_name + "after config save and reload")
    if not sconf.verify_running_config(vars.D1, "MIRROR_SESSION", "Mirror_Ses", "dst_ip", "15.1.1.2"):
        st.log("Failed to show mirror session details in running config after reload.")
        st.report_fail("test_case_failure_message",
                       "Failed to display mirror session details in running-config after config save and reload")

    st.reboot(vars.D1)

    if not mirror.verify_session(vars.D1, **mirror_args):
        st.log("failed to show mirror session details after reboot.")
        st.report_fail("mirror_session_fail", data.session_name + "after save and reboot")
    if not sconf.verify_running_config(vars.D1, "MIRROR_SESSION", "Mirror_Ses", "dst_ip", "15.1.1.2"):
        st.log("failed to show mirror session details in running config after reboot.")
        st.report_fail("test_case_failure_message",
                       "Failed to display mirror session details in running-config after save and reboot")

    st.report_pass("test_case_passed")
Ejemplo n.º 8
0
def test_ft_erspan_basic_functionality():

    """
    Author: Sesha Koilkonda  ([email protected])
    TC1 FtOpSoSyErspanFn019: Verify that maximum number of mirror sessions are created.
    TC2 FtOpSoSyErspanFn015: Verify that multiple mirror sessions can be created and assigned to rules from the same ACL.
    TC3 FtOpSoSyErspanFn011: Verify that ERSPAN is working as expected and intended traffic is mirrored to remote interface from multiple interfaces.
    Notes from dev: Only 1 Mirror ACL configuration is supported as of now.
                    maximum Acl rules that can be configured in mirror sesssion(s) is 3.
    :return:
    """
    ip_add_src, ip_add_dst = data.ip_T1D1P1, data.ip_T1D2P1
    max_sessions, data.mask = 4, '32'
    tc_fail = 0
    acl_dscp.config_classifier_table(vars.D1, enable='create', match_type="fields", class_name=data.acl_rule)
    acl_dscp.config_classifier_table(vars.D1, enable='yes', class_criteria='--src-ip', class_name=data.acl_rule,
                                     criteria_value="{}/{}".format(ip_add_src, data.mask), match_type="fields")
    acl_dscp.config_flow_update_table(vars.D1, policy_name=data.acl_table_name, flow='add', policy_type=data.type,
                                      class_name=data.acl_rule, priority_value=data.priority,
                                      description=data.description)
    acl_dscp.config_flow_update_table(vars.D1, policy_name=data.acl_table_name, flow='update',policy_type=data.type,
                                      class_name=data.acl_rule, priority_option='--mirror-session',
                                      priority_value=data.session_name)

    #Configure the maximum supported mirror sessions(Session1 alreday created as part of module config.)
    for ele in range(1, max_sessions):
        _, ip_add_src = ip.increment_ip_addr("{}/{}".format(ip_add_src.split('/')[0], data.mask), "host")
        _, ip_add_dst = ip.increment_ip_addr("{}/{}".format(ip_add_dst.split('/')[0], data.mask), "host")
        if ele == 2: _, ip_add_src = ip.increment_ip_addr("{}/{}".format(data.ip_D1T1P2, data.mask), "host")

        mirror_args = {'session_name': data.session_name + str(ele),'src_ip': ip_add_src.split('/')[0], 'dst_ip': ip_add_dst.split('/')[0],
                        'dscp':'50', 'ttl':'60', 'gre_type':'0x88ee', 'queue':data.queue}
        mirror.create_session(vars.D1, **mirror_args)

        if not mirror.verify_session(vars.D1, **mirror_args):
            st.log("failed to configure the mirror session: {} ".format(data.session_name + str(ele)))
            tc_fail = 1
        acl_dscp.config_classifier_table(vars.D1, enable='create', match_type="fields", class_name=data.acl_rule+ str(ele))
        acl_dscp.config_classifier_table(vars.D1, enable='yes', class_criteria='--src-ip', match_type="fields",
                                         class_name=data.acl_rule + str(ele),
                                         criteria_value="{}".format(ip_add_src))
        acl_dscp.config_flow_update_table(vars.D1, policy_name=data.acl_table_name, flow='add', policy_type=data.type,
                                          class_name=data.acl_rule+str(ele),priority_value=int(data.priority) + ele,
                                          description=data.description)
        acl_dscp.config_flow_update_table(vars.D1, policy_name=data.acl_table_name, flow='update',policy_type=data.type,
                                          class_name=data.acl_rule+str(ele), priority_option='--mirror-session',
                                          priority_value=data.session_name + str(ele))

    # Traffic validations for the mirror sessions.
    ip_add_src, ip_add_dst, tg_src = data.ip_T1D1P1, data.ip_T1D1P2, 'tg_ph_1'
    for ele in range(0, max_sessions):
        if ele == 2:
            _, ip_add_src = ip.increment_ip_addr("{}/{}".format(data.ip_D1T1P2.split('/')[0], data.mask), "host")
            _, ip_add_dst = ip.increment_ip_addr("{}/{}".format(data.ip_D1T1P1.split('/')[0], data.mask), "host")
            tg_src = 'tg_ph_2'

        retval = send_traffic(capture_values=[ip_add_dst], capture_fields=['dst_ip'], ip_src_addr= ip_add_src.split('/')[0],
                             ip_dst_addr= ip_add_dst.split('/')[0], tg_src_port=tg_src)
        if not retval[0]:
            st.log('Traffic validation failed for the mirror session combination: source_ip {} , destination_ip {}'.format(ip_add_src,ip_add_dst))
            tc_fail = ele
        _, ip_add_src = ip.increment_ip_addr("{}/{}".format(ip_add_src.split('/')[0], data.mask), "host")

    #Unconfigration part
    for ele in range(1, max_sessions):
        acl_dscp.config_flow_update_table(vars.D1, policy_name=data.acl_table_name, flow='del',
                                          policy_type=data.type, class_name=data.acl_rule + str(ele))
        acl_dscp.config_classifier_table(dut=vars.D1, enable="del", class_name=data.acl_rule+str(ele))
        mirror.delete_session(vars.D1, data.session_name + str(ele))
    if tc_fail == 1:
        st.report_fail("mirror_session_fail", "")
    elif tc_fail == 2:
        st.report_fail("traffic_verification_fail", "packet count")
    st.report_pass("test_case_passed")