Remove reliance on osprofiler configuration section
Change-Id: I5b06afc0da936c1def04375e9990a20b5d53c3e2 Closes-Bug: 1667417
This commit is contained in:
@@ -57,7 +57,7 @@ class WsgiMiddleware(object):
|
|||||||
|
|
||||||
|
|
||||||
def setup(binary, host):
|
def setup(binary, host):
|
||||||
if CONF.profiler.enabled:
|
if hasattr(CONF, 'profiler') and CONF.profiler.enabled:
|
||||||
profiler_initializer.init_from_conf(
|
profiler_initializer.init_from_conf(
|
||||||
conf=CONF,
|
conf=CONF,
|
||||||
context=context.get_admin_context().to_dict(),
|
context=context.get_admin_context().to_dict(),
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
import inspect
|
import inspect
|
||||||
import mock
|
import mock
|
||||||
|
|
||||||
|
from oslo_config import cfg
|
||||||
from oslo_utils import importutils
|
from oslo_utils import importutils
|
||||||
from osprofiler import initializer as profiler_init
|
from osprofiler import initializer as profiler_init
|
||||||
from osprofiler import opts as profiler_opts
|
from osprofiler import opts as profiler_opts
|
||||||
@@ -73,3 +74,9 @@ class TestProfiler(base.TestCase):
|
|||||||
project="magnum",
|
project="magnum",
|
||||||
service='foo',
|
service='foo',
|
||||||
host='localhost')
|
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)
|
||||||
|
|||||||
Reference in New Issue
Block a user