From d982a68446ad9b9c432ab2788900993aa21e135a Mon Sep 17 00:00:00 2001 From: Slawek Kaplonski Date: Fri, 20 Mar 2020 03:16:20 +0100 Subject: [PATCH] Finish migration to new engine facade in test_db_base_plugin_v2 Partially-Implements blueprint: enginefacade-switch Change-Id: I1b95d53f79c2c2b56a119c20017c3bf7fbc8550d --- .../tests/unit/db/test_db_base_plugin_v2.py | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/neutron/tests/unit/db/test_db_base_plugin_v2.py b/neutron/tests/unit/db/test_db_base_plugin_v2.py index 72f5ec17753..df7137697c6 100644 --- a/neutron/tests/unit/db/test_db_base_plugin_v2.py +++ b/neutron/tests/unit/db/test_db_base_plugin_v2.py @@ -6508,11 +6508,10 @@ class DbModelMixin(object): project_id='fake_project', mtu=1500) ctx.session.add(network) - with db_api.autonested_transaction(ctx.session): - sg = sg_models.SecurityGroup(name='sg', description='sg') - ctx.session.add(sg) # ensure db rels aren't loaded until commit for network object - # by sharing after a nested transaction + # by sharing after flush + ctx.session.flush() + network_obj.NetworkRBAC( ctx, object_id=network.id, action='access_as_shared', @@ -6556,11 +6555,12 @@ class DbModelMixin(object): return sg, rule def _make_floating_ip(self, ctx, port_id): - flip = l3_obj.FloatingIP( - ctx, floating_ip_address=netaddr.IPAddress('1.2.3.4'), - floating_network_id=uuidutils.generate_uuid(), - floating_port_id=port_id) - flip.create() + with db_api.CONTEXT_WRITER.using(ctx): + flip = l3_obj.FloatingIP( + ctx, floating_ip_address=netaddr.IPAddress('1.2.3.4'), + floating_network_id=uuidutils.generate_uuid(), + floating_port_id=port_id) + flip.create() return flip def _make_router(self, ctx): @@ -6579,7 +6579,7 @@ class DbModelMixin(object): self.assertEqual( obj.__table__.name, self._get_neutron_attr(ctx, attr_id).resource_type) - with ctx.session.begin(): + with db_api.CONTEXT_WRITER.using(ctx): ctx.session.delete(obj) with testtools.ExpectedException(orm.exc.NoResultFound): # we want to make sure that the attr resource was removed @@ -6755,7 +6755,7 @@ class DbModelTenantTestCase(DbModelMixin, testlib_api.SqlTestCase): return subnet def _make_port(self, ctx, network_id): - with ctx.session.begin(): + with db_api.CONTEXT_WRITER.using(ctx): port = models_v2.Port(network_id=network_id, mac_address='1', tenant_id='dbcheck', admin_state_up=True, status="COOL", @@ -6795,7 +6795,7 @@ class DbModelProjectTestCase(DbModelMixin, testlib_api.SqlTestCase): return subnet def _make_port(self, ctx, network_id): - with ctx.session.begin(): + with db_api.CONTEXT_WRITER.using(ctx): port = models_v2.Port(network_id=network_id, mac_address='1', project_id='dbcheck', admin_state_up=True, status="COOL",