Add config option to enable/disable alarm creation during testing

It's not always true that Gonocchi is deployed in the environment,
in which case the aodh tempest tests will always fail at the resource
setup phase.

This patch adds the option to config if alarm should be created in the
resource setup method.

Change-Id: I69adb9eef8a0bdbe2333e3ec4866a44aae50d0a2
This commit is contained in:
Lingxian Kong 2019-08-21 15:51:09 +12:00
parent 18b5fce680
commit 6a7d798239
2 changed files with 16 additions and 9 deletions

View File

@ -9,27 +9,31 @@
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from tempest import config
from tempest.lib.common.utils import data_utils
from tempest.lib import decorators
from tempest.lib import exceptions as lib_exc
from telemetry_tempest_plugin.aodh.api import base
CONF = config.CONF
class TelemetryAlarmingAPITest(base.BaseAlarmingTest):
@classmethod
def resource_setup(cls):
super(TelemetryAlarmingAPITest, cls).resource_setup()
cls.rule = {'metrics': ['c0d457b6-957e-41de-a384-d5eb0957de3b'],
'comparison_operator': 'gt',
'aggregation_method': 'mean',
'threshold': 80.0,
'granularity': 70}
for i in range(2):
cls.create_alarm(
gnocchi_aggregation_by_metrics_threshold_rule=cls.rule)
if CONF.alarming_plugin.create_alarms:
cls.rule = {'metrics': ['c0d457b6-957e-41de-a384-d5eb0957de3b'],
'comparison_operator': 'gt',
'aggregation_method': 'mean',
'threshold': 80.0,
'granularity': 70}
for i in range(2):
cls.create_alarm(
gnocchi_aggregation_by_metrics_threshold_rule=cls.rule)
@decorators.idempotent_id('1c918e06-210b-41eb-bd45-14676dd77cd7')
def test_alarm_list(self):

View File

@ -92,6 +92,9 @@ AlarmingGroup = [
choices=['public', 'admin', 'internal',
'publicURL', 'adminURL', 'internalURL'],
help="The endpoint type to use for the alarming service."),
cfg.BoolOpt('create_alarms',
default=True,
help="If create alarms dynamically before testing."),
]
metric_opts = [