Ensure statistics aggregates are ordered with parameterized first
Fixes bug 1298528 Due to WSME re-ordering of query parameters, in the mixed case any parameterized aggregates must be specified in the URL first, prior to any unparameterized aggregates. Otherwise the aggregate parameter will be associated with the wrong aggregate function. Change-Id: Ib2c76d03a4fc91d13074a03caade2c776d2309b3
This commit is contained in:
@@ -181,13 +181,13 @@ class StatisticsManagerTest(utils.BaseTestCase):
|
||||
|
||||
def test_list_by_meter_name_with_aggregates(self):
|
||||
aggregates = [
|
||||
{
|
||||
'func': 'count',
|
||||
},
|
||||
{
|
||||
'func': 'cardinality',
|
||||
'param': 'resource_id',
|
||||
},
|
||||
{
|
||||
'func': 'count',
|
||||
}
|
||||
]
|
||||
stats = list(self.mgr.list(meter_name='instance',
|
||||
aggregates=aggregates))
|
||||
|
||||
@@ -26,13 +26,19 @@ class StatisticsManager(base.Manager):
|
||||
def _build_aggregates(self, aggregates):
|
||||
url_aggregates = []
|
||||
for aggregate in aggregates:
|
||||
url_aggregates.append(
|
||||
"aggregate.func=%(func)s" % aggregate
|
||||
)
|
||||
if 'param' in aggregate:
|
||||
url_aggregates.append(
|
||||
url_aggregates.insert(
|
||||
0,
|
||||
"aggregate.param=%(param)s" % aggregate
|
||||
)
|
||||
url_aggregates.insert(
|
||||
0,
|
||||
"aggregate.func=%(func)s" % aggregate
|
||||
)
|
||||
else:
|
||||
url_aggregates.append(
|
||||
"aggregate.func=%(func)s" % aggregate
|
||||
)
|
||||
return url_aggregates
|
||||
|
||||
def list(self, meter_name, q=None, period=None, groupby=[], aggregates=[]):
|
||||
|
||||
Reference in New Issue
Block a user