-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use the new enginefacade from oslo_db
As per blueprint [1], the existing use of oslo_db session handling (e.g., context.session.begin()) introduces potential issues. Notably, unit tests failed during the Caracal release, though no definitive deployment impact has been identified yet. To future-proof the code and align with recommended practices, we are migrating to the enginefacade pattern now. This involves replacing: with context.session.begin(): context.session.add(obj) with 'db_api.CONTEXT_WRITER.using(context)' [1] https://blueprints.launchpad.net/neutron/+spec/enginefacade-switch [2] Oslo db spec: http://specs.openstack.org/openstack/oslo-specs/specs/kilo/make-enginefacade-a-facade.html
- Loading branch information
1 parent
0586f85
commit 9d9f5b9
Showing
4 changed files
with
83 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
networking_aci/tests/unit/plugins/ml2/drivers/mech_aci/test_db_plugin.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from neutron.tests.unit.plugins.ml2 import test_plugin | ||
from neutron_lib import context | ||
from neutron_lib.db import api as db_api | ||
from oslotest import base | ||
|
||
from networking_aci.db.models import HostgroupModeModel | ||
from networking_aci.plugins.ml2.drivers.mech_aci.common import DBPlugin | ||
|
||
|
||
class NetworkingDBPluginTests(test_plugin.Ml2PluginV2TestCase, base.BaseTestCase): | ||
|
||
def _create_hostgroup_mode(self, hostgroup, mode): | ||
ctx = context.get_admin_context() | ||
with db_api.CONTEXT_WRITER.using(ctx): | ||
self._hg_mode = HostgroupModeModel(hostgroup=hostgroup, mode=mode) | ||
ctx.session.add(self._hg_mode) | ||
|
||
def test_set_hostgroup_mode(self): | ||
new_hg_mode = 'something-different' | ||
|
||
self._create_hostgroup_mode(hostgroup="hg-1", mode="infra") | ||
plugin = DBPlugin() | ||
ctx = context.get_admin_context() | ||
plugin.set_hostgroup_mode(ctx, "hg-1", new_hg_mode) | ||
|
||
hg_mode = plugin.get_hostgroup_mode(ctx, "hg-1") | ||
self.assertEqual(new_hg_mode, hg_mode, f"Hostgroup Mode should match {new_hg_mode} but got {hg_mode}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters