Make sure that the period is returned as an int as the api expects an int.
bug #1132628 Change-Id: Iccb71232e1fbb53318af231a4966c0d19a83fca5 Signed-off-by: Angus Salkeld <asalkeld@redhat.com>
This commit is contained in:
parent
9335d81316
commit
0cdd947579
@ -232,7 +232,8 @@ class Connection(base.Connection):
|
||||
function (key, value) {
|
||||
value.avg = value.sum / value.count;
|
||||
value.duration = (value.duration_end - value.duration_start) / 1000;
|
||||
value.period = (value.period_end - value.period_start) / 1000;
|
||||
value.period = NumberInt((value.period_end - value.period_start)
|
||||
/ 1000);
|
||||
return value;
|
||||
}""")
|
||||
|
||||
|
@ -403,7 +403,8 @@ class Connection(base.Connection):
|
||||
'duration_end': result.tsmax,
|
||||
'duration': timeutils.delta_seconds(result.tsmin,
|
||||
result.tsmax),
|
||||
'period': timeutils.delta_seconds(period_start, period_end),
|
||||
'period': int(timeutils.delta_seconds(period_start,
|
||||
period_end)),
|
||||
'period_start': period_start,
|
||||
'period_end': period_end}
|
||||
|
||||
|
@ -765,6 +765,14 @@ class StatisticsTest(DBTestBase):
|
||||
assert results['sum'] == 27
|
||||
assert results['avg'] == 9
|
||||
|
||||
def test_period_is_int(self):
|
||||
f = storage.EventFilter(
|
||||
meter='volume.size',
|
||||
)
|
||||
results = self.conn.get_meter_statistics(f)[0]
|
||||
assert(isinstance(results['period'], int))
|
||||
assert results['count'] == 6
|
||||
|
||||
def test_by_user_period(self):
|
||||
f = storage.EventFilter(
|
||||
user='user-5',
|
||||
@ -787,6 +795,7 @@ class StatisticsTest(DBTestBase):
|
||||
self.assertEqual(r['max'], 9)
|
||||
self.assertEqual(r['sum'], 17)
|
||||
self.assertEqual(r['period'], 7200)
|
||||
self.assertEqual(isinstance(r['period'], int))
|
||||
self.assertEqual(r['period_end'],
|
||||
r['period_start']
|
||||
+ datetime.timedelta(seconds=7200))
|
||||
|
Loading…
x
Reference in New Issue
Block a user