Fix metrics statistics with multiple statistics
When getting metrics statistics by monasca client, if statistics option has multiple statistics, it will be failed with 422 status and "Invalid statistic" description. Change-Id: Icd90e298f93af8a6aa798e2b0f9967123767cd0a
This commit is contained in:
parent
5ce5074a38
commit
fc51f82d94
|
@ -257,7 +257,7 @@ def get_query_statistics(req):
|
|||
if isinstance(params['statistics'], list):
|
||||
statistics.extend(params['statistics'])
|
||||
else:
|
||||
statistics.append(params['statistics'])
|
||||
statistics.extend(params['statistics'].split(','))
|
||||
statistics = [statistic.lower() for statistic in statistics]
|
||||
if not all(statistic in ['avg', 'min', 'max', 'count', 'sum'] for
|
||||
statistic in statistics):
|
||||
|
|
|
@ -13,9 +13,8 @@
|
|||
# under the License.
|
||||
|
||||
import time
|
||||
import datetime
|
||||
|
||||
from oslo_utils import timeutils
|
||||
import six.moves.urllib.parse as urlparse
|
||||
|
||||
from monasca_tempest_tests.tests.api import base
|
||||
from monasca_tempest_tests.tests.api import constants
|
||||
|
@ -88,10 +87,10 @@ class TestStatistics(base.BaseMonascaTest):
|
|||
@test.attr(type="gate")
|
||||
def test_list_statistics(self):
|
||||
query_parms = '?name=' + str(self._test_name) + \
|
||||
'&statistics=avg,sum,min,max,count' + '&start_time=' + \
|
||||
str(self._start_time_iso) + '&end_time=' + \
|
||||
str(self._end_time_iso) + '&merge_metrics=true' + \
|
||||
'&period=100000'
|
||||
'&statistics=' + urlparse.quote('avg,sum,min,max,count') + \
|
||||
'&start_time=' + str(self._start_time_iso) + \
|
||||
'&end_time=' + str(self._end_time_iso) + \
|
||||
'&merge_metrics=true' + '&period=100000'
|
||||
resp, response_body = self.monasca_client.list_statistics(
|
||||
query_parms)
|
||||
self.assertEqual(200, resp.status)
|
||||
|
|
Loading…
Reference in New Issue