Sync tempest code for cassandra support

* Ie60d668692e1f25f555dda2355f4e513d582736c Added the cassandra support
  it syncs the same in tempest plugin side.

* Copied flake8 ignores from monasca-api code base
  in order to avoid breakage.

Change-Id: I27ecc28e48da5a96e5e639026d212da3b6467646
Story: 2001400
Task:  6121
This commit is contained in:
Chandan Kumar 2017-12-17 12:46:14 +05:30 committed by Witold Bedyk
parent f68f2e0925
commit 1247b3e976
4 changed files with 43 additions and 18 deletions

View File

@ -1,4 +1,5 @@
# (C) Copyright 2015 Hewlett Packard Enterprise Development Company LP # (C) Copyright 2015 Hewlett Packard Enterprise Development Company LP
# (C) Copyright 2017 SUSE LLC
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may # Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain # not use this file except in compliance with the License. You may obtain
@ -133,36 +134,46 @@ def get_expected_elements_inner_offset_limit(all_elements, offset, limit, inner_
total_statistics = 0 total_statistics = 0
if offset is None: if offset is None:
offset_id = 0 offset_id = None
offset_time = "" offset_time = ""
passed_offset = True
else: else:
offset_tuple = offset.split('_') offset_tuple = offset.split('_')
offset_id = int(offset_tuple[0]) if len(offset_tuple) > 1 else 0 offset_id = offset_tuple[0] if len(offset_tuple) > 1 else u'0'
offset_time = offset_tuple[1] if len(offset_tuple) > 1 else offset_tuple[0] offset_time = offset_tuple[1] if len(offset_tuple) > 1 else offset_tuple[0]
passed_offset = False
for element in all_elements: for element in all_elements:
element_id = int(element['id']) element_id = element['id']
if offset_id is not None and element_id < offset_id: if (not passed_offset) and element_id != offset_id:
continue continue
next_element = None next_element = None
for value in element[inner_key]:
if (element_id == offset_id and value[0] > offset_time) or \
element_id > offset_id:
for value in element[inner_key]:
if passed_offset or (element_id == offset_id and value[0] > offset_time):
if not passed_offset:
passed_offset = True
if not next_element: if not next_element:
next_element = element.copy() next_element = element.copy()
next_element[inner_key] = [value] next_element[inner_key] = [value]
else: else:
next_element[inner_key].append(value) next_element[inner_key].append(value)
total_statistics += 1 total_statistics += 1
if total_statistics >= limit: if total_statistics >= limit:
break break
if next_element: if next_element:
expected_elements.append(next_element) expected_elements.append(next_element)
if total_statistics >= limit: if total_statistics >= limit:
break break
for i in range(len(expected_elements)): if element_id == offset_id:
expected_elements[i]['id'] = str(i) passed_offset = True
# if index is used in the element id, reset to start at zero
if expected_elements and expected_elements[0]['id'].isdigit():
for i in range(len(expected_elements)):
expected_elements[i]['id'] = str(i)
return expected_elements return expected_elements

View File

@ -1,4 +1,5 @@
# (C) Copyright 2016 Hewlett Packard Enterprise Development LP # (C) Copyright 2016 Hewlett Packard Enterprise Development LP
# (C) Copyright 2017 SUSE LLC
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may # Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain # not use this file except in compliance with the License. You may obtain
@ -75,9 +76,14 @@ class TestDimensions(base.BaseMonascaTest):
resp, response_body = cls.monasca_client.list_metrics( resp, response_body = cls.monasca_client.list_metrics(
param) param)
elements = response_body['elements'] elements = response_body['elements']
metric_name1_count = 0
for element in elements: for element in elements:
returned_name_set.add(str(element['name'])) returned_name_set.add(str(element['name']))
if cls._test_metric_names.issubset(returned_name_set): if (str(element['name']) == metric_name1):
metric_name1_count += 1
# Java version of influxdb never returns both metric1 in the list but Python does.
if cls._test_metric_names.issubset(returned_name_set) \
and (metric_name1_count == 2 or i == constants.MAX_RETRIES - 1):
return return
time.sleep(constants.RETRY_WAIT_SECS) time.sleep(constants.RETRY_WAIT_SECS)

View File

@ -1,4 +1,5 @@
# (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP # (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
# (C) Copyright 2017 SUSE LLC
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may # Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain # not use this file except in compliance with the License. You may obtain
@ -238,7 +239,7 @@ class TestStatistics(base.BaseMonascaTest):
resp, response_body = self.monasca_client.list_metrics(query_parms) resp, response_body = self.monasca_client.list_metrics(query_parms)
self.assertEqual(200, resp.status) self.assertEqual(200, resp.status)
elements = response_body['elements'] elements = response_body['elements']
if elements: if elements and len(elements) == num_metrics:
break break
else: else:
time.sleep(constants.RETRY_WAIT_SECS) time.sleep(constants.RETRY_WAIT_SECS)

17
tox.ini
View File

@ -42,9 +42,16 @@ commands =
commands = oslo_debug_helper {posargs} commands = oslo_debug_helper {posargs}
[flake8] [flake8]
# E123, E125 skipped as they are invalid PEP-8. # TODO: ignored checks should be enabled in the future
# H201 no 'except:' at least use 'except Exception:'
show-source = True # H302 import only modules
ignore = E123,E125 # H405 multi line docstring summary not separated with an empty line
ignore = F821,H201,H302,H405
# H106: Dont put vim configuration in source files
# H203: Use assertIs(Not)None to check for None
enable-extensions=H106,H203
max-complexity = 50
max-line-length = 120
builtins = _ builtins = _
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,tools,build
show-source = True