Add sleep to let Thresh process alarm definitions

Tests are randomly failing with not alarms being created.
The metrics were sent immediately after the alarm definitions are
created so add a sleep of constants.ALARM_DEFINITION_CREATION_WAIT
to give Thresh a chance to process the new alarm definitions

Note that is currently, 1 second but will be increased to 3
seconds in https://review.openstack.org/#/c/543399

Change-Id: I9f944212dd97d94ab82b49021b454505646b1e03
Story: 2001533
Task:  6338
This commit is contained in:
Craig Bryant 2018-02-09 09:48:13 -07:00 committed by Witold Bedyk
parent e2ac3a49b7
commit 43aa28492c
1 changed files with 8 additions and 3 deletions

View File

@ -1,4 +1,4 @@
# (C) Copyright 2016-2017 Hewlett Packard Enterprise Development LP
# (C) Copyright 2016-2018 Hewlett Packard Enterprise Development LP
#
# 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
@ -15,12 +15,14 @@
import time
import urllib
from monasca_tempest_tests.tests.api import base
from monasca_tempest_tests.tests.api import helpers
from tempest.lib.common.utils import data_utils
from tempest.lib import decorators
from tempest.lib import exceptions
from monasca_tempest_tests.tests.api import base
from monasca_tempest_tests.tests.api import constants
from monasca_tempest_tests.tests.api import helpers
GROUP_BY_ALLOWED_PARAMS = {'alarm_definition_id', 'name', 'state', 'severity',
'link', 'lifecycle_state', 'metric_name',
@ -126,6 +128,9 @@ class TestAlarmsCount(base.BaseMonascaTest):
msg = "Failed to create alarm_definition during setup: {} {}".format(resp.status, response_body)
assert False, msg
# Give Thresh time to process the new Alarm Definitions
time.sleep(constants.ALARM_DEFINITION_CREATION_WAIT)
# create alarms
for metric in metrics_to_send:
metric['timestamp'] = int(time.time() * 1000)