示例#1
0
def test_alarms():
    output = """+------+----------+-------------+-----------+----------+------------+
| UUID | Alarm ID | Reason Text | Entity ID | Severity | Time Stamp |
+------+----------+-------------+-----------+----------+------------+
+------+----------+-------------+-----------+----------+------------+
Mon Apr  3 19:41:50 UTC 2017
controller-0:~$ """

    table_ = table_parser.table(output)
    print("empty table: {}".format(table_))
    alarms = system_helper.get_alarms()
    # system_helper.delete_alarms()
    # system_helper.get_alarms()
    system_helper.get_alarms_table()
    def teardown():
        LOG.fixture_step("Unsuppress all events")
        system_helper.unsuppress_all_events(fail_ok=True)

        LOG.fixture_step("Delete 300.005 alarm(s)")
        active_alarm_tab = system_helper.get_alarms_table(
            query_key='alarm_id', query_value='300.005')
        alarm_uuids = table_parser.get_column(active_alarm_tab, 'UUID')
        system_helper.delete_alarms(alarm_uuids)
示例#3
0
    def del_alarms():
        LOG.fixture_step(
            "Delete 300.005 alarms and ensure they are removed from alarm-list"
        )
        alarms_tab = system_helper.get_alarms_table(uuid=True)
        alarm_uuids = table_parser.get_values(table_=alarms_tab,
                                              target_header='UUID',
                                              **{'Alarm ID': alarm_id})
        if alarm_uuids:
            system_helper.delete_alarms(alarms=alarm_uuids)

        post_del_alarms = system_helper.get_alarms(alarm_id=alarm_id)
        assert not post_del_alarms, "300.005 alarm still exits after deletion"
示例#4
0
def pre_alarm_():
    """
    Text fixture to get pre-test existing alarm list.
    Args:None

    Returns: list of alarms

    """
    pre_alarms = system_helper.get_alarms_table()
    pre_list = table_parser.get_all_rows(pre_alarms)
    # Time stamps are removed before comparing alarms with post test alarms.
    # The time stamp  is the last item in each alarm row.
    for n in pre_list:
        n.pop()
    return pre_list
示例#5
0
def test_GET_ialarms_valid(sysinv_rest, authorize_valid, resource_valid,
                           expected_status):
    """
    Test GET of <resource> with valid authentication.

    Args:
        n/a

    Prerequisites: system is running
    Test Setups:
        n/a
    Test Steps:
        - Using requests GET <resource> with proper authentication
        - Determine if expected status_code of 200 is received
    Test Teardown:
        n/a
    """
    r = sysinv_rest
    path = "/ialarms/{}"
    if resource_valid:
        alarm_list = system_helper.get_alarms_table()
    else:
        alarm_list = {'values': [['ffffffff-ffff-ffff-ffff-ffffffffffff']]}

    for alarm in alarm_list['values']:
        alarm_uuid = alarm
        message = "Using requests GET {} with proper authentication"
        LOG.tc_step(message.format(path))
        res = path.format(alarm_uuid)
        status_code, text = r.get(resource=res, auth=authorize_valid)
        message = "Retrieved: status_code: {} message: {}"
        LOG.debug(message.format(status_code, text))
        if status_code == 404:
            pytest.skip("Unsupported resource in this configuration.")
        else:
            message = "Determine if expected code of {} is received"
            LOG.tc_step(message.format(expected_status))
            message = \
                "Expected code of expected_status - received {} and message {}"
            assert status_code == expected_status, \
                message.format(expected_status, status_code, text)
示例#6
0
def test_alarms_and_events_timestamp_order(generate_alarms):
    """
    Verify the chronological order to the alarms

    Scenario:
    1. Query the events and alarms table
    2. Verify the list is shown most recent alarm to oldest (based on timestamp) [REQ-14]
    """
    alarm_id = generate_alarms

    LOG.tc_step("Check system events are displayed in chronological order")
    events_table = system_helper.get_events_table(limit=15, show_uuid=True)
    check_timestamps_order(events_table)

    LOG.tc_step("Check active alarms are displayed in chronological order")
    alarms_table = system_helper.get_alarms_table()
    assert 10 == len(
        table_parser.get_values(alarms_table, 'UUID',
                                **{'Alarm ID':
                                   alarm_id})), "Unexpected alarm count"

    check_timestamps_order(table_=alarms_table)
示例#7
0
def test_event_list(event_option, severity):
    """
       Test logs is to verify log generation of Critical Major Minor of alarms and logs
       Args:
           test_event_list event_option and Severity

       Test Setup:
           - Generate alarms according to severity
       Test Steps:
           - Query alarms/logs with severity
           - Verify generated alarm was success.
       Test Teardown:
           - None
    """
    limit = 5
    LOG.tc_step('Generate alarms.')
    if event_option == 'alarms':
        alarm_log_generate_str = "fmClientCli -c  \"### ###300.005###set###system.vm### ### ###" + \
                         severity + "###Automation Test Alarm ### ###Automation Generate### ###True###True###\""
        alarm_id="300.005"
    else:
        alarm_id = "600.005"
        alarm_log_generate_str = "fmClientCli -c  \"### ###600.005###msg###system.vm###host=compute-0.vm=$i### ### " + \
                        severity + "###'oam' Test###Automation Generate###cpu-cycles-limit-" \
                                   "exceeded### ###True###True### \""
    alarm_generate_succ = generate_alarm_log(alarm_log_generate_str, int(limit))
    assert alarm_generate_succ, "Alarm / LOG Generated"

    LOG.tc_step('Query ' + event_option + ' ' + severity)
    query_tab = system_helper.get_events_table(limit=limit, show_only=event_option, severity=severity)

    LOG.tc_step('Verify test result')
    check_flag = query_check(len(query_tab['values']), int(limit) - 1)
    assert check_flag != 1, " Test Failed "
    active_alarm_uuid = system_helper.get_alarms_table(uuid=True, query_key='alarm_id', query_value=alarm_id,
                                                       query_type='string')
    if event_option == 'alarms':
        uuid_val = active_alarm_uuid['values'][0][0]
        system_helper.delete_alarms(alarms=uuid_val)
def test_alarm_suppression(alarm_test_prep):
    """
       Verify suppression and unsuppression of active alarm and query alarms.

       Test Setup:
           - Unsuppress all alarms
             Generate alarms
       Test Steps:

            Suppress alarms
            Verify alarm supressed
            Generate alarm again
            Verify suppressed alarms no in active
            Unsuppressed alarm
            Verify unsuppressed in active alarm list.
            Delete last active alarm
       Test Teardown:
           - Unsuppress all alarms
    """
    LOG.tc_step('Suppress generated alarm and Verify it is suppressed')
    alarm_uuid = alarm_test_prep
    query_active_alarm = system_helper.get_alarms_table(query_key='uuid',
                                                        query_value=alarm_uuid)
    alarm_id = table_parser.get_values(table_=query_active_alarm,
                                       target_header='Alarm ID',
                                       **{"UUID": alarm_uuid})[0]
    assert '300.005' == alarm_id
    # alarm_id = ''.join(alarm_id)
    system_helper.suppress_event(alarm_id=alarm_id)

    LOG.tc_step('Generate Alarm again and Verify not in the Active list')
    system_helper.generate_event(event_id=alarm_id)
    alarms = system_helper.get_alarms(alarm_id=alarm_id)
    assert not alarms, "300.005 alarm appears in the active alarms table after regenerating"

    LOG.tc_step('UnSuppress alarm and verify it is unsuppressed')
    system_helper.unsuppress_event(alarm_id=alarm_id)
示例#9
0
def get_sensor_alarm(host, sensor_name):
    """Verify that the correct sensor action occurs for the triggered
    event and configured sensor action."""

    alarm_generated = False
    alarm_uuid = None
    alarm_id = None
    alarm_severity = None

    query_value = 'host={}'.format(host)
    alarms_table = system_helper.get_alarms_table(
        query_key='entity_instance_id',
        query_value=query_value,
        query_type='string')

    for alarm in alarms_table['values']:
        if sensor_name in alarm[2]:
            alarm_generated = True
            alarm_uuid = alarm[0]
            alarm_id = alarm[1]
            alarm_severity = alarm[4]
            break

    return alarm_generated, alarm_uuid, alarm_id, alarm_severity
示例#10
0
def test_system_alarms_and_events_on_lock_unlock_compute(no_simplex):
    """
    Verify fm alarm-show command

    Test Steps:
    - Delete active alarms
    - Lock a host
    - Check active alarm generated for host lock
    - Check relative values are the same in fm alarm-list and fm alarm-show
    <uuid>
    - Check host lock 'set' event logged via fm event-list
    - Unlock host
    - Check active alarms cleared via fm alarm-list
    - Check host lock 'clear' event logged via fm event-list
    """

    # Remove following step because it's unnecessary and fails the test when
    # alarm is re-generated
    # # Clear the alarms currently present
    # LOG.tc_step("Clear the alarms table")
    # system_helper.delete_alarms()

    # Raise a new alarm by locking a compute node
    # Get the compute
    compute_host = host_helper.get_up_hypervisors()[0]
    if compute_host == system_helper.get_active_controller_name():
        compute_host = system_helper.get_standby_controller_name()
        if not compute_host:
            skip('Standby controller unavailable')

    LOG.tc_step("Lock a nova hypervisor host {}".format(compute_host))
    pre_lock_time = common.get_date_in_format()
    HostsToRecover.add(compute_host)
    host_helper.lock_host(compute_host)

    LOG.tc_step("Check host lock alarm is generated")
    post_lock_alarms = \
        system_helper.wait_for_alarm(field='UUID', entity_id=compute_host,
                                     reason=compute_host,
                                     alarm_id=EventLogID.HOST_LOCK,
                                     strict=False,
                                     fail_ok=False)[1]

    LOG.tc_step(
        "Check related fields in fm alarm-list and fm alarm-show are of the "
        "same values")
    post_lock_alarms_tab = system_helper.get_alarms_table(uuid=True)

    alarms_l = ['Alarm ID', 'Entity ID', 'Severity', 'Reason Text']
    alarms_s = ['alarm_id', 'entity_instance_id', 'severity', 'reason_text']

    # Only 1 alarm since we are now checking the specific alarm ID
    for post_alarm in post_lock_alarms:
        LOG.tc_step(
            "Verify {} for alarm {} in alarm-list are in sync with "
            "alarm-show".format(
                alarms_l, post_alarm))

        alarm_show_tab = table_parser.table(cli.fm('alarm-show', post_alarm)[1])
        alarm_list_tab = table_parser.filter_table(post_lock_alarms_tab,
                                                   UUID=post_alarm)

        for i in range(len(alarms_l)):
            alarm_l_val = table_parser.get_column(alarm_list_tab,
                                                  alarms_l[i])[0]
            alarm_s_val = table_parser.get_value_two_col_table(alarm_show_tab,
                                                               alarms_s[i])

            assert alarm_l_val == alarm_s_val, \
                "{} value in alarm-list: {} is different than alarm-show: " \
                "{}".format(alarms_l[i], alarm_l_val, alarm_s_val)

    LOG.tc_step("Check host lock is logged via fm event-list")
    system_helper.wait_for_events(entity_instance_id=compute_host,
                                  start=pre_lock_time, timeout=60,
                                  event_log_id=EventLogID.HOST_LOCK,
                                  fail_ok=False, **{'state': 'set'})

    pre_unlock_time = common.get_date_in_format()
    LOG.tc_step("Unlock {}".format(compute_host))
    host_helper.unlock_host(compute_host)

    LOG.tc_step("Check host lock active alarm cleared")
    alarm_sets = [(EventLogID.HOST_LOCK, compute_host)]
    system_helper.wait_for_alarms_gone(alarm_sets, fail_ok=False)

    LOG.tc_step("Check host lock clear event logged")
    system_helper.wait_for_events(event_log_id=EventLogID.HOST_LOCK,
                                  start=pre_unlock_time,
                                  entity_instance_id=compute_host,
                                  fail_ok=False, **{'state': 'clear'})