diff options
author | Zuul <zuul@review.opendev.org> | 2021-11-09 13:58:49 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2021-11-09 13:58:49 +0000 |
commit | bae60995e3573d2f11aec102870d569ab72c877b (patch) | |
tree | dec7845c89d8255e8764ea758aae33d4ab49f7f4 /nova | |
parent | 59e06f9f3a5285bbc3061f511e35a519bf990b7b (diff) | |
parent | 063ed41174c27c20871696f7c6dcb1eddb4310ee (diff) | |
download | nova-bae60995e3573d2f11aec102870d569ab72c877b.tar.gz |
Merge "Use ReplaceEngineFacade fixture"
Diffstat (limited to 'nova')
-rw-r--r-- | nova/tests/fixtures/nova.py | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/nova/tests/fixtures/nova.py b/nova/tests/fixtures/nova.py index b028d962b1..0acc3fa151 100644 --- a/nova/tests/fixtures/nova.py +++ b/nova/tests/fixtures/nova.py @@ -32,6 +32,7 @@ from oslo_concurrency import lockutils from oslo_config import cfg from oslo_db import exception as db_exc from oslo_db.sqlalchemy import enginefacade +from oslo_db.sqlalchemy import test_fixtures as db_fixtures from oslo_log import log as logging import oslo_messaging as messaging from oslo_messaging import conffixture as messaging_conffixture @@ -632,21 +633,24 @@ class Database(fixtures.Fixture): connection=self.connection) self.get_engine = ctxt_mgr.writer.get_engine else: - # NOTE(gibi): this inject a new factory for each test and - # registers a cleanup that cleans the factory at the end - # of the test case. This way we can let each test configure the - # factory so we can avoid having a global flag guarding against - # factory re-configuration - self.addCleanup(main_db_api.context_manager.patch_factory( - enginefacade._TransactionFactory())) + # NOTE(gibi): this injects a new factory for each test and + # cleans it up at then end of the test case. This way we can + # let each test configure the factory so we can avoid having a + # global flag guarding against factory re-configuration + new_engine = enginefacade.transaction_context() + self.useFixture( + db_fixtures.ReplaceEngineFacadeFixture( + main_db_api.context_manager, new_engine)) main_db_api.configure(CONF) self.get_engine = main_db_api.get_engine elif self.database == 'api': # NOTE(gibi): similar note applies here as for the main_db_api # above - self.addCleanup(api_db_api.context_manager.patch_factory( - enginefacade._TransactionFactory())) + new_engine = enginefacade.transaction_context() + self.useFixture( + db_fixtures.ReplaceEngineFacadeFixture( + api_db_api.context_manager, new_engine)) api_db_api.configure(CONF) self.get_engine = api_db_api.get_engine |