]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Use debug level logging during unit tests
authorJoe Gordon <joe.gordon0@gmail.com>
Mon, 10 Mar 2014 18:02:13 +0000 (11:02 -0700)
committerJoe Gordon <joe.gordon0@gmail.com>
Wed, 12 Mar 2014 22:12:05 +0000 (15:12 -0700)
When unit tests fail we need to debug, so we should have debug level logging on.
We use fixtures FakeLogger during testing, to enable debug logging pass
in log level as a parameter.

http://bazaar.launchpad.net/~python-fixtures/python-fixtures/trunk/vi
ew/head:/lib/fixtures/_fixtures/logger.py#L68

Taken from nova (Change-Id: I70790aa39c0774726de71e5fa5751c45e7e34ffd)

Change-Id: I24bcce3a9a50322f20f06670d1fe95d929aa2e72

cinder/test.py
cinder/tests/conf_fixture.py

index 479eeea5460ba0e9f8b20cd66fc36d928440df0c..dbd45ec7df4ffd1d2fef9f1efa7bb2319e2e66f6 100644 (file)
@@ -28,6 +28,7 @@ import tempfile
 import uuid
 
 import fixtures
+import logging
 import mox
 from oslo.config import cfg
 import stubout
@@ -37,7 +38,7 @@ from testtools import matchers
 from cinder.common import config  # noqa Need to register global_opts
 from cinder.db import migration
 from cinder.openstack.common.db.sqlalchemy import session
-from cinder.openstack.common import log as logging
+from cinder.openstack.common import log as oslo_logging
 from cinder.openstack.common import timeutils
 from cinder import service
 from cinder.tests import conf_fixture
@@ -51,7 +52,7 @@ test_opts = [
 CONF = cfg.CONF
 CONF.register_opts(test_opts)
 
-LOG = logging.getLogger(__name__)
+LOG = oslo_logging.getLogger(__name__)
 
 _DB_CACHE = None
 
@@ -128,7 +129,8 @@ class TestCase(testtools.TestCase):
             stderr = self.useFixture(fixtures.StringStream('stderr')).stream
             self.useFixture(fixtures.MonkeyPatch('sys.stderr', stderr))
 
-        self.log_fixture = self.useFixture(fixtures.FakeLogger())
+        self.log_fixture = self.useFixture(fixtures.FakeLogger(
+            level=logging.DEBUG))
 
         conf_fixture.set_defaults(CONF)
         CONF([], default_config_files=[])
index ddde6b91937f312e938ae21594d476e31208ef74..e3a913f0821061fd52f88fe81bb794e2efea84cb 100644 (file)
@@ -41,7 +41,6 @@ def set_defaults(conf):
     conf.set_default('fake_rabbit', True)
     conf.set_default('rpc_backend', 'cinder.openstack.common.rpc.impl_fake')
     conf.set_default('iscsi_num_targets', 8)
-    conf.set_default('verbose', True)
     conf.set_default('connection', 'sqlite://', group='database')
     conf.set_default('sqlite_synchronous', False)
     conf.set_default('policy_file', 'cinder/tests/policy.json')