Allow to use environment variable to override some metric values
Change-Id: Ifd1d04ce813028f115c19bc983e7dd1e63c6f8a5
diff --git a/telemetry_tempest_plugin/config.py b/telemetry_tempest_plugin/config.py
index d5d9245..7ca6e6f 100644
--- a/telemetry_tempest_plugin/config.py
+++ b/telemetry_tempest_plugin/config.py
@@ -60,8 +60,16 @@
cfg.IntOpt('alarm_granularity',
default=300,
help="Granularity to use for aodh alarms. This must match the "
- "configured Gnocchi archive policy")
-
+ "configured Gnocchi archive policy"),
+ cfg.StrOpt('alarm_metric_name',
+ default="cpu_util",
+ help="Name of the metric to create an alarm on."),
+ cfg.StrOpt('alarm_aggregation_method',
+ default="mean",
+ help="Aggregation method to use for alarm."),
+ cfg.IntOpt('alarm_threshold',
+ default=10,
+ help="Threshold to cross for the alarm to trigger."),
]
event_opts = [
diff --git a/telemetry_tempest_plugin/scenario/telemetry_integration_gabbits/create_stack.json b/telemetry_tempest_plugin/scenario/telemetry_integration_gabbits/create_stack.json
index 57a6366..126f0c5 100644
--- a/telemetry_tempest_plugin/scenario/telemetry_integration_gabbits/create_stack.json
+++ b/telemetry_tempest_plugin/scenario/telemetry_integration_gabbits/create_stack.json
@@ -42,11 +42,11 @@
"type": "OS::Ceilometer::GnocchiAggregationByResourcesAlarm",
"properties": {
"description": "Scale-up if the mean CPU > 10% on 1 minute",
- "metric": "cpu_util",
- "aggregation_method": "mean",
+ "metric": "$ENVIRON["CEILOMETER_METRIC_NAME"]",
+ "aggregation_method": "$ENVIRON["GNOCCHI_AGGREGATION_METHOD"]",
"granularity": $ENVIRON["AODH_GRANULARITY"],
"evaluation_periods": 1,
- "threshold": 10,
+ "threshold": $ENVIRON["AODH_THRESHOLD"],
"comparison_operator": "gt",
"alarm_actions": [
{
diff --git a/telemetry_tempest_plugin/scenario/telemetry_integration_gabbits/update_stack.json b/telemetry_tempest_plugin/scenario/telemetry_integration_gabbits/update_stack.json
index 54f8e29..a107f4b 100644
--- a/telemetry_tempest_plugin/scenario/telemetry_integration_gabbits/update_stack.json
+++ b/telemetry_tempest_plugin/scenario/telemetry_integration_gabbits/update_stack.json
@@ -41,11 +41,11 @@
"type": "OS::Ceilometer::GnocchiAggregationByResourcesAlarm",
"properties": {
"description": "Scale-down if the mean CPU > 10% on 1 minute",
- "metric": "cpu_util",
- "aggregation_method": "mean",
+ "metric": "$ENVIRON["CEILOMETER_METRIC_NAME"]",
+ "aggregation_method": "$ENVIRON["GNOCCHI_AGGREGATION_METHOD"]",
"granularity": $ENVIRON["AODH_GRANULARITY"],
"evaluation_periods": 1,
- "threshold": 10,
+ "threshold": $ENVIRON["AODH_THRESHOLD"],
"comparison_operator": "gt",
"alarm_actions": [
{
diff --git a/telemetry_tempest_plugin/scenario/test_telemetry_integration.py b/telemetry_tempest_plugin/scenario/test_telemetry_integration.py
index 22155dd..f6634f5 100644
--- a/telemetry_tempest_plugin/scenario/test_telemetry_integration.py
+++ b/telemetry_tempest_plugin/scenario/test_telemetry_integration.py
@@ -82,6 +82,11 @@
os.environ.update({
"ADMIN_TOKEN": admin_auth[0],
"USER_TOKEN": auth[0],
+ "CEILOMETER_METRIC_NAME":
+ config.CONF.telemetry.alarm_metric_name,
+ "GNOCCHI_AGGREGATION_METHOD":
+ config.CONF.telemetry.alarm_aggregation_method,
+ "AODH_THRESHOLD": str(config.CONF.telemetry.alarm_threshold),
"AODH_GRANULARITY": str(config.CONF.telemetry.alarm_granularity),
"AODH_SERVICE_URL": self._get_endpoint(auth, "alarming_plugin"),
"GNOCCHI_SERVICE_URL": self._get_endpoint(auth, "metric"),