Merge "Add a test equivalent to default_log_levels"

This commit is contained in:
Jenkins 2014-05-21 13:23:36 +00:00 committed by Gerrit Code Review
commit fb6b9100a4
2 changed files with 28 additions and 4 deletions

View File

@ -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',

View File

@ -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)