Skip to content

Commit 2e50aef

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 2badef9 commit 2e50aef

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
@@ -4473,9 +4473,15 @@ class L3NatDBSepTestCase(L3BaseForSepTests, L3NatTestCaseBase,
44734473

44744474
def test_port_deletion_prevention_handles_missing_port(self):
44754475
pl = directory.get_plugin(plugin_constants.L3)
4476-
self.assertIsNone(
4477-
pl.prevent_l3_port_deletion(context.get_admin_context(), 'fakeid')
4478-
)
4476+
# NOTE(slaweq): it's needed to make at least one API call to the
4477+
# application to initialize all models which are using lazy loading of
4478+
# some attributes,
4479+
# check https://bugs.launchpad.net/neutron/+bug/2028285 for details
4480+
with self.network():
4481+
self.assertIsNone(
4482+
pl.prevent_l3_port_deletion(context.get_admin_context(),
4483+
'fakeid')
4484+
)
44794485

44804486

44814487
class L3TestExtensionManagerWithDNS(L3TestExtensionManager):

0 commit comments

Comments
 (0)