blob: ac0fd11e3d05774df41198ef0cf9c39122c0cb87 [file] [log] [blame]
ZhiQiang Fan39f97222013-09-20 04:49:44 +08001# Copyright 2012 OpenStack Foundation
Jay Pipesf4dad392012-06-05 16:03:58 -04002# All Rights Reserved.
3#
4# Licensed under the Apache License, Version 2.0 (the "License"); you may
5# not use this file except in compliance with the License. You may obtain
6# a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13# License for the specific language governing permissions and limitations
14# under the License.
15
Miguel Lavallecc939612013-02-22 17:27:20 -060016import netaddr
Jay Pipesf4dad392012-06-05 16:03:58 -040017
Sean Dague1937d092013-05-17 16:36:38 -040018from tempest.api.network import base
Masayuki Igawa259c1132013-10-31 17:48:44 +090019from tempest.common.utils import data_utils
Matthew Treinish03b48df2014-01-29 16:59:49 +000020from tempest import config
sukhdevc704a702014-01-15 11:50:56 -080021from tempest import exceptions
Masayuki Igawa6d495d62014-03-19 16:38:57 +090022from tempest import test
Unmesh Gurjar44986832012-05-08 19:57:10 +053023
Matthew Treinish03b48df2014-01-29 16:59:49 +000024CONF = config.CONF
25
Unmesh Gurjar44986832012-05-08 19:57:10 +053026
raiesmh0867698322013-08-20 13:09:01 +053027class NetworksTestJSON(base.BaseNetworkTest):
28 _interface = 'json'
Unmesh Gurjar44986832012-05-08 19:57:10 +053029
Miguel Lavallecc939612013-02-22 17:27:20 -060030 """
Mark McClainf2982e82013-07-06 17:48:03 -040031 Tests the following operations in the Neutron API using the REST client for
32 Neutron:
Miguel Lavallecc939612013-02-22 17:27:20 -060033
34 create a network for a tenant
35 list tenant's networks
36 show a tenant network details
37 create a subnet for a tenant
38 list tenant's subnets
39 show a tenant subnet details
raiesmh08e1aad982013-08-05 14:19:36 +053040 network update
41 subnet update
sukhdevc704a702014-01-15 11:50:56 -080042 delete a network also deletes its subnets
Miguel Lavallecc939612013-02-22 17:27:20 -060043
Henry Gessauffda37a2014-01-16 11:17:55 -050044 All subnet tests are run once with ipv4 and once with ipv6.
45
Mark McClainf2982e82013-07-06 17:48:03 -040046 v2.0 of the Neutron API is assumed. It is also assumed that the following
Miguel Lavallecc939612013-02-22 17:27:20 -060047 options are defined in the [network] section of etc/tempest.conf:
48
49 tenant_network_cidr with a block of cidr's from which smaller blocks
Henry Gessauffda37a2014-01-16 11:17:55 -050050 can be allocated for tenant ipv4 subnets
51
52 tenant_network_v6_cidr is the equivalent for ipv6 subnets
Miguel Lavallecc939612013-02-22 17:27:20 -060053
54 tenant_network_mask_bits with the mask bits to be used to partition the
Henry Gessauffda37a2014-01-16 11:17:55 -050055 block defined by tenant_network_cidr
56
57 tenant_network_v6_mask_bits is the equivalent for ipv6 subnets
Miguel Lavallecc939612013-02-22 17:27:20 -060058 """
59
Unmesh Gurjar44986832012-05-08 19:57:10 +053060 @classmethod
Masayuki Igawa6d495d62014-03-19 16:38:57 +090061 @test.safe_setup
Unmesh Gurjar44986832012-05-08 19:57:10 +053062 def setUpClass(cls):
raiesmh0867698322013-08-20 13:09:01 +053063 super(NetworksTestJSON, cls).setUpClass()
Jay Pipesf4dad392012-06-05 16:03:58 -040064 cls.network = cls.create_network()
65 cls.name = cls.network['name']
Miguel Lavallecc939612013-02-22 17:27:20 -060066 cls.subnet = cls.create_subnet(cls.network)
67 cls.cidr = cls.subnet['cidr']
Unmesh Gurjar44986832012-05-08 19:57:10 +053068
Masayuki Igawa6d495d62014-03-19 16:38:57 +090069 @test.attr(type='smoke')
raiesmh08e1aad982013-08-05 14:19:36 +053070 def test_create_update_delete_network_subnet(self):
Mark Maglana5885eb32014-02-28 10:57:34 -080071 # Create a network
Masayuki Igawa259c1132013-10-31 17:48:44 +090072 name = data_utils.rand_name('network-')
Eugene Nikanorove9d255a2013-12-18 16:31:42 +040073 resp, body = self.client.create_network(name=name)
Miguel Lavallecc939612013-02-22 17:27:20 -060074 self.assertEqual('201', resp['status'])
Unmesh Gurjar44986832012-05-08 19:57:10 +053075 network = body['network']
raiesmh08e1aad982013-08-05 14:19:36 +053076 net_id = network['id']
Mark Maglana5885eb32014-02-28 10:57:34 -080077 # Verify network update
raiesmh08e1aad982013-08-05 14:19:36 +053078 new_name = "New_network"
Eugene Nikanorove9d255a2013-12-18 16:31:42 +040079 resp, body = self.client.update_network(net_id, name=new_name)
raiesmh08e1aad982013-08-05 14:19:36 +053080 self.assertEqual('200', resp['status'])
81 updated_net = body['network']
82 self.assertEqual(updated_net['name'], new_name)
Miguel Lavallecc939612013-02-22 17:27:20 -060083 # Find a cidr that is not in use yet and create a subnet with it
Matthew Treinish6b8cd2a2014-03-03 20:45:56 +000084 subnet = self.create_subnet(network)
raiesmh08e1aad982013-08-05 14:19:36 +053085 subnet_id = subnet['id']
Mark Maglana5885eb32014-02-28 10:57:34 -080086 # Verify subnet update
87 new_name = "New_subnet"
88 resp, body = self.client.update_subnet(subnet_id, name=new_name)
raiesmh08e1aad982013-08-05 14:19:36 +053089 self.assertEqual('200', resp['status'])
90 updated_subnet = body['subnet']
Mark Maglana5885eb32014-02-28 10:57:34 -080091 self.assertEqual(updated_subnet['name'], new_name)
raiesmh0867698322013-08-20 13:09:01 +053092 # Delete subnet and network
raiesmh08e1aad982013-08-05 14:19:36 +053093 resp, body = self.client.delete_subnet(subnet_id)
Miguel Lavallecc939612013-02-22 17:27:20 -060094 self.assertEqual('204', resp['status'])
Matthew Treinish6b8cd2a2014-03-03 20:45:56 +000095 # Remove subnet from cleanup list
96 self.subnets.pop()
raiesmh08e1aad982013-08-05 14:19:36 +053097 resp, body = self.client.delete_network(net_id)
Unmesh Gurjar44986832012-05-08 19:57:10 +053098 self.assertEqual('204', resp['status'])
99
Masayuki Igawa6d495d62014-03-19 16:38:57 +0900100 @test.attr(type='smoke')
Unmesh Gurjar44986832012-05-08 19:57:10 +0530101 def test_show_network(self):
Mark Maglana5885eb32014-02-28 10:57:34 -0800102 # Verify the details of a network
Miguel Lavallecc939612013-02-22 17:27:20 -0600103 resp, body = self.client.show_network(self.network['id'])
Unmesh Gurjar44986832012-05-08 19:57:10 +0530104 self.assertEqual('200', resp['status'])
105 network = body['network']
Mark Maglana5885eb32014-02-28 10:57:34 -0800106 for key in ['id', 'name']:
107 self.assertEqual(network[key], self.network[key])
Unmesh Gurjar44986832012-05-08 19:57:10 +0530108
Masayuki Igawa6d495d62014-03-19 16:38:57 +0900109 @test.attr(type='smoke')
jun xied557d9b2014-01-09 14:00:36 +0800110 def test_show_network_fields(self):
Mark Maglana5885eb32014-02-28 10:57:34 -0800111 # Verify specific fields of a network
Zhi Kun Liu903596c2014-04-11 08:55:53 -0500112 fields = ['id', 'name']
jun xied557d9b2014-01-09 14:00:36 +0800113 resp, body = self.client.show_network(self.network['id'],
Zhi Kun Liu903596c2014-04-11 08:55:53 -0500114 fields=fields)
jun xied557d9b2014-01-09 14:00:36 +0800115 self.assertEqual('200', resp['status'])
116 network = body['network']
Zhi Kun Liu903596c2014-04-11 08:55:53 -0500117 self.assertEqual(sorted(network.keys()), sorted(fields))
118 for field_name in fields:
Mark Maglana5885eb32014-02-28 10:57:34 -0800119 self.assertEqual(network[field_name], self.network[field_name])
jun xied557d9b2014-01-09 14:00:36 +0800120
Masayuki Igawa6d495d62014-03-19 16:38:57 +0900121 @test.attr(type='smoke')
Unmesh Gurjar44986832012-05-08 19:57:10 +0530122 def test_list_networks(self):
Sean Dague46c4a2b2013-01-03 17:54:17 -0500123 # Verify the network exists in the list of all networks
Unmesh Gurjar44986832012-05-08 19:57:10 +0530124 resp, body = self.client.list_networks()
raiesmh0867698322013-08-20 13:09:01 +0530125 self.assertEqual('200', resp['status'])
Mark Maglana5885eb32014-02-28 10:57:34 -0800126 networks = [network['id'] for network in body['networks']
127 if network['id'] == self.network['id']]
128 self.assertNotEmpty(networks, "Created network not found in the list")
Unmesh Gurjar44986832012-05-08 19:57:10 +0530129
Masayuki Igawa6d495d62014-03-19 16:38:57 +0900130 @test.attr(type='smoke')
jun xie0b4735d2014-01-07 15:42:58 +0800131 def test_list_networks_fields(self):
Mark Maglana5885eb32014-02-28 10:57:34 -0800132 # Verify specific fields of the networks
Zhi Kun Liu903596c2014-04-11 08:55:53 -0500133 fields = ['id', 'name']
134 resp, body = self.client.list_networks(fields=fields)
jun xie0b4735d2014-01-07 15:42:58 +0800135 self.assertEqual('200', resp['status'])
136 networks = body['networks']
Mark Maglana5885eb32014-02-28 10:57:34 -0800137 self.assertNotEmpty(networks, "Network list returned is empty")
138 for network in networks:
Zhi Kun Liu903596c2014-04-11 08:55:53 -0500139 self.assertEqual(sorted(network.keys()), sorted(fields))
jun xie0b4735d2014-01-07 15:42:58 +0800140
Masayuki Igawa6d495d62014-03-19 16:38:57 +0900141 @test.attr(type='smoke')
Miguel Lavallecc939612013-02-22 17:27:20 -0600142 def test_show_subnet(self):
Mark Maglana5885eb32014-02-28 10:57:34 -0800143 # Verify the details of a subnet
Miguel Lavallecc939612013-02-22 17:27:20 -0600144 resp, body = self.client.show_subnet(self.subnet['id'])
145 self.assertEqual('200', resp['status'])
146 subnet = body['subnet']
Mark Maglana5885eb32014-02-28 10:57:34 -0800147 self.assertNotEmpty(subnet, "Subnet returned has no fields")
148 for key in ['id', 'cidr']:
149 self.assertIn(key, subnet)
150 self.assertEqual(subnet[key], self.subnet[key])
Miguel Lavallecc939612013-02-22 17:27:20 -0600151
Masayuki Igawa6d495d62014-03-19 16:38:57 +0900152 @test.attr(type='smoke')
jun xied557d9b2014-01-09 14:00:36 +0800153 def test_show_subnet_fields(self):
Mark Maglana5885eb32014-02-28 10:57:34 -0800154 # Verify specific fields of a subnet
Zhi Kun Liu903596c2014-04-11 08:55:53 -0500155 fields = ['id', 'network_id']
jun xied557d9b2014-01-09 14:00:36 +0800156 resp, body = self.client.show_subnet(self.subnet['id'],
Zhi Kun Liu903596c2014-04-11 08:55:53 -0500157 fields=fields)
jun xied557d9b2014-01-09 14:00:36 +0800158 self.assertEqual('200', resp['status'])
159 subnet = body['subnet']
Zhi Kun Liu903596c2014-04-11 08:55:53 -0500160 self.assertEqual(sorted(subnet.keys()), sorted(fields))
161 for field_name in fields:
Mark Maglana5885eb32014-02-28 10:57:34 -0800162 self.assertEqual(subnet[field_name], self.subnet[field_name])
jun xied557d9b2014-01-09 14:00:36 +0800163
Masayuki Igawa6d495d62014-03-19 16:38:57 +0900164 @test.attr(type='smoke')
Miguel Lavallecc939612013-02-22 17:27:20 -0600165 def test_list_subnets(self):
166 # Verify the subnet exists in the list of all subnets
167 resp, body = self.client.list_subnets()
raiesmh0867698322013-08-20 13:09:01 +0530168 self.assertEqual('200', resp['status'])
Mark Maglana5885eb32014-02-28 10:57:34 -0800169 subnets = [subnet['id'] for subnet in body['subnets']
170 if subnet['id'] == self.subnet['id']]
171 self.assertNotEmpty(subnets, "Created subnet not found in the list")
raiesmh08e1aad982013-08-05 14:19:36 +0530172
Masayuki Igawa6d495d62014-03-19 16:38:57 +0900173 @test.attr(type='smoke')
jun xie0b4735d2014-01-07 15:42:58 +0800174 def test_list_subnets_fields(self):
Mark Maglana5885eb32014-02-28 10:57:34 -0800175 # Verify specific fields of subnets
Zhi Kun Liu903596c2014-04-11 08:55:53 -0500176 fields = ['id', 'network_id']
177 resp, body = self.client.list_subnets(fields=fields)
jun xie0b4735d2014-01-07 15:42:58 +0800178 self.assertEqual('200', resp['status'])
179 subnets = body['subnets']
Mark Maglana5885eb32014-02-28 10:57:34 -0800180 self.assertNotEmpty(subnets, "Subnet list returned is empty")
181 for subnet in subnets:
Zhi Kun Liu903596c2014-04-11 08:55:53 -0500182 self.assertEqual(sorted(subnet.keys()), sorted(fields))
jun xie0b4735d2014-01-07 15:42:58 +0800183
sukhdevc704a702014-01-15 11:50:56 -0800184 def _try_delete_network(self, net_id):
185 # delete network, if it exists
186 try:
187 self.client.delete_network(net_id)
188 # if network is not found, this means it was deleted in the test
189 except exceptions.NotFound:
190 pass
191
Masayuki Igawa6d495d62014-03-19 16:38:57 +0900192 @test.attr(type='smoke')
sukhdevc704a702014-01-15 11:50:56 -0800193 def test_delete_network_with_subnet(self):
194 # Creates a network
195 name = data_utils.rand_name('network-')
196 resp, body = self.client.create_network(name=name)
197 self.assertEqual('201', resp['status'])
198 network = body['network']
199 net_id = network['id']
200 self.addCleanup(self._try_delete_network, net_id)
201
202 # Find a cidr that is not in use yet and create a subnet with it
203 subnet = self.create_subnet(network)
204 subnet_id = subnet['id']
205
206 # Delete network while the subnet still exists
207 resp, body = self.client.delete_network(net_id)
208 self.assertEqual('204', resp['status'])
209
210 # Verify that the subnet got automatically deleted.
211 self.assertRaises(exceptions.NotFound, self.client.show_subnet,
212 subnet_id)
213
214 # Since create_subnet adds the subnet to the delete list, and it is
215 # is actually deleted here - this will create and issue, hence remove
216 # it from the list.
217 self.subnets.pop()
218
Edgar Magana6a9ac342014-01-16 13:52:49 -0800219 @test.attr(type='smoke')
220 def test_create_delete_subnet_with_gw(self):
221 gateway = '10.100.0.13'
222 name = data_utils.rand_name('network-')
223 resp, body = self.client.create_network(name=name)
224 self.assertEqual('201', resp['status'])
225 network = body['network']
226 net_id = network['id']
227 subnet = self.create_subnet(network, gateway)
228 # Verifies Subnet GW in IPv4
229 self.assertEqual(subnet['gateway_ip'], gateway)
230 # Delete network and subnet
231 resp, body = self.client.delete_network(net_id)
232 self.assertEqual('204', resp['status'])
233 self.subnets.pop()
234
235 @test.attr(type='smoke')
236 def test_create_delete_subnet_without_gw(self):
sridhargaddamb1e58892014-05-13 14:18:14 +0530237 net = netaddr.IPNetwork(CONF.network.tenant_network_cidr)
238 gateway_ip = str(netaddr.IPAddress(net.first + 1))
Edgar Magana6a9ac342014-01-16 13:52:49 -0800239 name = data_utils.rand_name('network-')
240 resp, body = self.client.create_network(name=name)
241 self.assertEqual('201', resp['status'])
242 network = body['network']
243 net_id = network['id']
244 subnet = self.create_subnet(network)
245 # Verifies Subnet GW in IPv4
sridhargaddamb1e58892014-05-13 14:18:14 +0530246 self.assertEqual(subnet['gateway_ip'], gateway_ip)
Edgar Magana6a9ac342014-01-16 13:52:49 -0800247 # Delete network and subnet
248 resp, body = self.client.delete_network(net_id)
249 self.assertEqual('204', resp['status'])
250 self.subnets.pop()
251
raiesmh086b055e22013-09-16 12:59:57 +0530252
253class NetworksTestXML(NetworksTestJSON):
254 _interface = 'xml'
255
256
Ken'ichi Ohmichi91c675d2014-02-06 02:15:21 +0900257class BulkNetworkOpsTestJSON(base.BaseNetworkTest):
raiesmh086b055e22013-09-16 12:59:57 +0530258 _interface = 'json'
259
260 """
261 Tests the following operations in the Neutron API using the REST client for
262 Neutron:
263
264 bulk network creation
265 bulk subnet creation
Eugene Nikanorove9d255a2013-12-18 16:31:42 +0400266 bulk port creation
raiesmh086b055e22013-09-16 12:59:57 +0530267 list tenant's networks
268
269 v2.0 of the Neutron API is assumed. It is also assumed that the following
270 options are defined in the [network] section of etc/tempest.conf:
271
272 tenant_network_cidr with a block of cidr's from which smaller blocks
273 can be allocated for tenant networks
274
275 tenant_network_mask_bits with the mask bits to be used to partition the
276 block defined by tenant-network_cidr
277 """
278
279 @classmethod
Masayuki Igawa6d495d62014-03-19 16:38:57 +0900280 @test.safe_setup
raiesmh086b055e22013-09-16 12:59:57 +0530281 def setUpClass(cls):
Ken'ichi Ohmichi91c675d2014-02-06 02:15:21 +0900282 super(BulkNetworkOpsTestJSON, cls).setUpClass()
raiesmh086b055e22013-09-16 12:59:57 +0530283 cls.network1 = cls.create_network()
284 cls.network2 = cls.create_network()
285
286 def _delete_networks(self, created_networks):
287 for n in created_networks:
288 resp, body = self.client.delete_network(n['id'])
289 self.assertEqual(204, resp.status)
290 # Asserting that the networks are not found in the list after deletion
291 resp, body = self.client.list_networks()
Mark Maglana5885eb32014-02-28 10:57:34 -0800292 networks_list = [network['id'] for network in body['networks']]
raiesmh086b055e22013-09-16 12:59:57 +0530293 for n in created_networks:
294 self.assertNotIn(n['id'], networks_list)
295
296 def _delete_subnets(self, created_subnets):
297 for n in created_subnets:
298 resp, body = self.client.delete_subnet(n['id'])
299 self.assertEqual(204, resp.status)
300 # Asserting that the subnets are not found in the list after deletion
301 resp, body = self.client.list_subnets()
Mark Maglana5885eb32014-02-28 10:57:34 -0800302 subnets_list = [subnet['id'] for subnet in body['subnets']]
raiesmh086b055e22013-09-16 12:59:57 +0530303 for n in created_subnets:
304 self.assertNotIn(n['id'], subnets_list)
305
306 def _delete_ports(self, created_ports):
307 for n in created_ports:
308 resp, body = self.client.delete_port(n['id'])
309 self.assertEqual(204, resp.status)
310 # Asserting that the ports are not found in the list after deletion
311 resp, body = self.client.list_ports()
Mark Maglana5885eb32014-02-28 10:57:34 -0800312 ports_list = [port['id'] for port in body['ports']]
raiesmh086b055e22013-09-16 12:59:57 +0530313 for n in created_ports:
314 self.assertNotIn(n['id'], ports_list)
315
Masayuki Igawa6d495d62014-03-19 16:38:57 +0900316 @test.attr(type='smoke')
Nayna Patelb03eab42013-08-08 08:58:48 +0000317 def test_bulk_create_delete_network(self):
318 # Creates 2 networks in one request
Masayuki Igawa259c1132013-10-31 17:48:44 +0900319 network_names = [data_utils.rand_name('network-'),
320 data_utils.rand_name('network-')]
Nayna Patelb03eab42013-08-08 08:58:48 +0000321 resp, body = self.client.create_bulk_network(2, network_names)
322 created_networks = body['networks']
323 self.assertEqual('201', resp['status'])
324 self.addCleanup(self._delete_networks, created_networks)
325 # Asserting that the networks are found in the list after creation
326 resp, body = self.client.list_networks()
Mark Maglana5885eb32014-02-28 10:57:34 -0800327 networks_list = [network['id'] for network in body['networks']]
Nayna Patelb03eab42013-08-08 08:58:48 +0000328 for n in created_networks:
329 self.assertIsNotNone(n['id'])
330 self.assertIn(n['id'], networks_list)
raiesmh0867698322013-08-20 13:09:01 +0530331
Masayuki Igawa6d495d62014-03-19 16:38:57 +0900332 @test.attr(type='smoke')
raiesmh082d5c6512013-09-06 15:35:05 +0530333 def test_bulk_create_delete_subnet(self):
334 # Creates 2 subnets in one request
Matthew Treinish03b48df2014-01-29 16:59:49 +0000335 cidr = netaddr.IPNetwork(CONF.network.tenant_network_cidr)
336 mask_bits = CONF.network.tenant_network_mask_bits
Mark Maglana5885eb32014-02-28 10:57:34 -0800337 cidrs = [subnet_cidr for subnet_cidr in cidr.subnet(mask_bits)]
raiesmh082d5c6512013-09-06 15:35:05 +0530338 networks = [self.network1['id'], self.network2['id']]
Mark Maglana5885eb32014-02-28 10:57:34 -0800339 names = [data_utils.rand_name('subnet-') for i in range(len(networks))]
340 subnets_list = []
raiesmh082d5c6512013-09-06 15:35:05 +0530341 # TODO(raies): "for IPv6, version list [4, 6] will be used.
342 # and cidr for IPv6 will be of IPv6"
343 ip_version = [4, 4]
344 for i in range(len(names)):
345 p1 = {
346 'network_id': networks[i],
347 'cidr': str(cidrs[(i)]),
348 'name': names[i],
349 'ip_version': ip_version[i]
350 }
Mark Maglana5885eb32014-02-28 10:57:34 -0800351 subnets_list.append(p1)
352 del subnets_list[1]['name']
353 resp, body = self.client.create_bulk_subnet(subnets_list)
raiesmh082d5c6512013-09-06 15:35:05 +0530354 created_subnets = body['subnets']
355 self.addCleanup(self._delete_subnets, created_subnets)
356 self.assertEqual('201', resp['status'])
357 # Asserting that the subnets are found in the list after creation
358 resp, body = self.client.list_subnets()
Mark Maglana5885eb32014-02-28 10:57:34 -0800359 subnets_list = [subnet['id'] for subnet in body['subnets']]
raiesmh082d5c6512013-09-06 15:35:05 +0530360 for n in created_subnets:
361 self.assertIsNotNone(n['id'])
362 self.assertIn(n['id'], subnets_list)
363
Masayuki Igawa6d495d62014-03-19 16:38:57 +0900364 @test.attr(type='smoke')
raiesmh082d5c6512013-09-06 15:35:05 +0530365 def test_bulk_create_delete_port(self):
366 # Creates 2 ports in one request
raiesmh082d5c6512013-09-06 15:35:05 +0530367 networks = [self.network1['id'], self.network2['id']]
Mark Maglana5885eb32014-02-28 10:57:34 -0800368 names = [data_utils.rand_name('port-') for i in range(len(networks))]
raiesmh082d5c6512013-09-06 15:35:05 +0530369 port_list = []
370 state = [True, False]
371 for i in range(len(names)):
372 p1 = {
373 'network_id': networks[i],
374 'name': names[i],
375 'admin_state_up': state[i],
376 }
377 port_list.append(p1)
378 del port_list[1]['name']
379 resp, body = self.client.create_bulk_port(port_list)
380 created_ports = body['ports']
381 self.addCleanup(self._delete_ports, created_ports)
382 self.assertEqual('201', resp['status'])
383 # Asserting that the ports are found in the list after creation
384 resp, body = self.client.list_ports()
Mark Maglana5885eb32014-02-28 10:57:34 -0800385 ports_list = [port['id'] for port in body['ports']]
raiesmh082d5c6512013-09-06 15:35:05 +0530386 for n in created_ports:
387 self.assertIsNotNone(n['id'])
388 self.assertIn(n['id'], ports_list)
389
raiesmh0867698322013-08-20 13:09:01 +0530390
Ken'ichi Ohmichi91c675d2014-02-06 02:15:21 +0900391class BulkNetworkOpsTestXML(BulkNetworkOpsTestJSON):
raiesmh0867698322013-08-20 13:09:01 +0530392 _interface = 'xml'
Henry Gessauffda37a2014-01-16 11:17:55 -0500393
394
395class NetworksIpV6TestJSON(NetworksTestJSON):
396 _ip_version = 6
Henry Gessauffda37a2014-01-16 11:17:55 -0500397
armando-migliaccio5bb7aef2014-02-19 21:55:14 -0800398 @classmethod
399 def setUpClass(cls):
Matthew Treinishe2e33cf2014-03-03 19:28:41 +0000400 if not CONF.network_feature_enabled.ipv6:
armando-migliaccio5bb7aef2014-02-19 21:55:14 -0800401 skip_msg = "IPv6 Tests are disabled."
402 raise cls.skipException(skip_msg)
armando-migliaccio649d8c02014-05-05 14:26:15 -0700403 super(NetworksIpV6TestJSON, cls).setUpClass()
armando-migliaccio5bb7aef2014-02-19 21:55:14 -0800404
Edgar Magana6a9ac342014-01-16 13:52:49 -0800405 @test.attr(type='smoke')
406 def test_create_delete_subnet_with_gw(self):
407 gateway = '2003::2'
408 name = data_utils.rand_name('network-')
409 resp, body = self.client.create_network(name=name)
410 self.assertEqual('201', resp['status'])
411 network = body['network']
412 net_id = network['id']
413 subnet = self.create_subnet(network, gateway)
414 # Verifies Subnet GW in IPv6
415 self.assertEqual(subnet['gateway_ip'], gateway)
416 # Delete network and subnet
417 resp, body = self.client.delete_network(net_id)
418 self.assertEqual('204', resp['status'])
419 self.subnets.pop()
420
421 @test.attr(type='smoke')
422 def test_create_delete_subnet_without_gw(self):
423 name = data_utils.rand_name('network-')
424 resp, body = self.client.create_network(name=name)
425 self.assertEqual('201', resp['status'])
426 network = body['network']
427 net_id = network['id']
428 subnet = self.create_subnet(network)
429 # Verifies Subnet GW in IPv6
430 self.assertEqual(subnet['gateway_ip'], '2003::1')
431 # Delete network and subnet
432 resp, body = self.client.delete_network(net_id)
433 self.assertEqual('204', resp['status'])
434 self.subnets.pop()
435
Henry Gessauffda37a2014-01-16 11:17:55 -0500436
437class NetworksIpV6TestXML(NetworksIpV6TestJSON):
438 _interface = 'xml'