Skip to content

Commit

Permalink
[tests] fixes to the common AgentCheckTest class
Browse files Browse the repository at this point in the history
* For metrics and service checks, if there were none reported during
the check run, the coverage report would raise because of a division
by zero.
* Remove the warning message when using count.
  • Loading branch information
LeoCavaille committed Mar 17, 2015
1 parent 2fffdfd commit 9fc51fa
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,10 @@ def coverage_report(self):
tested_metrics += 1
else:
untested_metrics.append(m)
coverage_metrics=100.0 * tested_metrics / total_metrics
if total_metrics == 0:
coverage_metrics = 100.0
else:
coverage_metrics = 100.0 * tested_metrics / total_metrics

total_sc = len(self.service_checks)
tested_sc = 0
Expand All @@ -190,7 +193,11 @@ def coverage_report(self):
tested_sc += 1
else:
untested_sc.append(sc)
coverage_sc=100.0 * tested_sc / total_sc

if total_sc == 0:
coverage_sc = 100.0
else:
coverage_sc = 100.0 * tested_sc / total_sc

coverage = """Coverage
========================================
Expand Down Expand Up @@ -240,8 +247,6 @@ def assertMetric(self, metric_name, value=None, tags=None, count=None, at_least=
if count is not None:
log.debug(" * should have exactly {0} data points".format(count))
if at_least is not None:
if count is not None:
log.warn("Tolerance param will be ignored b/c count is present")
log.debug(" * should have at least {0} data points".format(at_least))

candidates = []
Expand All @@ -266,8 +271,6 @@ def assertMetricTagPrefix(self, metric_name, tag_prefix, count=None, at_least=1)
if count is not None:
log.debug(" * should have exactly {0} data points".format(count))
if at_least is not None:
if count is not None:
log.warn("Tolerance param will be ignored b/c count is present")
log.debug(" * should have at least {0} data points".format(at_least))

candidates = []
Expand All @@ -290,8 +293,6 @@ def assertMetricTag(self, metric_name, tag, count=None, at_least=1):
if count is not None:
log.debug(" * should have exactly {0} data points".format(count))
if at_least is not None:
if count is not None:
log.warn("Tolerance param will be ignored b/c count is present")
log.debug(" * should have at least {0} data points".format(at_least))

candidates = []
Expand Down

0 comments on commit 9fc51fa

Please sign in to comment.