summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorey O'Brien <corey.obrien@rackspace.com>2017-02-24 08:41:40 -0500
committerSpyros Trigazis (strigazi) <strigazi@gmail.com>2017-06-07 09:29:06 +0000
commitbdddbdf2defd5b8cd4996ee6163746571146ea7c (patch)
tree756e4d5ec0adec40f459efa4593489385e65f421
parentdacadc2afd4b5675833987ca507ac16dae55996e (diff)
Remove reliance on osprofiler configuration section4.1.2
Notes
Notes (review): Code-Review+2: Spyros Trigazis (strigazi) <strigazi@gmail.com> Code-Review+2: Adrian Otto <aotto@aotto.com> Workflow+1: Adrian Otto <aotto@aotto.com> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Wed, 07 Jun 2017 14:40:31 +0000 Reviewed-on: https://review.openstack.org/454812 Project: openstack/magnum Branch: refs/heads/stable/ocata
-rw-r--r--magnum/common/profiler.py2
-rw-r--r--magnum/tests/unit/common/test_profiler.py7
2 files changed, 8 insertions, 1 deletions
diff --git a/magnum/common/profiler.py b/magnum/common/profiler.py
index a529df4..b24ebe7 100644
--- a/magnum/common/profiler.py
+++ b/magnum/common/profiler.py
@@ -57,7 +57,7 @@ class WsgiMiddleware(object):
57 57
58 58
59def setup(binary, host): 59def setup(binary, host):
60 if CONF.profiler.enabled: 60 if hasattr(CONF, 'profiler') and CONF.profiler.enabled:
61 profiler_initializer.init_from_conf( 61 profiler_initializer.init_from_conf(
62 conf=CONF, 62 conf=CONF,
63 context=context.get_admin_context().to_dict(), 63 context=context.get_admin_context().to_dict(),
diff --git a/magnum/tests/unit/common/test_profiler.py b/magnum/tests/unit/common/test_profiler.py
index e68cd1e..a21f9e5 100644
--- a/magnum/tests/unit/common/test_profiler.py
+++ b/magnum/tests/unit/common/test_profiler.py
@@ -16,6 +16,7 @@
16import inspect 16import inspect
17import mock 17import mock
18 18
19from oslo_config import cfg
19from oslo_utils import importutils 20from oslo_utils import importutils
20from osprofiler import initializer as profiler_init 21from osprofiler import initializer as profiler_init
21from osprofiler import opts as profiler_opts 22from osprofiler import opts as profiler_opts
@@ -73,3 +74,9 @@ class TestProfiler(base.TestCase):
73 project="magnum", 74 project="magnum",
74 service='foo', 75 service='foo',
75 host='localhost') 76 host='localhost')
77
78 @mock.patch.object(profiler_init, 'init_from_conf')
79 @mock.patch.object(conf, 'CONF', new=cfg.ConfigOpts())
80 def test_setup_profiler_without_osprofiler(self, mock_init):
81 profiler.setup('foo', 'localhost')
82 self.assertFalse(mock_init.called)