From 87655e10927586a847281e05546a6351e4be8907 Mon Sep 17 00:00:00 2001 From: Andrea Frittoli Date: Thu, 9 Mar 2017 11:09:47 +0000 Subject: [PATCH] Fix sahara tempest plugin configuration config.CONF cannot be used in register_opts, because register_opts is invoked by Tempest as part of the process of building config.CONF itself, so that ends up in a recursive call that raises duplication opion exceptions. Make sure that register_opts uses the supplied conf object (as opposed to tempest.config). Register the "sahara" option in the existing 'service_available' group rather than recreating the group. Cleanup all the exception handling that was required to catch the issues described above. Any more exception should surface as it would be sympthom of an issue to be fixed. Depends-on: I1afae0d1f9c4a6aec2742aaba4928cdde54b224f Change-Id: I1a2cf1cfe367eaf86eb6844ab6bfd8d3c2de51ec --- sahara_tempest_plugin/config.py | 12 +++----- sahara_tempest_plugin/plugin.py | 49 ++++++++------------------------- 2 files changed, 15 insertions(+), 46 deletions(-) diff --git a/sahara_tempest_plugin/config.py b/sahara_tempest_plugin/config.py index 597751df..e2090ef2 100644 --- a/sahara_tempest_plugin/config.py +++ b/sahara_tempest_plugin/config.py @@ -15,14 +15,10 @@ from oslo_config import cfg -service_available_group = cfg.OptGroup(name="service_available", - title="Available OpenStack Services") - -ServiceAvailableGroup = [ - cfg.BoolOpt("sahara", - default=True, - help="Whether or not sahara is expected to be available"), -] +service_option = cfg.BoolOpt("sahara", + default=True, + help="Whether or not sahara is expected to be " + "available") data_processing_group = cfg.OptGroup(name="data-processing", title="Data Processing options") diff --git a/sahara_tempest_plugin/plugin.py b/sahara_tempest_plugin/plugin.py index 55b10196..b4f1d5d3 100644 --- a/sahara_tempest_plugin/plugin.py +++ b/sahara_tempest_plugin/plugin.py @@ -16,7 +16,6 @@ import os -from oslo_config import cfg from tempest import config from tempest.test_discover import plugins @@ -32,34 +31,16 @@ class SaharaTempestPlugin(plugins.TempestPlugin): return full_test_dir, base_path def register_opts(self, conf): - # Ignore the duplicate error: it means that the same content - # is (still) defined in Tempest - try: - config.register_opt_group(conf, - sahara_config.service_available_group, - sahara_config.ServiceAvailableGroup) - except cfg.DuplicateOptError: - pass - try: - config.register_opt_group(conf, - sahara_config.data_processing_group, - sahara_config.DataProcessingGroup) - except cfg.DuplicateOptError: - pass + conf.register_opt(sahara_config.service_option, + group='service_available') + conf.register_group(sahara_config.data_processing_group) + conf.register_opts(sahara_config.DataProcessingGroup + + sahara_config.DataProcessingAdditionalGroup, + sahara_config.data_processing_group) - conf.register_opts(sahara_config.DataProcessingAdditionalGroup, - sahara_config.data_processing_group.name) - - try: - config.register_opt_group(conf, sahara_config. - data_processing_feature_group, - sahara_config. - DataProcessingFeaturesGroup) - except cfg.DuplicateOptError: - pass - config.CONF.data_processing = conf['data-processing'] - config.CONF.data_processing_feature_enabled = conf[ - 'data-processing-feature-enabled'] + conf.register_group(sahara_config.data_processing_feature_group) + conf.register_opts(sahara_config.DataProcessingFeaturesGroup, + sahara_config.data_processing_feature_group) def get_opt_lists(self): return [ @@ -67,19 +48,11 @@ class SaharaTempestPlugin(plugins.TempestPlugin): sahara_config.DataProcessingGroup), (sahara_config.data_processing_feature_group.name, sahara_config.DataProcessingFeaturesGroup), - (sahara_config.service_available_group.name, - sahara_config.ServiceAvailableGroup) ] def get_service_clients(self): - # Ignore the ArgsAlreadyParsed error: it means that - # the same content is (still) defined in Tempest - try: - data_processing_config = ( - config.service_client_config('data-processing')) - except cfg.ArgsAlreadyParsedError: - # the service name must be returned with the other params - data_processing_config = {'service': 'data-processing'} + data_processing_config = ( + config.service_client_config('data-processing')) params = { 'name': 'data_processing',