Esempio n. 1
0
def test_ft_stp_loopguard_enable_interface_shut_noshut():
    st.log("Verify the stp convergence")
    if not stp_wrap.poll_stp_convergence(
            vars, sc_data.vlan, iteration=20, delay=1):
        st.report_fail("stp_convergence_fail")
    st.log("Enable loop guard on interface")
    stp.config_stp_interface_params(vars.D1, vars.D1D2P2, loop_guard='enable')
    st.log("disable stp on an interface")
    stp.config_stp_enable_interface(vars.D2, vars.D2D1P2, mode="disable")
    st.wait(5)
    st.log("verify port moved to inconsistent state")
    if not stp.check_rg_current_state(vars.D1, sc_data.vlan, vars.D1D2P2):
        st.report_fail("port_inconsistent_state_fail")
    st.log("shutdown the root forwarding port")
    interface.interface_shutdown(vars.D1, vars.D1D2P1)
    st.log("enable stp on an interface")
    stp.config_stp_enable_interface(vars.D2, vars.D2D1P2, mode="enable")
    st.wait(5)
    if not stp.verify_stp_intf_status(vars.D1,
                                      interface=vars.D1D2P2,
                                      status="FORWARDING",
                                      vlanid=sc_data.vlan):
        st.report_fail("port_forwarding_fail")
    interface.interface_noshutdown(vars.D1, vars.D1D2P1)
    st.log("Unconfiguring the loop guard interface mode")
    stp.config_stp_interface_params(vars.D1, vars.D1D2P2, loop_guard='disable')
    st.report_pass("test_case_passed")
Esempio n. 2
0
def test_ft_port_fn_verify_shut_noshut():
    if not ipapi.config_ip_addr_interface(vars.D1, interface_name=vars.D1D2P1, ip_address=intf_data.ip_address,
                                          subnet=intf_data.mask, family="ipv4", config='add'):
        st.report_fail("operation_failed")
    if not ipapi.config_ip_addr_interface(vars.D2, interface_name=vars.D2D1P1, ip_address=intf_data.ip_address1,
                                          subnet=intf_data.mask, family="ipv4", config='add'):
        st.report_fail("operation_failed")
    if not ipapi.ping(vars.D1, intf_data.ip_address1, family='ipv4', count=1):
        st.report_fail("ping_fail", intf_data.ip_address, intf_data.ip_address1)
    if not ipapi.ping(vars.D2, intf_data.ip_address, family='ipv4', count=1):
        st.report_fail("ping_fail", intf_data.ip_address1, intf_data.ip_address)
    for _ in range(3):
        intfapi.interface_shutdown(vars.D1, [vars.D1D2P1], skip_verify=True)
        intfapi.interface_noshutdown(vars.D1, [vars.D1D2P1], skip_verify=True)
    if not ipapi.ping(vars.D1, intf_data.ip_address1, family='ipv4', count=5):
        st.report_fail("ping_fail", intf_data.ip_address, intf_data.ip_address1)
    if not ipapi.ping(vars.D2, intf_data.ip_address, family='ipv4', count=1):
        st.report_fail("ping_fail", intf_data.ip_address1, intf_data.ip_address)
    rbapi.config_save_reload(vars.D1)
    if not ipapi.config_ip_addr_interface(vars.D1, interface_name=vars.D1D2P1, ip_address=intf_data.ip_address,
                                          subnet=intf_data.mask, family="ipv4", config='remove'):
        st.report_fail("operation_failed")
    if not ipapi.config_ip_addr_interface(vars.D2, interface_name=vars.D2D1P1, ip_address=intf_data.ip_address1,
                                          subnet=intf_data.mask, family="ipv4", config='remove'):
        st.report_fail("operation_failed")
    for _ in range(3):
        intfapi.interface_shutdown(vars.D1, [vars.D1D2P1], skip_verify=True)
        intfapi.interface_noshutdown(vars.D1, [vars.D1D2P1], skip_verify=True)
    if not st.poll_wait(intfapi.verify_interface_status, 15, vars.D1, vars.D1D2P1, "oper", "up"):
        st.report_fail("interface_is_down_on_dut", [vars.D1D2P1])
    if not st.poll_wait(intfapi.verify_interface_status, 15, vars.D2, vars.D2D1P1, "oper", "up"):
        st.report_fail("interface_is_down_on_dut", [vars.D2D1P1])
    st.report_pass("test_case_passed")
Esempio n. 3
0
def test_ft_erspan_portchannel_shut_noshut():

    """
    Author: Kanala Ramprakash Reddy ( [email protected])
    TC1 FtOpSoSyErspanFn020: Verify that ERSPAN is working as expected after portchannel shut/no shut.
    :return:
    """
    st.log("############### Test started to check ERSPAN status between multiple link flaps###############")
    st.log("Creating mirror session")
    mirror.create_session(vars.D1, session_name=data.mirror_session, gre_type=data.gre_type, dscp=data.dscp,
                          ttl=data.ttl, queue=data.queue, src_ip=data.ip_T1D1P2, dst_ip=data.ip_T1D2P1)

    st.log("Creating ACL Policy")
    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=data.src_ip_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.mirror_action)
    stream = data.tg1.tg_traffic_config(port_handle=data.tg_ph_1, mode='create', transmit_mode='continuous', length_mode='fixed',
                               rate_pps=data.rate_pps, l2_encap='ethernet_ii', mac_src='00:0a:01:00:00:01',
                               mac_dst=dut_mac, l3_protocol="ipv4", ip_src_addr=data.ip_T1D1P1,
                               ip_dst_addr=data.ip_T1D1P2)['stream_id']
    intf_obj.clear_interface_counters(vars.D1)
    st.log("Starting the traffic")
    data.tg1.tg_traffic_control(action='run', stream_handle=stream)
    for _ in range(5):
        intf_obj.interface_shutdown(vars.D1, [vars.D1D2P1], skip_verify=True)
        if not poll_wait(mirror.verify_session_all, 20, vars.D1, mirror_type="erspan", status="inactive",
                         session_name=data.mirror_session):
            st.error("Mirror session status should be inactive after port shutdown")
            data.flag = 0
        intf_obj.interface_noshutdown(vars.D1, [vars.D1D2P1], skip_verify=True)
        if not poll_wait(mirror.verify_session_all, 20, vars.D1, mirror_type="erspan", status="active",
                         session_name=data.mirror_session):
            st.error("Mirror session status should be active after port startup")
            data.flag = 0
    data.tg1.tg_traffic_control(action='stop', stream_handle=stream)
    if data.flag == 0:
        st.report_fail("test_case_failed")
    else:
        st.report_pass("test_case_passed")
Esempio n. 4
0
def test_ft_snmp_link_up_trap():
    """
    Author : Prasad Darnasi<*****@*****.**>
    Verify that trap is sent when a link is UP.
    """
    check_flag = snmptrapd_checking()
    if not check_flag:
        st.report_fail("snmptrapd_not_running")

    # trigger trap on DUT
    intf_obj.interface_shutdown(vars.D1, vars.D1T1P1)
    intf_obj.interface_noshutdown(vars.D1, vars.D1T1P1)

    # get data from capture
    read_cmd = "cat {}".format(capture_file)

    output = execute_command(ssh_conn_obj, read_cmd)
    trap_lines = output.split("\n")[:-1]

    result = any('linkUp' in x for x in trap_lines)
    if result == 0:
        st.report_fail("snmp_output_failed", "linkUp")
    else:
        st.report_pass("test_case_passed")
Esempio n. 5
0
def test_system_up_performance():
    timer_dict = {}
    test_port = vars.D1D2P1
    max_port_up_time = 20
    if not intapi.verify_interface_status(vars.D1, test_port, 'oper', 'up'):
        st.error('{} interface is down on dut'.format(test_port))
        st.report_fail('test_case_failed')

    st.banner("START - REBOOT TEST ")
    tstart = datetime.now()
    st.reboot(vars.D1)
    bcapi.get_system_status(vars.D1)
    tdiff = datetime.now() - tstart
    timer_dict['REBOOT_TEST'] = "{} {}".format(tdiff, 'H:M:S:msec')
    st.banner("END - REBOOT TEST -- {}".format(timer_dict['REBOOT_TEST']))

    st.banner("START - CONFIG REBOOT TEST ")
    tstart = datetime.now()
    config_reload(vars.D1)
    bcapi.get_system_status(vars.D1)
    tdiff = datetime.now() - tstart
    timer_dict['CONFIG_REBOOT_TEST'] = "{} {}".format(tdiff, 'H:M:S:msec')
    st.banner("END - CONFIG REBOOT TEST -- {}".format(
        timer_dict['CONFIG_REBOOT_TEST']))

    st.banner("START - PORT UP TEST ")
    logapi.clear_logging(vars.D1)
    intapi.interface_shutdown(vars.D1, test_port)
    intapi.verify_interface_status(vars.D1, test_port, 'oper', 'down')
    st.wait(5)
    intapi.interface_noshutdown(vars.D1, test_port)
    if not intapi.poll_for_interface_status(
            vars.D1, test_port, 'oper', 'up', iteration=max_port_up_time,
            delay=1):
        st.error('{} interface is down on dut for MAX time = {}'.format(
            test_port, max_port_up_time))
    log_down = logapi.show_logging(
        vars.D1,
        filter_list=['sudo config interface startup {}'.format(test_port)])
    log_up = logapi.show_logging(
        vars.D1,
        filter_list=[
            'Set operation status UP to host interface {}'.format(test_port)
        ])
    logapi.show_logging(vars.D1)
    log_down_time = utils.log_parser(log_down[0])[0]
    log_up_time = utils.log_parser(log_up[0])[0]
    f_down_time = utils.convert_time_to_milli_seconds(
        days=0,
        hours=log_down_time['hours'],
        minutes=log_down_time['minutes'],
        seconds=log_down_time['seconds'],
        milli_second=log_down_time['micro_second'])

    f_up_time = utils.convert_time_to_milli_seconds(
        days=0,
        hours=log_up_time['hours'],
        minutes=log_up_time['minutes'],
        seconds=log_up_time['seconds'],
        milli_second=log_up_time['micro_second'])

    st.log("f_down_time : {} , f_up_time : {}".format(f_down_time, f_up_time))
    timer_dict['PORT_UP_TEST'] = "{} {}".format(
        (f_up_time - f_down_time) / 1000, 'mili sec')
    st.banner("END - PORT UP TEST -- {}".format(timer_dict['PORT_UP_TEST']))

    st.log("\n" + pprint.pformat(timer_dict, width=2) + '\n')
    st.log('\n' +
           cutils.sprint_vtable(['Test Name', 'Time'], timer_dict.items()) +
           '\n')
    csv_str = '\nTest, Result\n'
    for i, j in timer_dict.items():
        csv_str += "{}, {}\n".format(i, j)
    st.log(csv_str)
    st.report_pass('test_case_passed')
Esempio n. 6
0
def verify_thresholds(data=[]):
    max_threshold = 999999
    var_delay = 2
    opt_delay = 2
    clear_wait = 8
    final_wait = 20
    mymode = ""
    family_list = crm_obj.crm_get_family_list(data.D1)
    for family in family_list:
        if family != 'all':
            (data.used_counter[family],
             data.free_counter[family]) = crm_obj.crm_get_resources_count(
                 data.D1, family)
            data.resource_count_max[
                family] = data.used_counter[family] + data.free_counter[family]
            st.log("verify_thresholds: {} used {} free {} max {}".format(
                family, data.used_counter[family], data.free_counter[family],
                data.resource_count_max[family]))
    ##################### USED #############################
    for family in family_list:
        if family != 'all':
            crm_obj.set_crm_thresholds_type(data.D1,
                                            family=family,
                                            type="used")
            crm_obj.set_crm_thresholds_value(data.D1,
                                             family=family,
                                             mode="high",
                                             value=max_threshold)
            crm_obj.set_crm_thresholds_value(data.D1,
                                             family=family,
                                             mode="low",
                                             value=max_threshold)

    #show logs
    st.log("show log messages:")
    slog_obj.show_logging(data.D1, lines=50)
    # Clear Logs
    slog_obj.clear_logging(data.D1)

    st.log("configure Thresholds for used")
    for family in family_list:
        if family != 'all':
            hi_th = data.used_counter[family] - 1
            if hi_th < 0:
                hi_th = 0
            mymode = "high"
            if family in acl_family_list:
                mymode = "low"
            crm_obj.set_crm_thresholds_value(data.D1,
                                             family=family,
                                             mode=mymode,
                                             value=hi_th)
            mymode = "low"
            if family in acl_family_list:
                mymode = "high"

            low_th = hi_th - 1
            if low_th < 0:
                low_th = 0
            #crm_obj.set_crm_thresholds_type(data.D1, family=family, type="used")
            crm_obj.set_crm_thresholds_value(data.D1,
                                             family=family,
                                             mode=mymode,
                                             value=low_th)
            crm_obj.set_crm_thresholds_type(data.D1,
                                            family=family,
                                            type="used")
    st.wait(opt_delay)  ## EXCEED
    st.wait(var_delay)  ## EXCEED
    crm_obj.get_crm_resources(data.D1, "all")
    interface_obj.interface_shutdown(data.D1,
                                     data.dut_p1_interface,
                                     skip_verify=False)
    interface_obj.interface_shutdown(data.D1,
                                     data.dut_p2_interface,
                                     skip_verify=False)
    macapi.clear_mac(data.D1)
    crm_fdb_config_clear(data)
    st.wait(opt_delay)  ## CLEAR

    # Restore
    interface_obj.interface_noshutdown(data.D1,
                                       data.dut_p1_interface,
                                       skip_verify=False)
    interface_obj.interface_noshutdown(data.D1,
                                       data.dut_p2_interface,
                                       skip_verify=False)
    st.wait(opt_delay)  # delay is required to populate tables

    ##################### PERCENTAGE #############################
    for family in family_list:
        if family != 'all':
            crm_obj.set_crm_thresholds_value(data.D1,
                                             family=family,
                                             mode="high",
                                             value=max_threshold)
            crm_obj.set_crm_thresholds_value(data.D1,
                                             family=family,
                                             mode="low",
                                             value=max_threshold)
    crm_fdb_send_traffic(data)
    st.log("Configure Thresholds for percentage")
    for family in family_list:
        if family != 'all' and family != 'snat' and family != 'dnat' and family != 'ipmc':
            hi_th = 0
            mymode = "high"
            crm_obj.set_crm_thresholds_value(data.D1,
                                             family=family,
                                             mode=mymode,
                                             value=hi_th)
            mymode = "low"
            low_th = 100
            #crm_obj.set_crm_thresholds_type(data.D1, family=family, type="percentage")
            crm_obj.set_crm_thresholds_value(data.D1,
                                             family=family,
                                             mode=mymode,
                                             value=low_th)
            crm_obj.set_crm_thresholds_type(data.D1,
                                            family=family,
                                            type="percentage")
    st.wait(opt_delay)  ## EXCEED
    st.wait(var_delay)  ## EXCEED
    crm_obj.get_crm_resources(data.D1, "all")
    crm_acl_unconfig(data)
    crm_acl_config(data)
    interface_obj.interface_shutdown(data.D1,
                                     data.dut_p1_interface,
                                     skip_verify=False)
    interface_obj.interface_shutdown(data.D1,
                                     data.dut_p2_interface,
                                     skip_verify=False)
    macapi.clear_mac(data.D1)
    crm_fdb_config_clear(data)
    st.wait(opt_delay)  ## CLEAR
    st.wait(var_delay)  ## EXCEED

    ##################### FREE #############################
    crm_obj.get_crm_resources(data.D1, "all")
    for family in family_list:
        if family != 'all':
            crm_obj.set_crm_thresholds_type(data.D1,
                                            family=family,
                                            type="used")
            crm_obj.set_crm_thresholds_value(data.D1,
                                             family=family,
                                             mode="high",
                                             value=max_threshold)
            crm_obj.set_crm_thresholds_value(data.D1,
                                             family=family,
                                             mode="low",
                                             value=max_threshold)
    st.wait(clear_wait)
    st.log("configure Thresholds for free")
    for family in family_list:
        if family != 'all':
            mymode = "high"
            hi_th = 0
            crm_obj.set_crm_thresholds_value(data.D1,
                                             family=family,
                                             mode=mymode,
                                             value=hi_th)
            mymode = "low"
            low_th = max_threshold
            #crm_obj.set_crm_thresholds_type(data.D1, family=family, type="free")
            crm_obj.set_crm_thresholds_value(data.D1,
                                             family=family,
                                             mode=mymode,
                                             value=low_th)
            crm_obj.set_crm_thresholds_type(data.D1,
                                            family=family,
                                            type="free")

    st.wait(opt_delay)  ## EXCEED
    crm_obj.get_crm_resources(data.D1, "all")
    interface_obj.interface_noshutdown(data.D1,
                                       data.dut_p1_interface,
                                       skip_verify=False)
    interface_obj.interface_noshutdown(data.D1,
                                       data.dut_p2_interface,
                                       skip_verify=False)
    crm_fdb_send_traffic(data)
    # CLEAR TH
    st.wait(final_wait)  ## CLEAR
    if not poll_wait(check_logging_result, 60, data):
        crm_obj.get_crm_resources(data.D1, "all")
        st.error('Failed to get threshold logs, CRM threshold tests failed')