Suppress UT log messages
Large logger output during unit test run is causing subunit.parser failures. Most of this output is unnecessary for unit tests, so we should just suppress this logging. Also switching oslo.context args from user and tenant to user_id and project_id to get rid of deprecation warnings and move to new expected attributes. The minimum version of oslo.context has been raised to ensure we have a version with the renamed kwargs, so we are safe changing this. Originally planned to change as its own change in Iecee4cbd57ac319a02f9bfdf24e3742dbbcb3950, but it causes enough log output in the unit tests that failures are preventing either patch from going through without the other included. Change-Id: I9272f71e0e68268ad9f558ddd1e1183e3ea69806 Partial-bug: #1728640
This commit is contained in:
parent
ff469f6076
commit
d0fab07245
@ -122,7 +122,7 @@ class ExtensionManager(object):
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
LOG.info('Initializing extension manager.')
|
||||
LOG.debug('Initializing extension manager.')
|
||||
|
||||
self.cls_list = CONF.osapi_volume_extension
|
||||
self.extensions = {}
|
||||
@ -137,7 +137,7 @@ class ExtensionManager(object):
|
||||
return
|
||||
|
||||
alias = ext.alias
|
||||
LOG.info('Loaded extension: %s', alias)
|
||||
LOG.debug('Loaded extension: %s', alias)
|
||||
|
||||
if alias in self.extensions:
|
||||
raise exception.Error("Found duplicate extension: %s" % alias)
|
||||
|
@ -66,11 +66,10 @@ class RequestContext(context.RequestContext):
|
||||
:param overwrite: Set to False to ensure that the greenthread local
|
||||
copy of the index is not overwritten.
|
||||
"""
|
||||
# NOTE(jamielennox): oslo.context still uses some old variables names.
|
||||
# These arguments are maintained instead of passed as kwargs to
|
||||
# maintain the interface for tests.
|
||||
kwargs.setdefault('user', user_id)
|
||||
kwargs.setdefault('tenant', project_id)
|
||||
# NOTE(smcginnis): To keep it compatible for code using positional
|
||||
# args, explicityly set user_id and project_id in kwargs.
|
||||
kwargs.setdefault('user_id', user_id)
|
||||
kwargs.setdefault('project_id', project_id)
|
||||
|
||||
super(RequestContext, self).__init__(is_admin=is_admin, **kwargs)
|
||||
|
||||
@ -122,7 +121,7 @@ class RequestContext(context.RequestContext):
|
||||
result['user_id'] = self.user_id
|
||||
result['project_id'] = self.project_id
|
||||
result['project_name'] = self.project_name
|
||||
result['domain'] = self.domain
|
||||
result['domain_id'] = self.domain_id
|
||||
result['read_deleted'] = self.read_deleted
|
||||
result['remote_address'] = self.remote_address
|
||||
result['timestamp'] = self.timestamp.isoformat()
|
||||
@ -136,7 +135,7 @@ class RequestContext(context.RequestContext):
|
||||
return cls(user_id=values.get('user_id'),
|
||||
project_id=values.get('project_id'),
|
||||
project_name=values.get('project_name'),
|
||||
domain=values.get('domain'),
|
||||
domain=values.get('domain_id'),
|
||||
read_deleted=values.get('read_deleted'),
|
||||
remote_address=values.get('remote_address'),
|
||||
timestamp=values.get('timestamp'),
|
||||
@ -208,28 +207,6 @@ class RequestContext(context.RequestContext):
|
||||
def deepcopy(self):
|
||||
return copy.deepcopy(self)
|
||||
|
||||
# NOTE(sirp): the openstack/common version of RequestContext uses
|
||||
# tenant/user whereas the Cinder version uses project_id/user_id.
|
||||
# NOTE(adrienverge): The Cinder version of RequestContext now uses
|
||||
# tenant/user internally, so it is compatible with context-aware code from
|
||||
# openstack/common. We still need this shim for the rest of Cinder's
|
||||
# code.
|
||||
@property
|
||||
def project_id(self):
|
||||
return self.tenant
|
||||
|
||||
@project_id.setter
|
||||
def project_id(self, value):
|
||||
self.tenant = value
|
||||
|
||||
@property
|
||||
def user_id(self):
|
||||
return self.user
|
||||
|
||||
@user_id.setter
|
||||
def user_id(self, value):
|
||||
self.user = value
|
||||
|
||||
|
||||
def get_admin_context(read_deleted="no"):
|
||||
return RequestContext(user_id=None,
|
||||
|
@ -102,6 +102,15 @@ class TestCase(testtools.TestCase):
|
||||
MOCK_WORKER = True
|
||||
MOCK_TOOZ = True
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(TestCase, self).__init__(*args, **kwargs)
|
||||
|
||||
# Suppress some log messages during test runs
|
||||
castellan_logger = logging.getLogger('castellan')
|
||||
castellan_logger.setLevel(logging.ERROR)
|
||||
stevedore_logger = logging.getLogger('stevedore')
|
||||
stevedore_logger.setLevel(logging.ERROR)
|
||||
|
||||
def _get_joined_notifier(self, *args, **kwargs):
|
||||
# We create a new fake notifier but we join the notifications with
|
||||
# the default notifier
|
||||
|
Loading…
x
Reference in New Issue
Block a user