コード例 #1
0
def error_handling_module_hooks():
    global_vars_and_constants_init()
    if not st.is_valid_base_config():
        full_cleanup()
    error_handling_module_config(config='yes')
    if eh_data.clear_logs:
        clear_logging(eh_data.dut_list, thread=True)
    yield
    error_handling_module_config(config='no')
コード例 #2
0
def test_ft_ntp_disable_enable_with_message_log():
    """
    Author: Anil Kumar Kacharla <*****@*****.**>
    Referrence Topology : 	Test bed ID:4 D1--Mgmt network
    Verify that Ntp synchronization is successful after doing NTP server on and off  and the message log display the correct time based upon the system up time.
    """
    st.log("Ensuring minimum topology")
    vars = st.ensure_min_topology("D1")
    data.string_generate = 'Iam Testing NTP'
    data.lines = 1
    data.time_date = time.strftime('%a %B %d %H:%M:%S %Z %Y')
    ntp_obj.config_date(vars.D1, data.time_date)
    st.log("checking time in message log without ntp ")
    log_message_1 = syslog_obj.show_logging(vars.D1,
                                            severity=None,
                                            filter_list=[],
                                            lines=data.lines)
    if not log_message_1:
        st.log("log message_1 not created")
        st.report_fail("operation_failed")
    clock = common_obj.log_parser(log_message_1[0])
    config_ntp_server_on_config_db_file(vars.D1, data.servers)
    st.log("Generating log messages")
    syslog_obj.clear_logging(vars.D1)
    syslog_obj.write_logging(vars.D1, data.string_generate)
    log_message = syslog_obj.show_logging(vars.D1,
                                          severity=None,
                                          filter_list=[data.string_generate])
    if not log_message:
        st.log("log message not created")
        st.report_fail("operation_failed")
    st.log("printing system clock")
    ntp_obj.show_clock(vars.D1)
    out = common_obj.log_parser(log_message[0])
    if not (clock[0]['month'] == out[0]['month'] and clock[0]['hours']
            == out[0]['hours'] and clock[0]['date'] == out[0]['date']
            and clock[0]['minutes'] <= out[0]['minutes']
            or clock[0]['seconds'] >= out[0]['seconds']):
        st.log("time not updated")
        st.report_fail("operation_failed")
    st.log("message log displaying correct timed based on system up time")
    st.log("disabling ntp")
    basic_obj.service_operations(vars.D1, data.ntp_service, action="stop")
    if not ntp_obj.verify_ntp_service_status(vars.D1, 'inactive (dead)'):
        st.log("ntp disabled failed")
        st.report_fail("operation_failed")
    st.log("Enabling NTP")
    basic_obj.service_operations(vars.D1, data.ntp_service, action="restart")
    if not ntp_obj.verify_ntp_service_status(
            vars.D1, 'active (running)', iteration=65, delay=2):
        st.log("ntp is exited after enable and disable ntp")
        st.report_fail("operation_failed")
    if not ntp_obj.verify_ntp_status(
            vars.D1, iteration=65, delay=2, server=data.servers):
        st.log("ntp syncronization failed after enable and disable ntp")
        st.report_fail("operation_failed")
    st.report_pass("test_case_passed")
コード例 #3
0
def crm_clear_syslog(dut, maxretries=5, severity_type='WARNING', filters=[]):
    delay = 2
    for retry in range(0, maxretries):
        slog_obj.clear_logging(dut)
        st.log(
            'crminfo: Waiting {} secs for syslog to be cleared.. retry {}\n'.
            format(delay, retry + 1))
        st.wait(delay)
        if not slog_obj.get_logging_count(
                dut, severity=severity_type, filter_list=filters):
            return True
    return False
コード例 #4
0
ファイル: test_reboot.py プロジェクト: zero804/sonic-mgmt
def test_ft_sytem_bootup_logging_debug():
    """
    Author : Praveen Kumar Kota <*****@*****.**>
    Testbed : D1 --- Mgmt Network
    Verify that no unwanted logs are shown on DUT console with logging level "Debug".
    """
    st.log("clearing the logging buffer")
    if not log.clear_logging(vars.D1):
        st.report_fail("failed_to_clear_logs", vars.D1)
    st.log("enabling logging level as debug")
    if not log.set_logging_severity(vars.D1, severity="Debug"):
        st.report_fail("logging_severity_level_change_failed", vars.D1)
    st.log("waiting the DUT to idle for sometime")
    st.wait(data.idle_sleep)
    log.set_logging_severity(vars.D1, severity="INFO")
    platform = basic_obj.get_hwsku(vars.D1)
    logs = ['in obtaining media setting for'
            ] if platform.lower() in ['accton-as9716-32d'] else []
    if not log.check_for_logs_after_reboot(
            vars.D1, 'Error', log_severity=['DEBUG', 'INFO'
                                            ], except_logs=logs):
        st.report_fail("logs_are_getting_generated_after_reboot", vars.D1)
    if not log.check_unwanted_logs_in_logging(vars.D1, user_filter=[]):
        st.report_fail("logs_are_getting_generated_after_reboot", vars.D1)
    st.report_pass("test_case_passed")
コード例 #5
0
def pvst_elastic_module_hooks(request):
    global vars
    global stp_ela
    try:
        vars = st.ensure_min_topology("D1D2:3", "D2D3:3", "D1D3:3")
        lib_stp.init_cli_type()
        stp_ela = stp_wrap.apply_and_verify_module_config(vars, stp_protocol)
        st.log(stp_ela)
    except Exception as e:
        st.log(e)
        st.report_fail("exception", e)
    dut_list = stp_wrap.get_dut_list(vars)
    for d in dut_list:
        slog.clear_logging(d)
    yield
    stp.config_stp_in_parallel(dut_list, feature=stp_protocol, mode="disable")
    vlan.clear_vlan_configuration(dut_list)
    portchannel.clear_portchannel_configuration(dut_list)
    stp_wrap.complete_data.clear()
コード例 #6
0
def test_ft_vlan_syslog_verify():
    """
    Author:Anil Kumar Kacharla <*****@*****.**>
    Referrence Topology :   Test bed ID:4 D1--Mgmt network
    verify VLAN syslog functionality.
    """
    vars = st.ensure_min_topology("D1")
    sc_data.vlan_test = str(random_vlan_list(1, [int(sc_data.vlan)])[0])
    result = 1
    slog.clear_logging(vars.D1)
    st.log("checking vlan count before vlan addition or deletion")
    count_before_add = slog.get_logging_count(vars.D1,
                                              severity="NOTICE",
                                              filter_list=["addVlan"])
    count_before_delete = slog.get_logging_count(vars.D1,
                                                 severity="NOTICE",
                                                 filter_list=["removeVlan"])
    st.log("vlan count before  adding vlan:{}".format(count_before_add))
    st.log("vlan count before  deleting vlan:{}".format(count_before_delete))
    vlan.create_vlan(vars.D1, sc_data.vlan_test)
    vlan.delete_vlan(vars.D1, sc_data.vlan_test)
    st.log("checking vlan count after adding vlan")
    count_after_add = slog.get_logging_count(vars.D1,
                                             severity="NOTICE",
                                             filter_list=["addVlan:"])
    st.log("vlan count after  adding vlan:{}".format(count_after_add))
    count_after_delete = slog.get_logging_count(vars.D1,
                                                severity="NOTICE",
                                                filter_list=["removeVlan:"])
    st.log("vlan count after  deleting vlan:{}".format(count_after_delete))
    if not count_after_add > count_before_add:
        st.error("vlan log count increamented after adding vlan:{}".format(
            count_after_add))
        result = 0
    if not count_after_delete > count_before_delete:
        st.error("vlan log count increamented after deleting vlan:{}".format(
            count_after_delete))
        result = 0
    if not result:
        st.report_fail("test_case_fail")
    st.log(" vlan count after adding or deleting vlan is incremented")
    st.report_pass("test_case_passed")
コード例 #7
0
ファイル: test_reboot.py プロジェクト: yozhao101/sonic-mgmt
def test_ft_sytem_bootup_logging_debug():
    """
    Author : Praveen Kumar Kota <*****@*****.**>
    Testbed : D1 --- Mgmt Network
    Verify that no unwanted logs are shown on DUT console with logging level "Debug".
    """
    vars = st.ensure_min_topology("D1")
    st.log("clearing the logging buffer")
    if not log.clear_logging(vars.D1):
        st.report_fail("failed_to_clear_logs", vars.D1)
    st.log("enabling logging level as debug")
    if not log.set_logging_severity(vars.D1, severity="Debug"):
        st.report_fail("logging_severity_level_change_failed", vars.D1)
    st.log("waiting the DUT to idle for sometime")
    st.wait(data.idle_sleep)
    log.set_logging_severity(vars.D1, severity="INFO")
    if not log.check_unwanted_logs_in_logging(vars.D1, user_filter=[]):
        st.report_fail("logs_are_getting_generated_after_reboot", vars.D1)
    st.report_pass("test_case_passed")
コード例 #8
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')
コード例 #9
0
def error_handling_func_hooks():
    if eh_data.debug:
        get_running_config(vars.D1)
    yield
    if eh_data.clear_logs:
        clear_logging(eh_data.dut_list, thread=True)
コード例 #10
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')