Skip to content

Commit

Permalink
Ensure the statistics are sorted
Browse files Browse the repository at this point in the history
Sort the statistics by the period start date before
returning them, and restore the test that verifies
this behavior.

bug 1151345

Change-Id: I4f05ea049b7609cea9dab947738b7aabf3f062ef
Signed-off-by: Doug Hellmann <doug.hellmann@dreamhost.com>
  • Loading branch information
Doug Hellmann committed Mar 8, 2013
1 parent e7fc028 commit 0bc53f7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 3 additions & 1 deletion ceilometer/storage/impl_mongodb.py
Expand Up @@ -20,6 +20,7 @@

import copy
import datetime
import operator
import re
import urlparse

Expand Down Expand Up @@ -519,7 +520,8 @@ def get_meter_statistics(self, event_filter, period=None):
query=q,
)

return [r['value'] for r in results['results']]
return sorted((r['value'] for r in results['results']),
key=operator.itemgetter('period_start'))

def get_volume_sum(self, event_filter):
"""Return the sum of the volume field for the events
Expand Down
4 changes: 0 additions & 4 deletions tests/storage/base.py
Expand Up @@ -804,9 +804,6 @@ def test_by_user_period(self):
self.assertEqual(set(r['period_end'] for r in results),
set([datetime.datetime(2012, 9, 25, 12, 28),
datetime.datetime(2012, 9, 25, 14, 28)]))
'''
# FXIME(llu) Temporary comment out to pass Jenkins unittest.
# Will resume this after bug #1151345 is fixed.
r = results[0]
self.assertEqual(r['period_start'],
datetime.datetime(2012, 9, 25, 10, 28))
Expand All @@ -824,7 +821,6 @@ def test_by_user_period(self):
datetime.datetime(2012, 9, 25, 10, 30))
self.assertEqual(r['duration_end'],
datetime.datetime(2012, 9, 25, 11, 31))
'''

def test_by_project(self):
f = storage.EventFilter(
Expand Down

0 comments on commit 0bc53f7

Please sign in to comment.