Avoid duplicate 'barbican' service_available option

The cinder and barbican tempest plugins both need the 'barbican'
service_available option to be defined, but they both can't register
the option. This patch ensures the cinder plugin registers the option
only when the barbican plugin isn't present.

Closes-Bug: #1991068
Change-Id: I51a22afae4fc98e2c2b8c1e82e8211a27649022c
This commit is contained in:
Alan Bishop 2022-09-28 09:06:19 -07:00
parent e2fbcad776
commit 89823d9868
2 changed files with 17 additions and 8 deletions

View File

@ -26,11 +26,11 @@ cinder_option = [
# The barbican service is discovered by config_tempest [1], and will appear
# in the [service_available] group in tempest.conf. However, the 'barbican'
# option isn't registered by tempest itself, and so we do it here. This adds
# the ability to test CONF.service_available.barbican.
# option isn't registered by tempest itself, and so we may need to do it.
# This adds the ability to test CONF.service_available.barbican.
#
# [1] I96800a95f844ce7675d266e456e01620e63e347a
service_available_option = [
barbican_service_option = [
cfg.BoolOpt('barbican',
default=False,
help="Whether or not barbican is expected to be available"),

View File

@ -14,6 +14,7 @@
# under the License.
import os
import sys
from tempest import config
from tempest.test_discover import plugins
@ -46,8 +47,12 @@ class CinderTempestPlugin(plugins.TempestPlugin):
config.register_opt_group(conf, config.volume_feature_group,
project_config.cinder_option)
config.register_opt_group(conf, config.service_available_group,
project_config.service_available_option)
# Define the 'barbican' service_available option, but only if the
# barbican_tempest_plugin isn't present. It also defines the option,
# and we need to avoid a duplicate option registration.
if 'barbican_tempest_plugin' not in sys.modules:
config.register_opt_group(conf, config.service_available_group,
project_config.barbican_service_option)
def get_opt_lists(self):
"""Get a list of options for sample config generation.
@ -55,8 +60,12 @@ class CinderTempestPlugin(plugins.TempestPlugin):
:return: A list of tuples with the group name and options in that
group.
"""
return [
opt_lists = [
(config.volume_feature_group.name, project_config.cinder_option),
(config.service_available_group.name,
project_config.service_available_option),
]
if 'barbican_tempest_plugin' not in sys.modules:
opt_lists.append((config.service_available_group.name,
project_config.barbican_service_option))
return opt_lists