Skip to content

Commit de9e3e8

Browse files
averdagukarelyatin
authored andcommitted
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 (cherry picked from commit 2a196fe) (cherry picked from commit a8bf8cd)
1 parent ca25eb9 commit de9e3e8

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
@@ -1515,9 +1515,10 @@ def test_enable_subnet_dhcp_options_in_ovn_ipv4(self, grm, gps):
15151515
self.mech_driver.nb_ovn.set_lswitch_port.assert_has_calls(
15161516
set_lsp_calls, any_order=True)
15171517

1518+
@mock.patch.object(ovn_utils, 'get_system_dns_resolvers')
15181519
@mock.patch.object(db_base_plugin_v2.NeutronDbPluginV2, 'get_ports')
15191520
@mock.patch.object(n_net, 'get_random_mac')
1520-
def test_enable_subnet_dhcp_options_in_ovn_ipv6(self, grm, gps):
1521+
def test_enable_subnet_dhcp_options_in_ovn_ipv6(self, grm, gps, gsd):
15211522
grm.return_value = '01:02:03:04:05:06'
15221523
gps.return_value = [
15231524
{'id': 'port-id-1', 'device_owner': 'nova:compute'},
@@ -1530,6 +1531,7 @@ def test_enable_subnet_dhcp_options_in_ovn_ipv6(self, grm, gps):
15301531
{'opt_value': '10::34', 'ip_version': 6,
15311532
'opt_name': 'dns-server'}]},
15321533
{'id': 'port-id-10', 'device_owner': 'network:foo'}]
1534+
gsd.return_value = []
15331535
subnet = {'id': 'subnet-id', 'ip_version': 6, 'cidr': '10::0/64',
15341536
'gateway_ip': '10::1', 'enable_dhcp': True,
15351537
'ipv6_address_mode': 'dhcpv6-stateless',
@@ -1696,7 +1698,9 @@ def test_update_subnet_dhcp_options_in_ovn_ipv6(self):
16961698
self.mech_driver.nb_ovn.add_dhcp_options.assert_called_once_with(
16971699
subnet['id'], **new_options)
16981700

1699-
def test_update_subnet_dhcp_options_in_ovn_ipv6_not_change(self):
1701+
@mock.patch.object(ovn_utils, 'get_system_dns_resolvers')
1702+
def test_update_subnet_dhcp_options_in_ovn_ipv6_not_change(self, gsd):
1703+
gsd.return_value = []
17001704
subnet = {'id': 'subnet-id', 'ip_version': 6, 'cidr': '10::0/64',
17011705
'gateway_ip': '10::1', 'enable_dhcp': True,
17021706
'ipv6_address_mode': 'dhcpv6-stateless',

0 commit comments

Comments
 (0)