Skip to content

Commit

Permalink
[postgres/ci] more coverage when asserting metric tags
Browse files Browse the repository at this point in the history
+ refactor a bit the code with the new handy methods that were added to
AgentCheckTest
+ added a bunch of FIXMEs in the code where me mutate caps-variables
which are supposed to be constant. Not doing it now b/c it involves a
further refactoring of the whole check logic
  • Loading branch information
LeoCavaille committed Apr 7, 2015
1 parent 1e33409 commit ab60a13
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
3 changes: 3 additions & 0 deletions checks.d/postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,10 +365,12 @@ def _collect_stats(self, key, db, instance_tags, relations, custom_metrics):
bgw_instance_metrics = self._get_bgw_metrics(key, db)

if db_instance_metrics is not None:
# FIXME: constants shouldn't be modified
self.DB_METRICS['metrics'] = db_instance_metrics
metric_scope.append(self.DB_METRICS)

if bgw_instance_metrics is not None:
# FIXME: constants shouldn't be modified
self.BGW_METRICS['metrics'] = bgw_instance_metrics
metric_scope.append(self.BGW_METRICS)

Expand All @@ -383,6 +385,7 @@ def _collect_stats(self, key, db, instance_tags, relations, custom_metrics):

replication_metrics = self._get_replication_metrics(key, db)
if replication_metrics is not None:
# FIXME: constants shouldn't be modified
self.REPLICATION_METRICS['metrics'] = replication_metrics
metric_scope.append(self.REPLICATION_METRICS)

Expand Down
6 changes: 1 addition & 5 deletions tests/test_postgres.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,7 @@ def test_checks(self):
}
]

self.run_check(dict(instances=instances))
# Rate metrics, need 2 collection rounds
time.sleep(1)
self.run_check(dict(instances=instances))
self.run_check_twice(dict(instances=instances))

# Useful to get server version
# FIXME: Not great, should have a function like that available
Expand Down Expand Up @@ -219,4 +216,3 @@ def test_checks(self):
)

self.coverage_report()
return

0 comments on commit ab60a13

Please sign in to comment.