Merge "Update alarm history only if change in alarm property"
This commit is contained in:
commit
1116249c51
@ -459,6 +459,8 @@ class AlarmController(rest.RestController):
|
||||
def _record_change(self, data, now, on_behalf_of=None, type=None):
|
||||
if not cfg.CONF.alarm.record_history:
|
||||
return
|
||||
if not data:
|
||||
return
|
||||
type = type or alarm_models.AlarmChange.RULE_CHANGE
|
||||
scrubbed_data = utils.stringify_timestamps(data)
|
||||
detail = json.dumps(scrubbed_data)
|
||||
|
@ -2182,6 +2182,28 @@ class TestAlarms(v2.FunctionalTest,
|
||||
history[0]['detail'])
|
||||
self.assertEqual('low', new_alarm['severity'])
|
||||
|
||||
def test_redundant_update_alarm_property_no_history_change(self):
|
||||
alarm = self._get_alarm('a')
|
||||
history = self._get_alarm_history(alarm)
|
||||
self.assertEqual([], history)
|
||||
self.assertEqual('critical', alarm['severity'])
|
||||
|
||||
self._update_alarm(alarm, dict(severity='low'))
|
||||
new_alarm = self._get_alarm('a')
|
||||
history = self._get_alarm_history(alarm)
|
||||
self.assertEqual(1, len(history))
|
||||
self.assertEqual(jsonutils.dumps({'severity': 'low'}),
|
||||
history[0]['detail'])
|
||||
self.assertEqual('low', new_alarm['severity'])
|
||||
|
||||
self._update_alarm(alarm, dict(severity='low'))
|
||||
updated_alarm = self._get_alarm('a')
|
||||
updated_history = self._get_alarm_history(updated_alarm)
|
||||
self.assertEqual(1, len(updated_history))
|
||||
self.assertEqual(jsonutils.dumps({'severity': 'low'}),
|
||||
updated_history[0]['detail'])
|
||||
self.assertEqual(history, updated_history)
|
||||
|
||||
def test_get_recorded_alarm_history_on_create(self):
|
||||
new_alarm = {
|
||||
'name': 'new_alarm',
|
||||
|
Loading…
Reference in New Issue
Block a user