osprofiler should not run for unit tests. This makes stack
traces harder to debug, and generally complicates things, with
no benefit.
The backup tests were already doing this, so port that
method to the base Cinder test class.
Closes-Bug: #
1394785
Closes-Bug: #
1447400
Change-Id: Ifcaaf365aaab24c6fa2a6eca58f546860124f1fc
'cinder/tests/unit/policy.json'),
group='oslo_policy')
+ self._disable_osprofiler()
+
+ def _disable_osprofiler(self):
+ """Disable osprofiler.
+
+ osprofiler should not run for unit tests.
+ """
+
+ side_effect = lambda value: value
+ mock_decorator = mock.MagicMock(side_effect=side_effect)
+ p = mock.patch("osprofiler.profiler.trace_cls",
+ return_value=mock_decorator)
+ p.start()
+
def _common_cleanup(self):
"""Runs after each test method to tear down test environment."""
super(BaseBackupTest, self).setUp()
vol_tmpdir = tempfile.mkdtemp()
self.flags(volumes_dir=vol_tmpdir)
- with mock.patch("osprofiler.profiler.trace_cls") as mock_trace_cls:
- side_effect = lambda value: value
- mock_decorator = mock.MagicMock(side_effect=side_effect)
- mock_trace_cls.return_value = mock_decorator
- self.backup_mgr = \
- importutils.import_object(CONF.backup_manager)
+ self.backup_mgr = importutils.import_object(CONF.backup_manager)
self.backup_mgr.host = 'testhost'
self.ctxt = context.get_admin_context()
self.backup_mgr.driver.set_initialized()