blob: b3f949f9aeff17cdca63f0ba6e91bc95bb3c1248 [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
raiesmh086b055e22013-09-16 12:59:57 +0530279 def _delete_networks(self, created_networks):
280 for n in created_networks:
281 resp, body = self.client.delete_network(n['id'])
282 self.assertEqual(204, resp.status)
283 # Asserting that the networks are not found in the list after deletion
284 resp, body = self.client.list_networks()
Mark Maglana5885eb32014-02-28 10:57:34 -0800285 networks_list = [network['id'] for network in body['networks']]
raiesmh086b055e22013-09-16 12:59:57 +0530286 for n in created_networks:
287 self.assertNotIn(n['id'], networks_list)
288
289 def _delete_subnets(self, created_subnets):
290 for n in created_subnets:
291 resp, body = self.client.delete_subnet(n['id'])
292 self.assertEqual(204, resp.status)
293 # Asserting that the subnets are not found in the list after deletion
294 resp, body = self.client.list_subnets()
Mark Maglana5885eb32014-02-28 10:57:34 -0800295 subnets_list = [subnet['id'] for subnet in body['subnets']]
raiesmh086b055e22013-09-16 12:59:57 +0530296 for n in created_subnets:
297 self.assertNotIn(n['id'], subnets_list)
298
299 def _delete_ports(self, created_ports):
300 for n in created_ports:
301 resp, body = self.client.delete_port(n['id'])
302 self.assertEqual(204, resp.status)
303 # Asserting that the ports are not found in the list after deletion
304 resp, body = self.client.list_ports()
Mark Maglana5885eb32014-02-28 10:57:34 -0800305 ports_list = [port['id'] for port in body['ports']]
raiesmh086b055e22013-09-16 12:59:57 +0530306 for n in created_ports:
307 self.assertNotIn(n['id'], ports_list)
308
Masayuki Igawa6d495d62014-03-19 16:38:57 +0900309 @test.attr(type='smoke')
Nayna Patelb03eab42013-08-08 08:58:48 +0000310 def test_bulk_create_delete_network(self):
311 # Creates 2 networks in one request
Masayuki Igawa259c1132013-10-31 17:48:44 +0900312 network_names = [data_utils.rand_name('network-'),
313 data_utils.rand_name('network-')]
Nayna Patelb03eab42013-08-08 08:58:48 +0000314 resp, body = self.client.create_bulk_network(2, network_names)
315 created_networks = body['networks']
316 self.assertEqual('201', resp['status'])
317 self.addCleanup(self._delete_networks, created_networks)
318 # Asserting that the networks are found in the list after creation
319 resp, body = self.client.list_networks()
Mark Maglana5885eb32014-02-28 10:57:34 -0800320 networks_list = [network['id'] for network in body['networks']]
Nayna Patelb03eab42013-08-08 08:58:48 +0000321 for n in created_networks:
322 self.assertIsNotNone(n['id'])
323 self.assertIn(n['id'], networks_list)
raiesmh0867698322013-08-20 13:09:01 +0530324
Masayuki Igawa6d495d62014-03-19 16:38:57 +0900325 @test.attr(type='smoke')
raiesmh082d5c6512013-09-06 15:35:05 +0530326 def test_bulk_create_delete_subnet(self):
Assaf Mullere4f78992014-06-19 17:32:14 +0300327 networks = [self.create_network(), self.create_network()]
raiesmh082d5c6512013-09-06 15:35:05 +0530328 # Creates 2 subnets in one request
Matthew Treinish03b48df2014-01-29 16:59:49 +0000329 cidr = netaddr.IPNetwork(CONF.network.tenant_network_cidr)
330 mask_bits = CONF.network.tenant_network_mask_bits
Mark Maglana5885eb32014-02-28 10:57:34 -0800331 cidrs = [subnet_cidr for subnet_cidr in cidr.subnet(mask_bits)]
Mark Maglana5885eb32014-02-28 10:57:34 -0800332 names = [data_utils.rand_name('subnet-') for i in range(len(networks))]
333 subnets_list = []
raiesmh082d5c6512013-09-06 15:35:05 +0530334 # TODO(raies): "for IPv6, version list [4, 6] will be used.
335 # and cidr for IPv6 will be of IPv6"
336 ip_version = [4, 4]
337 for i in range(len(names)):
338 p1 = {
Assaf Mullere4f78992014-06-19 17:32:14 +0300339 'network_id': networks[i]['id'],
raiesmh082d5c6512013-09-06 15:35:05 +0530340 'cidr': str(cidrs[(i)]),
341 'name': names[i],
342 'ip_version': ip_version[i]
343 }
Mark Maglana5885eb32014-02-28 10:57:34 -0800344 subnets_list.append(p1)
345 del subnets_list[1]['name']
346 resp, body = self.client.create_bulk_subnet(subnets_list)
raiesmh082d5c6512013-09-06 15:35:05 +0530347 created_subnets = body['subnets']
348 self.addCleanup(self._delete_subnets, created_subnets)
349 self.assertEqual('201', resp['status'])
350 # Asserting that the subnets are found in the list after creation
351 resp, body = self.client.list_subnets()
Mark Maglana5885eb32014-02-28 10:57:34 -0800352 subnets_list = [subnet['id'] for subnet in body['subnets']]
raiesmh082d5c6512013-09-06 15:35:05 +0530353 for n in created_subnets:
354 self.assertIsNotNone(n['id'])
355 self.assertIn(n['id'], subnets_list)
356
Masayuki Igawa6d495d62014-03-19 16:38:57 +0900357 @test.attr(type='smoke')
raiesmh082d5c6512013-09-06 15:35:05 +0530358 def test_bulk_create_delete_port(self):
Assaf Mullere4f78992014-06-19 17:32:14 +0300359 networks = [self.create_network(), self.create_network()]
raiesmh082d5c6512013-09-06 15:35:05 +0530360 # Creates 2 ports in one request
Mark Maglana5885eb32014-02-28 10:57:34 -0800361 names = [data_utils.rand_name('port-') for i in range(len(networks))]
raiesmh082d5c6512013-09-06 15:35:05 +0530362 port_list = []
363 state = [True, False]
364 for i in range(len(names)):
365 p1 = {
Assaf Mullere4f78992014-06-19 17:32:14 +0300366 'network_id': networks[i]['id'],
raiesmh082d5c6512013-09-06 15:35:05 +0530367 'name': names[i],
368 'admin_state_up': state[i],
369 }
370 port_list.append(p1)
371 del port_list[1]['name']
372 resp, body = self.client.create_bulk_port(port_list)
373 created_ports = body['ports']
374 self.addCleanup(self._delete_ports, created_ports)
375 self.assertEqual('201', resp['status'])
376 # Asserting that the ports are found in the list after creation
377 resp, body = self.client.list_ports()
Mark Maglana5885eb32014-02-28 10:57:34 -0800378 ports_list = [port['id'] for port in body['ports']]
raiesmh082d5c6512013-09-06 15:35:05 +0530379 for n in created_ports:
380 self.assertIsNotNone(n['id'])
381 self.assertIn(n['id'], ports_list)
382
raiesmh0867698322013-08-20 13:09:01 +0530383
Ken'ichi Ohmichi91c675d2014-02-06 02:15:21 +0900384class BulkNetworkOpsTestXML(BulkNetworkOpsTestJSON):
raiesmh0867698322013-08-20 13:09:01 +0530385 _interface = 'xml'
Henry Gessauffda37a2014-01-16 11:17:55 -0500386
387
388class NetworksIpV6TestJSON(NetworksTestJSON):
389 _ip_version = 6
Henry Gessauffda37a2014-01-16 11:17:55 -0500390
armando-migliaccio5bb7aef2014-02-19 21:55:14 -0800391 @classmethod
392 def setUpClass(cls):
Matthew Treinishe2e33cf2014-03-03 19:28:41 +0000393 if not CONF.network_feature_enabled.ipv6:
armando-migliaccio5bb7aef2014-02-19 21:55:14 -0800394 skip_msg = "IPv6 Tests are disabled."
395 raise cls.skipException(skip_msg)
armando-migliaccio649d8c02014-05-05 14:26:15 -0700396 super(NetworksIpV6TestJSON, cls).setUpClass()
armando-migliaccio5bb7aef2014-02-19 21:55:14 -0800397
Edgar Magana6a9ac342014-01-16 13:52:49 -0800398 @test.attr(type='smoke')
399 def test_create_delete_subnet_with_gw(self):
400 gateway = '2003::2'
401 name = data_utils.rand_name('network-')
402 resp, body = self.client.create_network(name=name)
403 self.assertEqual('201', resp['status'])
404 network = body['network']
405 net_id = network['id']
406 subnet = self.create_subnet(network, gateway)
407 # Verifies Subnet GW in IPv6
408 self.assertEqual(subnet['gateway_ip'], gateway)
409 # Delete network and subnet
410 resp, body = self.client.delete_network(net_id)
411 self.assertEqual('204', resp['status'])
412 self.subnets.pop()
413
414 @test.attr(type='smoke')
415 def test_create_delete_subnet_without_gw(self):
416 name = data_utils.rand_name('network-')
417 resp, body = self.client.create_network(name=name)
418 self.assertEqual('201', resp['status'])
419 network = body['network']
420 net_id = network['id']
421 subnet = self.create_subnet(network)
422 # Verifies Subnet GW in IPv6
423 self.assertEqual(subnet['gateway_ip'], '2003::1')
424 # Delete network and subnet
425 resp, body = self.client.delete_network(net_id)
426 self.assertEqual('204', resp['status'])
427 self.subnets.pop()
428
Henry Gessauffda37a2014-01-16 11:17:55 -0500429
430class NetworksIpV6TestXML(NetworksIpV6TestJSON):
431 _interface = 'xml'