Merge "Don't evaluate ceilometer watchrules"

This commit is contained in:
Jenkins 2014-10-10 16:06:53 +00:00 committed by Gerrit Code Review
commit 351b23fc61
2 changed files with 30 additions and 1 deletions

View File

@ -225,7 +225,7 @@ class WatchRule(object):
return fn()
def evaluate(self):
if self.state == self.SUSPENDED:
if self.state in [self.CEILOMETER_CONTROLLED, self.SUSPENDED]:
return []
# has enough time progressed to run the rule
self.now = timeutils.utcnow()

View File

@ -413,6 +413,35 @@ class WatchRuleTest(HeatTestCase):
self.assertEqual(self.wr.SUSPENDED, self.wr.state)
self.assertEqual([], actions)
def test_evaluate_ceilometer_controlled(self):
rule = {'EvaluationPeriods': '1',
'MetricName': 'test_metric',
'Period': '300',
'Statistic': 'Maximum',
'ComparisonOperator': 'GreaterThanOrEqualToThreshold',
'Threshold': '30'}
now = timeutils.utcnow()
self.m.StubOutWithMock(timeutils, 'utcnow')
timeutils.utcnow().MultipleTimes().AndReturn(now)
self.m.ReplayAll()
# Now data breaches Threshold, but we're suspended
last = now - datetime.timedelta(seconds=300)
data = WatchData(35, now - datetime.timedelta(seconds=150))
self.wr = watchrule.WatchRule(context=self.ctx,
watch_name="testwatch",
rule=rule,
watch_data=[data],
stack_id=self.stack_id,
last_evaluated=last)
self.wr.state_set(self.wr.CEILOMETER_CONTROLLED)
actions = self.wr.evaluate()
self.assertEqual(self.wr.CEILOMETER_CONTROLLED, self.wr.state)
self.assertEqual([], actions)
def test_rule_actions_alarm_normal(self):
rule = {'EvaluationPeriods': '1',
'MetricName': 'test_metric',