Merge "Revert "fix usage of opportunistic test cases with enginefacade""
This commit is contained in:
commit
a5818b8e9f
@ -27,7 +27,6 @@ from keystoneauth1 import session as ks
|
||||
import mock
|
||||
from oslo_concurrency import lockutils
|
||||
from oslo_config import cfg
|
||||
from oslo_db.sqlalchemy import enginefacade
|
||||
import oslo_messaging as messaging
|
||||
from oslo_messaging import conffixture as messaging_conffixture
|
||||
|
||||
@ -938,42 +937,6 @@ class BannedDBSchemaOperations(fixtures.Fixture):
|
||||
lambda *a, **k: self._explode(thing, 'alter')))
|
||||
|
||||
|
||||
class EngineFacadeFixture(fixtures.Fixture):
|
||||
"""Fixture to isolation EngineFacade during tests.
|
||||
|
||||
Because many elements of EngineFacade are based on globals, once
|
||||
an engine facade has been initialized, all future code goes
|
||||
through it. This means that the initialization of sqlite in
|
||||
databases in our Database fixture will drive all connections to
|
||||
sqlite. While that's fine in a production environment, during
|
||||
testing this means we can't test against multiple backends in the
|
||||
same test run.
|
||||
|
||||
oslo.db does not yet support a reset mechanism here. This builds a
|
||||
custom in tree engine facade fixture to handle this. Eventually
|
||||
this will be added to oslo.db and this can be removed. Tracked by
|
||||
https://bugs.launchpad.net/oslo.db/+bug/1548960
|
||||
|
||||
"""
|
||||
def __init__(self, ctx_manager, engine, sessionmaker):
|
||||
super(EngineFacadeFixture, self).__init__()
|
||||
self._ctx_manager = ctx_manager
|
||||
self._engine = engine
|
||||
self._sessionmaker = sessionmaker
|
||||
|
||||
def setUp(self):
|
||||
super(EngineFacadeFixture, self).setUp()
|
||||
|
||||
self._existing_factory = self._ctx_manager._root_factory
|
||||
self._ctx_manager._root_factory = enginefacade._TestTransactionFactory(
|
||||
self._engine, self._sessionmaker, apply_global=False,
|
||||
synchronous_reader=True)
|
||||
self.addCleanup(self.cleanup)
|
||||
|
||||
def cleanup(self):
|
||||
self._ctx_manager._root_factory = self._existing_factory
|
||||
|
||||
|
||||
class ForbidNewLegacyNotificationFixture(fixtures.Fixture):
|
||||
"""Make sure the test fails if new legacy notification is added"""
|
||||
def __init__(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user