change name of rally.common.log module
Copied `rally.common.log` to `rally.common.logging` Marked `rally.common.log` as deprecated Change-Id: Ia7926e5f8a716a8a5b74c0f46d9b797e4fe23ddc Closes-Bug: #1521573
This commit is contained in:
parent
8e374ae1c1
commit
79adee9c00
@ -138,7 +138,7 @@ Inherit a class for your plugin from the base *Context* class. Then, implement t
|
|||||||
.. code-block:: python
|
.. code-block:: python
|
||||||
|
|
||||||
from rally.task import context
|
from rally.task import context
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally import osclients
|
from rally import osclients
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ import jinja2.meta
|
|||||||
import jsonschema
|
import jsonschema
|
||||||
|
|
||||||
from rally.common.i18n import _, _LI
|
from rally.common.i18n import _, _LI
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
from rally.common import objects
|
from rally.common import objects
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally.deployment import engine as deploy_engine
|
from rally.deployment import engine as deploy_engine
|
||||||
|
@ -30,7 +30,7 @@ import six
|
|||||||
import sqlalchemy.exc
|
import sqlalchemy.exc
|
||||||
|
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
from rally.common.plugin import discover
|
from rally.common.plugin import discover
|
||||||
from rally.common.plugin import info
|
from rally.common.plugin import info
|
||||||
from rally.common import version
|
from rally.common import version
|
||||||
|
@ -32,7 +32,7 @@ from rally.cli import envutils
|
|||||||
from rally.common import fileutils
|
from rally.common import fileutils
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import junit
|
from rally.common import junit
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
from rally.common import utils as rutils
|
from rally.common import utils as rutils
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
|
@ -17,7 +17,7 @@ import collections
|
|||||||
import threading
|
import threading
|
||||||
|
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
@ -13,260 +13,8 @@
|
|||||||
# 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
|
from rally.common.logging import * # noqa
|
||||||
import logging
|
|
||||||
|
|
||||||
from oslo_config import cfg
|
import warnings
|
||||||
from oslo_log import handlers
|
warnings.warn("rally.common.log is deprecated since Rally 0.1.2. "
|
||||||
from oslo_log import log as oslogging
|
"Please use rally.common.logging instead.")
|
||||||
|
|
||||||
from rally.common.i18n import _
|
|
||||||
|
|
||||||
DEBUG_OPTS = [cfg.BoolOpt(
|
|
||||||
"rally-debug",
|
|
||||||
default=False,
|
|
||||||
help="Print debugging output only for Rally. "
|
|
||||||
"Off-site components stay quiet.")]
|
|
||||||
|
|
||||||
CONF = cfg.CONF
|
|
||||||
CONF.register_cli_opts(DEBUG_OPTS)
|
|
||||||
oslogging.register_options(CONF)
|
|
||||||
|
|
||||||
logging.RDEBUG = logging.DEBUG + 1
|
|
||||||
logging.addLevelName(logging.RDEBUG, "RALLYDEBUG")
|
|
||||||
|
|
||||||
CRITICAL = logging.CRITICAL
|
|
||||||
DEBUG = logging.DEBUG
|
|
||||||
ERROR = logging.ERROR
|
|
||||||
FATAL = logging.FATAL
|
|
||||||
INFO = logging.INFO
|
|
||||||
NOTSET = logging.NOTSET
|
|
||||||
RDEBUG = logging.RDEBUG
|
|
||||||
WARN = logging.WARN
|
|
||||||
WARNING = logging.WARNING
|
|
||||||
|
|
||||||
|
|
||||||
def setup(product_name, version="unknown"):
|
|
||||||
dbg_color = handlers.ColorHandler.LEVEL_COLORS[logging.DEBUG]
|
|
||||||
handlers.ColorHandler.LEVEL_COLORS[logging.RDEBUG] = dbg_color
|
|
||||||
|
|
||||||
oslogging.setup(CONF, product_name, version)
|
|
||||||
|
|
||||||
if CONF.rally_debug:
|
|
||||||
oslogging.getLogger(
|
|
||||||
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"):
|
|
||||||
|
|
||||||
if name not in oslogging._loggers:
|
|
||||||
oslogging._loggers[name] = RallyContextAdapter(logging.getLogger(name),
|
|
||||||
{"project": "rally",
|
|
||||||
"version": version})
|
|
||||||
return oslogging._loggers[name]
|
|
||||||
|
|
||||||
|
|
||||||
LOG = getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
class ExceptionLogger(object):
|
|
||||||
"""Context that intercepts and logs exceptions.
|
|
||||||
|
|
||||||
Usage::
|
|
||||||
LOG = logging.getLogger(__name__)
|
|
||||||
...
|
|
||||||
|
|
||||||
def foobar():
|
|
||||||
with ExceptionLogger(LOG, "foobar warning") as e:
|
|
||||||
return house_of_raising_exception()
|
|
||||||
|
|
||||||
if e.exception:
|
|
||||||
raise e.exception # remove if not required
|
|
||||||
"""
|
|
||||||
|
|
||||||
def __init__(self, logger, warn=None):
|
|
||||||
self.logger = logger
|
|
||||||
self.warn = warn
|
|
||||||
self.exception = None
|
|
||||||
|
|
||||||
def __enter__(self):
|
|
||||||
return self
|
|
||||||
|
|
||||||
def __exit__(self, type_, value, traceback):
|
|
||||||
if value:
|
|
||||||
self.exception = value
|
|
||||||
|
|
||||||
if self.warn:
|
|
||||||
self.logger.warning(self.warn)
|
|
||||||
self.logger.debug(value)
|
|
||||||
if is_debug():
|
|
||||||
self.logger.exception(value)
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
class CatcherHandler(logging.handlers.BufferingHandler):
|
|
||||||
def __init__(self):
|
|
||||||
logging.handlers.BufferingHandler.__init__(self, 0)
|
|
||||||
|
|
||||||
def shouldFlush(self):
|
|
||||||
return False
|
|
||||||
|
|
||||||
def emit(self, record):
|
|
||||||
self.buffer.append(record)
|
|
||||||
|
|
||||||
|
|
||||||
class LogCatcher(object):
|
|
||||||
"""Context manager that catches log messages.
|
|
||||||
|
|
||||||
User can make an assertion on their content or fetch them all.
|
|
||||||
|
|
||||||
Usage::
|
|
||||||
LOG = logging.getLogger(__name__)
|
|
||||||
...
|
|
||||||
|
|
||||||
def foobar():
|
|
||||||
with LogCatcher(LOG) as catcher_in_rye:
|
|
||||||
LOG.warning("Running Kids")
|
|
||||||
|
|
||||||
catcher_in_rye.assertInLogs("Running Kids")
|
|
||||||
"""
|
|
||||||
def __init__(self, logger):
|
|
||||||
self.logger = getattr(logger, "logger", logger)
|
|
||||||
self.handler = CatcherHandler()
|
|
||||||
|
|
||||||
def __enter__(self):
|
|
||||||
self.logger.addHandler(self.handler)
|
|
||||||
return self
|
|
||||||
|
|
||||||
def __exit__(self, type_, value, traceback):
|
|
||||||
self.logger.removeHandler(self.handler)
|
|
||||||
|
|
||||||
def assertInLogs(self, msg):
|
|
||||||
"""Assert that `msg' is a substring at least of one logged message.
|
|
||||||
|
|
||||||
:param msg: Substring to look for.
|
|
||||||
:return: Log messages where the `msg' was found.
|
|
||||||
Raises AssertionError if none.
|
|
||||||
"""
|
|
||||||
in_logs = [record.msg
|
|
||||||
for record in self.handler.buffer if msg in record.msg]
|
|
||||||
if not in_logs:
|
|
||||||
raise AssertionError("Expected `%s' is not in logs" % msg)
|
|
||||||
return in_logs
|
|
||||||
|
|
||||||
def fetchLogRecords(self):
|
|
||||||
"""Returns all logged Records."""
|
|
||||||
return self.handler.buffer
|
|
||||||
|
|
||||||
def fetchLogs(self):
|
|
||||||
"""Returns all logged messages."""
|
|
||||||
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():
|
|
||||||
return CONF.debug or CONF.rally_debug
|
|
||||||
|
273
rally/common/logging.py
Normal file
273
rally/common/logging.py
Normal file
@ -0,0 +1,273 @@
|
|||||||
|
# Copyright 2014: Mirantis Inc.
|
||||||
|
# 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 functools
|
||||||
|
|
||||||
|
from oslo_config import cfg
|
||||||
|
from oslo_log import handlers
|
||||||
|
from oslo_log import log as oslogging
|
||||||
|
|
||||||
|
from rally.common.i18n import _
|
||||||
|
|
||||||
|
log = __import__("logging")
|
||||||
|
|
||||||
|
DEBUG_OPTS = [cfg.BoolOpt(
|
||||||
|
"rally-debug",
|
||||||
|
default=False,
|
||||||
|
help="Print debugging output only for Rally. "
|
||||||
|
"Off-site components stay quiet.")]
|
||||||
|
|
||||||
|
CONF = cfg.CONF
|
||||||
|
CONF.register_cli_opts(DEBUG_OPTS)
|
||||||
|
oslogging.register_options(CONF)
|
||||||
|
|
||||||
|
log.RDEBUG = log.DEBUG + 1
|
||||||
|
log.addLevelName(log.RDEBUG, "RALLYDEBUG")
|
||||||
|
|
||||||
|
CRITICAL = log.CRITICAL
|
||||||
|
DEBUG = log.DEBUG
|
||||||
|
ERROR = log.ERROR
|
||||||
|
FATAL = log.FATAL
|
||||||
|
INFO = log.INFO
|
||||||
|
NOTSET = log.NOTSET
|
||||||
|
RDEBUG = log.RDEBUG
|
||||||
|
WARN = log.WARN
|
||||||
|
WARNING = log.WARNING
|
||||||
|
|
||||||
|
|
||||||
|
def setup(product_name, version="unknown"):
|
||||||
|
dbg_color = handlers.ColorHandler.LEVEL_COLORS[log.DEBUG]
|
||||||
|
handlers.ColorHandler.LEVEL_COLORS[log.RDEBUG] = dbg_color
|
||||||
|
|
||||||
|
oslogging.setup(CONF, product_name, version)
|
||||||
|
|
||||||
|
if CONF.rally_debug:
|
||||||
|
oslogging.getLogger(
|
||||||
|
project=product_name).logger.setLevel(log.RDEBUG)
|
||||||
|
|
||||||
|
|
||||||
|
class RallyContextAdapter(oslogging.KeywordArgumentAdapter):
|
||||||
|
|
||||||
|
def debug(self, msg, *args, **kwargs):
|
||||||
|
self.log(log.RDEBUG, msg, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
def getLogger(name="unknown", version="unknown"):
|
||||||
|
|
||||||
|
if name not in oslogging._loggers:
|
||||||
|
oslogging._loggers[name] = RallyContextAdapter(log.getLogger(name),
|
||||||
|
{"project": "rally",
|
||||||
|
"version": version})
|
||||||
|
return oslogging._loggers[name]
|
||||||
|
|
||||||
|
|
||||||
|
LOG = getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class ExceptionLogger(object):
|
||||||
|
"""Context that intercepts and logs exceptions.
|
||||||
|
|
||||||
|
Usage::
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
...
|
||||||
|
|
||||||
|
def foobar():
|
||||||
|
with ExceptionLogger(LOG, "foobar warning") as e:
|
||||||
|
return house_of_raising_exception()
|
||||||
|
|
||||||
|
if e.exception:
|
||||||
|
raise e.exception # remove if not required
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, logger, warn=None):
|
||||||
|
self.logger = logger
|
||||||
|
self.warn = warn
|
||||||
|
self.exception = None
|
||||||
|
|
||||||
|
def __enter__(self):
|
||||||
|
return self
|
||||||
|
|
||||||
|
def __exit__(self, type_, value, traceback):
|
||||||
|
if value:
|
||||||
|
self.exception = value
|
||||||
|
|
||||||
|
if self.warn:
|
||||||
|
self.logger.warning(self.warn)
|
||||||
|
self.logger.debug(value)
|
||||||
|
if is_debug():
|
||||||
|
self.logger.exception(value)
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
class CatcherHandler(log.handlers.BufferingHandler):
|
||||||
|
def __init__(self):
|
||||||
|
log.handlers.BufferingHandler.__init__(self, 0)
|
||||||
|
|
||||||
|
def shouldFlush(self):
|
||||||
|
return False
|
||||||
|
|
||||||
|
def emit(self, record):
|
||||||
|
self.buffer.append(record)
|
||||||
|
|
||||||
|
|
||||||
|
class LogCatcher(object):
|
||||||
|
"""Context manager that catches log messages.
|
||||||
|
|
||||||
|
User can make an assertion on their content or fetch them all.
|
||||||
|
|
||||||
|
Usage::
|
||||||
|
LOG = logging.getLogger(__name__)
|
||||||
|
...
|
||||||
|
|
||||||
|
def foobar():
|
||||||
|
with LogCatcher(LOG) as catcher_in_rye:
|
||||||
|
LOG.warning("Running Kids")
|
||||||
|
|
||||||
|
catcher_in_rye.assertInLogs("Running Kids")
|
||||||
|
"""
|
||||||
|
def __init__(self, logger):
|
||||||
|
self.logger = getattr(logger, "logger", logger)
|
||||||
|
self.handler = CatcherHandler()
|
||||||
|
|
||||||
|
def __enter__(self):
|
||||||
|
self.logger.addHandler(self.handler)
|
||||||
|
return self
|
||||||
|
|
||||||
|
def __exit__(self, type_, value, traceback):
|
||||||
|
self.logger.removeHandler(self.handler)
|
||||||
|
|
||||||
|
def assertInLogs(self, msg):
|
||||||
|
"""Assert that `msg' is a substring at least of one logged message.
|
||||||
|
|
||||||
|
:param msg: Substring to look for.
|
||||||
|
:return: Log messages where the `msg' was found.
|
||||||
|
Raises AssertionError if none.
|
||||||
|
"""
|
||||||
|
in_logs = [record.msg
|
||||||
|
for record in self.handler.buffer if msg in record.msg]
|
||||||
|
if not in_logs:
|
||||||
|
raise AssertionError("Expected `%s' is not in logs" % msg)
|
||||||
|
return in_logs
|
||||||
|
|
||||||
|
def fetchLogRecords(self):
|
||||||
|
"""Returns all logged Records."""
|
||||||
|
return self.handler.buffer
|
||||||
|
|
||||||
|
def fetchLogs(self):
|
||||||
|
"""Returns all logged messages."""
|
||||||
|
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():
|
||||||
|
return CONF.debug or CONF.rally_debug
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
import itertools
|
import itertools
|
||||||
|
|
||||||
from rally.common import log
|
from rally.common import logging
|
||||||
from rally import osclients
|
from rally import osclients
|
||||||
from rally.plugins.openstack.context.cleanup import base as cleanup_base
|
from rally.plugins.openstack.context.cleanup import base as cleanup_base
|
||||||
from rally.plugins.openstack.context.keystone import users
|
from rally.plugins.openstack.context.keystone import users
|
||||||
@ -34,7 +34,7 @@ from rally.verification.tempest import config as tempest_conf
|
|||||||
def list_opts():
|
def list_opts():
|
||||||
return [
|
return [
|
||||||
("DEFAULT",
|
("DEFAULT",
|
||||||
itertools.chain(log.DEBUG_OPTS,
|
itertools.chain(logging.DEBUG_OPTS,
|
||||||
osclients.OSCLIENTS_OPTS)),
|
osclients.OSCLIENTS_OPTS)),
|
||||||
("benchmark",
|
("benchmark",
|
||||||
itertools.chain(cinder_utils.CINDER_BENCHMARK_OPTS,
|
itertools.chain(cinder_utils.CINDER_BENCHMARK_OPTS,
|
||||||
|
@ -21,7 +21,7 @@ from oslo_utils import importutils
|
|||||||
|
|
||||||
import rally
|
import rally
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ import paramiko
|
|||||||
import six
|
import six
|
||||||
|
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
@ -27,7 +27,7 @@ import time
|
|||||||
|
|
||||||
from six import moves
|
from six import moves
|
||||||
|
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
@ -19,7 +19,7 @@ import jsonschema
|
|||||||
import six
|
import six
|
||||||
|
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
from rally.common.plugin import plugin
|
from rally.common.plugin import plugin
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally.deployment.serverprovider import provider
|
from rally.deployment.serverprovider import provider
|
||||||
|
@ -18,7 +18,7 @@ import os
|
|||||||
import six
|
import six
|
||||||
|
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
from rally.common import objects
|
from rally.common import objects
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally.deployment import engine
|
from rally.deployment import engine
|
||||||
|
@ -19,7 +19,7 @@ import netaddr
|
|||||||
import six
|
import six
|
||||||
|
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
from rally.common import objects
|
from rally.common import objects
|
||||||
from rally.deployment import engine
|
from rally.deployment import engine
|
||||||
from rally.deployment.serverprovider import provider
|
from rally.deployment.serverprovider import provider
|
||||||
|
@ -19,7 +19,7 @@ import time
|
|||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ import six
|
|||||||
from six import moves
|
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 logging
|
||||||
from rally.deployment.serverprovider import provider
|
from rally.deployment.serverprovider import provider
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ import os
|
|||||||
import novaclient.exceptions
|
import novaclient.exceptions
|
||||||
|
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
from rally.common import objects
|
from rally.common import objects
|
||||||
from rally.deployment.serverprovider import provider
|
from rally.deployment.serverprovider import provider
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
import six
|
import six
|
||||||
|
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ import os
|
|||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import 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 import consts
|
from rally import consts
|
||||||
|
@ -20,7 +20,7 @@ import time
|
|||||||
|
|
||||||
from six.moves import queue as Queue
|
from six.moves import queue as Queue
|
||||||
|
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
from rally.common import utils
|
from rally.common import utils
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally.task import runner
|
from rally.task import runner
|
||||||
|
@ -20,7 +20,7 @@ import time
|
|||||||
|
|
||||||
from six.moves import queue as Queue
|
from six.moves import queue as Queue
|
||||||
|
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
from rally.common import utils
|
from rally.common import utils
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally.task import runner
|
from rally.task import runner
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
from six import moves
|
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 logging
|
||||||
from rally.common import utils as rutils
|
from rally.common import utils as rutils
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
from rally.common import utils as rutils
|
from rally.common import utils as rutils
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally.plugins.openstack.context.cleanup import manager as resource_manager
|
from rally.plugins.openstack.context.cleanup import manager as resource_manager
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
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
|
||||||
|
@ -17,7 +17,7 @@ import time
|
|||||||
|
|
||||||
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 logging
|
||||||
from rally.common.plugin import discover
|
from rally.common.plugin import discover
|
||||||
from rally.common import utils as rutils
|
from rally.common import utils as rutils
|
||||||
from rally import osclients
|
from rally import osclients
|
||||||
|
@ -17,7 +17,7 @@ from boto import exception as boto_exception
|
|||||||
from neutronclient.common import exceptions as neutron_exceptions
|
from neutronclient.common import exceptions as neutron_exceptions
|
||||||
from saharaclient.api import base as saharaclient_base
|
from saharaclient.api import base as saharaclient_base
|
||||||
|
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
from rally.common.plugin import discover
|
from rally.common.plugin import discover
|
||||||
from rally.common import utils
|
from rally.common import utils
|
||||||
from rally.plugins.openstack.context.cleanup import base
|
from rally.plugins.openstack.context.cleanup import base
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
from rally.common import utils as rutils
|
from rally.common import utils as rutils
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally import osclients
|
from rally import osclients
|
||||||
|
@ -16,7 +16,7 @@ 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 logging
|
||||||
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
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
from rally.common import utils as rutils
|
from rally.common import utils as rutils
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally.plugins.openstack.context.cleanup import manager as resource_manager
|
from rally.plugins.openstack.context.cleanup import manager as resource_manager
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
from rally.common import utils as rutils
|
from rally.common import utils as rutils
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally.plugins.openstack.context.cleanup import manager as resource_manager
|
from rally.plugins.openstack.context.cleanup import manager as resource_manager
|
||||||
|
@ -15,7 +15,7 @@ import random
|
|||||||
import six
|
import six
|
||||||
|
|
||||||
from rally.common.i18n import _, _LE
|
from rally.common.i18n import _, _LE
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
from rally import osclients
|
from rally import osclients
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
|
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
from rally.common import objects
|
from rally.common import objects
|
||||||
from rally import osclients
|
from rally import osclients
|
||||||
from rally.plugins.openstack.context.keystone import users
|
from rally.plugins.openstack.context.keystone import users
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
from rally import osclients
|
from rally import osclients
|
||||||
|
@ -22,7 +22,7 @@ import six
|
|||||||
|
|
||||||
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 logging
|
||||||
from rally.common import objects
|
from rally.common import objects
|
||||||
from rally.common import utils as rutils
|
from rally.common import utils as rutils
|
||||||
from rally import consts
|
from rally import consts
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log
|
from rally.common import logging
|
||||||
from rally.common import utils
|
from rally.common import utils
|
||||||
from rally import consts as rally_consts
|
from rally import consts as rally_consts
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
@ -25,7 +25,7 @@ from rally.plugins.openstack.scenarios.manila import utils as manila_utils
|
|||||||
from rally.task import context
|
from rally.task import context
|
||||||
|
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
LOG = log.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
CONTEXT_NAME = consts.SHARE_NETWORKS_CONTEXT_NAME
|
CONTEXT_NAME = consts.SHARE_NETWORKS_CONTEXT_NAME
|
||||||
|
|
||||||
@ -124,7 +124,8 @@ 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())
|
||||||
|
|
||||||
@log.log_task_wrapper(LOG.info, _("Enter context: `%s`") % CONTEXT_NAME)
|
@logging.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 +136,7 @@ class ManilaShareNetworks(context.Context):
|
|||||||
# TODO(vponomaryov): add support of autocreated resources
|
# TODO(vponomaryov): add support of autocreated resources
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@log.log_task_wrapper(LOG.info, _("Exit context: `%s`") % CONTEXT_NAME)
|
@logging.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
|
||||||
|
@ -19,7 +19,7 @@ import zipfile
|
|||||||
from rally.common import fileutils
|
from rally.common import fileutils
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common.i18n import _LE
|
from rally.common.i18n import _LE
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
from rally.common import utils
|
from rally.common import utils
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
import six
|
import six
|
||||||
|
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
from rally.common import utils
|
from rally.common import utils
|
||||||
from rally import osclients
|
from rally import osclients
|
||||||
from rally.plugins.openstack.wrappers import network
|
from rally.plugins.openstack.wrappers import network
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
|
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
from rally.common import utils
|
from rally.common import utils
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally import osclients
|
from rally import osclients
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
import six
|
import six
|
||||||
|
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
from rally.common import utils
|
from rally.common import utils
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally import osclients
|
from rally import osclients
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
import six
|
import six
|
||||||
|
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
from rally.common import utils
|
from rally.common import utils
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally import osclients
|
from rally import osclients
|
||||||
|
@ -18,7 +18,7 @@ import shutil
|
|||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
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
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
from novaclient import exceptions as nova_exceptions
|
from novaclient import exceptions as nova_exceptions
|
||||||
|
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
from rally.common import utils as rutils
|
from rally.common import utils as rutils
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally import osclients
|
from rally import osclients
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
import novaclient.exceptions
|
import novaclient.exceptions
|
||||||
|
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
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
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
from rally.common import utils as rutils
|
from rally.common import utils as rutils
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally import osclients
|
from rally import osclients
|
||||||
|
@ -12,7 +12,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 log as logging
|
from rally.common import logging
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
@ -12,7 +12,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 log as logging
|
from rally.common import logging
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
@ -12,7 +12,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 log as logging
|
from rally.common import logging
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
@ -12,7 +12,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 log as logging
|
from rally.common import logging
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
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
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
|
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
from rally.common import utils as rutils
|
from rally.common import utils as rutils
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
from rally.common import utils as rutils
|
from rally.common import utils as rutils
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
|
@ -17,7 +17,7 @@ import requests
|
|||||||
from six.moves.urllib import parse
|
from six.moves.urllib import parse
|
||||||
|
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
from rally.common import utils as rutils
|
from rally.common import utils as rutils
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally import osclients
|
from rally import osclients
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
import requests
|
import requests
|
||||||
|
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
from rally.common import utils as rutils
|
from rally.common import utils as rutils
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
from rally.common import utils as rutils
|
from rally.common import utils as rutils
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally import osclients
|
from rally import osclients
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
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
|
||||||
|
@ -19,7 +19,7 @@ import six
|
|||||||
|
|
||||||
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 logging
|
||||||
from rally.common import utils
|
from rally.common import utils
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally import osclients
|
from rally import osclients
|
||||||
|
@ -12,7 +12,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 log
|
from rally.common import 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.ceilometer import utils
|
from rally.plugins.openstack.scenarios.ceilometer import utils
|
||||||
@ -22,8 +22,8 @@ from rally.task import validation
|
|||||||
class CeilometerStats(utils.CeilometerScenario):
|
class CeilometerStats(utils.CeilometerScenario):
|
||||||
"""Benchmark scenarios for Ceilometer Stats API."""
|
"""Benchmark scenarios for Ceilometer Stats API."""
|
||||||
|
|
||||||
@log.log_deprecated("Use 'get_stats' method, now samples are created in "
|
@logging.log_deprecated("Use 'get_stats' method, now samples are created"
|
||||||
"context", "0.1.2")
|
"in context", "0.1.2")
|
||||||
@validation.required_services(consts.Service.CEILOMETER)
|
@validation.required_services(consts.Service.CEILOMETER)
|
||||||
@validation.required_openstack(users=True)
|
@validation.required_openstack(users=True)
|
||||||
@scenario.configure()
|
@scenario.configure()
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
import random
|
import random
|
||||||
|
|
||||||
from rally.common import log as logging
|
from rally.common import 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
|
||||||
|
@ -12,7 +12,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 log as logging
|
from rally.common import 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.ec2 import utils
|
from rally.plugins.openstack.scenarios.ec2 import utils
|
||||||
|
@ -18,7 +18,7 @@ import time
|
|||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
from rally.plugins.openstack import scenario
|
from rally.plugins.openstack import scenario
|
||||||
from rally.task import atomic
|
from rally.task import atomic
|
||||||
|
@ -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 log as logging
|
from rally.common import 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
|
||||||
|
@ -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 log as logging
|
from rally.common import 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
|
||||||
|
@ -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 log as logging
|
from rally.common import 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.murano import utils
|
from rally.plugins.openstack.scenarios.murano import utils
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
import random
|
import random
|
||||||
|
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
from rally.plugins.openstack import scenario
|
from rally.plugins.openstack import scenario
|
||||||
from rally.plugins.openstack.wrappers import network as network_wrapper
|
from rally.plugins.openstack.wrappers import network as network_wrapper
|
||||||
|
@ -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 log as logging
|
from rally.common import 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.nova import utils
|
from rally.plugins.openstack.scenarios.nova import utils
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
import jsonschema
|
import jsonschema
|
||||||
|
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally import exceptions as rally_exceptions
|
from rally import exceptions as rally_exceptions
|
||||||
from rally.plugins.openstack import scenario
|
from rally.plugins.openstack import scenario
|
||||||
|
@ -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 log as logging
|
from rally.common import 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.sahara import utils
|
from rally.plugins.openstack.scenarios.sahara import utils
|
||||||
|
@ -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 log as logging
|
from rally.common import 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.sahara import utils
|
from rally.plugins.openstack.scenarios.sahara import utils
|
||||||
|
@ -20,7 +20,7 @@ from oslo_utils import uuidutils
|
|||||||
from saharaclient.api import base as sahara_base
|
from saharaclient.api import base as sahara_base
|
||||||
|
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
from rally.common import utils as rutils
|
from rally.common import utils as rutils
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
|
@ -21,7 +21,7 @@ from oslo_config import cfg
|
|||||||
import six
|
import six
|
||||||
|
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
from rally.common import sshutils
|
from rally.common import sshutils
|
||||||
from rally.plugins.openstack.scenarios.cinder import utils as cinder_utils
|
from rally.plugins.openstack.scenarios.cinder import utils as cinder_utils
|
||||||
from rally.plugins.openstack.scenarios.nova import utils as nova_utils
|
from rally.plugins.openstack.scenarios.nova import utils as nova_utils
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from rally.common import log as logging
|
from rally.common import 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
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
import random
|
import random
|
||||||
|
|
||||||
from rally.common import log as logging
|
from rally.common import 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
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
import abc
|
import abc
|
||||||
|
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
|
|
||||||
import six
|
import six
|
||||||
|
@ -19,7 +19,7 @@ import collections
|
|||||||
from keystoneclient import exceptions
|
from keystoneclient import exceptions
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
|
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
@ -19,7 +19,7 @@ import netaddr
|
|||||||
import six
|
import six
|
||||||
|
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
from rally.common import utils
|
from rally.common import utils
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
|
@ -19,7 +19,7 @@ import copy
|
|||||||
import jsonschema
|
import jsonschema
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
from rally.common.plugin import plugin
|
from rally.common.plugin import plugin
|
||||||
from rally.common import utils
|
from rally.common import utils
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
|
@ -23,7 +23,7 @@ import jsonschema
|
|||||||
import six
|
import six
|
||||||
|
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
from rally.common import objects
|
from rally.common import objects
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
|
@ -20,7 +20,7 @@ import time
|
|||||||
|
|
||||||
import jsonschema
|
import jsonschema
|
||||||
|
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
from rally.common.plugin import plugin
|
from rally.common.plugin import plugin
|
||||||
from rally.common import utils as rutils
|
from rally.common import utils as rutils
|
||||||
from rally import consts
|
from rally import consts
|
||||||
|
@ -19,7 +19,7 @@ import time
|
|||||||
|
|
||||||
import six
|
import six
|
||||||
|
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
from rally.common.plugin import plugin
|
from rally.common.plugin import plugin
|
||||||
from rally.common import utils
|
from rally.common import utils
|
||||||
from rally import consts
|
from rally import consts
|
||||||
|
@ -22,7 +22,7 @@ from novaclient import exceptions as nova_exc
|
|||||||
import six
|
import six
|
||||||
|
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ from six.moves.urllib import parse
|
|||||||
|
|
||||||
from rally.common import db
|
from rally.common import db
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
from rally.common import objects
|
from rally.common import objects
|
||||||
from rally.common import utils
|
from rally.common import utils
|
||||||
from rally import exceptions
|
from rally import exceptions
|
||||||
|
@ -25,7 +25,7 @@ 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.io import subunit_v2
|
from rally.common.io import subunit_v2
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
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
|
||||||
|
@ -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 log as logging
|
from rally.common import logging
|
||||||
from rally import consts
|
from rally import consts
|
||||||
from rally import osclients
|
from rally import osclients
|
||||||
from rally.task import context
|
from rally.task import context
|
||||||
|
@ -138,8 +138,8 @@ def check_import_of_logging(logical_line, filename):
|
|||||||
N310
|
N310
|
||||||
"""
|
"""
|
||||||
|
|
||||||
excluded_files = ["./rally/common/log.py",
|
excluded_files = ["./rally/common/logging.py",
|
||||||
"./tests/unit/test_log.py",
|
"./tests/unit/test_logging.py",
|
||||||
"./tests/ci/rally_verify.py"]
|
"./tests/ci/rally_verify.py"]
|
||||||
|
|
||||||
forbidden_imports = ["from oslo_log",
|
forbidden_imports = ["from oslo_log",
|
||||||
@ -150,7 +150,7 @@ def check_import_of_logging(logical_line, filename):
|
|||||||
for forbidden_import in forbidden_imports:
|
for forbidden_import in forbidden_imports:
|
||||||
if logical_line.startswith(forbidden_import):
|
if logical_line.startswith(forbidden_import):
|
||||||
yield (0, "N310 Wrong module for logging is imported. Please "
|
yield (0, "N310 Wrong module for logging is imported. Please "
|
||||||
"use `rally.common.log` instead.")
|
"use `rally.common.logging` instead.")
|
||||||
|
|
||||||
|
|
||||||
@skip_ignored_lines
|
@skip_ignored_lines
|
||||||
@ -182,12 +182,12 @@ def no_use_conf_debug_check(logical_line, filename):
|
|||||||
|
|
||||||
N312
|
N312
|
||||||
"""
|
"""
|
||||||
excluded_files = ["./rally/common/log.py"]
|
excluded_files = ["./rally/common/logging.py"]
|
||||||
|
|
||||||
point = logical_line.find("CONF.debug")
|
point = logical_line.find("CONF.debug")
|
||||||
if point != -1 and filename not in excluded_files:
|
if point != -1 and filename not in excluded_files:
|
||||||
yield(point, "N312 Don't use `CONF.debug`. "
|
yield(point, "N312 Don't use `CONF.debug`. "
|
||||||
"Function `rally.common.log.is_debug` "
|
"Function `rally.common.logging.is_debug` "
|
||||||
"should be used instead.")
|
"should be used instead.")
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
import mock
|
import mock
|
||||||
|
|
||||||
from rally.common.i18n import _
|
from rally.common.i18n import _
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
from tests.unit import test
|
from tests.unit import test
|
||||||
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
from rally.common import log as logging
|
from rally.common import logging
|
||||||
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
|
||||||
|
@ -88,17 +88,17 @@ class HackingTestCase(test.TestCase):
|
|||||||
bad_imports = ["from oslo_log import log",
|
bad_imports = ["from oslo_log import log",
|
||||||
"import oslo_log",
|
"import oslo_log",
|
||||||
"import logging"]
|
"import logging"]
|
||||||
good_imports = ["from rally.common import log",
|
good_imports = ["from rally.common import logging",
|
||||||
"from rally.common.log",
|
"from rally.common.logging",
|
||||||
"import rally.common.log"]
|
"import rally.common.logging"]
|
||||||
|
|
||||||
for bad_import in bad_imports:
|
for bad_import in bad_imports:
|
||||||
checkres = checks.check_import_of_logging(bad_import, "fakefile")
|
checkres = checks.check_import_of_logging(bad_import, "fakefile")
|
||||||
self.assertIsNotNone(next(checkres))
|
self.assertIsNotNone(next(checkres))
|
||||||
|
|
||||||
for bad_import in bad_imports:
|
for bad_import in bad_imports:
|
||||||
checkres = checks.check_import_of_logging(bad_import,
|
checkres = checks.check_import_of_logging(
|
||||||
"./rally/common/log.py")
|
bad_import, "./rally/common/logging.py")
|
||||||
self.assertEqual([], list(checkres))
|
self.assertEqual([], list(checkres))
|
||||||
|
|
||||||
for good_import in good_imports:
|
for good_import in good_imports:
|
||||||
|
@ -17,15 +17,15 @@ import logging
|
|||||||
|
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
from rally.common import log
|
from rally.common import logging as log
|
||||||
from tests.unit import test
|
from tests.unit import test
|
||||||
|
|
||||||
|
|
||||||
class LogTestCase(test.TestCase):
|
class LogTestCase(test.TestCase):
|
||||||
|
|
||||||
@mock.patch("rally.common.log.CONF")
|
@mock.patch("rally.common.logging.CONF")
|
||||||
@mock.patch("rally.common.log.handlers")
|
@mock.patch("rally.common.logging.handlers")
|
||||||
@mock.patch("rally.common.log.oslogging")
|
@mock.patch("rally.common.logging.oslogging")
|
||||||
def test_setup(self, mock_oslogging, mock_handlers, mock_conf):
|
def test_setup(self, mock_oslogging, mock_handlers, mock_conf):
|
||||||
|
|
||||||
proj = "fakep"
|
proj = "fakep"
|
||||||
@ -45,11 +45,11 @@ class LogTestCase(test.TestCase):
|
|||||||
mock_oslogging.getLogger(None).logger.setLevel.assert_called_once_with(
|
mock_oslogging.getLogger(None).logger.setLevel.assert_called_once_with(
|
||||||
logging.RDEBUG)
|
logging.RDEBUG)
|
||||||
|
|
||||||
@mock.patch("rally.common.log.logging")
|
@mock.patch("rally.common.logging.log")
|
||||||
@mock.patch("rally.common.log.RallyContextAdapter")
|
@mock.patch("rally.common.logging.RallyContextAdapter")
|
||||||
@mock.patch("rally.common.log.oslogging")
|
@mock.patch("rally.common.logging.oslogging")
|
||||||
def test_getLogger(self, mock_oslogging, mock_rally_context_adapter,
|
def test_getLogger(self, mock_oslogging, mock_rally_context_adapter,
|
||||||
mock_logging):
|
mock_log):
|
||||||
|
|
||||||
name = "fake"
|
name = "fake"
|
||||||
vers = "fake"
|
vers = "fake"
|
||||||
@ -59,31 +59,31 @@ class LogTestCase(test.TestCase):
|
|||||||
|
|
||||||
self.assertIn(name, mock_oslogging._loggers)
|
self.assertIn(name, mock_oslogging._loggers)
|
||||||
mock_rally_context_adapter.assert_called_once_with(
|
mock_rally_context_adapter.assert_called_once_with(
|
||||||
mock_logging.getLogger(name),
|
mock_log.getLogger(name),
|
||||||
{"project": "rally", "version": vers})
|
{"project": "rally", "version": vers})
|
||||||
self.assertEqual(mock_oslogging._loggers[name], returned_logger)
|
self.assertEqual(mock_oslogging._loggers[name], returned_logger)
|
||||||
|
|
||||||
|
|
||||||
class LogRallyContaxtAdapter(test.TestCase):
|
class LogRallyContaxtAdapter(test.TestCase):
|
||||||
|
|
||||||
@mock.patch("rally.common.log.logging")
|
@mock.patch("rally.common.logging.log")
|
||||||
@mock.patch("rally.common.log.oslogging.KeywordArgumentAdapter")
|
@mock.patch("rally.common.logging.oslogging.KeywordArgumentAdapter")
|
||||||
def test_debug(self, mock_keyword_argument_adapter, mock_logging):
|
def test_debug(self, mock_keyword_argument_adapter, mock_log):
|
||||||
|
|
||||||
mock_logging.RDEBUG = 123
|
mock_log.RDEBUG = 123
|
||||||
fake_msg = "fake message"
|
fake_msg = "fake message"
|
||||||
radapter = log.RallyContextAdapter(mock.MagicMock(), "fakep")
|
radapter = log.RallyContextAdapter(mock.MagicMock(), "fakep")
|
||||||
radapter.log = mock.MagicMock()
|
radapter.log = mock.MagicMock()
|
||||||
|
|
||||||
radapter.debug(fake_msg)
|
radapter.debug(fake_msg)
|
||||||
|
|
||||||
radapter.log.assert_called_once_with(mock_logging.RDEBUG,
|
radapter.log.assert_called_once_with(mock_log.RDEBUG,
|
||||||
fake_msg)
|
fake_msg)
|
||||||
|
|
||||||
|
|
||||||
class ExceptionLoggerTestCase(test.TestCase):
|
class ExceptionLoggerTestCase(test.TestCase):
|
||||||
|
|
||||||
@mock.patch("rally.common.log.is_debug")
|
@mock.patch("rally.common.logging.is_debug")
|
||||||
def test_context(self, mock_is_debug):
|
def test_context(self, mock_is_debug):
|
||||||
# Prepare
|
# Prepare
|
||||||
mock_is_debug.return_value = True
|
mock_is_debug.return_value = True
|
||||||
@ -147,7 +147,7 @@ class CatcherHandlerTestCase(test.TestCase):
|
|||||||
class LogCatcherUnitTestCase(test.TestCase):
|
class LogCatcherUnitTestCase(test.TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(LogCatcherUnitTestCase, self).setUp()
|
super(LogCatcherUnitTestCase, self).setUp()
|
||||||
patcher = mock.patch("rally.common.log.CatcherHandler")
|
patcher = mock.patch("rally.common.logging.CatcherHandler")
|
||||||
self.catcher_handler = patcher.start()
|
self.catcher_handler = patcher.start()
|
||||||
self.catcher_handler.return_value.buffer = [
|
self.catcher_handler.return_value.buffer = [
|
||||||
mock.Mock(msg="foo"), mock.Mock(msg="bar")]
|
mock.Mock(msg="foo"), mock.Mock(msg="bar")]
|
Loading…
x
Reference in New Issue
Block a user