Don't modify global variables in unit tests
The unit test
test_enable_dhcp_helper_enable_metadata_nonisolated_dist_network
modifies the global variables fake_port1, fake_port2, creating flakiness
on unit tests that use those variables when execured in environments
with high concurrency.
Creating a deepcopy of the variable avoid that those changes can be
propagated to other unit tests.
Closes-Bug: #1809643
Change-Id: Idfd0e99739952baf4d7b545b406cd1b251deb5f8
Signed-off-by: aojeagarcia <aojeagarcia@suse.com>
(cherry picked from commit e83e5618b7
)
This commit is contained in:
parent
b5a0401472
commit
44441bee0b
|
@ -690,14 +690,15 @@ class TestDhcpAgentEventHandler(base.BaseTestCase):
|
|||
is_isolated_network=False)
|
||||
|
||||
def test_enable_dhcp_helper_enable_metadata_nonisolated_dist_network(self):
|
||||
nonisolated_dist_network.ports[0].device_owner = (
|
||||
nonisolated_dvr_network = copy.deepcopy(nonisolated_dist_network)
|
||||
nonisolated_dvr_network.ports[0].device_owner = (
|
||||
const.DEVICE_OWNER_ROUTER_INTF)
|
||||
nonisolated_dist_network.ports[0].fixed_ips[0].ip_address = '172.9.9.1'
|
||||
nonisolated_dist_network.ports[1].device_owner = (
|
||||
nonisolated_dvr_network.ports[0].fixed_ips[0].ip_address = '172.9.9.1'
|
||||
nonisolated_dvr_network.ports[1].device_owner = (
|
||||
const.DEVICE_OWNER_DVR_INTERFACE)
|
||||
nonisolated_dist_network.ports[1].fixed_ips[0].ip_address = '172.9.9.1'
|
||||
nonisolated_dvr_network.ports[1].fixed_ips[0].ip_address = '172.9.9.1'
|
||||
|
||||
self._enable_dhcp_helper(nonisolated_dist_network,
|
||||
self._enable_dhcp_helper(nonisolated_dvr_network,
|
||||
enable_isolated_metadata=True,
|
||||
is_isolated_network=False)
|
||||
|
||||
|
|
Loading…
Reference in New Issue