Merge "Add support for empty or missing "extra_args" in metrics config file"
This commit is contained in:
commit
e1a3453e90
|
@ -57,7 +57,7 @@ CONF.register_opts(collector_monasca_opts, COLLECTOR_MONASCA_OPTS)
|
||||||
METRICS_CONF = ck_utils.load_conf(CONF.collect.metrics_conf)
|
METRICS_CONF = ck_utils.load_conf(CONF.collect.metrics_conf)
|
||||||
|
|
||||||
MONASCA_EXTRA_SCHEMA = {
|
MONASCA_EXTRA_SCHEMA = {
|
||||||
Required('extra_args'): {
|
Required('extra_args', default={}): {
|
||||||
# Key corresponding to the resource id in a metric's dimensions
|
# Key corresponding to the resource id in a metric's dimensions
|
||||||
# Allows to adapt the resource identifier. Should not need to be
|
# Allows to adapt the resource identifier. Should not need to be
|
||||||
# modified in a standard OpenStack installation
|
# modified in a standard OpenStack installation
|
||||||
|
|
|
@ -62,7 +62,7 @@ cfg.CONF.register_opts(collector_prometheus_opts, PROMETHEUS_COLLECTOR_OPTS)
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
|
|
||||||
PROMETHEUS_EXTRA_SCHEMA = {
|
PROMETHEUS_EXTRA_SCHEMA = {
|
||||||
Required('extra_args'): {
|
Required('extra_args', default={}): {
|
||||||
Required('aggregation_method', default='max'):
|
Required('aggregation_method', default='max'):
|
||||||
In([
|
In([
|
||||||
'avg', 'count', 'max',
|
'avg', 'count', 'max',
|
||||||
|
|
|
@ -81,11 +81,17 @@ class MetricConfigValidationTest(tests.TestCase):
|
||||||
|
|
||||||
def test_monasca_minimal_config_no_extra_args(self):
|
def test_monasca_minimal_config_no_extra_args(self):
|
||||||
data = copy.deepcopy(self.base_data)
|
data = copy.deepcopy(self.base_data)
|
||||||
|
expected_output = copy.deepcopy(self.base_output)
|
||||||
self.assertRaises(
|
expected_output['metric_one']['groupby'].extend(
|
||||||
verror.MultipleInvalid,
|
['project_id', 'resource_id'])
|
||||||
collector.monasca.MonascaCollector.check_configuration,
|
expected_output['metric_one']['extra_args'] = {
|
||||||
data,
|
'resource_key': 'resource_id',
|
||||||
|
'aggregation_method': 'max',
|
||||||
|
'forced_project_id': ''
|
||||||
|
}
|
||||||
|
self.assertEqual(
|
||||||
|
collector.monasca.MonascaCollector.check_configuration(data),
|
||||||
|
expected_output,
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_monasca_minimal_config_minimal_extra_args(self):
|
def test_monasca_minimal_config_minimal_extra_args(self):
|
||||||
|
@ -107,12 +113,28 @@ class MetricConfigValidationTest(tests.TestCase):
|
||||||
|
|
||||||
def test_prometheus_minimal_config_empty_extra_args(self):
|
def test_prometheus_minimal_config_empty_extra_args(self):
|
||||||
data = copy.deepcopy(self.base_data)
|
data = copy.deepcopy(self.base_data)
|
||||||
data['extra_args'] = {}
|
data['metrics']['metric_one']['extra_args'] = {}
|
||||||
|
|
||||||
self.assertRaises(
|
expected_output = copy.deepcopy(self.base_output)
|
||||||
verror.MultipleInvalid,
|
expected_output['metric_one']['groupby'].append('project_id')
|
||||||
collector.prometheus.PrometheusCollector.check_configuration,
|
expected_output['metric_one']['extra_args'] = {
|
||||||
data,
|
'aggregation_method': 'max',
|
||||||
|
}
|
||||||
|
self.assertEqual(
|
||||||
|
collector.prometheus.PrometheusCollector.check_configuration(data),
|
||||||
|
expected_output,
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_prometheus_minimal_config_no_extra_args(self):
|
||||||
|
data = copy.deepcopy(self.base_data)
|
||||||
|
expected_output = copy.deepcopy(self.base_output)
|
||||||
|
expected_output['metric_one']['groupby'].append('project_id')
|
||||||
|
expected_output['metric_one']['extra_args'] = {
|
||||||
|
'aggregation_method': 'max',
|
||||||
|
}
|
||||||
|
self.assertEqual(
|
||||||
|
collector.prometheus.PrometheusCollector.check_configuration(data),
|
||||||
|
expected_output,
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_prometheus_minimal_config_minimal_extra_args(self):
|
def test_prometheus_minimal_config_minimal_extra_args(self):
|
||||||
|
|
Loading…
Reference in New Issue