Work around deprecations for opportunistic tests
Some of the oslo.db opportunistic sql test classes we were using were deprecated[1] and it was causing a lot of noise in the log output. Refactor the tests to use the opportunistic mixin and new fixtures. [1] https://review.openstack.org/#/c/351411/ Change-Id: Iea6d7be5150d608f894625e86d2233e12ba56026
This commit is contained in:
parent
abb0d552a1
commit
ac02477c07
|
@ -10,17 +10,19 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
|
||||
from oslo_db.sqlalchemy import test_base as db_test
|
||||
from oslo_db.sqlalchemy import enginefacade
|
||||
from oslo_db.sqlalchemy import test_fixtures as db_fixtures
|
||||
from oslotest import base as test_base
|
||||
|
||||
from keystone.common import sql
|
||||
from keystone.identity.backends import sql as sql_backend
|
||||
from keystone.tests.unit.identity.backends import test_base
|
||||
from keystone.tests.unit.identity.backends import test_base as id_test_base
|
||||
from keystone.tests.unit.ksfixtures import database
|
||||
|
||||
|
||||
class TestIdentityDriver(db_test.DbTestCase,
|
||||
test_base.IdentityDriverTests):
|
||||
class TestIdentityDriver(db_fixtures.OpportunisticDBTestMixin,
|
||||
test_base.BaseTestCase,
|
||||
id_test_base.IdentityDriverTests):
|
||||
|
||||
expected_is_domain_aware = True
|
||||
expected_default_assignment_driver = 'sql'
|
||||
|
@ -29,6 +31,8 @@ class TestIdentityDriver(db_test.DbTestCase,
|
|||
|
||||
def setUp(self):
|
||||
super(TestIdentityDriver, self).setUp()
|
||||
self.engine = enginefacade.writer.get_engine()
|
||||
self.sessionmaker = enginefacade.writer.get_sessionmaker()
|
||||
|
||||
# Set keystone's connection URL to be the test engine's url.
|
||||
database.initialize_sql_session(self.engine.url)
|
||||
|
@ -47,8 +51,8 @@ class TestIdentityDriver(db_test.DbTestCase,
|
|||
|
||||
|
||||
class MySQLOpportunisticIdentityDriverTestCase(TestIdentityDriver):
|
||||
FIXTURE = db_test.MySQLOpportunisticFixture
|
||||
FIXTURE = db_fixtures.MySQLOpportunisticFixture
|
||||
|
||||
|
||||
class PostgreSQLOpportunisticIdentityDriverTestCase(TestIdentityDriver):
|
||||
FIXTURE = db_test.PostgreSQLOpportunisticFixture
|
||||
FIXTURE = db_fixtures.PostgresqlOpportunisticFixture
|
||||
|
|
|
@ -18,8 +18,10 @@ import os
|
|||
import fixtures
|
||||
from migrate.versioning import api as versioning_api
|
||||
from migrate.versioning import repository
|
||||
from oslo_db.sqlalchemy import test_base
|
||||
from oslo_db.sqlalchemy import enginefacade
|
||||
from oslo_db.sqlalchemy import test_fixtures as db_fixtures
|
||||
from oslo_db.sqlalchemy import test_migrations
|
||||
from oslotest import base as test_base
|
||||
import sqlalchemy
|
||||
import testtools
|
||||
|
||||
|
@ -199,18 +201,38 @@ class KeystoneMigrationsCheckers(test_migrations.WalkVersionsMixin):
|
|||
|
||||
|
||||
class TestKeystoneMigrationsMySQL(
|
||||
KeystoneMigrationsCheckers, test_base.MySQLOpportunisticTestCase):
|
||||
pass
|
||||
KeystoneMigrationsCheckers,
|
||||
db_fixtures.OpportunisticDBTestMixin,
|
||||
test_base.BaseTestCase):
|
||||
FIXTURE = db_fixtures.MySQLOpportunisticFixture
|
||||
|
||||
def setUp(self):
|
||||
super(TestKeystoneMigrationsMySQL, self).setUp()
|
||||
self.engine = enginefacade.writer.get_engine()
|
||||
self.sessionmaker = enginefacade.writer.get_sessionmaker()
|
||||
|
||||
|
||||
class TestKeystoneMigrationsPostgreSQL(
|
||||
KeystoneMigrationsCheckers, test_base.PostgreSQLOpportunisticTestCase):
|
||||
pass
|
||||
KeystoneMigrationsCheckers,
|
||||
db_fixtures.OpportunisticDBTestMixin,
|
||||
test_base.BaseTestCase):
|
||||
FIXTURE = db_fixtures.PostgresqlOpportunisticFixture
|
||||
|
||||
def setUp(self):
|
||||
super(TestKeystoneMigrationsPostgreSQL, self).setUp()
|
||||
self.engine = enginefacade.writer.get_engine()
|
||||
self.sessionmaker = enginefacade.writer.get_sessionmaker()
|
||||
|
||||
|
||||
class TestKeystoneMigrationsSQLite(
|
||||
KeystoneMigrationsCheckers, test_base.DbTestCase):
|
||||
pass
|
||||
KeystoneMigrationsCheckers,
|
||||
db_fixtures.OpportunisticDBTestMixin,
|
||||
test_base.BaseTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestKeystoneMigrationsSQLite, self).setUp()
|
||||
self.engine = enginefacade.writer.get_engine()
|
||||
self.sessionmaker = enginefacade.writer.get_sessionmaker()
|
||||
|
||||
|
||||
class TestKeystoneExpandSchemaMigrations(
|
||||
|
@ -246,19 +268,32 @@ class TestKeystoneExpandSchemaMigrations(
|
|||
|
||||
def setUp(self):
|
||||
super(TestKeystoneExpandSchemaMigrations, self).setUp()
|
||||
self.migrate_fully(migrate_repo.__file__)
|
||||
|
||||
|
||||
class TestKeystoneExpandSchemaMigrationsMySQL(
|
||||
TestKeystoneExpandSchemaMigrations,
|
||||
test_base.MySQLOpportunisticTestCase):
|
||||
pass
|
||||
db_fixtures.OpportunisticDBTestMixin,
|
||||
test_base.BaseTestCase,
|
||||
TestKeystoneExpandSchemaMigrations):
|
||||
FIXTURE = db_fixtures.MySQLOpportunisticFixture
|
||||
|
||||
def setUp(self):
|
||||
super(TestKeystoneExpandSchemaMigrationsMySQL, self).setUp()
|
||||
self.engine = enginefacade.writer.get_engine()
|
||||
self.sessionmaker = enginefacade.writer.get_sessionmaker()
|
||||
self.migrate_fully(migrate_repo.__file__)
|
||||
|
||||
|
||||
class TestKeystoneExpandSchemaMigrationsPostgreSQL(
|
||||
TestKeystoneExpandSchemaMigrations,
|
||||
test_base.PostgreSQLOpportunisticTestCase):
|
||||
pass
|
||||
db_fixtures.OpportunisticDBTestMixin,
|
||||
test_base.BaseTestCase,
|
||||
TestKeystoneExpandSchemaMigrations):
|
||||
FIXTURE = db_fixtures.PostgresqlOpportunisticFixture
|
||||
|
||||
def setUp(self):
|
||||
super(TestKeystoneExpandSchemaMigrationsPostgreSQL, self).setUp()
|
||||
self.engine = enginefacade.writer.get_engine()
|
||||
self.sessionmaker = enginefacade.writer.get_sessionmaker()
|
||||
self.migrate_fully(migrate_repo.__file__)
|
||||
|
||||
|
||||
class TestKeystoneDataMigrations(
|
||||
|
@ -292,18 +327,19 @@ class TestKeystoneDataMigrations(
|
|||
|
||||
class TestKeystoneDataMigrationsMySQL(
|
||||
TestKeystoneDataMigrations,
|
||||
test_base.MySQLOpportunisticTestCase):
|
||||
pass
|
||||
db_fixtures.OpportunisticDBTestMixin):
|
||||
FIXTURE = db_fixtures.MySQLOpportunisticFixture
|
||||
|
||||
|
||||
class TestKeystoneDataMigrationsPostgreSQL(
|
||||
TestKeystoneDataMigrations,
|
||||
test_base.PostgreSQLOpportunisticTestCase):
|
||||
pass
|
||||
db_fixtures.OpportunisticDBTestMixin):
|
||||
FIXTURE = db_fixtures.PostgresqlOpportunisticFixture
|
||||
|
||||
|
||||
class TestKeystoneDataMigrationsSQLite(
|
||||
TestKeystoneDataMigrations, test_base.DbTestCase):
|
||||
TestKeystoneDataMigrations,
|
||||
db_fixtures.OpportunisticDBTestMixin):
|
||||
pass
|
||||
|
||||
|
||||
|
@ -353,18 +389,19 @@ class TestKeystoneContractSchemaMigrations(
|
|||
|
||||
class TestKeystoneContractSchemaMigrationsMySQL(
|
||||
TestKeystoneContractSchemaMigrations,
|
||||
test_base.MySQLOpportunisticTestCase):
|
||||
pass
|
||||
db_fixtures.OpportunisticDBTestMixin):
|
||||
FIXTURE = db_fixtures.MySQLOpportunisticFixture
|
||||
|
||||
|
||||
class TestKeystoneContractSchemaMigrationsPostgreSQL(
|
||||
TestKeystoneContractSchemaMigrations,
|
||||
test_base.PostgreSQLOpportunisticTestCase):
|
||||
pass
|
||||
db_fixtures.OpportunisticDBTestMixin):
|
||||
FIXTURE = db_fixtures.PostgresqlOpportunisticFixture
|
||||
|
||||
|
||||
class TestKeystoneContractSchemaMigrationsSQLite(
|
||||
TestKeystoneContractSchemaMigrations, test_base.DbTestCase):
|
||||
TestKeystoneContractSchemaMigrations,
|
||||
db_fixtures.OpportunisticDBTestMixin):
|
||||
# In Sqlite an alter will appear as a create, so if we check for creates
|
||||
# we will get false positives.
|
||||
def setUp(self):
|
||||
|
|
|
@ -49,8 +49,10 @@ from migrate.versioning import repository
|
|||
from migrate.versioning import script
|
||||
import mock
|
||||
from oslo_db import exception as db_exception
|
||||
from oslo_db.sqlalchemy import test_base
|
||||
from oslo_db.sqlalchemy import enginefacade
|
||||
from oslo_db.sqlalchemy import test_fixtures as db_fixtures
|
||||
from oslo_log import log
|
||||
from oslotest import base as test_base
|
||||
import pytz
|
||||
from sqlalchemy.engine import reflection
|
||||
import sqlalchemy.exc
|
||||
|
@ -196,9 +198,12 @@ class SqlUpgradeGetInitVersionTests(unit.TestCase):
|
|||
self.assertEqual(initial_version, version)
|
||||
|
||||
|
||||
class SqlMigrateBase(test_base.DbTestCase):
|
||||
class SqlMigrateBase(db_fixtures.OpportunisticDBTestMixin,
|
||||
test_base.BaseTestCase):
|
||||
def setUp(self):
|
||||
super(SqlMigrateBase, self).setUp()
|
||||
self.engine = enginefacade.writer.get_engine()
|
||||
self.sessionmaker = enginefacade.writer.get_sessionmaker()
|
||||
|
||||
# NOTE(dstanek): Clear out sqlalchemy-migrate's script cache to allow
|
||||
# us to have multiple repos (expand, migrate, contract) where the
|
||||
|
@ -1495,11 +1500,11 @@ class SqlLegacyRepoUpgradeTests(SqlMigrateBase):
|
|||
|
||||
|
||||
class MySQLOpportunisticUpgradeTestCase(SqlLegacyRepoUpgradeTests):
|
||||
FIXTURE = test_base.MySQLOpportunisticFixture
|
||||
FIXTURE = db_fixtures.MySQLOpportunisticFixture
|
||||
|
||||
|
||||
class PostgreSQLOpportunisticUpgradeTestCase(SqlLegacyRepoUpgradeTests):
|
||||
FIXTURE = test_base.PostgreSQLOpportunisticFixture
|
||||
FIXTURE = db_fixtures.PostgresqlOpportunisticFixture
|
||||
|
||||
|
||||
class SqlExpandSchemaUpgradeTests(SqlMigrateBase):
|
||||
|
@ -1518,12 +1523,12 @@ class SqlExpandSchemaUpgradeTests(SqlMigrateBase):
|
|||
|
||||
class MySQLOpportunisticExpandSchemaUpgradeTestCase(
|
||||
SqlExpandSchemaUpgradeTests):
|
||||
FIXTURE = test_base.MySQLOpportunisticFixture
|
||||
FIXTURE = db_fixtures.MySQLOpportunisticFixture
|
||||
|
||||
|
||||
class PostgreSQLOpportunisticExpandSchemaUpgradeTestCase(
|
||||
SqlExpandSchemaUpgradeTests):
|
||||
FIXTURE = test_base.PostgreSQLOpportunisticFixture
|
||||
FIXTURE = db_fixtures.PostgresqlOpportunisticFixture
|
||||
|
||||
|
||||
class SqlDataMigrationUpgradeTests(SqlMigrateBase):
|
||||
|
@ -1543,12 +1548,12 @@ class SqlDataMigrationUpgradeTests(SqlMigrateBase):
|
|||
|
||||
class MySQLOpportunisticDataMigrationUpgradeTestCase(
|
||||
SqlDataMigrationUpgradeTests):
|
||||
FIXTURE = test_base.MySQLOpportunisticFixture
|
||||
FIXTURE = db_fixtures.MySQLOpportunisticFixture
|
||||
|
||||
|
||||
class PostgreSQLOpportunisticDataMigrationUpgradeTestCase(
|
||||
SqlDataMigrationUpgradeTests):
|
||||
FIXTURE = test_base.PostgreSQLOpportunisticFixture
|
||||
FIXTURE = db_fixtures.PostgresqlOpportunisticFixture
|
||||
|
||||
|
||||
class SqlContractSchemaUpgradeTests(SqlMigrateBase, unit.TestCase):
|
||||
|
@ -1577,12 +1582,12 @@ class SqlContractSchemaUpgradeTests(SqlMigrateBase, unit.TestCase):
|
|||
|
||||
class MySQLOpportunisticContractSchemaUpgradeTestCase(
|
||||
SqlContractSchemaUpgradeTests):
|
||||
FIXTURE = test_base.MySQLOpportunisticFixture
|
||||
FIXTURE = db_fixtures.MySQLOpportunisticFixture
|
||||
|
||||
|
||||
class PostgreSQLOpportunisticContractSchemaUpgradeTestCase(
|
||||
SqlContractSchemaUpgradeTests):
|
||||
FIXTURE = test_base.PostgreSQLOpportunisticFixture
|
||||
FIXTURE = db_fixtures.PostgresqlOpportunisticFixture
|
||||
|
||||
|
||||
class VersionTests(SqlMigrateBase):
|
||||
|
@ -2591,8 +2596,8 @@ class FullMigration(SqlMigrateBase, unit.TestCase):
|
|||
|
||||
|
||||
class MySQLOpportunisticFullMigration(FullMigration):
|
||||
FIXTURE = test_base.MySQLOpportunisticFixture
|
||||
FIXTURE = db_fixtures.MySQLOpportunisticFixture
|
||||
|
||||
|
||||
class PostgreSQLOpportunisticFullMigration(FullMigration):
|
||||
FIXTURE = test_base.PostgreSQLOpportunisticFixture
|
||||
FIXTURE = db_fixtures.PostgresqlOpportunisticFixture
|
||||
|
|
Loading…
Reference in New Issue