From f4decdafeb55efc15443b5f2f9907145d6049310 Mon Sep 17 00:00:00 2001 From: Adit Sarfaty Date: Sun, 28 Apr 2019 08:13:38 +0300 Subject: [PATCH] Fix bulk subnets unittests Commit Ia32ec4c11c0793e7df07dcce19c122b3c7f865e1 broke bulk sunbets creation unittests. This patch fixes some tests, and skips other. Change-Id: I25cad6447a2a2ccf3b9c7689904455c9468e01c5 --- vmware_nsx/plugins/common_v3/plugin.py | 3 ++- .../tests/unit/common_plugin/common_v3.py | 6 +++++ vmware_nsx/tests/unit/nsx_p/test_plugin.py | 10 +++++++- vmware_nsx/tests/unit/nsx_v/test_plugin.py | 23 ++++++++++++++++++- 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/vmware_nsx/plugins/common_v3/plugin.py b/vmware_nsx/plugins/common_v3/plugin.py index 6838fe342e..dad3bf1897 100644 --- a/vmware_nsx/plugins/common_v3/plugin.py +++ b/vmware_nsx/plugins/common_v3/plugin.py @@ -2104,7 +2104,8 @@ class NsxPluginV3Base(agentschedulers_db.AZDhcpAgentSchedulerDbMixin, context, subnet) def _rollback(subnet): - if subnet['enable_dhcp'] and subnet['id'] in _subnet_dhcp_info: + if (subnet and subnet['enable_dhcp'] and + subnet['id'] in _subnet_dhcp_info): self._rollback_subnet(subnet, _subnet_dhcp_info[subnet['id']]) del _subnet_dhcp_info[subnet['id']] diff --git a/vmware_nsx/tests/unit/common_plugin/common_v3.py b/vmware_nsx/tests/unit/common_plugin/common_v3.py index 095ee71c1b..a98be56158 100644 --- a/vmware_nsx/tests/unit/common_plugin/common_v3.py +++ b/vmware_nsx/tests/unit/common_plugin/common_v3.py @@ -297,6 +297,12 @@ class NsxV3TestSubnets(NsxV3SubnetMixin, def test_create_subnet_ipv6_slaac_with_port_not_found(self): self.skipTest('No DHCP v6 Support yet') + def test_bulk_create_subnet_ipv6_auto_addr_with_port_on_network(self): + self.skipTest('No DHCP v6 Support yet') + + def test_create_subnets_bulk_native_ipv6(self): + self.skipTest('Multiple IPv6 subnets on one network is not supported') + @with_disable_dhcp def test_update_subnet_inconsistent_ipv6_hostroute_dst_v4(self): super(NsxV3TestSubnets, diff --git a/vmware_nsx/tests/unit/nsx_p/test_plugin.py b/vmware_nsx/tests/unit/nsx_p/test_plugin.py index 242d4e527e..56da07dbe7 100644 --- a/vmware_nsx/tests/unit/nsx_p/test_plugin.py +++ b/vmware_nsx/tests/unit/nsx_p/test_plugin.py @@ -1059,10 +1059,18 @@ class NsxPTestSubnets(common_v3.NsxV3TestSubnets, 'ip_version': ip_version, 'enable_dhcp': False, 'tenant_id': self._tenant_id}} + if 'ipv6_mode' in kwargs: + base_data['subnet']['ipv6_ra_mode'] = kwargs['ipv6_mode'] + base_data['subnet']['ipv6_address_mode'] = kwargs['ipv6_mode'] + # auto-generate cidrs as they should not overlap + base_cidr = "10.0.%s.0/24" + if ip_version == constants.IP_VERSION_6: + base_cidr = "fd%s::/64" + # auto-generate cidrs as they should not overlap overrides = dict((k, v) for (k, v) in zip(range(number), - [{'cidr': "10.0.%s.0/24" % num} + [{'cidr': base_cidr % num} for num in range(number)])) kwargs.update({'override': overrides}) return self._create_bulk(fmt, number, 'subnet', base_data, **kwargs) diff --git a/vmware_nsx/tests/unit/nsx_v/test_plugin.py b/vmware_nsx/tests/unit/nsx_v/test_plugin.py index 8afe101b6d..c2184d4191 100644 --- a/vmware_nsx/tests/unit/nsx_v/test_plugin.py +++ b/vmware_nsx/tests/unit/nsx_v/test_plugin.py @@ -1989,16 +1989,28 @@ class TestSubnetsV2(NsxVPluginV2TestCase, def test_create_subnet_dhcpv6_stateless_with_ip_already_allocated(self): self.skipTest('No DHCP v6 Support yet') + def test_create_subnets_bulk_native_ipv6(self): + self.skipTest('No DHCP v6 Support yet') + def _create_subnet_bulk(self, fmt, number, net_id, name, ip_version=4, **kwargs): base_data = {'subnet': {'network_id': net_id, 'ip_version': ip_version, 'enable_dhcp': False, 'tenant_id': self._tenant_id}} + + if 'ipv6_mode' in kwargs: + base_data['subnet']['ipv6_ra_mode'] = kwargs['ipv6_mode'] + base_data['subnet']['ipv6_address_mode'] = kwargs['ipv6_mode'] + # auto-generate cidrs as they should not overlap + base_cidr = "10.0.%s.0/24" + if ip_version == constants.IP_VERSION_6: + base_cidr = "fd%s::/64" + # auto-generate cidrs as they should not overlap overrides = dict((k, v) for (k, v) in zip(range(number), - [{'cidr': "10.0.%s.0/24" % num} + [{'cidr': base_cidr % num} for num in range(number)])) kwargs.update({'override': overrides}) return self._create_bulk(fmt, number, 'subnet', base_data, **kwargs) @@ -2123,6 +2135,9 @@ class TestSubnetsV2(NsxVPluginV2TestCase, def test_create_subnet_ipv6_slaac_with_port_not_found(self): self.skipTest('Currently not supported') + def test_bulk_create_subnet_ipv6_auto_addr_with_port_on_network(self): + self.skipTest('Currently not supported') + def test_create_subnet_ipv6_gw_values(self): # This test should fail with response code 400 as IPv6 subnets with # DHCP are not supported by this plugin @@ -2212,6 +2227,9 @@ class TestSubnetPoolsV2(NsxVPluginV2TestCase, test_plugin.TestSubnetsV2): def test_create_subnet_ipv6_slaac_with_port_not_found(self): self.skipTest('Not supported') + def test_bulk_create_subnet_ipv6_auto_addr_with_port_on_network(self): + self.skipTest('Currently not supported') + def test_create_subnet_ipv6_slaac_with_dhcp_port_on_network(self): self.skipTest('Not supported') @@ -2263,6 +2281,9 @@ class TestSubnetPoolsV2(NsxVPluginV2TestCase, test_plugin.TestSubnetsV2): def test_create_subnet_only_ip_version_v6_old(self): self.skipTest('Currently not supported') + def test_create_subnets_bulk_native_ipv6(self): + self.skipTest('No DHCP v6 Support yet') + class TestBasicGet(test_plugin.TestBasicGet, NsxVPluginV2TestCase): pass