Changes for alarmed metrics
Use alarmDefintionId instead of alarmId to find the right notificaion. Further changes are needed to complete this change. Change-Id: I577559fd085261f01a36355095fa1c04a72fb9c9
This commit is contained in:
parent
3d1deca139
commit
eed5a4ad16
|
@ -51,6 +51,7 @@ class AlarmProcessor(BaseProcessor):
|
|||
expected_fields = [
|
||||
'actionsEnabled',
|
||||
'alarmId',
|
||||
'alarmDefinitionId',
|
||||
'alarmName',
|
||||
'newState',
|
||||
'oldState',
|
||||
|
@ -120,7 +121,7 @@ class AlarmProcessor(BaseProcessor):
|
|||
FROM alarm_action as aa
|
||||
JOIN notification_method as nm ON aa.action_id = nm.id
|
||||
WHERE aa.alarm_id = %s and aa.alarm_state = %s""",
|
||||
[alarm['alarmId'], alarm['newState']])
|
||||
[alarm['alarmDefinitionId'], alarm['newState']])
|
||||
except MySQLdb.Error:
|
||||
log.exception('Mysql Error')
|
||||
raise
|
||||
|
|
|
@ -87,8 +87,9 @@ class TestAlarmProcessor(unittest.TestCase):
|
|||
|
||||
def test_old_timestamp(self):
|
||||
"""Should cause the alarm_ttl to fire log a warning and push to finished queue."""
|
||||
alarm_dict = {"tenantId": "0", "alarmId": "0", "alarmName": "test Alarm", "oldState": "OK", "newState": "ALARM",
|
||||
"stateChangeReason": "I am alarming!", "timestamp": 1375346830, "actionsEnabled": 1}
|
||||
alarm_dict = {"tenantId": "0", "alarmDefinitionId": "0", "alarmId": "1", "alarmName": "test Alarm",
|
||||
"oldState": "OK", "newState": "ALARM", "stateChangeReason": "I am alarming!",
|
||||
"timestamp": 1375346830, "actionsEnabled": 1}
|
||||
self.alarm_queue.put(self._create_raw_alarm(0, 2, alarm_dict))
|
||||
finished, log_msg = self._run_alarm_processor(self.finished_queue, None)
|
||||
|
||||
|
@ -98,8 +99,9 @@ class TestAlarmProcessor(unittest.TestCase):
|
|||
def test_no_notifications(self):
|
||||
"""Test an alarm with no defined notifications
|
||||
"""
|
||||
alarm_dict = {"tenantId": "0", "alarmId": "0", "alarmName": "test Alarm", "oldState": "OK", "newState": "ALARM",
|
||||
"stateChangeReason": "I am alarming!", "timestamp": time.time(), "actionsEnabled": 1}
|
||||
alarm_dict = {"tenantId": "0", "alarmDefinitionId": "0", "alarmId": "1", "alarmName": "test Alarm",
|
||||
"oldState": "OK", "newState": "ALARM", "stateChangeReason": "I am alarming!",
|
||||
"timestamp": time.time(), "actionsEnabled": 1}
|
||||
self.alarm_queue.put(self._create_raw_alarm(0, 3, alarm_dict))
|
||||
finished, log_msg = self._run_alarm_processor(self.finished_queue, None)
|
||||
|
||||
|
@ -108,8 +110,9 @@ class TestAlarmProcessor(unittest.TestCase):
|
|||
def test_valid_notification(self):
|
||||
"""Test a valid notification, being put onto the notification_queue
|
||||
"""
|
||||
alarm_dict = {"tenantId": "0", "alarmId": "0", "alarmName": "test Alarm", "oldState": "OK", "newState": "ALARM",
|
||||
"stateChangeReason": "I am alarming!", "timestamp": time.time(), "actionsEnabled": 1}
|
||||
alarm_dict = {"tenantId": "0", "alarmDefinitionId": "0", "alarmId": "1", "alarmName": "test Alarm",
|
||||
"oldState": "OK", "newState": "ALARM", "stateChangeReason": "I am alarming!",
|
||||
"timestamp": time.time(), "actionsEnabled": 1}
|
||||
self.alarm_queue.put(self._create_raw_alarm(0, 4, alarm_dict))
|
||||
sql_response = [['test notification', 'EMAIL', 'me@here.com']]
|
||||
finished, log_msg = self._run_alarm_processor(self.notification_queue, sql_response)
|
||||
|
@ -119,8 +122,9 @@ class TestAlarmProcessor(unittest.TestCase):
|
|||
self.assertTrue(finished == [test_notification])
|
||||
|
||||
def test_two_valid_notifications(self):
|
||||
alarm_dict = {"tenantId": "0", "alarmId": "0", "alarmName": "test Alarm", "oldState": "OK", "newState": "ALARM",
|
||||
"stateChangeReason": "I am alarming!", "timestamp": time.time(), "actionsEnabled": 1}
|
||||
alarm_dict = {"tenantId": "0", "alarmDefinitionId": "0", "alarmId": "1", "alarmName": "test Alarm",
|
||||
"oldState": "OK", "newState": "ALARM", "stateChangeReason": "I am alarming!",
|
||||
"timestamp": time.time(), "actionsEnabled": 1}
|
||||
self.alarm_queue.put(self._create_raw_alarm(0, 5, alarm_dict))
|
||||
sql_response = [['test notification', 'EMAIL', 'me@here.com'], ['test notification2', 'EMAIL', 'me@here.com']]
|
||||
finished, log_msg = self._run_alarm_processor(self.notification_queue, sql_response)
|
||||
|
|
Loading…
Reference in New Issue