Add @services decorator

This commit adds a new decorator used for specifying service tags for
a test. It just wraps the attr decorator but before adding the attr it
checks to make sure a valid service name was used.

Part of bp add-service-tags

Change-Id: I0cdf3f5c703a5e4573b8e9b26fb8ede9b6d77690
This commit is contained in:
Matthew Treinish
2013-09-09 19:55:23 +00:00
committed by Gerrit Code Review
parent 2b59f84e3e
commit 16c4379f78
2 changed files with 24 additions and 0 deletions

View File

@@ -65,6 +65,10 @@ class Unauthorized(RestClientException):
message = 'Unauthorized'
class InvalidServiceTag(RestClientException):
message = "Invalid service tag"
class TimeoutException(TempestException):
message = "Request timed out"

View File

@@ -26,6 +26,7 @@ import testtools
from tempest import clients
from tempest import config
from tempest import exceptions
from tempest.openstack.common import log as logging
LOG = logging.getLogger(__name__)
@@ -57,6 +58,25 @@ def attr(*args, **kwargs):
return decorator
def services(*args, **kwargs):
"""A decorator used to set an attr for each service used in a test case
This decorator applies a testtools attr for each service that gets
exercised by a test case.
"""
valid_service_list = ['compute', 'image', 'volume', 'orchestration',
'network', 'identity', 'object', 'dashboard']
def decorator(f):
for service in args:
if service not in valid_service_list:
raise exceptions.InvalidServiceTag('%s is not a valid service'
% service)
attr(type=list(args))(f)
return f
return decorator
def stresstest(*args, **kwargs):
"""Add stress test decorator