diff --git a/heat/tests/common.py b/heat/tests/common.py index 7aa7717415..4d98cf7b48 100644 --- a/heat/tests/common.py +++ b/heat/tests/common.py @@ -30,7 +30,29 @@ from heat.engine import scheduler from heat.tests import utils -class HeatTestCase(testscenarios.WithScenarios, testtools.TestCase): +TEST_DEFAULT_LOGLEVELS = {'migrate': logging.WARN} + + +class FakeLogMixin: + def setup_logging(self): + # Assign default logs to self.logger so we can still + # assert on heat logs. + self.logger = self.useFixture( + fixtures.FakeLogger(level=logging.DEBUG)) + base_list = set([nlog.split('.')[0] + for nlog in logging.Logger.manager.loggerDict]) + for base in base_list: + if base in TEST_DEFAULT_LOGLEVELS: + self.useFixture(fixtures.FakeLogger( + level=TEST_DEFAULT_LOGLEVELS[base], + name=base)) + elif base != 'heat': + self.useFixture(fixtures.FakeLogger( + name=base)) + + +class HeatTestCase(testscenarios.WithScenarios, + testtools.TestCase, FakeLogMixin): TIME_STEP = 0.1 @@ -38,7 +60,7 @@ class HeatTestCase(testscenarios.WithScenarios, testtools.TestCase): super(HeatTestCase, self).setUp() self.m = mox.Mox() self.addCleanup(self.m.UnsetStubs) - self.logger = self.useFixture(fixtures.FakeLogger(level=logging.DEBUG)) + self.setup_logging() scheduler.ENABLE_SLEEP = False self.useFixture(fixtures.MonkeyPatch( 'heat.common.exception._FATAL_EXCEPTION_FORMAT_ERRORS', diff --git a/heat/tests/db/test_migrations.py b/heat/tests/db/test_migrations.py index b44b75f415..9aacf81efb 100644 --- a/heat/tests/db/test_migrations.py +++ b/heat/tests/db/test_migrations.py @@ -36,7 +36,7 @@ from heat.db.sqlalchemy import migrate_repo from heat.db.sqlalchemy import migration from heat.openstack.common.db.sqlalchemy import test_migrations from heat.openstack.common import log as logging - +from heat.tests import common LOG = logging.getLogger(__name__) @@ -53,7 +53,8 @@ def get_table(engine, name): class TestHeatMigrations(test_migrations.BaseMigrationTestCase, - test_migrations.WalkVersionsMixin): + test_migrations.WalkVersionsMixin, + common.FakeLogMixin): """Test sqlalchemy-migrate migrations.""" def __init__(self, *args, **kwargs): @@ -74,6 +75,7 @@ class TestHeatMigrations(test_migrations.BaseMigrationTestCase, os.environ["HEAT_LOCK_PATH"] = lock_dir super(TestHeatMigrations, self).setUp() + self.setup_logging() def clean_lock_dir(): shutil.rmtree(lock_dir, ignore_errors=True)