Skip to content

Commit

Permalink
Merge pull request python-diamond#629 from williamjoy/patch-2
Browse files Browse the repository at this point in the history
dict generator does not work for python 2.6
  • Loading branch information
shortdudey123 authored Apr 5, 2017
2 parents ce5a2b8 + 40b9e2d commit 50e7eb5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/collectors/mesos/mesos.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,8 @@ def _group_and_publish_tasks_statistics(self, result):

def _sum_statistics(self, x, y):
stats = set(x) | set(y)
summed_stats = {
key: x.get(key, 0) + y.get(key, 0)
for key in stats
}
summed_stats = dict([(key, x.get(key, 0) + y.get(key, 0))
for key in stats])
return summed_stats

def _collect_slave_statistics(self):
Expand Down
7 changes: 7 additions & 0 deletions src/collectors/mesos/test/testmesos.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,13 @@ def test_https(self):
self.assertEqual('https://localhost:5050/metrics/snapshot',
self.collector._get_url("metrics/snapshot"))

def test_sum_statistics(self):
metrics_1 = {'cpu': 50, 'mem': 30, 'loadavg': 1}
metrics_2 = {'cpu': 10, 'mem': 30, 'network': 10}
self.assertEqual(self.collector._sum_statistics(metrics_1, metrics_2),
{'mem': 60, 'loadavg': 1, 'network': 10, 'cpu': 60})


##########################################################################
if __name__ == "__main__":
unittest.main()

0 comments on commit 50e7eb5

Please sign in to comment.