diff --git a/watcher_tempest_plugin/config.py b/watcher_tempest_plugin/config.py index 426399d..e1f3386 100644 --- a/watcher_tempest_plugin/config.py +++ b/watcher_tempest_plugin/config.py @@ -21,3 +21,15 @@ service_option = cfg.BoolOpt("watcher", default=True, help="Whether or not watcher is expected to be " "available") + +optimization_group = cfg.OptGroup(name="optimize", + title="Watcher Service Options") + +OptimizationGroup = [ + cfg.StrOpt("datasource", + default="gnocchi", + choices=["gnocchi", ""], + help="Name of the data source used with the Watcher Service" + "gnocchi is a supported datasources. use ''" + "for no datasource"), +] diff --git a/watcher_tempest_plugin/plugin.py b/watcher_tempest_plugin/plugin.py index 560c544..8dac36b 100644 --- a/watcher_tempest_plugin/plugin.py +++ b/watcher_tempest_plugin/plugin.py @@ -30,5 +30,12 @@ class WatcherTempestPlugin(plugins.TempestPlugin): conf.register_opt(watcher_config.service_option, group='service_available') + conf.register_group(watcher_config.optimization_group) + conf.register_opts(watcher_config.OptimizationGroup, + watcher_config.optimization_group) + def get_opt_lists(self): - return [('service_available', [watcher_config.service_option])] + return [('service_available', [watcher_config.service_option]), + (watcher_config.optimization_group.name, + watcher_config.OptimizationGroup) + ] diff --git a/watcher_tempest_plugin/tests/scenario/base.py b/watcher_tempest_plugin/tests/scenario/base.py index 37f2cf2..df8c690 100644 --- a/watcher_tempest_plugin/tests/scenario/base.py +++ b/watcher_tempest_plugin/tests/scenario/base.py @@ -302,6 +302,16 @@ class BaseInfraOptimScenarioTest(manager.ScenarioTest): return measures_body def make_host_statistic(self, metrics=dict()): + """Add host metrics to the datasource + + :param metrics: The metrics add to resource when using Gnocchi + """ + if not CONF.optimize.datasource: + pass + else: + self.make_host_statistic_gnocchi(metrics) + + def make_host_statistic_gnocchi(self, metrics=dict()): """Create host resource and its measures in Gnocchi DB :param metrics: The metrics add to resource when using Gnocchi @@ -337,6 +347,17 @@ class BaseInfraOptimScenarioTest(manager.ScenarioTest): return True def make_instance_statistic(self, instance, metrics=dict()): + """Add instance resources and its measures to the datasource + + :param instance: Instance response body + :param metrics: The metrics add to resource when using datasource + """ + if not CONF.optimize.datasource: + pass + else: + self.make_instance_statistic_gnocchi(instance, metrics) + + def make_instance_statistic_gnocchi(self, instance, metrics=dict()): """Create instance resource and its measures in Gnocchi DB :param instance: Instance response body