From: Joe Gordon Date: Mon, 10 Mar 2014 18:02:13 +0000 (-0700) Subject: Use debug level logging during unit tests X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=365a9908b89688fa609ba86c84941848628346d9;p=openstack-build%2Fcinder-build.git Use debug level logging during unit tests 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 --- diff --git a/cinder/test.py b/cinder/test.py index 479eeea54..dbd45ec7d 100644 --- a/cinder/test.py +++ b/cinder/test.py @@ -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=[]) diff --git a/cinder/tests/conf_fixture.py b/cinder/tests/conf_fixture.py index ddde6b919..e3a913f08 100644 --- a/cinder/tests/conf_fixture.py +++ b/cinder/tests/conf_fixture.py @@ -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')