Remove reliance on osprofiler configuration section

Change-Id: I5b06afc0da936c1def04375e9990a20b5d53c3e2
Closes-Bug: 1667417
Depends-On: Ia2881f5c6b84993850f2642c7a7f240ce6ad3f73
This commit is contained in:
Corey O'Brien 2017-02-24 08:41:40 -05:00 committed by Spyros Trigazis (strigazi)
parent dacadc2afd
commit bdddbdf2de
2 changed files with 8 additions and 1 deletions

View File

@ -57,7 +57,7 @@ class WsgiMiddleware(object):
def setup(binary, host):
if CONF.profiler.enabled:
if hasattr(CONF, 'profiler') and CONF.profiler.enabled:
profiler_initializer.init_from_conf(
conf=CONF,
context=context.get_admin_context().to_dict(),

View File

@ -16,6 +16,7 @@
import inspect
import mock
from oslo_config import cfg
from oslo_utils import importutils
from osprofiler import initializer as profiler_init
from osprofiler import opts as profiler_opts
@ -73,3 +74,9 @@ class TestProfiler(base.TestCase):
project="magnum",
service='foo',
host='localhost')
@mock.patch.object(profiler_init, 'init_from_conf')
@mock.patch.object(conf, 'CONF', new=cfg.ConfigOpts())
def test_setup_profiler_without_osprofiler(self, mock_init):
profiler.setup('foo', 'localhost')
self.assertFalse(mock_init.called)