diff --git a/vmware_nsx_tempest_plugin/common/constants.py b/vmware_nsx_tempest_plugin/common/constants.py index 85890ff..28e6062 100644 --- a/vmware_nsx_tempest_plugin/common/constants.py +++ b/vmware_nsx_tempest_plugin/common/constants.py @@ -35,7 +35,7 @@ PORT_SEC_PROFILE = "SpoofGuardSwitchingProfile" SEC_GRPS_PROFILE = "SwitchSecuritySwitchingProfile" # NSXV3 MDProxy constants. -MD_ERROR_CODE_WHEN_LS_BOUNDED = "10026" +MD_ERROR_CODE_WHEN_LS_BOUNDED = "22047" INTERVAL_BETWEEN_EXEC_RETRY_ON_SSH = 5 MAX_NO_OF_TIMES_EXECUTION_OVER_SSH = 30 MD_BASE_URL = "http://169.254.169.254/" diff --git a/vmware_nsx_tempest_plugin/tests/nsxv3/api/test_native_dhcp_negative.py b/vmware_nsx_tempest_plugin/tests/nsxv3/api/test_native_dhcp_negative.py index 1a928cf..f2ea214 100644 --- a/vmware_nsx_tempest_plugin/tests/nsxv3/api/test_native_dhcp_negative.py +++ b/vmware_nsx_tempest_plugin/tests/nsxv3/api/test_native_dhcp_negative.py @@ -134,4 +134,4 @@ class NSXv3NativeDHCPNegative(base.BaseNetworkTest): nsx_network = self.nsxp.get_logical_switch(network['name'], network['id']) self.assertIsNotNone(nsx_network) - self.assertEqual(nsx_network['subnets'], []) + self.assertNotIn('subnets', nsx_network) diff --git a/vmware_nsx_tempest_plugin/tests/scenario/test_new_case_coverage.py b/vmware_nsx_tempest_plugin/tests/scenario/test_new_case_coverage.py index 7c235d3..154b498 100644 --- a/vmware_nsx_tempest_plugin/tests/scenario/test_new_case_coverage.py +++ b/vmware_nsx_tempest_plugin/tests/scenario/test_new_case_coverage.py @@ -324,18 +324,23 @@ class TestNewCase(feature_manager.FeatureManager): network_state = topology_dict['network_state'] subnet_state = topology_dict['subnet_state'] network_cidr = ( - CONF.network.project_network_cidr.rsplit('/')[0]).rsplit('.', - 1) + CONF.network.project_network_cidr.rsplit( + '/')[0]).rsplit('.', 1) + last_bit = CONF.network.project_network_cidr.rsplit('.')[-1] + range_start = "." + str(int(last_bit.rsplit('/')[0]) + 3) + range_del = "." + str(int(last_bit.rsplit('/')[0]) + 6) + time.sleep(constants.NSX_NETWORK_REALISE_TIMEOUT) fix_ip = [{'subnet_id': subnet_state.get( 'id'), - 'ip_address': network_cidr[0] + '.5'}, + 'ip_address': network_cidr[0] + str(range_start)}, {'subnet_id': subnet_state.get('id'), - 'ip_address': network_cidr[0] + '.6'}] + 'ip_address': network_cidr[0] + str(range_del)}] # self.assertRaises(exceptions.BadRequest, # self.cmgr_adm.ports_client.create_port, # **args) # Updating this case to support multiple fixed Ips # for port after VIO 7.1.1 & 7.2 + time.sleep(constants.NSX_NETWORK_REALISE_TIMEOUT) port = self.create_topology_port( network_state, ports_client=self.cmgr_adm.ports_client, @@ -356,6 +361,10 @@ class TestNewCase(feature_manager.FeatureManager): network_cidr = ( CONF.network.project_network_cidr.rsplit('/')[0]).rsplit('.', 1) + last_bit = CONF.network.project_network_cidr.rsplit('.')[-1] + range_start = "." + str(int(last_bit.rsplit('/')[0]) + 4) + range_del = "." + str(int(last_bit.rsplit('/')[0]) + 7) + time.sleep(constants.NSX_NETWORK_REALISE_TIMEOUT) fix_ip1 = [ {'subnet_id': subnet_state.get('id'), 'ip_address': network_cidr[0] + '.5'}] @@ -366,9 +375,9 @@ class TestNewCase(feature_manager.FeatureManager): self.assertEqual("ACTIVE", port['status']) fix_ip = [{'subnet_id': subnet_state.get( 'id'), - 'ip_address': network_cidr[0] + '.6'}, + 'ip_address': network_cidr[0] + str(range_start)}, {'subnet_id': subnet_state.get('id'), - 'ip_address': network_cidr[0] + '.7'}] + 'ip_address': network_cidr[0] + str(range_del)}] args = {'fixed_ips': fix_ip} # self.assertRaises(exceptions.BadRequest, # self.cmgr_adm.ports_client.update_port, @@ -524,8 +533,8 @@ class TestNewCase(feature_manager.FeatureManager): port['network_id'] == network_state['id']: port = port break - if port['port_security_enabled'] is not False: - raise Exception("Port security of dhcp port is enabled") + if port['port_security_enabled'] is not False: + raise Exception("Port security of dhcp port is enabled") @decorators.idempotent_id('1209349d-91cc-8905-b217-98844cab5545') @testtools.skipUnless( @@ -1996,8 +2005,6 @@ class TestNewCase(feature_manager.FeatureManager): @decorators.idempotent_id('b3881f7a-4d7a-464d-9ecd-dc829e346e95') def test_switching_gateway_tier1_router(self): - """ - """ name = "ipv4-ext-network" networks_client_ex = self.cmgr_adm.networks_client ext_network = self.create_topology_network( @@ -2007,9 +2014,15 @@ class TestNewCase(feature_manager.FeatureManager): self.assertTrue(ext_network['router:external']) subnet_client_ex = self.cmgr_adm.subnets_client subnet_name_ex = ext_network['name'] + 'sub' + network_cidr = ( + CONF.network.project_network_cidr.rsplit( + '/')[0]).rsplit('.', 1) + last_bit = CONF.network.project_network_cidr.rsplit('.')[-1] + range_start = "." + str(int(last_bit.rsplit('/')[0]) + 2) + range_del = "." + str(int(last_bit.rsplit('/')[0]) + 5) allocation_pools = {'allocation_pools': [{ - 'start': '100.20.0.2', - 'end': '100.20.0.14'}]} + 'start': network_cidr[0] + str(range_start), + 'end': network_cidr[0] + str(range_del)}]} self.create_topology_subnet(subnet_name_ex, ext_network, subnets_client=subnet_client_ex, ip_version=4, enable_dhcp=False, @@ -2071,3 +2084,23 @@ class TestNewCase(feature_manager.FeatureManager): router['id'], external_gateway_info=router_dict)['router'] self.assertEqual(router_update['external_gateway_info']['network_id'], ext_network['id']) + + @decorators.idempotent_id('b3881f7a-4d7a-464d-9ecd-dc829e342345') + def test_update_subnet_with_invalid_gateway(self): + """Test updating subnet with invalid range IP""" + name = data_utils.rand_name("ipv4-no-sub-net1") + networks_client_ex = self.cmgr_adm.networks_client + nor_network = self.create_topology_network( + name, networks_client=networks_client_ex) + self.assertIsNotNone(nor_network['id']) + subnet_client = self.cmgr_adm.subnets_client + subnet_no_gw = nor_network['name'] + 'sub-no-gw' + sub_resp = self.create_topology_subnet( + subnet_no_gw, nor_network, subnets_client=subnet_client, + ip_version=4, enable_dhcp=True, gateway_ip=None) + self.assertIsNone(sub_resp['gateway_ip']) + + # Update invalid gateway of ipv4 subnet outside the same range + self.assertRaises(exceptions.BadRequest, + self.cmgr_adm.subnets_client.update_subnet, + sub_resp['id'], gateway_ip="22.0.0.1")