Skip to content

Commit

Permalink
Merge "Disable profiler for unit tests"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Jun 18, 2015
2 parents bfcc27e + 6cf6319 commit f51ba45
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
14 changes: 14 additions & 0 deletions cinder/test.py
Expand Up @@ -224,6 +224,20 @@ def setUp(self):
'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."""

Expand Down
7 changes: 1 addition & 6 deletions cinder/tests/unit/test_backup.py
Expand Up @@ -47,12 +47,7 @@ def setUp(self):
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()
Expand Down

0 comments on commit f51ba45

Please sign in to comment.