Merge "Fix the return of statistic with getting no sample"
This commit is contained in:
commit
e63ee55317
@ -735,6 +735,10 @@ class Connection(base.Connection):
|
||||
res = self._make_stats_query(sample_filter,
|
||||
None,
|
||||
aggregate).first()
|
||||
if not res:
|
||||
# NOTE(liusheng):The 'res' may be NoneType, because no
|
||||
# sample has found with sample filter(s).
|
||||
return
|
||||
|
||||
query = self._make_stats_query(sample_filter, groupby, aggregate)
|
||||
# HACK(jd) This is an awful method to compute stats by period, but
|
||||
|
@ -1359,6 +1359,14 @@ class StatisticsTest(DBTestBase,
|
||||
self.assertEqual(results.sum, 18)
|
||||
self.assertEqual(results.avg, 6)
|
||||
|
||||
def test_with_no_sample(self):
|
||||
f = storage.SampleFilter(
|
||||
user='user-not-exists',
|
||||
meter='volume.size',
|
||||
)
|
||||
results = list(self.conn.get_meter_statistics(f, period=1800))
|
||||
self.assertEqual([], results)
|
||||
|
||||
|
||||
class StatisticsGroupByTest(DBTestBase,
|
||||
tests_db.MixinTestsWithBackendScenarios):
|
||||
|
Loading…
x
Reference in New Issue
Block a user