Work around tests that don't use nova.test as a base
The db migration tests use a bunch of setup inside oslo_db that is only exported as a base test class. This means that none of these do the standard setup that the rest of the Nova tests do, including things like logging capture. Long term, the relationship between nova and oslo_db needs to be fixed so that these are available as fixtures, not just base class. However, in the short term we can setup logging correctly before initializing the rest of the test class to keep these from scrambling the test output. Change-Id: I3c663d276cffa6146ac8f45bde7d70f7aece0c89
This commit is contained in:
parent
15b392a67b
commit
759dfc0fbd
|
@ -27,6 +27,7 @@ from sqlalchemy.types import UserDefinedType
|
|||
from nova.db.sqlalchemy import api as db
|
||||
from nova.db.sqlalchemy import utils
|
||||
from nova import exception
|
||||
from nova.tests import fixtures as nova_fixtures
|
||||
|
||||
SA_VERSION = compat_utils.SQLA_VERSION
|
||||
|
||||
|
@ -36,11 +37,23 @@ class CustomType(UserDefinedType):
|
|||
def get_col_spec(self):
|
||||
return "CustomType"
|
||||
|
||||
# TODO(sdague): no tests in the nova/tests tree should inherit from
|
||||
# base test classes in another library. This causes all kinds of havoc
|
||||
# in these doing things incorrectly for what we need in subunit
|
||||
# reporting. This is a long unwind, but should be done in the future
|
||||
# and any code needed out of oslo_db should be exported / accessed as
|
||||
# a fixture.
|
||||
|
||||
|
||||
class TestMigrationUtilsSQLite(test_base.DbTestCase):
|
||||
"""Class for testing utils that are used in db migrations."""
|
||||
|
||||
def setUp(self):
|
||||
# NOTE(sdague): the oslo_db base test case completely
|
||||
# invalidates our logging setup, we actually have to do that
|
||||
# before it is called to keep this from vomitting all over our
|
||||
# test output.
|
||||
self.useFixture(nova_fixtures.StandardLogging())
|
||||
super(TestMigrationUtilsSQLite, self).setUp()
|
||||
self.meta = MetaData(bind=self.engine)
|
||||
|
||||
|
|
|
@ -33,10 +33,6 @@ For postgres on Ubuntu this can be done with the following commands::
|
|||
"""
|
||||
|
||||
import glob
|
||||
# NOTE(dhellmann): Use stdlib logging instead of oslo.log because we
|
||||
# need to call methods on the logger that are not exposed through the
|
||||
# adapter provided by oslo.log.
|
||||
import logging
|
||||
import os
|
||||
|
||||
from migrate import UniqueConstraint
|
||||
|
@ -59,6 +55,13 @@ from nova import exception
|
|||
from nova import test
|
||||
from nova.tests import fixtures as nova_fixtures
|
||||
|
||||
# TODO(sdague): no tests in the nova/tests tree should inherit from
|
||||
# base test classes in another library. This causes all kinds of havoc
|
||||
# in these doing things incorrectly for what we need in subunit
|
||||
# reporting. This is a long unwind, but should be done in the future
|
||||
# and any code needed out of oslo_db should be exported / accessed as
|
||||
# a fixture.
|
||||
|
||||
|
||||
class NovaMigrationsCheckers(test_migrations.ModelsMigrationsSync,
|
||||
test_migrations.WalkVersionsMixin):
|
||||
|
@ -84,14 +87,13 @@ class NovaMigrationsCheckers(test_migrations.ModelsMigrationsSync,
|
|||
return self.engine
|
||||
|
||||
def setUp(self):
|
||||
super(NovaMigrationsCheckers, self).setUp()
|
||||
# NOTE(viktors): We should reduce log output because it causes issues,
|
||||
# when we run tests with testr
|
||||
migrate_log = logging.getLogger('migrate')
|
||||
old_level = migrate_log.level
|
||||
migrate_log.setLevel(logging.WARN)
|
||||
self.addCleanup(migrate_log.setLevel, old_level)
|
||||
# NOTE(sdague): the oslo_db base test case completely
|
||||
# invalidates our logging setup, we actually have to do that
|
||||
# before it is called to keep this from vomitting all over our
|
||||
# test output.
|
||||
self.useFixture(nova_fixtures.StandardLogging())
|
||||
|
||||
super(NovaMigrationsCheckers, self).setUp()
|
||||
# NOTE(rpodolyaka): we need to repeat the functionality of the base
|
||||
# test case a bit here as this gets overriden by oslotest base test
|
||||
# case and nova base test case cleanup must be the last one (as it
|
||||
|
|
Loading…
Reference in New Issue