Skip to content

Commit 2a196fe

Browse files
committed
Fix TestOVNMechanismDriver ipv6 tests
- test_update_subnet_dhcp_options_in_ovn_ipv6_not_change - test_enable_subnet_dhcp_options_in_ovn_ipv6 This tests will fail if host where unit tests has ipv6 dns_servers configured. This patch mocks get_system_dns_servers to avoid tests to look at the host configuration. Closes-Bug: #2056778 Change-Id: I2e703ab4b63c90d7a14f0dc41d37b0a98163bce0
1 parent e8468a6 commit 2a196fe

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

neutron/tests/unit/plugins/ml2/drivers/ovn/mech_driver/test_mech_driver.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1616,9 +1616,10 @@ def test_enable_subnet_dhcp_options_in_ovn_ipv4(self, grm, gps):
16161616
self.mech_driver.nb_ovn.set_lswitch_port.assert_has_calls(
16171617
set_lsp_calls, any_order=True)
16181618

1619+
@mock.patch.object(ovn_utils, 'get_system_dns_resolvers')
16191620
@mock.patch.object(db_base_plugin_v2.NeutronDbPluginV2, 'get_ports')
16201621
@mock.patch.object(n_net, 'get_random_mac')
1621-
def test_enable_subnet_dhcp_options_in_ovn_ipv6(self, grm, gps):
1622+
def test_enable_subnet_dhcp_options_in_ovn_ipv6(self, grm, gps, gsd):
16221623
grm.return_value = '01:02:03:04:05:06'
16231624
gps.return_value = [
16241625
{'id': 'port-id-1', 'device_owner': 'nova:compute'},
@@ -1631,6 +1632,7 @@ def test_enable_subnet_dhcp_options_in_ovn_ipv6(self, grm, gps):
16311632
{'opt_value': '10::34', 'ip_version': 6,
16321633
'opt_name': 'dns-server'}]},
16331634
{'id': 'port-id-10', 'device_owner': 'network:foo'}]
1635+
gsd.return_value = []
16341636
subnet = {'id': 'subnet-id', 'ip_version': 6, 'cidr': '10::0/64',
16351637
'gateway_ip': '10::1', 'enable_dhcp': True,
16361638
'ipv6_address_mode': 'dhcpv6-stateless',
@@ -1797,7 +1799,9 @@ def test_update_subnet_dhcp_options_in_ovn_ipv6(self):
17971799
self.mech_driver.nb_ovn.add_dhcp_options.assert_called_once_with(
17981800
subnet['id'], **new_options)
17991801

1800-
def test_update_subnet_dhcp_options_in_ovn_ipv6_not_change(self):
1802+
@mock.patch.object(ovn_utils, 'get_system_dns_resolvers')
1803+
def test_update_subnet_dhcp_options_in_ovn_ipv6_not_change(self, gsd):
1804+
gsd.return_value = []
18011805
subnet = {'id': 'subnet-id', 'ip_version': 6, 'cidr': '10::0/64',
18021806
'gateway_ip': '10::1', 'enable_dhcp': True,
18031807
'ipv6_address_mode': 'dhcpv6-stateless',

0 commit comments

Comments
 (0)