Refactoring log utils
* Moved log functions from rally/common/utils.py #L137-L234 to rally/common/log.y * Moved test tunctions form test/unit/common/test_utils.py to test/unit/common/test_log.py Change-Id: Icac3e87d507a3cf90e27071cb26bc871dac78514
This commit is contained in:
parent
32318312b0
commit
4bfbeb271d
@ -13,12 +13,14 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
import functools
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from oslo_log import handlers
|
from oslo_log import handlers
|
||||||
from oslo_log import log as oslogging
|
from oslo_log import log as oslogging
|
||||||
|
|
||||||
|
from rally.common.i18n import _
|
||||||
|
|
||||||
DEBUG_OPTS = [cfg.BoolOpt(
|
DEBUG_OPTS = [cfg.BoolOpt(
|
||||||
"rally-debug",
|
"rally-debug",
|
||||||
@ -55,6 +57,12 @@ def setup(product_name, version="unknown"):
|
|||||||
project=product_name).logger.setLevel(logging.RDEBUG)
|
project=product_name).logger.setLevel(logging.RDEBUG)
|
||||||
|
|
||||||
|
|
||||||
|
class RallyContextAdapter(oslogging.KeywordArgumentAdapter):
|
||||||
|
|
||||||
|
def debug(self, msg, *args, **kwargs):
|
||||||
|
self.log(logging.RDEBUG, msg, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
def getLogger(name="unknown", version="unknown"):
|
def getLogger(name="unknown", version="unknown"):
|
||||||
|
|
||||||
if name not in oslogging._loggers:
|
if name not in oslogging._loggers:
|
||||||
@ -64,10 +72,7 @@ def getLogger(name="unknown", version="unknown"):
|
|||||||
return oslogging._loggers[name]
|
return oslogging._loggers[name]
|
||||||
|
|
||||||
|
|
||||||
class RallyContextAdapter(oslogging.KeywordArgumentAdapter):
|
LOG = getLogger(__name__)
|
||||||
|
|
||||||
def debug(self, msg, *args, **kwargs):
|
|
||||||
self.log(logging.RDEBUG, msg, *args, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
class ExceptionLogger(object):
|
class ExceptionLogger(object):
|
||||||
@ -164,5 +169,104 @@ class LogCatcher(object):
|
|||||||
return [record.msg for record in self.handler.buffer]
|
return [record.msg for record in self.handler.buffer]
|
||||||
|
|
||||||
|
|
||||||
|
def _log_wrapper(obj, log_function, msg, **kw):
|
||||||
|
"""A logging wrapper for any method of a class.
|
||||||
|
|
||||||
|
Class instances that use this decorator should have self.task or
|
||||||
|
self.deployment attribute. The wrapper produces logs messages both
|
||||||
|
before and after the method execution, in the following format
|
||||||
|
(example for tasks):
|
||||||
|
|
||||||
|
"Task <Task UUID> | Starting: <Logging message>"
|
||||||
|
[Method execution...]
|
||||||
|
"Task <Task UUID> | Completed: <Logging message>"
|
||||||
|
|
||||||
|
:param obj: task or deployment which must be attribute of "self"
|
||||||
|
:param log_function: Logging method to be used, e.g. LOG.info
|
||||||
|
:param msg: Text message (possibly parameterized) to be put to the log
|
||||||
|
:param **kw: Parameters for msg
|
||||||
|
"""
|
||||||
|
def decorator(f):
|
||||||
|
@functools.wraps(f)
|
||||||
|
def wrapper(self, *args, **kwargs):
|
||||||
|
params = {"msg": msg % kw, "obj_name": obj.title(),
|
||||||
|
"uuid": getattr(self, obj)["uuid"]}
|
||||||
|
log_function(_("%(obj_name)s %(uuid)s | Starting: %(msg)s") %
|
||||||
|
params)
|
||||||
|
result = f(self, *args, **kwargs)
|
||||||
|
log_function(_("%(obj_name)s %(uuid)s | Completed: %(msg)s") %
|
||||||
|
params)
|
||||||
|
return result
|
||||||
|
return wrapper
|
||||||
|
return decorator
|
||||||
|
|
||||||
|
|
||||||
|
def log_task_wrapper(log_function, msg, **kw):
|
||||||
|
return _log_wrapper("task", log_function, msg, **kw)
|
||||||
|
|
||||||
|
|
||||||
|
def log_deploy_wrapper(log_function, msg, **kw):
|
||||||
|
return _log_wrapper("deployment", log_function, msg, **kw)
|
||||||
|
|
||||||
|
|
||||||
|
def log_verification_wrapper(log_function, msg, **kw):
|
||||||
|
return _log_wrapper("verification", log_function, msg, **kw)
|
||||||
|
|
||||||
|
|
||||||
|
def log_deprecated(message, rally_version, log_function=None, once=False):
|
||||||
|
"""A wrapper marking a certain method as deprecated.
|
||||||
|
|
||||||
|
:param message: Message that describes why the method was deprecated
|
||||||
|
:param rally_version: version of Rally when the method was deprecated
|
||||||
|
:param log_function: Logging method to be used, e.g. LOG.info
|
||||||
|
:param once: Show only once (default is each)
|
||||||
|
"""
|
||||||
|
log_function = log_function or LOG.warning
|
||||||
|
|
||||||
|
def decorator(f):
|
||||||
|
@functools.wraps(f)
|
||||||
|
def wrapper(*args, **kwargs):
|
||||||
|
if (not once) or (not getattr(f, "_warned_dep_method", False)):
|
||||||
|
log_function("'%(func)s' is deprecated in Rally v%(version)s: "
|
||||||
|
"%(msg)s" % {"msg": message,
|
||||||
|
"version": rally_version,
|
||||||
|
"func": f.__name__})
|
||||||
|
setattr(f, "_warned_dep_method", once)
|
||||||
|
return f(*args, **kwargs)
|
||||||
|
return wrapper
|
||||||
|
return decorator
|
||||||
|
|
||||||
|
|
||||||
|
def log_deprecated_args(message, rally_version, deprecated_args,
|
||||||
|
log_function=None, once=False):
|
||||||
|
"""A wrapper marking certain arguments as deprecated.
|
||||||
|
|
||||||
|
:param message: Message that describes why the arguments were deprecated
|
||||||
|
:param rally_version: version of Rally when the arguments were deprecated
|
||||||
|
:param deprecated_args: List of deprecated args.
|
||||||
|
:param log_function: Logging method to be used, e.g. LOG.info
|
||||||
|
:param once: Show only once (default is each)
|
||||||
|
"""
|
||||||
|
log_function = log_function or LOG.warning
|
||||||
|
|
||||||
|
def decorator(f):
|
||||||
|
@functools.wraps(f)
|
||||||
|
def wrapper(*args, **kwargs):
|
||||||
|
if (not once) or (not getattr(f, "_warned_dep_args", False)):
|
||||||
|
deprecated = ", ".join([
|
||||||
|
"`%s'" % x for x in deprecated_args if x in kwargs])
|
||||||
|
if deprecated:
|
||||||
|
log_function(
|
||||||
|
"%(msg)s (args %(args)s deprecated in Rally "
|
||||||
|
"v%(version)s)" %
|
||||||
|
{"msg": message, "version": rally_version,
|
||||||
|
"args": deprecated})
|
||||||
|
setattr(f, "_warned_dep_args", once)
|
||||||
|
result = f(*args, **kwargs)
|
||||||
|
return result
|
||||||
|
return wrapper
|
||||||
|
return decorator
|
||||||
|
|
||||||
|
|
||||||
def is_debug():
|
def is_debug():
|
||||||
return CONF.debug or CONF.rally_debug
|
return CONF.debug or CONF.rally_debug
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import functools
|
|
||||||
import inspect
|
import inspect
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
import random
|
import random
|
||||||
@ -24,7 +23,6 @@ import time
|
|||||||
|
|
||||||
from six import moves
|
from six import moves
|
||||||
|
|
||||||
from rally.common.i18n import _
|
|
||||||
from rally.common import log as logging
|
from rally.common import log as logging
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
|
|
||||||
@ -134,105 +132,6 @@ class RAMInt(object):
|
|||||||
self.__int.value = 0
|
self.__int.value = 0
|
||||||
|
|
||||||
|
|
||||||
def _log_wrapper(obj, log_function, msg, **kw):
|
|
||||||
"""A logging wrapper for any method of a class.
|
|
||||||
|
|
||||||
Class instances that use this decorator should have self.task or
|
|
||||||
self.deployment attribute. The wrapper produces logs messages both
|
|
||||||
before and after the method execution, in the following format
|
|
||||||
(example for tasks):
|
|
||||||
|
|
||||||
"Task <Task UUID> | Starting: <Logging message>"
|
|
||||||
[Method execution...]
|
|
||||||
"Task <Task UUID> | Completed: <Logging message>"
|
|
||||||
|
|
||||||
:param obj: task or deployment which must be attribute of "self"
|
|
||||||
:param log_function: Logging method to be used, e.g. LOG.info
|
|
||||||
:param msg: Text message (possibly parameterized) to be put to the log
|
|
||||||
:param **kw: Parameters for msg
|
|
||||||
"""
|
|
||||||
def decorator(f):
|
|
||||||
@functools.wraps(f)
|
|
||||||
def wrapper(self, *args, **kwargs):
|
|
||||||
params = {"msg": msg % kw, "obj_name": obj.title(),
|
|
||||||
"uuid": getattr(self, obj)["uuid"]}
|
|
||||||
log_function(_("%(obj_name)s %(uuid)s | Starting: %(msg)s") %
|
|
||||||
params)
|
|
||||||
result = f(self, *args, **kwargs)
|
|
||||||
log_function(_("%(obj_name)s %(uuid)s | Completed: %(msg)s") %
|
|
||||||
params)
|
|
||||||
return result
|
|
||||||
return wrapper
|
|
||||||
return decorator
|
|
||||||
|
|
||||||
|
|
||||||
def log_task_wrapper(log_function, msg, **kw):
|
|
||||||
return _log_wrapper("task", log_function, msg, **kw)
|
|
||||||
|
|
||||||
|
|
||||||
def log_deploy_wrapper(log_function, msg, **kw):
|
|
||||||
return _log_wrapper("deployment", log_function, msg, **kw)
|
|
||||||
|
|
||||||
|
|
||||||
def log_verification_wrapper(log_function, msg, **kw):
|
|
||||||
return _log_wrapper("verification", log_function, msg, **kw)
|
|
||||||
|
|
||||||
|
|
||||||
def log_deprecated(message, rally_version, log_function=None, once=False):
|
|
||||||
"""A wrapper marking a certain method as deprecated.
|
|
||||||
|
|
||||||
:param message: Message that describes why the method was deprecated
|
|
||||||
:param rally_version: version of Rally when the method was deprecated
|
|
||||||
:param log_function: Logging method to be used, e.g. LOG.info
|
|
||||||
:param once: Show only once (default is each)
|
|
||||||
"""
|
|
||||||
log_function = log_function or LOG.warning
|
|
||||||
|
|
||||||
def decorator(f):
|
|
||||||
@functools.wraps(f)
|
|
||||||
def wrapper(*args, **kwargs):
|
|
||||||
if (not once) or (not getattr(f, "_warned_dep_method", False)):
|
|
||||||
log_function("'%(func)s' is deprecated in Rally v%(version)s: "
|
|
||||||
"%(msg)s" % {"msg": message,
|
|
||||||
"version": rally_version,
|
|
||||||
"func": f.__name__})
|
|
||||||
setattr(f, "_warned_dep_method", once)
|
|
||||||
return f(*args, **kwargs)
|
|
||||||
return wrapper
|
|
||||||
return decorator
|
|
||||||
|
|
||||||
|
|
||||||
def log_deprecated_args(message, rally_version, deprecated_args,
|
|
||||||
log_function=None, once=False):
|
|
||||||
"""A wrapper marking certain arguments as deprecated.
|
|
||||||
|
|
||||||
:param message: Message that describes why the arguments were deprecated
|
|
||||||
:param rally_version: version of Rally when the arguments were deprecated
|
|
||||||
:param deprecated_args: List of deprecated args.
|
|
||||||
:param log_function: Logging method to be used, e.g. LOG.info
|
|
||||||
:param once: Show only once (default is each)
|
|
||||||
"""
|
|
||||||
log_function = log_function or LOG.warning
|
|
||||||
|
|
||||||
def decorator(f):
|
|
||||||
@functools.wraps(f)
|
|
||||||
def wrapper(*args, **kwargs):
|
|
||||||
if (not once) or (not getattr(f, "_warned_dep_args", False)):
|
|
||||||
deprecated = ", ".join([
|
|
||||||
"`%s'" % x for x in deprecated_args if x in kwargs])
|
|
||||||
if deprecated:
|
|
||||||
log_function(
|
|
||||||
"%(msg)s (args %(args)s deprecated in Rally "
|
|
||||||
"v%(version)s)" %
|
|
||||||
{"msg": message, "version": rally_version,
|
|
||||||
"args": deprecated})
|
|
||||||
setattr(f, "_warned_dep_args", once)
|
|
||||||
result = f(*args, **kwargs)
|
|
||||||
return result
|
|
||||||
return wrapper
|
|
||||||
return decorator
|
|
||||||
|
|
||||||
|
|
||||||
def get_method_class(func):
|
def get_method_class(func):
|
||||||
"""Return the class that defined the given method.
|
"""Return the class that defined the given method.
|
||||||
|
|
||||||
|
@ -21,7 +21,6 @@ import six
|
|||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import log as logging
|
||||||
from rally.common.plugin import plugin
|
from rally.common.plugin import plugin
|
||||||
from rally.common import utils
|
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally.deployment.serverprovider import provider
|
from rally.deployment.serverprovider import provider
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
@ -112,15 +111,15 @@ class Engine(plugin.Plugin):
|
|||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
"""Cleanup OpenStack deployment."""
|
"""Cleanup OpenStack deployment."""
|
||||||
|
|
||||||
@utils.log_deploy_wrapper(LOG.info, _("OpenStack cloud deployment."))
|
@logging.log_deploy_wrapper(LOG.info, _("OpenStack cloud deployment."))
|
||||||
def make_deploy(self):
|
def make_deploy(self):
|
||||||
self.deployment.set_started()
|
self.deployment.set_started()
|
||||||
endpoints = self.deploy()
|
endpoints = self.deploy()
|
||||||
self.deployment.set_completed()
|
self.deployment.set_completed()
|
||||||
return endpoints
|
return endpoints
|
||||||
|
|
||||||
@utils.log_deploy_wrapper(LOG.info,
|
@logging.log_deploy_wrapper(LOG.info, _("Destroy cloud and free "
|
||||||
_("Destroy cloud and free allocated resources."))
|
"allocated resources."))
|
||||||
def make_cleanup(self):
|
def make_cleanup(self):
|
||||||
self.deployment.update_status(consts.DeployStatus.CLEANUP_STARTED)
|
self.deployment.update_status(consts.DeployStatus.CLEANUP_STARTED)
|
||||||
self.cleanup()
|
self.cleanup()
|
||||||
|
@ -20,7 +20,6 @@ import six
|
|||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import log as logging
|
||||||
from rally.common import objects
|
from rally.common import objects
|
||||||
from rally.common import utils
|
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally.deployment import engine
|
from rally.deployment import engine
|
||||||
from rally.deployment.serverprovider import provider
|
from rally.deployment.serverprovider import provider
|
||||||
@ -96,7 +95,7 @@ class DevstackEngine(engine.Engine):
|
|||||||
if "local_conf" in self.config:
|
if "local_conf" in self.config:
|
||||||
self.local_conf.update(self.config["local_conf"])
|
self.local_conf.update(self.config["local_conf"])
|
||||||
|
|
||||||
@utils.log_deploy_wrapper(LOG.info, _("Prepare server for devstack"))
|
@logging.log_deploy_wrapper(LOG.info, _("Prepare server for devstack"))
|
||||||
def prepare_server(self, server):
|
def prepare_server(self, server):
|
||||||
script_path = os.path.abspath(os.path.join(os.path.dirname(__file__),
|
script_path = os.path.abspath(os.path.join(os.path.dirname(__file__),
|
||||||
"devstack", "install.sh"))
|
"devstack", "install.sh"))
|
||||||
@ -104,7 +103,7 @@ class DevstackEngine(engine.Engine):
|
|||||||
if server.password:
|
if server.password:
|
||||||
server.ssh.run("chpasswd", stdin="rally:%s" % server.password)
|
server.ssh.run("chpasswd", stdin="rally:%s" % server.password)
|
||||||
|
|
||||||
@utils.log_deploy_wrapper(LOG.info, _("Deploy devstack"))
|
@logging.log_deploy_wrapper(LOG.info, _("Deploy devstack"))
|
||||||
def deploy(self):
|
def deploy(self):
|
||||||
self.servers = self.get_provider().create_servers()
|
self.servers = self.get_provider().create_servers()
|
||||||
devstack_repo = self.config.get("devstack_repo", DEVSTACK_REPO)
|
devstack_repo = self.config.get("devstack_repo", DEVSTACK_REPO)
|
||||||
|
@ -21,7 +21,6 @@ import six
|
|||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import log as logging
|
||||||
from rally.common import objects
|
from rally.common import objects
|
||||||
from rally.common import utils
|
|
||||||
from rally.deployment import engine
|
from rally.deployment import engine
|
||||||
from rally.deployment.serverprovider import provider
|
from rally.deployment.serverprovider import provider
|
||||||
from rally.deployment.serverprovider.providers import lxc
|
from rally.deployment.serverprovider.providers import lxc
|
||||||
@ -111,7 +110,7 @@ class LxcEngine(engine.Engine):
|
|||||||
return provider.ProviderFactory.get_provider(self.config["provider"],
|
return provider.ProviderFactory.get_provider(self.config["provider"],
|
||||||
self.deployment)
|
self.deployment)
|
||||||
|
|
||||||
@utils.log_deploy_wrapper(LOG.info, _("Create containers on host"))
|
@logging.log_deploy_wrapper(LOG.info, _("Create containers on host"))
|
||||||
def deploy(self):
|
def deploy(self):
|
||||||
name = self.config["container_name"]
|
name = self.config["container_name"]
|
||||||
start_script = self.config.get("start_script",
|
start_script = self.config.get("start_script",
|
||||||
|
@ -23,7 +23,6 @@ from six import moves
|
|||||||
|
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import log as logging
|
||||||
from rally.common import utils
|
|
||||||
from rally.deployment.serverprovider import provider
|
from rally.deployment.serverprovider import provider
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
|
|
||||||
@ -309,7 +308,7 @@ class LxcProvider(provider.ProviderFactory):
|
|||||||
return provider.ProviderFactory.get_provider(
|
return provider.ProviderFactory.get_provider(
|
||||||
self.config["host_provider"], self.deployment)
|
self.config["host_provider"], self.deployment)
|
||||||
|
|
||||||
@utils.log_deploy_wrapper(LOG.info, _("Create containers on host"))
|
@logging.log_deploy_wrapper(LOG.info, _("Create containers on host"))
|
||||||
def create_servers(self):
|
def create_servers(self):
|
||||||
host_provider = self.get_host_provider()
|
host_provider = self.get_host_provider()
|
||||||
name_prefix = self.config["container_name_prefix"]
|
name_prefix = self.config["container_name_prefix"]
|
||||||
@ -353,7 +352,7 @@ class LxcProvider(provider.ProviderFactory):
|
|||||||
self.resources.create(info)
|
self.resources.create(info)
|
||||||
return servers
|
return servers
|
||||||
|
|
||||||
@utils.log_deploy_wrapper(LOG.info, _("Destroy host(s)"))
|
@logging.log_deploy_wrapper(LOG.info, _("Destroy host(s)"))
|
||||||
def destroy_servers(self):
|
def destroy_servers(self):
|
||||||
for resource in self.resources.get_all():
|
for resource in self.resources.get_all():
|
||||||
server = provider.Server.from_credentials(resource["info"]["host"])
|
server = provider.Server.from_credentials(resource["info"]["host"])
|
||||||
|
@ -22,7 +22,6 @@ from rally.common.i18n import _
|
|||||||
from rally.common import log as logging
|
from rally.common import log as logging
|
||||||
from rally.common import objects
|
from rally.common import objects
|
||||||
from rally.common.plugin import plugin
|
from rally.common.plugin import plugin
|
||||||
from rally.common import utils
|
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
|
|
||||||
@ -695,8 +694,8 @@ class Clients(object):
|
|||||||
return self.cache["services_data"]
|
return self.cache["services_data"]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@utils.log_deprecated("Use rally.osclients.configure decorator instead.",
|
@logging.log_deprecated("Use rally.osclients.configure decorator instead.",
|
||||||
"0.1.2")
|
"0.1.2")
|
||||||
def register(cls, client_name):
|
def register(cls, client_name):
|
||||||
"""DEPRECATED!Decorator that adds new OpenStack client dynamically.
|
"""DEPRECATED!Decorator that adds new OpenStack client dynamically.
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ class CeilometerSampleGenerator(context.Context):
|
|||||||
"samples_per_resource": 5
|
"samples_per_resource": 5
|
||||||
}
|
}
|
||||||
|
|
||||||
@rutils.log_task_wrapper(LOG.info, _("Enter context: `Ceilometer`"))
|
@logging.log_task_wrapper(LOG.info, _("Enter context: `Ceilometer`"))
|
||||||
def setup(self):
|
def setup(self):
|
||||||
counter_name = self.config["counter_name"]
|
counter_name = self.config["counter_name"]
|
||||||
counter_type = self.config["counter_type"]
|
counter_type = self.config["counter_type"]
|
||||||
@ -87,7 +87,7 @@ class CeilometerSampleGenerator(context.Context):
|
|||||||
self.context["tenants"][tenant_id]["resources"].append(
|
self.context["tenants"][tenant_id]["resources"].append(
|
||||||
sample[0].resource_id)
|
sample[0].resource_id)
|
||||||
|
|
||||||
@rutils.log_task_wrapper(LOG.info, _("Exit context: `Ceilometer`"))
|
@logging.log_task_wrapper(LOG.info, _("Exit context: `Ceilometer`"))
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
# We don't have API for removal of samples and resources
|
# We don't have API for removal of samples and resources
|
||||||
pass
|
pass
|
||||||
|
@ -49,7 +49,7 @@ class VolumeGenerator(context.Context):
|
|||||||
"volumes_per_tenant": 1
|
"volumes_per_tenant": 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@rutils.log_task_wrapper(LOG.info, _("Enter context: `Volumes`"))
|
@logging.log_task_wrapper(LOG.info, _("Enter context: `Volumes`"))
|
||||||
def setup(self):
|
def setup(self):
|
||||||
size = self.config["size"]
|
size = self.config["size"]
|
||||||
volumes_per_tenant = self.config["volumes_per_tenant"]
|
volumes_per_tenant = self.config["volumes_per_tenant"]
|
||||||
@ -65,7 +65,7 @@ class VolumeGenerator(context.Context):
|
|||||||
vol = cinder_util._create_volume(size, display_name=rnd_name)
|
vol = cinder_util._create_volume(size, display_name=rnd_name)
|
||||||
self.context["tenants"][tenant_id]["volumes"].append(vol._info)
|
self.context["tenants"][tenant_id]["volumes"].append(vol._info)
|
||||||
|
|
||||||
@rutils.log_task_wrapper(LOG.info, _("Exit context: `Volumes`"))
|
@logging.log_task_wrapper(LOG.info, _("Exit context: `Volumes`"))
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
# TODO(boris-42): Delete only resources created by this context
|
# TODO(boris-42): Delete only resources created by this context
|
||||||
resource_manager.cleanup(names=["cinder.volumes"],
|
resource_manager.cleanup(names=["cinder.volumes"],
|
||||||
|
@ -17,7 +17,6 @@ import sys
|
|||||||
|
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import log as logging
|
||||||
from rally.common import utils as rutils
|
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
from rally.plugins.openstack.context.cleanup import manager
|
from rally.plugins.openstack.context.cleanup import manager
|
||||||
@ -63,7 +62,7 @@ class AdminCleanup(CleanupMixin, context.Context):
|
|||||||
% missing)
|
% missing)
|
||||||
raise NoSuchCleanupResources(missing)
|
raise NoSuchCleanupResources(missing)
|
||||||
|
|
||||||
@rutils.log_task_wrapper(LOG.info, _("admin resources cleanup"))
|
@logging.log_task_wrapper(LOG.info, _("admin resources cleanup"))
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
manager.cleanup(names=self.config,
|
manager.cleanup(names=self.config,
|
||||||
admin_required=True,
|
admin_required=True,
|
||||||
@ -88,7 +87,7 @@ class UserCleanup(CleanupMixin, context.Context):
|
|||||||
% missing)
|
% missing)
|
||||||
raise NoSuchCleanupResources(missing)
|
raise NoSuchCleanupResources(missing)
|
||||||
|
|
||||||
@rutils.log_task_wrapper(LOG.info, _("user resources cleanup"))
|
@logging.log_task_wrapper(LOG.info, _("user resources cleanup"))
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
manager.cleanup(names=self.config,
|
manager.cleanup(names=self.config,
|
||||||
admin_required=False,
|
admin_required=False,
|
||||||
|
@ -62,7 +62,7 @@ class EC2ServerGenerator(context.Context):
|
|||||||
"additionalProperties": False
|
"additionalProperties": False
|
||||||
}
|
}
|
||||||
|
|
||||||
@rutils.log_task_wrapper(LOG.info, _("Enter context: `EC2 Servers`"))
|
@logging.log_task_wrapper(LOG.info, _("Enter context: `EC2 Servers`"))
|
||||||
def setup(self):
|
def setup(self):
|
||||||
image = self.config["image"]
|
image = self.config["image"]
|
||||||
flavor = self.config["flavor"]
|
flavor = self.config["flavor"]
|
||||||
@ -92,7 +92,7 @@ class EC2ServerGenerator(context.Context):
|
|||||||
|
|
||||||
self.context["tenants"][tenant_id]["ec2_servers"] = current_servers
|
self.context["tenants"][tenant_id]["ec2_servers"] = current_servers
|
||||||
|
|
||||||
@rutils.log_task_wrapper(LOG.info, _("Exit context: `EC2 Servers`"))
|
@logging.log_task_wrapper(LOG.info, _("Exit context: `EC2 Servers`"))
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
resource_manager.cleanup(names=["ec2.servers"],
|
resource_manager.cleanup(names=["ec2.servers"],
|
||||||
users=self.context.get("users", []))
|
users=self.context.get("users", []))
|
||||||
|
@ -17,7 +17,6 @@ import collections
|
|||||||
from rally.common import broker
|
from rally.common import broker
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import log as logging
|
||||||
from rally.common import utils as rutils
|
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
from rally.plugins.openstack.scenarios.fuel import utils as fuel_utils
|
from rally.plugins.openstack.scenarios.fuel import utils as fuel_utils
|
||||||
@ -101,7 +100,8 @@ class FuelEnvGenerator(base.Context):
|
|||||||
broker.run(publish, consume, threads)
|
broker.run(publish, consume, threads)
|
||||||
self.context["fuel"] = {}
|
self.context["fuel"] = {}
|
||||||
|
|
||||||
@rutils.log_task_wrapper(LOG.info, _("Enter context: `fuel_environments`"))
|
@logging.log_task_wrapper(LOG.info,
|
||||||
|
_("Enter context: `fuel_environments`"))
|
||||||
def setup(self):
|
def setup(self):
|
||||||
"""Create Fuel environments, using the broker pattern."""
|
"""Create Fuel environments, using the broker pattern."""
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ class FuelEnvGenerator(base.Context):
|
|||||||
msg=_("failed to create the requested"
|
msg=_("failed to create the requested"
|
||||||
" number of environments."))
|
" number of environments."))
|
||||||
|
|
||||||
@rutils.log_task_wrapper(LOG.info, _("Exit context: `fuel_environments`"))
|
@logging.log_task_wrapper(LOG.info, _("Exit context: `fuel_environments`"))
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
"""Delete environments, using the broker pattern."""
|
"""Delete environments, using the broker pattern."""
|
||||||
self._delete_envs()
|
self._delete_envs()
|
||||||
|
@ -63,7 +63,7 @@ class ImageGenerator(context.Context):
|
|||||||
"additionalProperties": False
|
"additionalProperties": False
|
||||||
}
|
}
|
||||||
|
|
||||||
@rutils.log_task_wrapper(LOG.info, _("Enter context: `Images`"))
|
@logging.log_task_wrapper(LOG.info, _("Enter context: `Images`"))
|
||||||
def setup(self):
|
def setup(self):
|
||||||
image_url = self.config["image_url"]
|
image_url = self.config["image_url"]
|
||||||
image_type = self.config["image_type"]
|
image_type = self.config["image_type"]
|
||||||
@ -92,7 +92,7 @@ class ImageGenerator(context.Context):
|
|||||||
|
|
||||||
self.context["tenants"][tenant_id]["images"] = current_images
|
self.context["tenants"][tenant_id]["images"] = current_images
|
||||||
|
|
||||||
@rutils.log_task_wrapper(LOG.info, _("Exit context: `Images`"))
|
@logging.log_task_wrapper(LOG.info, _("Exit context: `Images`"))
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
# TODO(boris-42): Delete only resources created by this context
|
# TODO(boris-42): Delete only resources created by this context
|
||||||
resource_manager.cleanup(names=["glance.images"],
|
resource_manager.cleanup(names=["glance.images"],
|
||||||
|
@ -70,7 +70,7 @@ class StackGenerator(context.Context):
|
|||||||
template["resources"]["TestResource%d" % i] = rand_string
|
template["resources"]["TestResource%d" % i] = rand_string
|
||||||
return template
|
return template
|
||||||
|
|
||||||
@rutils.log_task_wrapper(LOG.info, _("Enter context: `Stacks`"))
|
@logging.log_task_wrapper(LOG.info, _("Enter context: `Stacks`"))
|
||||||
def setup(self):
|
def setup(self):
|
||||||
template = self._prepare_stack_template(
|
template = self._prepare_stack_template(
|
||||||
self.config["resources_per_stack"])
|
self.config["resources_per_stack"])
|
||||||
@ -83,7 +83,7 @@ class StackGenerator(context.Context):
|
|||||||
stack = heat_scenario._create_stack(template)
|
stack = heat_scenario._create_stack(template)
|
||||||
self.context["tenants"][tenant_id]["stacks"].append(stack.id)
|
self.context["tenants"][tenant_id]["stacks"].append(stack.id)
|
||||||
|
|
||||||
@rutils.log_task_wrapper(LOG.info, _("Exit context: `Stacks`"))
|
@logging.log_task_wrapper(LOG.info, _("Exit context: `Stacks`"))
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
resource_manager.cleanup(names=["heat.stacks"],
|
resource_manager.cleanup(names=["heat.stacks"],
|
||||||
users=self.context.get("users", []))
|
users=self.context.get("users", []))
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import log as logging
|
||||||
from rally.common import objects
|
from rally.common import objects
|
||||||
from rally.common import utils as rutils
|
|
||||||
from rally import osclients
|
from rally import osclients
|
||||||
from rally.plugins.openstack.context.keystone import users
|
from rally.plugins.openstack.context.keystone import users
|
||||||
from rally.task import context
|
from rally.task import context
|
||||||
@ -44,7 +43,7 @@ class ExistingUsers(users.UserContextMixin, context.Context):
|
|||||||
# this is used only by benchmark engine
|
# this is used only by benchmark engine
|
||||||
CONFIG_SCHEMA = {}
|
CONFIG_SCHEMA = {}
|
||||||
|
|
||||||
@rutils.log_task_wrapper(LOG.info, _("Enter context: `existing_users`"))
|
@logging.log_task_wrapper(LOG.info, _("Enter context: `existing_users`"))
|
||||||
def setup(self):
|
def setup(self):
|
||||||
self.context["users"] = []
|
self.context["users"] = []
|
||||||
self.context["tenants"] = {}
|
self.context["tenants"] = {}
|
||||||
@ -65,6 +64,6 @@ class ExistingUsers(users.UserContextMixin, context.Context):
|
|||||||
"tenant_id": user_kclient.tenant_id
|
"tenant_id": user_kclient.tenant_id
|
||||||
})
|
})
|
||||||
|
|
||||||
@rutils.log_task_wrapper(LOG.info, _("Exit context: `existing_users`"))
|
@logging.log_task_wrapper(LOG.info, _("Exit context: `existing_users`"))
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
"""These users are not managed by Rally, so don't touch them."""
|
"""These users are not managed by Rally, so don't touch them."""
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
|
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import log as logging
|
||||||
from rally.common import utils as rutils
|
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
from rally import osclients
|
from rally import osclients
|
||||||
@ -79,13 +78,13 @@ class RoleGenerator(context.Context):
|
|||||||
user_id=user["id"], role_id=role["id"],
|
user_id=user["id"], role_id=role["id"],
|
||||||
project_id=user["tenant_id"])
|
project_id=user["tenant_id"])
|
||||||
|
|
||||||
@rutils.log_task_wrapper(LOG.info, _("Enter context: `roles`"))
|
@logging.log_task_wrapper(LOG.info, _("Enter context: `roles`"))
|
||||||
def setup(self):
|
def setup(self):
|
||||||
"""Add roles to all users."""
|
"""Add roles to all users."""
|
||||||
self.context["roles"] = [self._add_role(self.endpoint, name)
|
self.context["roles"] = [self._add_role(self.endpoint, name)
|
||||||
for name in self.config]
|
for name in self.config]
|
||||||
|
|
||||||
@rutils.log_task_wrapper(LOG.info, _("Exit context: `roles`"))
|
@logging.log_task_wrapper(LOG.info, _("Exit context: `roles`"))
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
"""Remove roles from users."""
|
"""Remove roles from users."""
|
||||||
for role in self.context["roles"]:
|
for role in self.context["roles"]:
|
||||||
|
@ -266,7 +266,7 @@ class UserGenerator(UserContextMixin, context.Context):
|
|||||||
broker.run(publish, consume, threads)
|
broker.run(publish, consume, threads)
|
||||||
self.context["users"] = []
|
self.context["users"] = []
|
||||||
|
|
||||||
@rutils.log_task_wrapper(LOG.info, _("Enter context: `users`"))
|
@logging.log_task_wrapper(LOG.info, _("Enter context: `users`"))
|
||||||
def setup(self):
|
def setup(self):
|
||||||
"""Create tenants and users, using the broker pattern."""
|
"""Create tenants and users, using the broker pattern."""
|
||||||
self.context["users"] = []
|
self.context["users"] = []
|
||||||
@ -293,7 +293,7 @@ class UserGenerator(UserContextMixin, context.Context):
|
|||||||
ctx_name=self.get_name(),
|
ctx_name=self.get_name(),
|
||||||
msg=_("Failed to create the requested number of users."))
|
msg=_("Failed to create the requested number of users."))
|
||||||
|
|
||||||
@rutils.log_task_wrapper(LOG.info, _("Exit context: `users`"))
|
@logging.log_task_wrapper(LOG.info, _("Exit context: `users`"))
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
"""Delete tenants and users, using the broker pattern."""
|
"""Delete tenants and users, using the broker pattern."""
|
||||||
self._remove_default_security_group()
|
self._remove_default_security_group()
|
||||||
|
@ -124,7 +124,7 @@ class ManilaShareNetworks(context.Context):
|
|||||||
self.context["tenants"][tenant_id][CONTEXT_NAME]["sn_iterator"] = (
|
self.context["tenants"][tenant_id][CONTEXT_NAME]["sn_iterator"] = (
|
||||||
utils.RAMInt())
|
utils.RAMInt())
|
||||||
|
|
||||||
@utils.log_task_wrapper(LOG.info, _("Enter context: `%s`") % CONTEXT_NAME)
|
@log.log_task_wrapper(LOG.info, _("Enter context: `%s`") % CONTEXT_NAME)
|
||||||
def setup(self):
|
def setup(self):
|
||||||
self.context[CONTEXT_NAME] = {}
|
self.context[CONTEXT_NAME] = {}
|
||||||
if not self.config["use_share_networks"]:
|
if not self.config["use_share_networks"]:
|
||||||
@ -135,7 +135,7 @@ class ManilaShareNetworks(context.Context):
|
|||||||
# TODO(vponomaryov): add support of autocreated resources
|
# TODO(vponomaryov): add support of autocreated resources
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@utils.log_task_wrapper(LOG.info, _("Exit context: `%s`") % CONTEXT_NAME)
|
@log.log_task_wrapper(LOG.info, _("Exit context: `%s`") % CONTEXT_NAME)
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
# TODO(vponomaryov): add cleanup for autocreated resources when appear.
|
# TODO(vponomaryov): add cleanup for autocreated resources when appear.
|
||||||
return
|
return
|
||||||
|
@ -47,7 +47,7 @@ class PackageGenerator(context.Context):
|
|||||||
"additionalProperties": False
|
"additionalProperties": False
|
||||||
}
|
}
|
||||||
|
|
||||||
@utils.log_task_wrapper(LOG.info, _("Enter context: `Murano packages`"))
|
@logging.log_task_wrapper(LOG.info, _("Enter context: `Murano packages`"))
|
||||||
def setup(self):
|
def setup(self):
|
||||||
is_config_app_dir = False
|
is_config_app_dir = False
|
||||||
pckg_path = os.path.expanduser(self.config["app_package"])
|
pckg_path = os.path.expanduser(self.config["app_package"])
|
||||||
@ -74,7 +74,7 @@ class PackageGenerator(context.Context):
|
|||||||
|
|
||||||
self.context["tenants"][tenant_id]["packages"].append(package)
|
self.context["tenants"][tenant_id]["packages"].append(package)
|
||||||
|
|
||||||
@utils.log_task_wrapper(LOG.info, _("Exit context: `Murano packages`"))
|
@logging.log_task_wrapper(LOG.info, _("Exit context: `Murano packages`"))
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
resource_manager.cleanup(names=["murano.packages"],
|
resource_manager.cleanup(names=["murano.packages"],
|
||||||
users=self.context.get("users", []))
|
users=self.context.get("users", []))
|
||||||
|
@ -87,7 +87,7 @@ def _prepare_open_secgroup(endpoint, secgroup_name):
|
|||||||
class AllowSSH(context.Context):
|
class AllowSSH(context.Context):
|
||||||
"""Sets up security groups for all users to access VM via SSH."""
|
"""Sets up security groups for all users to access VM via SSH."""
|
||||||
|
|
||||||
@utils.log_task_wrapper(LOG.info, _("Enter context: `allow_ssh`"))
|
@logging.log_task_wrapper(LOG.info, _("Enter context: `allow_ssh`"))
|
||||||
def setup(self):
|
def setup(self):
|
||||||
admin_or_user = (self.context.get("admin") or
|
admin_or_user = (self.context.get("admin") or
|
||||||
self.context.get("users")[0])
|
self.context.get("users")[0])
|
||||||
@ -106,7 +106,7 @@ class AllowSSH(context.Context):
|
|||||||
user["secgroup"] = _prepare_open_secgroup(user["endpoint"],
|
user["secgroup"] = _prepare_open_secgroup(user["endpoint"],
|
||||||
secgroup_name)
|
secgroup_name)
|
||||||
|
|
||||||
@utils.log_task_wrapper(LOG.info, _("Exit context: `allow_ssh`"))
|
@logging.log_task_wrapper(LOG.info, _("Exit context: `allow_ssh`"))
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
for user, tenant_id in utils.iterate_per_tenants(
|
for user, tenant_id in utils.iterate_per_tenants(
|
||||||
self.context["users"]):
|
self.context["users"]):
|
||||||
|
@ -38,7 +38,7 @@ class ExistingNetwork(context.Context):
|
|||||||
"additionalProperties": False
|
"additionalProperties": False
|
||||||
}
|
}
|
||||||
|
|
||||||
@utils.log_task_wrapper(LOG.info, _("Enter context: `existing_network`"))
|
@logging.log_task_wrapper(LOG.info, _("Enter context: `existing_network`"))
|
||||||
def setup(self):
|
def setup(self):
|
||||||
for user, tenant_id in utils.iterate_per_tenants(
|
for user, tenant_id in utils.iterate_per_tenants(
|
||||||
self.context.get("users", [])):
|
self.context.get("users", [])):
|
||||||
@ -49,6 +49,6 @@ class ExistingNetwork(context.Context):
|
|||||||
self.context["tenants"][tenant_id]["networks"] = (
|
self.context["tenants"][tenant_id]["networks"] = (
|
||||||
net_wrapper.list_networks())
|
net_wrapper.list_networks())
|
||||||
|
|
||||||
@utils.log_task_wrapper(LOG.info, _("Exit context: `existing_network`"))
|
@logging.log_task_wrapper(LOG.info, _("Exit context: `existing_network`"))
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
"""Networks were not created by Rally, so nothing to do."""
|
"""Networks were not created by Rally, so nothing to do."""
|
||||||
|
@ -59,7 +59,7 @@ class Network(context.Context):
|
|||||||
"network_create_args": {}
|
"network_create_args": {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@utils.log_task_wrapper(LOG.info, _("Enter context: `network`"))
|
@logging.log_task_wrapper(LOG.info, _("Enter context: `network`"))
|
||||||
def setup(self):
|
def setup(self):
|
||||||
# NOTE(rkiran): Some clients are not thread-safe. Thus during
|
# NOTE(rkiran): Some clients are not thread-safe. Thus during
|
||||||
# multithreading/multiprocessing, it is likely the
|
# multithreading/multiprocessing, it is likely the
|
||||||
@ -81,7 +81,7 @@ class Network(context.Context):
|
|||||||
network_create_args=self.config["network_create_args"])
|
network_create_args=self.config["network_create_args"])
|
||||||
self.context["tenants"][tenant_id]["networks"].append(network)
|
self.context["tenants"][tenant_id]["networks"].append(network)
|
||||||
|
|
||||||
@utils.log_task_wrapper(LOG.info, _("Exit context: `network`"))
|
@logging.log_task_wrapper(LOG.info, _("Exit context: `network`"))
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
net_wrapper = network_wrapper.wrap(
|
net_wrapper = network_wrapper.wrap(
|
||||||
osclients.Clients(self.context["admin"]["endpoint"]),
|
osclients.Clients(self.context["admin"]["endpoint"]),
|
||||||
|
@ -49,7 +49,7 @@ class Lbaas(context.Context):
|
|||||||
"lbaas_version": 1
|
"lbaas_version": 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@utils.log_task_wrapper(LOG.info, _("Enter context: `lbaas`"))
|
@logging.log_task_wrapper(LOG.info, _("Enter context: `lbaas`"))
|
||||||
def setup(self):
|
def setup(self):
|
||||||
net_wrapper = network_wrapper.wrap(
|
net_wrapper = network_wrapper.wrap(
|
||||||
osclients.Clients(self.context["admin"]["endpoint"]),
|
osclients.Clients(self.context["admin"]["endpoint"]),
|
||||||
@ -76,7 +76,7 @@ class Lbaas(context.Context):
|
|||||||
"Context for LBaaS version %s not implemented."
|
"Context for LBaaS version %s not implemented."
|
||||||
% self.config["lbaas_version"])
|
% self.config["lbaas_version"])
|
||||||
|
|
||||||
@utils.log_task_wrapper(LOG.info, _("Exit context: `lbaas`"))
|
@logging.log_task_wrapper(LOG.info, _("Exit context: `lbaas`"))
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
net_wrapper = network_wrapper.wrap(
|
net_wrapper = network_wrapper.wrap(
|
||||||
osclients.Clients(self.context["admin"]["endpoint"]),
|
osclients.Clients(self.context["admin"]["endpoint"]),
|
||||||
|
@ -19,7 +19,6 @@ import tempfile
|
|||||||
|
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import log as logging
|
||||||
from rally.common import utils
|
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
from rally.task import context
|
from rally.task import context
|
||||||
@ -48,7 +47,7 @@ class Tempest(context.Context):
|
|||||||
tempest_config=self.config.get(
|
tempest_config=self.config.get(
|
||||||
"tempest-config"))
|
"tempest-config"))
|
||||||
|
|
||||||
@utils.log_task_wrapper(LOG.info, _("Enter context: `tempest`"))
|
@logging.log_task_wrapper(LOG.info, _("Enter context: `tempest`"))
|
||||||
def setup(self):
|
def setup(self):
|
||||||
self.verifier.log_file_raw = "/dev/null"
|
self.verifier.log_file_raw = "/dev/null"
|
||||||
# Create temporary directory for subunit-results.
|
# Create temporary directory for subunit-results.
|
||||||
@ -71,7 +70,7 @@ class Tempest(context.Context):
|
|||||||
|
|
||||||
self.context["verifier"] = self.verifier
|
self.context["verifier"] = self.verifier
|
||||||
|
|
||||||
@utils.log_task_wrapper(LOG.info, _("Exit context: `tempest`"))
|
@logging.log_task_wrapper(LOG.info, _("Exit context: `tempest`"))
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
LOG.info("Built-in stress cleanup from Tempest looks like can help to "
|
LOG.info("Built-in stress cleanup from Tempest looks like can help to "
|
||||||
"shot yourself in the foot. Sorry, but even Rally can not "
|
"shot yourself in the foot. Sorry, but even Rally can not "
|
||||||
|
@ -70,7 +70,7 @@ class FlavorsGenerator(context.Context):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@rutils.log_task_wrapper(LOG.info, _("Enter context: `flavors`"))
|
@logging.log_task_wrapper(LOG.info, _("Enter context: `flavors`"))
|
||||||
def setup(self):
|
def setup(self):
|
||||||
"""Create list of flavors."""
|
"""Create list of flavors."""
|
||||||
self.context["flavors"] = {}
|
self.context["flavors"] = {}
|
||||||
@ -96,7 +96,7 @@ class FlavorsGenerator(context.Context):
|
|||||||
self.context["flavors"][flavor_config["name"]] = flavor.to_dict()
|
self.context["flavors"][flavor_config["name"]] = flavor.to_dict()
|
||||||
LOG.debug("Created flavor with id '%s'" % flavor.id)
|
LOG.debug("Created flavor with id '%s'" % flavor.id)
|
||||||
|
|
||||||
@rutils.log_task_wrapper(LOG.info, _("Exit context: `flavors`"))
|
@logging.log_task_wrapper(LOG.info, _("Exit context: `flavors`"))
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
"""Delete created flavors."""
|
"""Delete created flavors."""
|
||||||
clients = osclients.Clients(self.context["admin"]["endpoint"])
|
clients = osclients.Clients(self.context["admin"]["endpoint"])
|
||||||
|
@ -17,7 +17,6 @@ import novaclient.exceptions
|
|||||||
|
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import log as logging
|
||||||
from rally.common import utils
|
|
||||||
from rally import osclients
|
from rally import osclients
|
||||||
from rally.plugins.openstack.context.cleanup import manager as resource_manager
|
from rally.plugins.openstack.context.cleanup import manager as resource_manager
|
||||||
from rally.task import context
|
from rally.task import context
|
||||||
@ -47,12 +46,12 @@ class Keypair(context.Context):
|
|||||||
"name": keypair_name,
|
"name": keypair_name,
|
||||||
"id": keypair.id}
|
"id": keypair.id}
|
||||||
|
|
||||||
@utils.log_task_wrapper(LOG.info, _("Enter context: `keypair`"))
|
@logging.log_task_wrapper(LOG.info, _("Enter context: `keypair`"))
|
||||||
def setup(self):
|
def setup(self):
|
||||||
for user in self.context["users"]:
|
for user in self.context["users"]:
|
||||||
user["keypair"] = self._generate_keypair(user["endpoint"])
|
user["keypair"] = self._generate_keypair(user["endpoint"])
|
||||||
|
|
||||||
@utils.log_task_wrapper(LOG.info, _("Exit context: `keypair`"))
|
@logging.log_task_wrapper(LOG.info, _("Exit context: `keypair`"))
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
# TODO(boris-42): Delete only resources created by this context
|
# TODO(boris-42): Delete only resources created by this context
|
||||||
resource_manager.cleanup(names=["nova.keypairs"],
|
resource_manager.cleanup(names=["nova.keypairs"],
|
||||||
|
@ -70,7 +70,7 @@ class ServerGenerator(context.Context):
|
|||||||
"auto_assign_nic": False
|
"auto_assign_nic": False
|
||||||
}
|
}
|
||||||
|
|
||||||
@rutils.log_task_wrapper(LOG.info, _("Enter context: `Servers`"))
|
@logging.log_task_wrapper(LOG.info, _("Enter context: `Servers`"))
|
||||||
def setup(self):
|
def setup(self):
|
||||||
image = self.config["image"]
|
image = self.config["image"]
|
||||||
flavor = self.config["flavor"]
|
flavor = self.config["flavor"]
|
||||||
@ -112,7 +112,7 @@ class ServerGenerator(context.Context):
|
|||||||
self.context["tenants"][tenant_id][
|
self.context["tenants"][tenant_id][
|
||||||
"servers"] = current_servers
|
"servers"] = current_servers
|
||||||
|
|
||||||
@rutils.log_task_wrapper(LOG.info, _("Exit context: `Servers`"))
|
@logging.log_task_wrapper(LOG.info, _("Exit context: `Servers`"))
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
resource_manager.cleanup(names=["nova.servers"],
|
resource_manager.cleanup(names=["nova.servers"],
|
||||||
users=self.context.get("users", []))
|
users=self.context.get("users", []))
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
|
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import log as logging
|
||||||
from rally.common import utils
|
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally import osclients
|
from rally import osclients
|
||||||
from rally.plugins.openstack.context.quotas import cinder_quotas
|
from rally.plugins.openstack.context.quotas import cinder_quotas
|
||||||
@ -61,7 +60,7 @@ class Quotas(context.Context):
|
|||||||
def _service_has_quotas(self, service):
|
def _service_has_quotas(self, service):
|
||||||
return len(self.config.get(service, {})) > 0
|
return len(self.config.get(service, {})) > 0
|
||||||
|
|
||||||
@utils.log_task_wrapper(LOG.info, _("Enter context: `quotas`"))
|
@logging.log_task_wrapper(LOG.info, _("Enter context: `quotas`"))
|
||||||
def setup(self):
|
def setup(self):
|
||||||
for tenant_id in self.context["tenants"]:
|
for tenant_id in self.context["tenants"]:
|
||||||
for service in self.manager:
|
for service in self.manager:
|
||||||
@ -69,7 +68,7 @@ class Quotas(context.Context):
|
|||||||
self.manager[service].update(tenant_id,
|
self.manager[service].update(tenant_id,
|
||||||
**self.config[service])
|
**self.config[service])
|
||||||
|
|
||||||
@utils.log_task_wrapper(LOG.info, _("Exit context: `quotas`"))
|
@logging.log_task_wrapper(LOG.info, _("Exit context: `quotas`"))
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
for service in self.manager:
|
for service in self.manager:
|
||||||
if self._service_has_quotas(service):
|
if self._service_has_quotas(service):
|
||||||
|
@ -89,7 +89,7 @@ class SaharaCluster(context.Context):
|
|||||||
"flavor_id"]
|
"flavor_id"]
|
||||||
}
|
}
|
||||||
|
|
||||||
@rutils.log_task_wrapper(LOG.info, _("Enter context: `Sahara Cluster`"))
|
@logging.log_task_wrapper(LOG.info, _("Enter context: `Sahara Cluster`"))
|
||||||
def setup(self):
|
def setup(self):
|
||||||
self.context["sahara_clusters"] = {}
|
self.context["sahara_clusters"] = {}
|
||||||
|
|
||||||
@ -160,7 +160,7 @@ class SaharaCluster(context.Context):
|
|||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@rutils.log_task_wrapper(LOG.info, _("Exit context: `Sahara Cluster`"))
|
@logging.log_task_wrapper(LOG.info, _("Exit context: `Sahara Cluster`"))
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
|
|
||||||
# TODO(boris-42): Delete only resources created by this context
|
# TODO(boris-42): Delete only resources created by this context
|
||||||
|
@ -51,8 +51,8 @@ class SaharaDataSources(context.Context):
|
|||||||
"output_type", "output_url_prefix"]
|
"output_type", "output_url_prefix"]
|
||||||
}
|
}
|
||||||
|
|
||||||
@rutils.log_task_wrapper(LOG.info,
|
@logging.log_task_wrapper(LOG.info,
|
||||||
_("Enter context: `Sahara Data Sources`"))
|
_("Enter context: `Sahara Data Sources`"))
|
||||||
def setup(self):
|
def setup(self):
|
||||||
self.context["sahara_output_conf"] = {
|
self.context["sahara_output_conf"] = {
|
||||||
"output_type": self.config["output_type"],
|
"output_type": self.config["output_type"],
|
||||||
@ -79,7 +79,7 @@ class SaharaDataSources(context.Context):
|
|||||||
|
|
||||||
self.context["tenants"][tenant_id]["sahara_input"] = input_ds.id
|
self.context["tenants"][tenant_id]["sahara_input"] = input_ds.id
|
||||||
|
|
||||||
@rutils.log_task_wrapper(LOG.info, _("Exit context: `Sahara EDP`"))
|
@logging.log_task_wrapper(LOG.info, _("Exit context: `Sahara EDP`"))
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
resources = ["job_executions", "jobs", "data_sources"]
|
resources = ["job_executions", "jobs", "data_sources"]
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ class SaharaImage(context.Context):
|
|||||||
image_id=image.id, new_tags=[plugin_name, hadoop_version])
|
image_id=image.id, new_tags=[plugin_name, hadoop_version])
|
||||||
return image.id
|
return image.id
|
||||||
|
|
||||||
@rutils.log_task_wrapper(LOG.info, _("Enter context: `Sahara Image`"))
|
@logging.log_task_wrapper(LOG.info, _("Enter context: `Sahara Image`"))
|
||||||
def setup(self):
|
def setup(self):
|
||||||
self.context["sahara_images"] = {}
|
self.context["sahara_images"] = {}
|
||||||
|
|
||||||
@ -111,7 +111,7 @@ class SaharaImage(context.Context):
|
|||||||
|
|
||||||
self.context["tenants"][tenant_id]["sahara_image"] = image_id
|
self.context["tenants"][tenant_id]["sahara_image"] = image_id
|
||||||
|
|
||||||
@rutils.log_task_wrapper(LOG.info, _("Exit context: `Sahara Image`"))
|
@logging.log_task_wrapper(LOG.info, _("Exit context: `Sahara Image`"))
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
|
|
||||||
# TODO(boris-42): Delete only resources created by this context
|
# TODO(boris-42): Delete only resources created by this context
|
||||||
|
@ -76,8 +76,8 @@ class SaharaJobBinaries(context.Context):
|
|||||||
# downloads for each tenant
|
# downloads for each tenant
|
||||||
lib_cache = {}
|
lib_cache = {}
|
||||||
|
|
||||||
@rutils.log_task_wrapper(LOG.info,
|
@logging.log_task_wrapper(LOG.info,
|
||||||
_("Enter context: `Sahara Job Binaries`"))
|
_("Enter context: `Sahara Job Binaries`"))
|
||||||
def setup(self):
|
def setup(self):
|
||||||
|
|
||||||
for user, tenant_id in rutils.iterate_per_tenants(
|
for user, tenant_id in rutils.iterate_per_tenants(
|
||||||
@ -138,8 +138,8 @@ class SaharaJobBinaries(context.Context):
|
|||||||
|
|
||||||
self.context["tenants"][tenant_id][lib_type].append(job_binary.id)
|
self.context["tenants"][tenant_id][lib_type].append(job_binary.id)
|
||||||
|
|
||||||
@rutils.log_task_wrapper(LOG.info,
|
@logging.log_task_wrapper(LOG.info,
|
||||||
_("Exit context: `Sahara Job Binaries`"))
|
_("Exit context: `Sahara Job Binaries`"))
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
resources = ["job_binary_internals", "job_binaries"]
|
resources = ["job_binary_internals", "job_binaries"]
|
||||||
|
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
|
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import log as logging
|
||||||
from rally.common import utils as rutils
|
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
from rally.plugins.openstack.context.swift import utils as swift_utils
|
from rally.plugins.openstack.context.swift import utils as swift_utils
|
||||||
@ -57,7 +56,7 @@ class SwiftObjectGenerator(swift_utils.SwiftObjectMixin, context.Context):
|
|||||||
"resource_management_workers": 30
|
"resource_management_workers": 30
|
||||||
}
|
}
|
||||||
|
|
||||||
@rutils.log_task_wrapper(LOG.info, _("Enter context: `swift_objects`"))
|
@logging.log_task_wrapper(LOG.info, _("Enter context: `swift_objects`"))
|
||||||
def setup(self):
|
def setup(self):
|
||||||
"""Create containers and objects, using the broker pattern."""
|
"""Create containers and objects, using the broker pattern."""
|
||||||
threads = self.config["resource_management_workers"]
|
threads = self.config["resource_management_workers"]
|
||||||
@ -91,7 +90,7 @@ class SwiftObjectGenerator(swift_utils.SwiftObjectMixin, context.Context):
|
|||||||
"expected %(expected)s but got %(actual)s.")
|
"expected %(expected)s but got %(actual)s.")
|
||||||
% {"expected": objects_num, "actual": objects_count})
|
% {"expected": objects_num, "actual": objects_count})
|
||||||
|
|
||||||
@rutils.log_task_wrapper(LOG.info, _("Exit context: `swift_objects`"))
|
@logging.log_task_wrapper(LOG.info, _("Exit context: `swift_objects`"))
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
"""Delete containers and objects, using the broker pattern."""
|
"""Delete containers and objects, using the broker pattern."""
|
||||||
threads = self.config["resource_management_workers"]
|
threads = self.config["resource_management_workers"]
|
||||||
|
@ -105,7 +105,7 @@ class BaseCustomImageGenerator(context.Context):
|
|||||||
"workers": 1
|
"workers": 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@utils.log_task_wrapper(LOG.info, _("Enter context: `custom_image`"))
|
@logging.log_task_wrapper(LOG.info, _("Enter context: `custom_image`"))
|
||||||
def setup(self):
|
def setup(self):
|
||||||
"""Creates custom image(s) with preinstalled applications.
|
"""Creates custom image(s) with preinstalled applications.
|
||||||
|
|
||||||
@ -185,7 +185,7 @@ class BaseCustomImageGenerator(context.Context):
|
|||||||
admin_clients.glance().images.get(
|
admin_clients.glance().images.get(
|
||||||
custom_image["id"]).update(is_public=True)
|
custom_image["id"]).update(is_public=True)
|
||||||
|
|
||||||
@utils.log_task_wrapper(LOG.info, _("Exit context: `custom_image`"))
|
@logging.log_task_wrapper(LOG.info, _("Exit context: `custom_image`"))
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
"""Delete created custom image(s)."""
|
"""Delete created custom image(s)."""
|
||||||
|
|
||||||
@ -225,8 +225,8 @@ class BaseCustomImageGenerator(context.Context):
|
|||||||
custom_image["id"])
|
custom_image["id"])
|
||||||
nova_scenario._delete_image(custom_image)
|
nova_scenario._delete_image(custom_image)
|
||||||
|
|
||||||
@utils.log_task_wrapper(LOG.info,
|
@logging.log_task_wrapper(LOG.info,
|
||||||
_("Custom image context: customizing"))
|
_("Custom image context: customizing"))
|
||||||
def customize_image(self, server, ip, user):
|
def customize_image(self, server, ip, user):
|
||||||
return self._customize_image(server, ip, user)
|
return self._customize_image(server, ip, user)
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
import random
|
import random
|
||||||
|
|
||||||
from rally.common import log as logging
|
from rally.common import log as logging
|
||||||
from rally.common import utils
|
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
from rally.plugins.openstack import scenario
|
from rally.plugins.openstack import scenario
|
||||||
@ -349,8 +348,8 @@ class CinderVolumes(cinder_utils.CinderScenario,
|
|||||||
@validation.required_services(consts.Service.NOVA, consts.Service.CINDER)
|
@validation.required_services(consts.Service.NOVA, consts.Service.CINDER)
|
||||||
@validation.required_openstack(users=True)
|
@validation.required_openstack(users=True)
|
||||||
@scenario.configure(context={"cleanup": ["cinder", "nova"]})
|
@scenario.configure(context={"cleanup": ["cinder", "nova"]})
|
||||||
@utils.log_deprecated_args("Use 'nested_level' as an int", "0.1.2",
|
@logging.log_deprecated_args("Use 'nested_level' as an int", "0.1.2",
|
||||||
["nested_level"], once=True)
|
["nested_level"], once=True)
|
||||||
def create_nested_snapshots_and_attach_volume(self,
|
def create_nested_snapshots_and_attach_volume(self,
|
||||||
size=None,
|
size=None,
|
||||||
nested_level=None,
|
nested_level=None,
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from rally.common import utils
|
from rally.common import log as logging
|
||||||
from rally.plugins.openstack import scenario
|
from rally.plugins.openstack import scenario
|
||||||
from rally.plugins.openstack.scenarios.keystone import utils as kutils
|
from rally.plugins.openstack.scenarios.keystone import utils as kutils
|
||||||
from rally.task import validation
|
from rally.task import validation
|
||||||
@ -24,7 +24,7 @@ class KeystoneBasic(kutils.KeystoneScenario):
|
|||||||
|
|
||||||
@validation.required_openstack(admin=True)
|
@validation.required_openstack(admin=True)
|
||||||
@scenario.configure(context={"admin_cleanup": ["keystone"]})
|
@scenario.configure(context={"admin_cleanup": ["keystone"]})
|
||||||
@utils.log_deprecated_args(
|
@logging.log_deprecated_args(
|
||||||
"The 'name_length' argument to create_user is ignored",
|
"The 'name_length' argument to create_user is ignored",
|
||||||
"0.1.2", ["name_length"], once=True)
|
"0.1.2", ["name_length"], once=True)
|
||||||
def create_user(self, name_length=10, **kwargs):
|
def create_user(self, name_length=10, **kwargs):
|
||||||
@ -37,7 +37,7 @@ class KeystoneBasic(kutils.KeystoneScenario):
|
|||||||
|
|
||||||
@validation.required_openstack(admin=True)
|
@validation.required_openstack(admin=True)
|
||||||
@scenario.configure(context={"admin_cleanup": ["keystone"]})
|
@scenario.configure(context={"admin_cleanup": ["keystone"]})
|
||||||
@utils.log_deprecated_args(
|
@logging.log_deprecated_args(
|
||||||
"The 'name_length' argument to create_delete_user is ignored",
|
"The 'name_length' argument to create_delete_user is ignored",
|
||||||
"0.1.2", ["name_length"], once=True)
|
"0.1.2", ["name_length"], once=True)
|
||||||
def create_delete_user(self, name_length=10, **kwargs):
|
def create_delete_user(self, name_length=10, **kwargs):
|
||||||
@ -65,7 +65,7 @@ class KeystoneBasic(kutils.KeystoneScenario):
|
|||||||
|
|
||||||
@validation.required_openstack(admin=True)
|
@validation.required_openstack(admin=True)
|
||||||
@scenario.configure(context={"admin_cleanup": ["keystone"]})
|
@scenario.configure(context={"admin_cleanup": ["keystone"]})
|
||||||
@utils.log_deprecated_args(
|
@logging.log_deprecated_args(
|
||||||
"The 'name_length' argument to create_tenant is ignored",
|
"The 'name_length' argument to create_tenant is ignored",
|
||||||
"0.1.2", ["name_length"], once=True)
|
"0.1.2", ["name_length"], once=True)
|
||||||
def create_tenant(self, name_length=10, **kwargs):
|
def create_tenant(self, name_length=10, **kwargs):
|
||||||
@ -78,7 +78,7 @@ class KeystoneBasic(kutils.KeystoneScenario):
|
|||||||
@validation.number("users_per_tenant", minval=1)
|
@validation.number("users_per_tenant", minval=1)
|
||||||
@validation.required_openstack(admin=True)
|
@validation.required_openstack(admin=True)
|
||||||
@scenario.configure(context={"admin_cleanup": ["keystone"]})
|
@scenario.configure(context={"admin_cleanup": ["keystone"]})
|
||||||
@utils.log_deprecated_args(
|
@logging.log_deprecated_args(
|
||||||
"The 'name_length' argument to create_tenant_with_users is ignored",
|
"The 'name_length' argument to create_tenant_with_users is ignored",
|
||||||
"0.1.2", ["name_length"], once=True)
|
"0.1.2", ["name_length"], once=True)
|
||||||
def create_tenant_with_users(self, users_per_tenant, name_length=10,
|
def create_tenant_with_users(self, users_per_tenant, name_length=10,
|
||||||
@ -94,7 +94,7 @@ class KeystoneBasic(kutils.KeystoneScenario):
|
|||||||
|
|
||||||
@validation.required_openstack(admin=True)
|
@validation.required_openstack(admin=True)
|
||||||
@scenario.configure(context={"admin_cleanup": ["keystone"]})
|
@scenario.configure(context={"admin_cleanup": ["keystone"]})
|
||||||
@utils.log_deprecated_args(
|
@logging.log_deprecated_args(
|
||||||
"The 'name_length' argument to create_and_list_users is ignored",
|
"The 'name_length' argument to create_and_list_users is ignored",
|
||||||
"0.1.2", ["name_length"], once=True)
|
"0.1.2", ["name_length"], once=True)
|
||||||
def create_and_list_users(self, name_length=10, **kwargs):
|
def create_and_list_users(self, name_length=10, **kwargs):
|
||||||
@ -108,7 +108,7 @@ class KeystoneBasic(kutils.KeystoneScenario):
|
|||||||
|
|
||||||
@validation.required_openstack(admin=True)
|
@validation.required_openstack(admin=True)
|
||||||
@scenario.configure(context={"admin_cleanup": ["keystone"]})
|
@scenario.configure(context={"admin_cleanup": ["keystone"]})
|
||||||
@utils.log_deprecated_args(
|
@logging.log_deprecated_args(
|
||||||
"The 'name_length' argument to create_and_list_tenants is ignored",
|
"The 'name_length' argument to create_and_list_tenants is ignored",
|
||||||
"0.1.2", ["name_length"], once=True)
|
"0.1.2", ["name_length"], once=True)
|
||||||
def create_and_list_tenants(self, name_length=10, **kwargs):
|
def create_and_list_tenants(self, name_length=10, **kwargs):
|
||||||
@ -175,7 +175,7 @@ class KeystoneBasic(kutils.KeystoneScenario):
|
|||||||
self._get_service(service.id)
|
self._get_service(service.id)
|
||||||
|
|
||||||
@validation.required_openstack(admin=True)
|
@validation.required_openstack(admin=True)
|
||||||
@utils.log_deprecated_args(
|
@logging.log_deprecated_args(
|
||||||
"The 'name' argument to create_and_delete_service will be ignored",
|
"The 'name' argument to create_and_delete_service will be ignored",
|
||||||
"0.0.5", ["name"])
|
"0.0.5", ["name"])
|
||||||
@scenario.configure(context={"admin_cleanup": ["keystone"]})
|
@scenario.configure(context={"admin_cleanup": ["keystone"]})
|
||||||
@ -191,7 +191,7 @@ class KeystoneBasic(kutils.KeystoneScenario):
|
|||||||
|
|
||||||
@validation.required_openstack(admin=True)
|
@validation.required_openstack(admin=True)
|
||||||
@scenario.configure(context={"admin_cleanup": ["keystone"]})
|
@scenario.configure(context={"admin_cleanup": ["keystone"]})
|
||||||
@utils.log_deprecated_args(
|
@logging.log_deprecated_args(
|
||||||
"The 'name_length' argument to create_update_and_delete_tenant is "
|
"The 'name_length' argument to create_update_and_delete_tenant is "
|
||||||
"ignored", "0.1.2", ["name_length"], once=True)
|
"ignored", "0.1.2", ["name_length"], once=True)
|
||||||
def create_update_and_delete_tenant(self, name_length=None, **kwargs):
|
def create_update_and_delete_tenant(self, name_length=None, **kwargs):
|
||||||
@ -205,7 +205,7 @@ class KeystoneBasic(kutils.KeystoneScenario):
|
|||||||
|
|
||||||
@validation.required_openstack(admin=True)
|
@validation.required_openstack(admin=True)
|
||||||
@scenario.configure(context={"admin_cleanup": ["keystone"]})
|
@scenario.configure(context={"admin_cleanup": ["keystone"]})
|
||||||
@utils.log_deprecated_args(
|
@logging.log_deprecated_args(
|
||||||
"The 'name_length' and 'password_length' arguments to "
|
"The 'name_length' and 'password_length' arguments to "
|
||||||
"create_user_update_password are ignored",
|
"create_user_update_password are ignored",
|
||||||
"0.1.2", ["name_length", "password_length"], once=True)
|
"0.1.2", ["name_length", "password_length"], once=True)
|
||||||
@ -217,7 +217,7 @@ class KeystoneBasic(kutils.KeystoneScenario):
|
|||||||
self._update_user_password(user.id, password)
|
self._update_user_password(user.id, password)
|
||||||
|
|
||||||
@validation.required_openstack(admin=True)
|
@validation.required_openstack(admin=True)
|
||||||
@utils.log_deprecated_args(
|
@logging.log_deprecated_args(
|
||||||
"The 'name' argument to create_and_list_services will be ignored",
|
"The 'name' argument to create_and_list_services will be ignored",
|
||||||
"0.0.5", ["name"])
|
"0.0.5", ["name"])
|
||||||
@scenario.configure(context={"admin_cleanup": ["keystone"]})
|
@scenario.configure(context={"admin_cleanup": ["keystone"]})
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from rally.common import utils as rutils
|
from rally.common import log as logging
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally.plugins.openstack import scenario
|
from rally.plugins.openstack import scenario
|
||||||
from rally.plugins.openstack.scenarios.manila import utils
|
from rally.plugins.openstack.scenarios.manila import utils
|
||||||
@ -65,7 +65,7 @@ class ManilaShares(utils.ManilaScenario):
|
|||||||
@validation.required_services(consts.Service.MANILA)
|
@validation.required_services(consts.Service.MANILA)
|
||||||
@validation.required_openstack(users=True)
|
@validation.required_openstack(users=True)
|
||||||
@scenario.configure(context={"cleanup": ["manila"]})
|
@scenario.configure(context={"cleanup": ["manila"]})
|
||||||
@rutils.log_deprecated_args(
|
@logging.log_deprecated_args(
|
||||||
"The 'name' argument to create_and_delete_service will be ignored",
|
"The 'name' argument to create_and_delete_service will be ignored",
|
||||||
"1.1.2", ["name"], once=True)
|
"1.1.2", ["name"], once=True)
|
||||||
def create_share_network_and_delete(self,
|
def create_share_network_and_delete(self,
|
||||||
@ -92,7 +92,7 @@ class ManilaShares(utils.ManilaScenario):
|
|||||||
@validation.required_services(consts.Service.MANILA)
|
@validation.required_services(consts.Service.MANILA)
|
||||||
@validation.required_openstack(users=True)
|
@validation.required_openstack(users=True)
|
||||||
@scenario.configure(context={"cleanup": ["manila"]})
|
@scenario.configure(context={"cleanup": ["manila"]})
|
||||||
@rutils.log_deprecated_args(
|
@logging.log_deprecated_args(
|
||||||
"The 'name' argument to create_and_delete_service will be ignored",
|
"The 'name' argument to create_and_delete_service will be ignored",
|
||||||
"1.1.2", ["name"], once=True)
|
"1.1.2", ["name"], once=True)
|
||||||
def create_share_network_and_list(self,
|
def create_share_network_and_list(self,
|
||||||
@ -141,7 +141,7 @@ class ManilaShares(utils.ManilaScenario):
|
|||||||
@validation.required_services(consts.Service.MANILA)
|
@validation.required_services(consts.Service.MANILA)
|
||||||
@validation.required_openstack(users=True)
|
@validation.required_openstack(users=True)
|
||||||
@scenario.configure(context={"cleanup": ["manila"]})
|
@scenario.configure(context={"cleanup": ["manila"]})
|
||||||
@rutils.log_deprecated_args(
|
@logging.log_deprecated_args(
|
||||||
"The 'name' argument to create_and_delete_service will be ignored",
|
"The 'name' argument to create_and_delete_service will be ignored",
|
||||||
"1.1.2", ["name"], once=True)
|
"1.1.2", ["name"], once=True)
|
||||||
def create_security_service_and_delete(self, security_service_type,
|
def create_security_service_and_delete(self, security_service_type,
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from rally.common import utils
|
from rally.common import log as logging
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
from rally.plugins.openstack import scenario
|
from rally.plugins.openstack import scenario
|
||||||
@ -33,8 +33,8 @@ class VMTasks(vm_utils.VMScenario):
|
|||||||
@types.set(image=types.ImageResourceType,
|
@types.set(image=types.ImageResourceType,
|
||||||
flavor=types.FlavorResourceType)
|
flavor=types.FlavorResourceType)
|
||||||
@validation.image_valid_on_flavor("flavor", "image")
|
@validation.image_valid_on_flavor("flavor", "image")
|
||||||
@utils.log_deprecated_args("Use `command' argument instead", "0.0.5",
|
@logging.log_deprecated_args("Use `command' argument instead", "0.0.5",
|
||||||
("script", "interpreter"), once=True)
|
("script", "interpreter"), once=True)
|
||||||
@validation.file_exists("script", required=False)
|
@validation.file_exists("script", required=False)
|
||||||
@validation.valid_command("command", required=False)
|
@validation.valid_command("command", required=False)
|
||||||
@validation.number("port", minval=1, maxval=65535, nullable=True,
|
@validation.number("port", minval=1, maxval=65535, nullable=True,
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
import random
|
import random
|
||||||
|
|
||||||
from rally.common import utils
|
from rally.common import log as logging
|
||||||
from rally.plugins.openstack import scenario
|
from rally.plugins.openstack import scenario
|
||||||
from rally.plugins.openstack.scenarios.zaqar import utils as zutils
|
from rally.plugins.openstack.scenarios.zaqar import utils as zutils
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ class ZaqarBasic(zutils.ZaqarScenario):
|
|||||||
"""Benchmark scenarios for Zaqar."""
|
"""Benchmark scenarios for Zaqar."""
|
||||||
|
|
||||||
@scenario.configure(context={"cleanup": ["zaqar"]})
|
@scenario.configure(context={"cleanup": ["zaqar"]})
|
||||||
@utils.log_deprecated_args(
|
@logging.log_deprecated_args(
|
||||||
"The 'name_length' argument to create_queue is ignored",
|
"The 'name_length' argument to create_queue is ignored",
|
||||||
"0.1.2", ["name_length"], once=True)
|
"0.1.2", ["name_length"], once=True)
|
||||||
def create_queue(self, name_length=None, **kwargs):
|
def create_queue(self, name_length=None, **kwargs):
|
||||||
@ -35,7 +35,7 @@ class ZaqarBasic(zutils.ZaqarScenario):
|
|||||||
self._queue_create(**kwargs)
|
self._queue_create(**kwargs)
|
||||||
|
|
||||||
@scenario.configure(context={"cleanup": ["zaqar"]})
|
@scenario.configure(context={"cleanup": ["zaqar"]})
|
||||||
@utils.log_deprecated_args(
|
@logging.log_deprecated_args(
|
||||||
"The 'name_length' argument to producer_consumer is ignored",
|
"The 'name_length' argument to producer_consumer is ignored",
|
||||||
"0.1.2", ["name_length"], once=True)
|
"0.1.2", ["name_length"], once=True)
|
||||||
def producer_consumer(self, name_length=None,
|
def producer_consumer(self, name_length=None,
|
||||||
|
@ -25,7 +25,6 @@ import six
|
|||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import log as logging
|
||||||
from rally.common import objects
|
from rally.common import objects
|
||||||
from rally.common import utils as rutils
|
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
from rally import osclients
|
from rally import osclients
|
||||||
@ -185,13 +184,13 @@ class BenchmarkEngine(object):
|
|||||||
self.existing_users = users or []
|
self.existing_users = users or []
|
||||||
self.abort_on_sla_failure = abort_on_sla_failure
|
self.abort_on_sla_failure = abort_on_sla_failure
|
||||||
|
|
||||||
@rutils.log_task_wrapper(LOG.info, _("Task validation check cloud."))
|
@logging.log_task_wrapper(LOG.info, _("Task validation check cloud."))
|
||||||
def _check_cloud(self):
|
def _check_cloud(self):
|
||||||
clients = osclients.Clients(self.admin)
|
clients = osclients.Clients(self.admin)
|
||||||
clients.verified_keystone()
|
clients.verified_keystone()
|
||||||
|
|
||||||
@rutils.log_task_wrapper(LOG.info,
|
@logging.log_task_wrapper(LOG.info,
|
||||||
_("Task validation of scenarios names."))
|
_("Task validation of scenarios names."))
|
||||||
def _validate_config_scenarios_name(self, config):
|
def _validate_config_scenarios_name(self, config):
|
||||||
available = set(s.get_name() for s in scenario.Scenario.get_all())
|
available = set(s.get_name() for s in scenario.Scenario.get_all())
|
||||||
|
|
||||||
@ -204,7 +203,7 @@ class BenchmarkEngine(object):
|
|||||||
names = ", ".join(specified - available)
|
names = ", ".join(specified - available)
|
||||||
raise exceptions.NotFoundScenarios(names=names)
|
raise exceptions.NotFoundScenarios(names=names)
|
||||||
|
|
||||||
@rutils.log_task_wrapper(LOG.info, _("Task validation of syntax."))
|
@logging.log_task_wrapper(LOG.info, _("Task validation of syntax."))
|
||||||
def _validate_config_syntax(self, config):
|
def _validate_config_syntax(self, config):
|
||||||
for subtask in config.subtasks:
|
for subtask in config.subtasks:
|
||||||
for pos, scenario_obj in enumerate(subtask.scenarios):
|
for pos, scenario_obj in enumerate(subtask.scenarios):
|
||||||
@ -241,7 +240,7 @@ class BenchmarkEngine(object):
|
|||||||
|
|
||||||
return user_context
|
return user_context
|
||||||
|
|
||||||
@rutils.log_task_wrapper(LOG.info, _("Task validation of semantic."))
|
@logging.log_task_wrapper(LOG.info, _("Task validation of semantic."))
|
||||||
def _validate_config_semantic(self, config):
|
def _validate_config_semantic(self, config):
|
||||||
self._check_cloud()
|
self._check_cloud()
|
||||||
|
|
||||||
@ -266,7 +265,7 @@ class BenchmarkEngine(object):
|
|||||||
admin, user, scenario_obj["name"],
|
admin, user, scenario_obj["name"],
|
||||||
pos, deployment, scenario_obj)
|
pos, deployment, scenario_obj)
|
||||||
|
|
||||||
@rutils.log_task_wrapper(LOG.info, _("Task validation."))
|
@logging.log_task_wrapper(LOG.info, _("Task validation."))
|
||||||
def validate(self):
|
def validate(self):
|
||||||
"""Perform full task configuration validation."""
|
"""Perform full task configuration validation."""
|
||||||
self.task.update_status(consts.TaskStatus.VERIFYING)
|
self.task.update_status(consts.TaskStatus.VERIFYING)
|
||||||
@ -301,7 +300,7 @@ class BenchmarkEngine(object):
|
|||||||
|
|
||||||
return context_obj
|
return context_obj
|
||||||
|
|
||||||
@rutils.log_task_wrapper(LOG.info, _("Benchmarking."))
|
@logging.log_task_wrapper(LOG.info, _("Benchmarking."))
|
||||||
def run(self):
|
def run(self):
|
||||||
"""Run the benchmark according to the test configuration.
|
"""Run the benchmark according to the test configuration.
|
||||||
|
|
||||||
|
@ -23,7 +23,6 @@ import six
|
|||||||
|
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import log as logging
|
||||||
from rally.common import utils
|
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
|
|
||||||
@ -101,7 +100,7 @@ def manager_list_size(sizes):
|
|||||||
return _list
|
return _list
|
||||||
|
|
||||||
|
|
||||||
@utils.log_deprecated("Use wait_for_status instead.", "0.1.2", once=True)
|
@logging.log_deprecated("Use wait_for_status instead.", "0.1.2", once=True)
|
||||||
def wait_for(resource, is_ready=None, ready_statuses=None,
|
def wait_for(resource, is_ready=None, ready_statuses=None,
|
||||||
failure_statuses=None, status_attr="status", update_resource=None,
|
failure_statuses=None, status_attr="status", update_resource=None,
|
||||||
timeout=60, check_interval=1):
|
timeout=60, check_interval=1):
|
||||||
@ -148,7 +147,7 @@ def wait_for(resource, is_ready=None, ready_statuses=None,
|
|||||||
check_interval=check_interval)
|
check_interval=check_interval)
|
||||||
|
|
||||||
|
|
||||||
@utils.log_deprecated("Use wait_for_status instead.", "0.1.2", once=True)
|
@logging.log_deprecated("Use wait_for_status instead.", "0.1.2", once=True)
|
||||||
def wait_is_ready(resource, is_ready, update_resource=None,
|
def wait_is_ready(resource, is_ready, update_resource=None,
|
||||||
timeout=60, check_interval=1):
|
timeout=60, check_interval=1):
|
||||||
|
|
||||||
@ -247,7 +246,7 @@ def wait_for_status(resource, ready_statuses, failure_statuses=None,
|
|||||||
resource_status=get_status(resource))
|
resource_status=get_status(resource))
|
||||||
|
|
||||||
|
|
||||||
@utils.log_deprecated("Use wait_for_status instead.", "0.1.2", once=True)
|
@logging.log_deprecated("Use wait_for_status instead.", "0.1.2", once=True)
|
||||||
def wait_for_delete(resource, update_resource=None, timeout=60,
|
def wait_for_delete(resource, update_resource=None, timeout=60,
|
||||||
check_interval=1):
|
check_interval=1):
|
||||||
"""Wait for the full deletion of resource.
|
"""Wait for the full deletion of resource.
|
||||||
|
@ -26,7 +26,6 @@ from oslo_utils import encodeutils
|
|||||||
from rally.common import costilius
|
from rally.common import costilius
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import log as logging
|
||||||
from rally.common import utils
|
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
from rally.verification.tempest import config
|
from rally.verification.tempest import config
|
||||||
@ -293,7 +292,7 @@ class Tempest(object):
|
|||||||
if os.path.exists(self.path()):
|
if os.path.exists(self.path()):
|
||||||
shutil.rmtree(self.path())
|
shutil.rmtree(self.path())
|
||||||
|
|
||||||
@utils.log_verification_wrapper(LOG.info, _("Run verification."))
|
@logging.log_verification_wrapper(LOG.info, _("Run verification."))
|
||||||
def _prepare_and_run(self, set_name, regex, tests_file):
|
def _prepare_and_run(self, set_name, regex, tests_file):
|
||||||
if not self.is_configured():
|
if not self.is_configured():
|
||||||
self.generate_config_file()
|
self.generate_config_file()
|
||||||
@ -385,7 +384,7 @@ class Tempest(object):
|
|||||||
LOG.error("JSON-log file not found.")
|
LOG.error("JSON-log file not found.")
|
||||||
return None, None
|
return None, None
|
||||||
|
|
||||||
@utils.log_verification_wrapper(
|
@logging.log_verification_wrapper(
|
||||||
LOG.info, _("Saving verification results."))
|
LOG.info, _("Saving verification results."))
|
||||||
def _save_results(self, log_file=None):
|
def _save_results(self, log_file=None):
|
||||||
total, test_cases = self.parse_results(log_file)
|
total, test_cases = self.parse_results(log_file)
|
||||||
|
87
tests/unit/common/test_log.py
Normal file
87
tests/unit/common/test_log.py
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
#
|
||||||
|
# All Rights Reserved.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
# not use this file except in compliance with the License. You may obtain
|
||||||
|
# a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
|
# License for the specific language governing permissions and limitations
|
||||||
|
# under the License.
|
||||||
|
|
||||||
|
import mock
|
||||||
|
|
||||||
|
from rally.common.i18n import _
|
||||||
|
from rally.common import log as logging
|
||||||
|
from tests.unit import test
|
||||||
|
|
||||||
|
|
||||||
|
class LogTestCase(test.TestCase):
|
||||||
|
|
||||||
|
def test_log_task_wrapper(self):
|
||||||
|
mock_log = mock.MagicMock()
|
||||||
|
msg = "test %(a)s %(b)s"
|
||||||
|
|
||||||
|
class TaskLog(object):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.task = {"uuid": "some_uuid"}
|
||||||
|
|
||||||
|
@logging.log_task_wrapper(mock_log, msg, a=10, b=20)
|
||||||
|
def some_method(self, x, y):
|
||||||
|
return x + y
|
||||||
|
|
||||||
|
t = TaskLog()
|
||||||
|
self.assertEqual(t.some_method.__name__, "some_method")
|
||||||
|
self.assertEqual(t.some_method(2, 2), 4)
|
||||||
|
params = {"msg": msg % {"a": 10, "b": 20}, "uuid": t.task["uuid"]}
|
||||||
|
expected = [
|
||||||
|
mock.call(_("Task %(uuid)s | Starting: %(msg)s") % params),
|
||||||
|
mock.call(_("Task %(uuid)s | Completed: %(msg)s") % params)
|
||||||
|
]
|
||||||
|
self.assertEqual(mock_log.mock_calls, expected)
|
||||||
|
|
||||||
|
def test_log_deprecated(self):
|
||||||
|
mock_log = mock.MagicMock()
|
||||||
|
|
||||||
|
@logging.log_deprecated("some alternative", "0.0.1", mock_log)
|
||||||
|
def some_method(x, y):
|
||||||
|
return x + y
|
||||||
|
|
||||||
|
self.assertEqual(some_method(2, 2), 4)
|
||||||
|
mock_log.assert_called_once_with("'some_method' is deprecated in "
|
||||||
|
"Rally v0.0.1: some alternative")
|
||||||
|
|
||||||
|
def test_log_deprecated_args(self):
|
||||||
|
mock_log = mock.MagicMock()
|
||||||
|
|
||||||
|
@logging.log_deprecated_args("Deprecated test", "0.0.1", ("z",),
|
||||||
|
mock_log, once=True)
|
||||||
|
def some_method(x, y, z):
|
||||||
|
return x + y + z
|
||||||
|
|
||||||
|
self.assertEqual(some_method(2, 2, z=3), 7)
|
||||||
|
mock_log.assert_called_once_with(
|
||||||
|
"Deprecated test (args `z' deprecated in Rally v0.0.1)")
|
||||||
|
|
||||||
|
mock_log.reset_mock()
|
||||||
|
self.assertEqual(some_method(2, 2, z=3), 7)
|
||||||
|
self.assertFalse(mock_log.called)
|
||||||
|
|
||||||
|
@logging.log_deprecated_args("Deprecated test", "0.0.1", ("z",),
|
||||||
|
mock_log, once=False)
|
||||||
|
def some_method(x, y, z):
|
||||||
|
return x + y + z
|
||||||
|
|
||||||
|
self.assertEqual(some_method(2, 2, z=3), 7)
|
||||||
|
mock_log.assert_called_once_with(
|
||||||
|
"Deprecated test (args `z' deprecated in Rally v0.0.1)")
|
||||||
|
|
||||||
|
mock_log.reset_mock()
|
||||||
|
self.assertEqual(some_method(2, 2, z=3), 7)
|
||||||
|
mock_log.assert_called_once_with(
|
||||||
|
"Deprecated test (args `z' deprecated in Rally v0.0.1)")
|
@ -22,7 +22,6 @@ import ddt
|
|||||||
import mock
|
import mock
|
||||||
import testtools
|
import testtools
|
||||||
|
|
||||||
from rally.common.i18n import _
|
|
||||||
from rally.common import utils
|
from rally.common import utils
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
from tests.unit import test
|
from tests.unit import test
|
||||||
@ -116,73 +115,6 @@ class TimerTestCase(test.TestCase):
|
|||||||
self.assertEqual(timer.error[0], type(Exception()))
|
self.assertEqual(timer.error[0], type(Exception()))
|
||||||
|
|
||||||
|
|
||||||
class LogTestCase(test.TestCase):
|
|
||||||
|
|
||||||
def test_log_task_wrapper(self):
|
|
||||||
mock_log = mock.MagicMock()
|
|
||||||
msg = "test %(a)s %(b)s"
|
|
||||||
|
|
||||||
class TaskLog(object):
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
self.task = {"uuid": "some_uuid"}
|
|
||||||
|
|
||||||
@utils.log_task_wrapper(mock_log, msg, a=10, b=20)
|
|
||||||
def some_method(self, x, y):
|
|
||||||
return x + y
|
|
||||||
|
|
||||||
t = TaskLog()
|
|
||||||
self.assertEqual(t.some_method.__name__, "some_method")
|
|
||||||
self.assertEqual(t.some_method(2, 2), 4)
|
|
||||||
params = {"msg": msg % {"a": 10, "b": 20}, "uuid": t.task["uuid"]}
|
|
||||||
expected = [
|
|
||||||
mock.call(_("Task %(uuid)s | Starting: %(msg)s") % params),
|
|
||||||
mock.call(_("Task %(uuid)s | Completed: %(msg)s") % params)
|
|
||||||
]
|
|
||||||
self.assertEqual(mock_log.mock_calls, expected)
|
|
||||||
|
|
||||||
def test_log_deprecated(self):
|
|
||||||
mock_log = mock.MagicMock()
|
|
||||||
|
|
||||||
@utils.log_deprecated("some alternative", "0.0.1", mock_log)
|
|
||||||
def some_method(x, y):
|
|
||||||
return x + y
|
|
||||||
|
|
||||||
self.assertEqual(some_method(2, 2), 4)
|
|
||||||
mock_log.assert_called_once_with("'some_method' is deprecated in "
|
|
||||||
"Rally v0.0.1: some alternative")
|
|
||||||
|
|
||||||
def test_log_deprecated_args(self):
|
|
||||||
mock_log = mock.MagicMock()
|
|
||||||
|
|
||||||
@utils.log_deprecated_args("Deprecated test", "0.0.1", ("z",),
|
|
||||||
mock_log, once=True)
|
|
||||||
def some_method(x, y, z):
|
|
||||||
return x + y + z
|
|
||||||
|
|
||||||
self.assertEqual(some_method(2, 2, z=3), 7)
|
|
||||||
mock_log.assert_called_once_with(
|
|
||||||
"Deprecated test (args `z' deprecated in Rally v0.0.1)")
|
|
||||||
|
|
||||||
mock_log.reset_mock()
|
|
||||||
self.assertEqual(some_method(2, 2, z=3), 7)
|
|
||||||
self.assertFalse(mock_log.called)
|
|
||||||
|
|
||||||
@utils.log_deprecated_args("Deprecated test", "0.0.1", ("z",),
|
|
||||||
mock_log, once=False)
|
|
||||||
def some_method(x, y, z):
|
|
||||||
return x + y + z
|
|
||||||
|
|
||||||
self.assertEqual(some_method(2, 2, z=3), 7)
|
|
||||||
mock_log.assert_called_once_with(
|
|
||||||
"Deprecated test (args `z' deprecated in Rally v0.0.1)")
|
|
||||||
|
|
||||||
mock_log.reset_mock()
|
|
||||||
self.assertEqual(some_method(2, 2, z=3), 7)
|
|
||||||
mock_log.assert_called_once_with(
|
|
||||||
"Deprecated test (args `z' deprecated in Rally v0.0.1)")
|
|
||||||
|
|
||||||
|
|
||||||
def module_level_method():
|
def module_level_method():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -15,8 +15,7 @@
|
|||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
from rally.common import log
|
from rally.common import log as logging
|
||||||
from rally.common import utils
|
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
from rally.plugins.openstack.scenarios.vm import vmtasks
|
from rally.plugins.openstack.scenarios.vm import vmtasks
|
||||||
from tests.unit import test
|
from tests.unit import test
|
||||||
@ -40,7 +39,7 @@ class VMTasksTestCase(test.ScenarioTestCase):
|
|||||||
return_value=(0, "\"foo_out\"", "foo_err"))
|
return_value=(0, "\"foo_out\"", "foo_err"))
|
||||||
|
|
||||||
def test_boot_runcommand_delete(self):
|
def test_boot_runcommand_delete(self):
|
||||||
with log.LogCatcher(utils.LOG) as catcher:
|
with logging.LogCatcher(logging.LOG) as catcher:
|
||||||
self.scenario.boot_runcommand_delete(
|
self.scenario.boot_runcommand_delete(
|
||||||
"foo_image", "foo_flavor",
|
"foo_image", "foo_flavor",
|
||||||
script="foo_script", interpreter="foo_interpreter",
|
script="foo_script", interpreter="foo_interpreter",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user