Skip tests based on service features disabled in tempest

It's not possible to know if services have certain features
enabled from the sevice API in certain cases. Let's leverage
the service specific feature groups in tempest. If a specific
service feature is disabled in tempest config, the decorated
tests would be skipped.

ex. If tempest.conf contains

[volume-feature-enabled]
backup = False

test_cinder_volume_create_backup_restore scenario test would be
skipped.

Change-Id: I7a2495182791595c87f8245ff5e13dfd841b013f
This commit is contained in:
Rabi Mishra 2019-01-10 17:00:57 +05:30
parent ad04045b63
commit 144bdc6f73
2 changed files with 24 additions and 7 deletions

View File

@ -132,19 +132,34 @@ def requires_service_type(service_type):
return decorator
def _check_require(group, feature, test_method):
features_group = getattr(config.CONF, group, None)
if not features_group:
return test_method
feature_enabled = features_group.get(feature, True)
skipper = testtools.skipUnless(feature_enabled,
"%s - Feature not enabled." % feature)
return skipper(test_method)
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 _check_require('heat_features_enabled', feature, test_method)
return decorator
def requires_service_feature(service, feature):
'''Decorator for tests requring specific service feature enabled in tempest.
The decorated test will be skipped when a specific feature is disabled.
'''
def decorator(test_method):
group = service + '_feature_enabled'
return _check_require(group, feature, test_method)
return decorator

View File

@ -17,11 +17,13 @@ import six
from tempest.lib import decorators
from heat_tempest_plugin.common import exceptions
from heat_tempest_plugin.common import test
from heat_tempest_plugin.tests.scenario import scenario_base
LOG = logging.getLogger(__name__)
@test.requires_service_feature('volume', 'backup')
class VolumeBackupRestoreIntegrationTest(scenario_base.ScenarioTestsBase):
"""Class is responsible for testing of volume backup."""