Merge "Don't notify alarm on each refresh"

This commit is contained in:
Jenkins 2016-05-12 08:30:12 +00:00 committed by Gerrit Code Review
commit d7165d0c44
2 changed files with 17 additions and 1 deletions

View File

@ -125,7 +125,9 @@ class Evaluator(object):
alarm.alarm_id)
else:
self._record_change(alarm)
self.notifier.notify(alarm, previous, reason, reason_data)
self.notifier.notify(alarm, previous, reason, reason_data)
elif alarm.repeat_actions:
self.notifier.notify(alarm, previous, reason, reason_data)
except Exception:
# retry will occur naturally on the next evaluation
# cycle (unless alarm state reverts in the meantime)

View File

@ -405,3 +405,17 @@ class TestEvaluate(base.TestEvaluatorBase):
(2, self.sub_rule2),
(3, self.sub_rule3)), False))
self.assertEqual(expected, self.notifier.notify.call_args)
def test_known_state_with_sub_rules_trending_state_and_not_repeat(self):
alarm = self.alarms[2]
alarm.state = 'ok'
maxs = [self._get_stats('max', self.sub_rule2['threshold'] + 0.01 * v)
for v in moves.xrange(-1, 4)]
avgs = [self._get_stats('avg', self.sub_rule3['threshold'] + 0.01 * v)
for v in moves.xrange(-1, 3)]
avgs2 = [self._get_stats('avg', self.sub_rule1['threshold'] - 0.01 * v)
for v in moves.xrange(1, 6)]
self.api_client.statistics.list.side_effect = [avgs2, maxs, avgs]
self.evaluator.evaluate(alarm)
self.assertEqual('ok', alarm.state)
self.assertEqual([], self.notifier.notify.mock_calls)