Skip to content

Commit 8ebd7db

Browse files
committed
[UT] Create network to make lazy loading in the models_v2 possible
In the test_port_deletion_prevention_handles_missing_port test which is part of the classes: * neutron.tests.unit.extensions.test_l3.L3NatDBSepTestCase * neutron.tests.unit.extensions.test_extraroute.ExtraRouteDBSepTestCase it is needed to call pecan application to e.g. create network to make all models to be ready. Otherwise things like port_forwarding attribute in the Port class, which is loaded in lazy mode isn't available and test was failing when was run in the isolated environment. It wasn't failing in the gate as there were other tests run by the same worker before this one and then it was all initialized properly. Closes-Bug: #2028285 Change-Id: Ie2382540d7c0a8813f093ddf51d82fe530026d71 (cherry picked from commit 14b2f4f)
1 parent d0c5478 commit 8ebd7db

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

neutron/tests/unit/extensions/test_l3.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4462,9 +4462,15 @@ class L3NatDBSepTestCase(L3BaseForSepTests, L3NatTestCaseBase,
44624462

44634463
def test_port_deletion_prevention_handles_missing_port(self):
44644464
pl = directory.get_plugin(plugin_constants.L3)
4465-
self.assertIsNone(
4466-
pl.prevent_l3_port_deletion(context.get_admin_context(), 'fakeid')
4467-
)
4465+
# NOTE(slaweq): it's needed to make at least one API call to the
4466+
# application to initialize all models which are using lazy loading of
4467+
# some attributes,
4468+
# check https://bugs.launchpad.net/neutron/+bug/2028285 for details
4469+
with self.network():
4470+
self.assertIsNone(
4471+
pl.prevent_l3_port_deletion(context.get_admin_context(),
4472+
'fakeid')
4473+
)
44684474

44694475

44704476
class L3TestExtensionManagerWithDNS(L3TestExtensionManager):

0 commit comments

Comments
 (0)