From 876449a31f8e7f86f2f0a9e5c692b9c09e06e6a8 Mon Sep 17 00:00:00 2001 From: rabi Date: Thu, 15 Mar 2018 21:56:49 +0530 Subject: [PATCH] Add feature flags in config to enable tests conditionally This would allow to skip tests if a required feature is not enabled in the config. Change-Id: Icb699497c1d348354b6a5880ea3e4ab2de6e059b --- heat_tempest_plugin/common/test.py | 16 ++++++++++++++++ heat_tempest_plugin/config.py | 11 +++++++++++ heat_tempest_plugin/plugin.py | 6 +++++- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/heat_tempest_plugin/common/test.py b/heat_tempest_plugin/common/test.py index f75385f..a4c0edf 100644 --- a/heat_tempest_plugin/common/test.py +++ b/heat_tempest_plugin/common/test.py @@ -110,6 +110,22 @@ def requires_resource_type(resource_type): return decorator +def requires_feature(feature): + '''Decorator for tests requring specific feature. + + The decorated test will be skipped when a specific feature is disabled. + ''' + def decorator(test_method): + features_group = getattr(config.CONF, 'heat_features_enabled', None) + if not features_group: + return test_method + feature_enabled = config.CONF.heat_features_enabled.get(feature, False) + skipper = testtools.skipUnless(feature_enabled, + "%s - Feature not enabled." % feature) + return skipper(test_method) + return decorator + + class HeatIntegrationTest(testtools.testcase.WithAttributes, testscenarios.WithScenarios, testtools.TestCase): diff --git a/heat_tempest_plugin/config.py b/heat_tempest_plugin/config.py index d658a98..e4c7b47 100644 --- a/heat_tempest_plugin/config.py +++ b/heat_tempest_plugin/config.py @@ -156,7 +156,18 @@ HeatGroup = [ ] +heat_features_group = cfg.OptGroup( + name='heat_features_enabled', + title="Enabled Orchestration Service Features") + +HeatFeaturesGroup = [ + cfg.BoolOpt('stack_cancel', + default=False, + help="If false, skip stack cancel tests") +] + def list_opts(): yield heat_group.name, HeatGroup + yield heat_features_group.name, HeatFeaturesGroup yield service_available_group.name, ServiceAvailableGroup diff --git a/heat_tempest_plugin/plugin.py b/heat_tempest_plugin/plugin.py index acf4fc7..6926691 100644 --- a/heat_tempest_plugin/plugin.py +++ b/heat_tempest_plugin/plugin.py @@ -34,7 +34,11 @@ class HeatTempestPlugin(plugins.TempestPlugin): heat_config.ServiceAvailableGroup) config.register_opt_group(conf, heat_config.heat_group, heat_config.HeatGroup) + config.register_opt_group(conf, heat_config.heat_features_group, + heat_config.HeatFeaturesGroup) def get_opt_lists(self): return [(heat_config.heat_group.name, - heat_config.HeatGroup)] + heat_config.HeatGroup), + (heat_config.heat_features_group.name, + heat_config.HeatFeaturesGroup)]