tests: generate unique network ids for L3HARouterVRIdAllocation

There is a bug in base test class where self.db_objs may end up with
non-unique values after update_obj_fields call. While we are looking at
fixing the underlying issue in the base class, this patch merely makes
L3HARouterVRIdAllocationDbObjectTestCase to not reuse the same network
id for all test objects.

Change-Id: Ib4e5ffa1df5adba5460d7e66d1c21b63745a7141
Related-Bug: #1717046
This commit is contained in:
Ihar Hrachyshka 2017-09-15 13:21:13 -06:00
parent f772094105
commit c56a8c1b7e
2 changed files with 4 additions and 2 deletions

View File

@ -601,6 +601,8 @@ class _BaseObjectTestCase(object):
Note: if a value is a dict itself, the method will recursively update
corresponding embedded objects.
'''
# TODO(ihrachys) make the method update db_objs to keep generated test
# objects unique despite new locked fields
for k, v in values_dict.items():
for db_obj, fields, obj in zip(
db_objs or self.db_objs,

View File

@ -70,5 +70,5 @@ class L3HARouterVRIdAllocationDbObjectTestCase(base.BaseDbObjectTestCase,
def setUp(self):
super(L3HARouterVRIdAllocationDbObjectTestCase, self).setUp()
network = self._create_test_network()
self.update_obj_fields({'network_id': network.id})
self.update_obj_fields(
{'network_id': lambda: self._create_test_network().id})