Browse Source

Remove reliance on osprofiler configuration section

Change-Id: I5b06afc0da936c1def04375e9990a20b5d53c3e2
Closes-Bug: 1667417
Depends-On: Ia2881f5c6b84993850f2642c7a7f240ce6ad3f73
tags/4.1.2^0
Corey O'Brien 2 years ago
parent
commit
bdddbdf2de
2 changed files with 8 additions and 1 deletions
  1. 1
    1
      magnum/common/profiler.py
  2. 7
    0
      magnum/tests/unit/common/test_profiler.py

+ 1
- 1
magnum/common/profiler.py View File

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

+ 7
- 0
magnum/tests/unit/common/test_profiler.py View File

@@ -16,6 +16,7 @@
16 16
 import inspect
17 17
 import mock
18 18
 
19
+from oslo_config import cfg
19 20
 from oslo_utils import importutils
20 21
 from osprofiler import initializer as profiler_init
21 22
 from osprofiler import opts as profiler_opts
@@ -73,3 +74,9 @@ class TestProfiler(base.TestCase):
73 74
                                           project="magnum",
74 75
                                           service='foo',
75 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)

Loading…
Cancel
Save