]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Disable profiler for unit tests
authorEric Harney <eharney@redhat.com>
Thu, 18 Jun 2015 17:04:43 +0000 (13:04 -0400)
committerEric Harney <eharney@redhat.com>
Thu, 18 Jun 2015 17:13:09 +0000 (13:13 -0400)
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/test.py
cinder/tests/unit/test_backup.py

index f5db6bdecd5845b473b46ace423d0e95a20e4ef5..ec025b1bf30290357fcfd395e79ebb03bd830f31 100644 (file)
@@ -224,6 +224,20 @@ class TestCase(testtools.TestCase):
                                  '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."""
 
index 66bccac214210db469a3461b3bbec2c96ce8fedd..1748a107afdf5eed9fa676edc8179d621955f2d5 100644 (file)
@@ -47,12 +47,7 @@ class BaseBackupTest(test.TestCase):
         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()