Add a test equivalent to default_log_levels
This is to mainly kill the migrate script logs but can be used to quieten down any log. Also the migrations were not using the FakeLogger so now both are using the same mechanism. Fixes-bug: 1281226 Change-Id: I2f1efcace6a38450020fcbf516ee5026204359d2
This commit is contained in:
parent
a54406651b
commit
8ddb4e9ac1
@ -30,7 +30,29 @@ from heat.engine import scheduler
|
|||||||
from heat.tests import utils
|
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
|
TIME_STEP = 0.1
|
||||||
|
|
||||||
@ -38,7 +60,7 @@ class HeatTestCase(testscenarios.WithScenarios, testtools.TestCase):
|
|||||||
super(HeatTestCase, self).setUp()
|
super(HeatTestCase, self).setUp()
|
||||||
self.m = mox.Mox()
|
self.m = mox.Mox()
|
||||||
self.addCleanup(self.m.UnsetStubs)
|
self.addCleanup(self.m.UnsetStubs)
|
||||||
self.logger = self.useFixture(fixtures.FakeLogger(level=logging.DEBUG))
|
self.setup_logging()
|
||||||
scheduler.ENABLE_SLEEP = False
|
scheduler.ENABLE_SLEEP = False
|
||||||
self.useFixture(fixtures.MonkeyPatch(
|
self.useFixture(fixtures.MonkeyPatch(
|
||||||
'heat.common.exception._FATAL_EXCEPTION_FORMAT_ERRORS',
|
'heat.common.exception._FATAL_EXCEPTION_FORMAT_ERRORS',
|
||||||
|
@ -36,7 +36,7 @@ from heat.db.sqlalchemy import migrate_repo
|
|||||||
from heat.db.sqlalchemy import migration
|
from heat.db.sqlalchemy import migration
|
||||||
from heat.openstack.common.db.sqlalchemy import test_migrations
|
from heat.openstack.common.db.sqlalchemy import test_migrations
|
||||||
from heat.openstack.common import log as logging
|
from heat.openstack.common import log as logging
|
||||||
|
from heat.tests import common
|
||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -53,7 +53,8 @@ def get_table(engine, name):
|
|||||||
|
|
||||||
|
|
||||||
class TestHeatMigrations(test_migrations.BaseMigrationTestCase,
|
class TestHeatMigrations(test_migrations.BaseMigrationTestCase,
|
||||||
test_migrations.WalkVersionsMixin):
|
test_migrations.WalkVersionsMixin,
|
||||||
|
common.FakeLogMixin):
|
||||||
"""Test sqlalchemy-migrate migrations."""
|
"""Test sqlalchemy-migrate migrations."""
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
@ -74,6 +75,7 @@ class TestHeatMigrations(test_migrations.BaseMigrationTestCase,
|
|||||||
os.environ["HEAT_LOCK_PATH"] = lock_dir
|
os.environ["HEAT_LOCK_PATH"] = lock_dir
|
||||||
|
|
||||||
super(TestHeatMigrations, self).setUp()
|
super(TestHeatMigrations, self).setUp()
|
||||||
|
self.setup_logging()
|
||||||
|
|
||||||
def clean_lock_dir():
|
def clean_lock_dir():
|
||||||
shutil.rmtree(lock_dir, ignore_errors=True)
|
shutil.rmtree(lock_dir, ignore_errors=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user