Fix error when test setup fails to produce the required metrics

Cannot use method fail() in a class method
Added quick fail to two other test groups
Added some detail to setup failure messages

Change-Id: I47deae35feea1b50916d8820334f30e2bb8f2cba
This commit is contained in:
Ryan Brandt
2015-12-18 08:26:53 -07:00
parent b6529717a7
commit 89ea8a5de3
3 changed files with 20 additions and 10 deletions

View File

@@ -36,6 +36,7 @@ class TestAlarmsStateHistory(base.BaseMonascaTest):
cls.monasca_client.create_alarm_definitions(alarm_definition)
# create some metrics to prime the system and create three alarms
num_transitions = 0
for i in xrange(60):
metric = helpers.create_metric()
cls.monasca_client.create_metrics(metric)
@@ -43,8 +44,12 @@ class TestAlarmsStateHistory(base.BaseMonascaTest):
list_alarms_state_history()
elements = response_body['elements']
if len(elements) >= MIN_HISTORY:
break
time.sleep(5)
return
else:
num_transitions = len(elements)
time.sleep(1)
assert False, "Required {} alarm state transitions, but found {}".format(MIN_HISTORY, num_transitions)
# @test.attr(type="gate")
# def test_list_alarms_state_history(self):

View File

@@ -51,7 +51,7 @@ class TestMetricsNames(base.BaseMonascaTest):
return
time.sleep(constants.RETRY_WAIT_SECS)
cls.fail('Unable to initialize metrics')
assert False, 'Unable to initialize metrics'
@classmethod
def resource_cleanup(cls):

View File

@@ -24,6 +24,7 @@ from tempest import test
from tempest_lib import exceptions
NUM_MEASUREMENTS = 100
MIN_REQUIRED_MEASUREMENTS = 2
WAIT_TIME = 30
metric_value1 = 1.23
metric_value2 = 4.56
@@ -59,20 +60,24 @@ class TestStatistics(base.BaseMonascaTest):
start_time_iso = helpers.timestamp_to_iso(cls._start_timestamp)
cls._start_time_iso = start_time_iso
num_measurements = 0
for i in xrange(constants.MAX_RETRIES):
resp, response_body = cls.monasca_client.\
list_measurements(query_param)
elements = response_body['elements']
for element in elements:
if str(element['name']) == name and len(
element['measurements']) == 2:
cls._end_timestamp = cls._start_timestamp + 1000 * 3
cls._end_time_iso = helpers.timestamp_to_iso(
cls._end_timestamp)
return
if str(element['name']) == name:
if len(element['measurements']) >= MIN_REQUIRED_MEASUREMENTS:
cls._end_timestamp = cls._start_timestamp + 1000 * 3
cls._end_time_iso = helpers.timestamp_to_iso(
cls._end_timestamp)
return
else:
num_measurements = len(element['measurements'])
break
time.sleep(constants.RETRY_WAIT_SECS)
assert False, "Failed to find enough measurements to test"
assert False, "Required {} measurements, found {}".format(MIN_REQUIRED_MEASUREMENTS, num_measurements)
@classmethod
def resource_cleanup(cls):