How to use _create_verify_delete_subnet method in tempest

Best Python code snippet using tempest_python

test_networks.py

Source:test_networks.py Github

copy

Full Screen

...130 self.networks.remove(network)131 for subnet in self.subnets:132 if subnet['network_id'] == network['id']:133 self.subnets.remove(subnet)134 def _create_verify_delete_subnet(self, cidr=None, mask_bits=None,135 **kwargs):136 network = self.create_network()137 net_id = network['id']138 gateway = kwargs.pop('gateway', None)139 subnet = self.create_subnet(network, gateway, cidr, mask_bits,140 **kwargs)141 compare_args_full = dict(gateway_ip=gateway, cidr=cidr,142 mask_bits=mask_bits, **kwargs)143 compare_args = dict((k, v) for k, v in compare_args_full.iteritems()144 if v is not None)145 if 'dns_nameservers' in set(subnet).intersection(compare_args):146 self.assertEqual(sorted(compare_args['dns_nameservers']),147 sorted(subnet['dns_nameservers']))148 del subnet['dns_nameservers'], compare_args['dns_nameservers']149 self._compare_resource_attrs(subnet, compare_args)150 self.client.delete_network(net_id)151 self.networks.pop()152 self.subnets.pop()153 @test.attr(type='smoke')154 @test.idempotent_id('0e269138-0da6-4efc-a46d-578161e7b221')155 def test_create_update_delete_network_subnet(self):156 # Create a network157 name = data_utils.rand_name('network-')158 network = self.create_network(network_name=name)159 self.addCleanup(self._delete_network, network)160 net_id = network['id']161 self.assertEqual('ACTIVE', network['status'])162 # Verify network update163 new_name = "New_network"164 body = self.client.update_network(net_id, name=new_name)165 updated_net = body['network']166 self.assertEqual(updated_net['name'], new_name)167 # Find a cidr that is not in use yet and create a subnet with it168 subnet = self.create_subnet(network)169 subnet_id = subnet['id']170 # Verify subnet update171 new_name = "New_subnet"172 body = self.client.update_subnet(subnet_id, name=new_name)173 updated_subnet = body['subnet']174 self.assertEqual(updated_subnet['name'], new_name)175 @test.attr(type='smoke')176 @test.idempotent_id('2bf13842-c93f-4a69-83ed-717d2ec3b44e')177 def test_show_network(self):178 # Verify the details of a network179 body = self.client.show_network(self.network['id'])180 network = body['network']181 for key in ['id', 'name', 'mtu']:182 self.assertEqual(network[key], self.network[key])183 @test.attr(type='smoke')184 @test.idempotent_id('867819bb-c4b6-45f7-acf9-90edcf70aa5e')185 def test_show_network_fields(self):186 # Verify specific fields of a network187 fields = ['id', 'name', 'mtu']188 body = self.client.show_network(self.network['id'],189 fields=fields)190 network = body['network']191 self.assertEqual(sorted(network.keys()), sorted(fields))192 for field_name in fields:193 self.assertEqual(network[field_name], self.network[field_name])194 @test.attr(type='smoke')195 @test.idempotent_id('f7ffdeda-e200-4a7a-bcbe-05716e86bf43')196 def test_list_networks(self):197 # Verify the network exists in the list of all networks198 body = self.client.list_networks()199 networks = [network['id'] for network in body['networks']200 if network['id'] == self.network['id']]201 self.assertNotEmpty(networks, "Created network not found in the list")202 @test.attr(type='smoke')203 @test.idempotent_id('6ae6d24f-9194-4869-9c85-c313cb20e080')204 def test_list_networks_fields(self):205 # Verify specific fields of the networks206 fields = ['id', 'name', 'mtu']207 body = self.client.list_networks(fields=fields)208 networks = body['networks']209 self.assertNotEmpty(networks, "Network list returned is empty")210 for network in networks:211 self.assertEqual(sorted(network.keys()), sorted(fields))212 @test.attr(type='smoke')213 @test.idempotent_id('bd635d81-6030-4dd1-b3b9-31ba0cfdf6cc')214 def test_show_subnet(self):215 # Verify the details of a subnet216 body = self.client.show_subnet(self.subnet['id'])217 subnet = body['subnet']218 self.assertNotEmpty(subnet, "Subnet returned has no fields")219 for key in ['id', 'cidr']:220 self.assertIn(key, subnet)221 self.assertEqual(subnet[key], self.subnet[key])222 @test.attr(type='smoke')223 @test.idempotent_id('270fff0b-8bfc-411f-a184-1e8fd35286f0')224 def test_show_subnet_fields(self):225 # Verify specific fields of a subnet226 fields = ['id', 'network_id']227 body = self.client.show_subnet(self.subnet['id'],228 fields=fields)229 subnet = body['subnet']230 self.assertEqual(sorted(subnet.keys()), sorted(fields))231 for field_name in fields:232 self.assertEqual(subnet[field_name], self.subnet[field_name])233 @test.attr(type='smoke')234 @test.idempotent_id('db68ba48-f4ea-49e9-81d1-e367f6d0b20a')235 def test_list_subnets(self):236 # Verify the subnet exists in the list of all subnets237 body = self.client.list_subnets()238 subnets = [subnet['id'] for subnet in body['subnets']239 if subnet['id'] == self.subnet['id']]240 self.assertNotEmpty(subnets, "Created subnet not found in the list")241 @test.attr(type='smoke')242 @test.idempotent_id('842589e3-9663-46b0-85e4-7f01273b0412')243 def test_list_subnets_fields(self):244 # Verify specific fields of subnets245 fields = ['id', 'network_id']246 body = self.client.list_subnets(fields=fields)247 subnets = body['subnets']248 self.assertNotEmpty(subnets, "Subnet list returned is empty")249 for subnet in subnets:250 self.assertEqual(sorted(subnet.keys()), sorted(fields))251 def _try_delete_network(self, net_id):252 # delete network, if it exists253 try:254 self.client.delete_network(net_id)255 # if network is not found, this means it was deleted in the test256 except lib_exc.NotFound:257 pass258 @test.attr(type='smoke')259 @test.idempotent_id('f04f61a9-b7f3-4194-90b2-9bcf660d1bfe')260 def test_delete_network_with_subnet(self):261 # Creates a network262 name = data_utils.rand_name('network-')263 body = self.client.create_network(name=name)264 network = body['network']265 net_id = network['id']266 self.addCleanup(self._try_delete_network, net_id)267 # Find a cidr that is not in use yet and create a subnet with it268 subnet = self.create_subnet(network)269 subnet_id = subnet['id']270 # Delete network while the subnet still exists271 body = self.client.delete_network(net_id)272 # Verify that the subnet got automatically deleted.273 self.assertRaises(lib_exc.NotFound, self.client.show_subnet,274 subnet_id)275 # Since create_subnet adds the subnet to the delete list, and it is276 # is actually deleted here - this will create and issue, hence remove277 # it from the list.278 self.subnets.pop()279 @test.attr(type='smoke')280 @test.idempotent_id('d2d596e2-8e76-47a9-ac51-d4648009f4d3')281 def test_create_delete_subnet_without_gateway(self):282 self._create_verify_delete_subnet()283 @test.attr(type='smoke')284 @test.idempotent_id('9393b468-186d-496d-aa36-732348cd76e7')285 def test_create_delete_subnet_with_gw(self):286 self._create_verify_delete_subnet(287 **self.subnet_dict(['gateway']))288 @test.attr(type='smoke')289 @test.idempotent_id('bec949c4-3147-4ba6-af5f-cd2306118404')290 def test_create_delete_subnet_with_allocation_pools(self):291 self._create_verify_delete_subnet(292 **self.subnet_dict(['allocation_pools']))293 @test.attr(type='smoke')294 @test.idempotent_id('8217a149-0c6c-4cfb-93db-0486f707d13f')295 def test_create_delete_subnet_with_gw_and_allocation_pools(self):296 self._create_verify_delete_subnet(**self.subnet_dict(297 ['gateway', 'allocation_pools']))298 @test.attr(type='smoke')299 @test.idempotent_id('d830de0a-be47-468f-8f02-1fd996118289')300 def test_create_delete_subnet_with_host_routes_and_dns_nameservers(self):301 self._create_verify_delete_subnet(302 **self.subnet_dict(['host_routes', 'dns_nameservers']))303 @test.attr(type='smoke')304 @test.idempotent_id('94ce038d-ff0a-4a4c-a56b-09da3ca0b55d')305 def test_create_delete_subnet_with_dhcp_enabled(self):306 self._create_verify_delete_subnet(enable_dhcp=True)307 @test.attr(type='smoke')308 @test.idempotent_id('3d3852eb-3009-49ec-97ac-5ce83b73010a')309 def test_update_subnet_gw_dns_host_routes_dhcp(self):310 network = self.create_network()311 self.addCleanup(self._delete_network, network)312 subnet = self.create_subnet(313 network, **self.subnet_dict(['gateway', 'host_routes',314 'dns_nameservers',315 'allocation_pools']))316 subnet_id = subnet['id']317 new_gateway = str(netaddr.IPAddress(318 self._subnet_data[self._ip_version]['gateway']) + 1)319 # Verify subnet update320 new_host_routes = self._subnet_data[self._ip_version][321 'new_host_routes']322 new_dns_nameservers = self._subnet_data[self._ip_version][323 'new_dns_nameservers']324 kwargs = {'host_routes': new_host_routes,325 'dns_nameservers': new_dns_nameservers,326 'gateway_ip': new_gateway, 'enable_dhcp': True}327 new_name = "New_subnet"328 body = self.client.update_subnet(subnet_id, name=new_name,329 **kwargs)330 updated_subnet = body['subnet']331 kwargs['name'] = new_name332 self.assertEqual(sorted(updated_subnet['dns_nameservers']),333 sorted(kwargs['dns_nameservers']))334 del subnet['dns_nameservers'], kwargs['dns_nameservers']335 self._compare_resource_attrs(updated_subnet, kwargs)336 @test.attr(type='smoke')337 @test.idempotent_id('a4d9ec4c-0306-4111-a75c-db01a709030b')338 def test_create_delete_subnet_all_attributes(self):339 self._create_verify_delete_subnet(340 enable_dhcp=True,341 **self.subnet_dict(['gateway', 'host_routes', 'dns_nameservers']))342 @test.attr(type='smoke')343 @test.idempotent_id('af774677-42a9-4e4b-bb58-16fe6a5bc1ec')344 def test_external_network_visibility(self):345 """Verifies user can see external networks but not subnets."""346 body = self.client.list_networks(**{'router:external': True})347 networks = [network['id'] for network in body['networks']]348 self.assertNotEmpty(networks, "No external networks found")349 nonexternal = [net for net in body['networks'] if350 not net['router:external']]351 self.assertEmpty(nonexternal, "Found non-external networks"352 " in filtered list (%s)." % nonexternal)353 self.assertIn(CONF.network.public_network_id, networks)354 subnets_iter = (network['subnets'] for network in body['networks'])355 # subnets_iter is a list (iterator) of lists. This flattens it to a356 # list of UUIDs357 public_subnets_iter = itertools.chain(*subnets_iter)358 body = self.client.list_subnets()359 subnets = [sub['id'] for sub in body['subnets']360 if sub['id'] in public_subnets_iter]361 self.assertEmpty(subnets, "Public subnets visible")362class BulkNetworkOpsTestJSON(base.BaseNetworkTest):363 """364 Tests the following operations in the Neutron API using the REST client for365 Neutron:366 bulk network creation367 bulk subnet creation368 bulk port creation369 list tenant's networks370 v2.0 of the Neutron API is assumed. It is also assumed that the following371 options are defined in the [network] section of etc/tempest.conf:372 tenant_network_cidr with a block of cidr's from which smaller blocks373 can be allocated for tenant networks374 tenant_network_mask_bits with the mask bits to be used to partition the375 block defined by tenant-network_cidr376 """377 def _delete_networks(self, created_networks):378 for n in created_networks:379 self.client.delete_network(n['id'])380 # Asserting that the networks are not found in the list after deletion381 body = self.client.list_networks()382 networks_list = [network['id'] for network in body['networks']]383 for n in created_networks:384 self.assertNotIn(n['id'], networks_list)385 def _delete_subnets(self, created_subnets):386 for n in created_subnets:387 self.client.delete_subnet(n['id'])388 # Asserting that the subnets are not found in the list after deletion389 body = self.client.list_subnets()390 subnets_list = [subnet['id'] for subnet in body['subnets']]391 for n in created_subnets:392 self.assertNotIn(n['id'], subnets_list)393 def _delete_ports(self, created_ports):394 for n in created_ports:395 self.client.delete_port(n['id'])396 # Asserting that the ports are not found in the list after deletion397 body = self.client.list_ports()398 ports_list = [port['id'] for port in body['ports']]399 for n in created_ports:400 self.assertNotIn(n['id'], ports_list)401 @test.attr(type='smoke')402 @test.idempotent_id('d4f9024d-1e28-4fc1-a6b1-25dbc6fa11e2')403 def test_bulk_create_delete_network(self):404 # Creates 2 networks in one request405 network_names = [data_utils.rand_name('network-'),406 data_utils.rand_name('network-')]407 body = self.client.create_bulk_network(network_names)408 created_networks = body['networks']409 self.addCleanup(self._delete_networks, created_networks)410 # Asserting that the networks are found in the list after creation411 body = self.client.list_networks()412 networks_list = [network['id'] for network in body['networks']]413 for n in created_networks:414 self.assertIsNotNone(n['id'])415 self.assertIn(n['id'], networks_list)416 @test.attr(type='smoke')417 @test.idempotent_id('8936533b-c0aa-4f29-8e53-6cc873aec489')418 def test_bulk_create_delete_subnet(self):419 networks = [self.create_network(), self.create_network()]420 # Creates 2 subnets in one request421 if self._ip_version == 4:422 cidr = netaddr.IPNetwork(CONF.network.tenant_network_cidr)423 mask_bits = CONF.network.tenant_network_mask_bits424 else:425 cidr = netaddr.IPNetwork(CONF.network.tenant_network_v6_cidr)426 mask_bits = CONF.network.tenant_network_v6_mask_bits427 cidrs = [subnet_cidr for subnet_cidr in cidr.subnet(mask_bits)]428 names = [data_utils.rand_name('subnet-') for i in range(len(networks))]429 subnets_list = []430 for i in range(len(names)):431 p1 = {432 'network_id': networks[i]['id'],433 'cidr': str(cidrs[(i)]),434 'name': names[i],435 'ip_version': self._ip_version436 }437 subnets_list.append(p1)438 del subnets_list[1]['name']439 body = self.client.create_bulk_subnet(subnets_list)440 created_subnets = body['subnets']441 self.addCleanup(self._delete_subnets, created_subnets)442 # Asserting that the subnets are found in the list after creation443 body = self.client.list_subnets()444 subnets_list = [subnet['id'] for subnet in body['subnets']]445 for n in created_subnets:446 self.assertIsNotNone(n['id'])447 self.assertIn(n['id'], subnets_list)448 @test.attr(type='smoke')449 @test.idempotent_id('48037ff2-e889-4c3b-b86a-8e3f34d2d060')450 def test_bulk_create_delete_port(self):451 networks = [self.create_network(), self.create_network()]452 # Creates 2 ports in one request453 names = [data_utils.rand_name('port-') for i in range(len(networks))]454 port_list = []455 state = [True, False]456 for i in range(len(names)):457 p1 = {458 'network_id': networks[i]['id'],459 'name': names[i],460 'admin_state_up': state[i],461 }462 port_list.append(p1)463 del port_list[1]['name']464 body = self.client.create_bulk_port(port_list)465 created_ports = body['ports']466 self.addCleanup(self._delete_ports, created_ports)467 # Asserting that the ports are found in the list after creation468 body = self.client.list_ports()469 ports_list = [port['id'] for port in body['ports']]470 for n in created_ports:471 self.assertIsNotNone(n['id'])472 self.assertIn(n['id'], ports_list)473class BulkNetworkOpsIpV6TestJSON(BulkNetworkOpsTestJSON):474 _ip_version = 6475class NetworksIpV6TestJSON(NetworksTestJSON):476 _ip_version = 6477 @test.attr(type='smoke')478 @test.idempotent_id('e41a4888-65a6-418c-a095-f7c2ef4ad59a')479 def test_create_delete_subnet_with_gw(self):480 net = netaddr.IPNetwork(CONF.network.tenant_network_v6_cidr)481 gateway = str(netaddr.IPAddress(net.first + 2))482 name = data_utils.rand_name('network-')483 network = self.create_network(network_name=name)484 subnet = self.create_subnet(network, gateway)485 # Verifies Subnet GW in IPv6486 self.assertEqual(subnet['gateway_ip'], gateway)487 @test.attr(type='smoke')488 @test.idempotent_id('ebb4fd95-524f-46af-83c1-0305b239338f')489 def test_create_delete_subnet_with_default_gw(self):490 net = netaddr.IPNetwork(CONF.network.tenant_network_v6_cidr)491 gateway_ip = str(netaddr.IPAddress(net.first + 1))492 name = data_utils.rand_name('network-')493 network = self.create_network(network_name=name)494 subnet = self.create_subnet(network)495 # Verifies Subnet GW in IPv6496 self.assertEqual(subnet['gateway_ip'], gateway_ip)497 @test.attr(type='smoke')498 @test.idempotent_id('a9653883-b2a4-469b-8c3c-4518430a7e55')499 def test_create_list_subnet_with_no_gw64_one_network(self):500 name = data_utils.rand_name('network-')501 network = self.create_network(name)502 ipv6_gateway = self.subnet_dict(['gateway'])['gateway']503 subnet1 = self.create_subnet(network,504 ip_version=6,505 gateway=ipv6_gateway)506 self.assertEqual(netaddr.IPNetwork(subnet1['cidr']).version, 6,507 'The created subnet is not IPv6')508 subnet2 = self.create_subnet(network,509 gateway=None,510 ip_version=4)511 self.assertEqual(netaddr.IPNetwork(subnet2['cidr']).version, 4,512 'The created subnet is not IPv4')513 # Verifies Subnet GW is set in IPv6514 self.assertEqual(subnet1['gateway_ip'], ipv6_gateway)515 # Verifies Subnet GW is None in IPv4516 self.assertEqual(subnet2['gateway_ip'], None)517 # Verifies all 2 subnets in the same network518 body = self.client.list_subnets()519 subnets = [sub['id'] for sub in body['subnets']520 if sub['network_id'] == network['id']]521 test_subnet_ids = [sub['id'] for sub in (subnet1, subnet2)]522 self.assertItemsEqual(subnets,523 test_subnet_ids,524 'Subnet are not in the same network')525class NetworksIpV6TestAttrs(NetworksIpV6TestJSON):526 @classmethod527 def resource_setup(cls):528 if not CONF.network_feature_enabled.ipv6_subnet_attributes:529 raise cls.skipException("IPv6 extended attributes for "530 "subnets not available")531 super(NetworksIpV6TestAttrs, cls).resource_setup()532 @test.attr(type='smoke')533 @test.idempotent_id('da40cd1b-a833-4354-9a85-cd9b8a3b74ca')534 def test_create_delete_subnet_with_v6_attributes_stateful(self):535 self._create_verify_delete_subnet(536 gateway=self._subnet_data[self._ip_version]['gateway'],537 ipv6_ra_mode='dhcpv6-stateful',538 ipv6_address_mode='dhcpv6-stateful')539 @test.attr(type='smoke')540 @test.idempotent_id('176b030f-a923-4040-a755-9dc94329e60c')541 def test_create_delete_subnet_with_v6_attributes_slaac(self):542 self._create_verify_delete_subnet(543 ipv6_ra_mode='slaac',544 ipv6_address_mode='slaac')545 @test.attr(type='smoke')546 @test.idempotent_id('7d410310-8c86-4902-adf9-865d08e31adb')547 def test_create_delete_subnet_with_v6_attributes_stateless(self):548 self._create_verify_delete_subnet(549 ipv6_ra_mode='dhcpv6-stateless',550 ipv6_address_mode='dhcpv6-stateless')551 def _test_delete_subnet_with_ports(self, mode):552 """Create subnet and delete it with existing ports"""553 slaac_network = self.create_network()554 subnet_slaac = self.create_subnet(slaac_network,555 **{'ipv6_ra_mode': mode,556 'ipv6_address_mode': mode})557 port = self.create_port(slaac_network)558 self.assertIsNotNone(port['fixed_ips'][0]['ip_address'])559 self.client.delete_subnet(subnet_slaac['id'])560 self.subnets.pop()561 subnets = self.client.list_subnets()562 subnet_ids = [subnet['id'] for subnet in subnets['subnets']]...

Full Screen

Full Screen

test_subnets.py

Source:test_subnets.py Github

copy

Full Screen

...186 def _compare_resource_attrs(self, actual, expected):187 exclude_keys = set(actual).symmetric_difference(expected)188 self.assertThat(actual, custom_matchers.MatchesDictExceptForKeys(189 expected, exclude_keys))190 def _create_verify_delete_subnet(self, cidr=None, mask_bits=None,191 **kwargs):192 network = self._create_network(_auto_clean_up=True)193 net_id = network['id']194 gateway = kwargs.pop('gateway', None)195 subnet = self._create_subnet(network, gateway, cidr, mask_bits,196 **kwargs)197 compare_args_full = dict(gateway_ip=gateway, cidr=cidr,198 mask_bits=mask_bits, **kwargs)199 compare_args = (dict((k, v)200 for k, v in six.iteritems(compare_args_full)201 if v is not None))202 if 'dns_nameservers' in set(subnet).intersection(compare_args):203 self.assertEqual(sorted(compare_args['dns_nameservers']),204 sorted(subnet['dns_nameservers']))205 del subnet['dns_nameservers'], compare_args['dns_nameservers']206 self._compare_resource_attrs(subnet, compare_args)207 self._delete_network(net_id)208 @decorators.idempotent_id('2ecbc3ab-93dd-44bf-a827-95beeb008e9a')209 def test_create_update_delete_network_subnet(self):210 # Create a network211 network = self._create_network(_auto_clean_up=True)212 net_id = network['id']213 self.assertEqual('ACTIVE', network['status'])214 # Verify network update215 new_name = data_utils.rand_name('new-adm-netwk')216 body = self.update_network(net_id, name=new_name)217 updated_net = body['network']218 self.assertEqual(updated_net['name'], new_name)219 # Find a cidr that is not in use yet and create a subnet with it220 subnet = self._create_subnet(network)221 subnet_id = subnet['id']222 # Verify subnet update223 new_name = data_utils.rand_name('new-subnet')224 body = self.update_subnet(subnet_id, name=new_name)225 updated_subnet = body['subnet']226 self.assertEqual(updated_subnet['name'], new_name)227 self._delete_network(net_id)228 @decorators.idempotent_id('a2cf6398-aece-4256-88a6-0dfe8aa44975')229 def test_show_network(self):230 # Verify the details of a network231 body = self.show_network(self.network['id'])232 network = body['network']233 for key in ['id', 'name']:234 self.assertEqual(network[key], self.network[key])235 @decorators.idempotent_id('5b42067d-4b9d-4f04-bb6a-adb9756ebe0c')236 def test_show_network_fields(self):237 # Verify specific fields of a network238 fields = ['id', 'name']239 body = self.show_network(self.network['id'], fields=fields)240 network = body['network']241 self.assertEqual(sorted(network.keys()), sorted(fields))242 for field_name in fields:243 self.assertEqual(network[field_name], self.network[field_name])244 @decorators.idempotent_id('324be3c2-457d-4e21-b0b3-5106bbbf1a28')245 def test_list_networks(self):246 # Verify the network exists in the list of all networks247 body = self.list_networks()248 networks = [network['id'] for network in body['networks']249 if network['id'] == self.network['id']]250 self.assertNotEmpty(networks, "Created network not found in the list")251 @decorators.idempotent_id('3a934a8d-6b52-427e-af49-3dfdd224fdeb')252 def test_list_networks_fields(self):253 # Verify specific fields of the networks254 fields = ['id', 'name']255 body = self.list_networks(fields=fields)256 networks = body['networks']257 self.assertNotEmpty(networks, "Network list returned is empty")258 for network in networks:259 self.assertEqual(sorted(network.keys()), sorted(fields))260 @decorators.idempotent_id('5f6616c4-bfa7-4308-8eab-f45d75c94c6d')261 def test_show_subnet(self):262 # Verify the details of a subnet263 body = self.show_subnet(self.subnet['id'])264 subnet = body['subnet']265 self.assertNotEmpty(subnet, "Subnet returned has no fields")266 for key in ['id', 'cidr']:267 self.assertIn(key, subnet)268 self.assertEqual(subnet[key], self.subnet[key])269 @decorators.idempotent_id('2f326955-551e-4e9e-a4f6-e5db77c34c8d')270 def test_show_subnet_fields(self):271 # Verify specific fields of a subnet272 fields = ['id', 'network_id']273 body = self.show_subnet(self.subnet['id'], fields=fields)274 subnet = body['subnet']275 self.assertEqual(sorted(subnet.keys()), sorted(fields))276 for field_name in fields:277 self.assertEqual(subnet[field_name], self.subnet[field_name])278 @decorators.idempotent_id('66631557-2466-4827-bba6-d961b0242be3')279 def test_list_subnets(self):280 # Verify the subnet exists in the list of all subnets281 body = self.list_subnets()282 subnets = [subnet['id'] for subnet in body['subnets']283 if subnet['id'] == self.subnet['id']]284 self.assertNotEmpty(subnets, "Created subnet not found in the list")285 @decorators.idempotent_id('3d5ea69b-f122-43e7-b7f4-c78586629eb8')286 def test_list_subnets_fields(self):287 # Verify specific fields of subnets288 fields = ['id', 'network_id']289 body = self.list_subnets(fields=fields)290 subnets = body['subnets']291 self.assertNotEmpty(subnets, "Subnet list returned is empty")292 for subnet in subnets:293 self.assertEqual(sorted(subnet.keys()), sorted(fields))294 @decorators.idempotent_id('e966bb2f-402c-49b7-8147-b275cee584c4')295 def test_delete_network_with_subnet(self):296 # Creates a network297 network = self._create_network(_auto_clean_up=True)298 net_id = network['id']299 # Find a cidr that is not in use yet and create a subnet with it300 subnet = self._create_subnet(network)301 subnet_id = subnet['id']302 # Delete network while the subnet still exists303 self._delete_network(net_id)304 # Verify that the subnet got automatically deleted.305 self.assertRaises(exceptions.NotFound,306 self.show_subnet, subnet_id)307 @decorators.idempotent_id('8aba0e1b-4b70-4181-a8a4-792c08db699d')308 def test_create_delete_subnet_without_gateway(self):309 self._create_verify_delete_subnet()310 @decorators.idempotent_id('67364a4b-6725-4dbe-84cf-504bdb20ac06')311 def test_create_delete_subnet_with_gw(self):312 self._create_verify_delete_subnet(313 **self.subnet_dict(['gateway']))314 @decorators.idempotent_id('f8f43e65-5090-4902-b5d2-2b610505cca6')315 def test_create_delete_subnet_with_allocation_pools(self):316 self._create_verify_delete_subnet(317 **self.subnet_dict(['allocation_pools']))318 @decorators.idempotent_id('5b085669-97e6-48e0-b99e-315a9b4d8482')319 def test_create_delete_subnet_with_gw_and_allocation_pools(self):320 self._create_verify_delete_subnet(**self.subnet_dict(321 ['gateway', 'allocation_pools']))322 @decorators.skip_because(bug="1501827")323 @decorators.idempotent_id('3c4c36a1-684b-4e89-8e71-d528f19322a0')324 def test_create_delete_subnet_with_host_routes_and_dns_nameservers(self):325 self._create_verify_delete_subnet(326 **self.subnet_dict(['host_routes', 'dns_nameservers']))327 @decorators.idempotent_id('df518c87-b817-48b5-9365-bd1daaf68955')328 def test_create_delete_subnet_with_dns_nameservers(self):329 self._create_verify_delete_subnet(330 **self.subnet_dict(['dns_nameservers']))331 @decorators.idempotent_id('b6822feb-6760-4052-b550-f0fe8bac7451')332 def test_create_delete_subnet_with_dhcp_enabled(self):333 self._create_verify_delete_subnet(enable_dhcp=True)334 @decorators.skip_because(bug="1501827")335 @decorators.idempotent_id('3c4c36a1-684a-4e89-8e71-d528f19324a0')336 def test_update_subnet_gw_dns_host_routes_dhcp(self):337 network = self._create_network(_auto_clean_up=True)338 subnet_attrs = ['gateway', 'host_routes',339 'dns_nameservers', 'allocation_pools']340 subnet_dict = self.subnet_dict(subnet_attrs)341 subnet = self._create_subnet(network, **subnet_dict)342 subnet_id = subnet['id']343 new_gateway = str(netaddr.IPAddress(344 self._subnet_data[self._ip_version]['gateway']) + 1)345 # Verify subnet update346 new_host_routes = self._subnet_data[self._ip_version][347 'new_host_routes']348 new_dns_nameservers = self._subnet_data[self._ip_version][349 'new_dns_nameservers']350 kwargs = {'host_routes': new_host_routes,351 'dns_nameservers': new_dns_nameservers,352 'gateway_ip': new_gateway, 'enable_dhcp': True}353 new_name = "New_subnet"354 body = self.update_subnet(subnet_id, name=new_name, **kwargs)355 updated_subnet = body['subnet']356 kwargs['name'] = new_name357 self.assertEqual(sorted(updated_subnet['dns_nameservers']),358 sorted(kwargs['dns_nameservers']))359 del subnet['dns_nameservers'], kwargs['dns_nameservers']360 self._compare_resource_attrs(updated_subnet, kwargs)361 self._delete_network(network['id'])362 @decorators.idempotent_id('a5caa7d9-ab71-4278-a57c-d6631b7474f8')363 def test_update_subnet_gw_dns_dhcp(self):364 network = self._create_network(_auto_clean_up=True)365 subnet_attrs = ['gateway',366 'dns_nameservers', 'allocation_pools']367 subnet_dict = self.subnet_dict(subnet_attrs)368 subnet = self._create_subnet(network, **subnet_dict)369 subnet_id = subnet['id']370 new_gateway = str(netaddr.IPAddress(371 self._subnet_data[self._ip_version]['gateway']) + 1)372 # Verify subnet update373 new_dns_nameservers = self._subnet_data[self._ip_version][374 'new_dns_nameservers']375 kwargs = {'dns_nameservers': new_dns_nameservers,376 'gateway_ip': new_gateway, 'enable_dhcp': True}377 new_name = "New_subnet"378 body = self.update_subnet(subnet_id, name=new_name, **kwargs)379 updated_subnet = body['subnet']380 kwargs['name'] = new_name381 self.assertEqual(sorted(updated_subnet['dns_nameservers']),382 sorted(kwargs['dns_nameservers']))383 del subnet['dns_nameservers'], kwargs['dns_nameservers']384 self._compare_resource_attrs(updated_subnet, kwargs)385 self._delete_network(network['id'])386 @decorators.skip_because(bug="1501827")387 @decorators.idempotent_id('a5caa7d5-ab71-4278-a57c-d6631b7474f8')388 def test_create_delete_subnet_all_attributes(self):389 self._create_verify_delete_subnet(390 enable_dhcp=True,391 **self.subnet_dict(['gateway',392 'host_routes',393 'dns_nameservers']))394 @decorators.idempotent_id('a5caa7d9-ab71-4278-a57c-d6631b7474c8')395 def test_create_delete_subnet_with_gw_dns(self):396 self._create_verify_delete_subnet(397 enable_dhcp=True,398 **self.subnet_dict(['gateway',399 'dns_nameservers']))400 @decorators.idempotent_id('3c4c36a1-684b-4e89-8e71-d518f19324a0')401 def test_add_upd_del_multiple_overlapping_networks_subnet(self):402 r0, R1 = 0, 3 # (todo) get from CONF403 return self._add_upd_del_multiple_networks_subnet(404 r0, R1, "ovla-netwk")405 @decorators.idempotent_id('5267bf9d-de82-4af9-914a-8320e9f4c38c')406 def test_add_upd_del_multiple_nonoverlapping_networks_subnet(self):407 r0, R1 = 1, 4 # (todo) get from CONF408 return self._add_upd_del_multiple_networks_subnet(409 r0, R1, "noov-netwk", _step_cidr=2)410 def _add_upd_del_multiple_networks_subnet(self, r0, R1,...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful