Merge "Fix alarm_count with multiple group_by fields from CLI"

This commit is contained in:
Jenkins 2017-02-13 11:15:31 +00:00 committed by Gerrit Code Review
commit cf6be5d8c4
2 changed files with 9 additions and 2 deletions

View File

@ -380,7 +380,7 @@ class AlarmsCount(alarms_api_v2.AlarmsCountV2API, alarming.Alarming):
if 'group_by' in query_parms:
if not isinstance(query_parms['group_by'], list):
query_parms['group_by'] = [query_parms['group_by']]
query_parms['group_by'] = query_parms['group_by'].split(',')
self._validate_group_by(query_parms['group_by'])
query_parms['metric_dimensions'] = helpers.get_query_dimensions(req, 'metric_dimensions')

View File

@ -13,6 +13,7 @@
# under the License.
import time
import urllib
from monasca_tempest_tests.tests.api import base
from monasca_tempest_tests.tests.api import helpers
@ -227,7 +228,13 @@ class TestAlarmsCount(base.BaseMonascaTest):
if alarm['state'] is 'ALARM' and alarm['severity'] is 'LOW':
alarm_low_count += 1
resp, response_body = self.monasca_client.count_alarms("?group_by=state,severity")
# Using urlencode mimics the CLI behavior. Without the urlencode, falcon
# treats group_by as a list, with the urlencode it treats group_by as
# a string. The API needs to handle both.
# test_with_all_group_by_params tests multiple group_by without
# urlencode
query_params = urllib.urlencode([('group_by', 'state,severity')])
resp, response_body = self.monasca_client.count_alarms("?" + query_params)
self._verify_counts_format(response_body, group_by=['state', 'severity'])
def run_count_test(self, query_string):