blob: 5e916f5d76a961886c82eae5479650aa2933eb2a [file] [log] [blame]
Daniel Mellado3c0aeab2016-01-29 11:30:25 +00001# Copyright 2013 OpenStack Foundation
2# 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
16import netaddr
Dongcan Yea71b8342018-05-02 06:56:26 +000017
Arkady Shtemplerb667ac32020-11-17 20:23:41 +020018from neutron_lib import constants as const
19
Chandan Kumarc125fd12017-11-15 19:41:01 +053020from tempest.common import utils as tutils
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000021from tempest.lib.common.utils import data_utils
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000022from tempest.lib import decorators
Arkady Shtemplerb667ac32020-11-17 20:23:41 +020023from tempest.lib import exceptions as lib_exc
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000024
Chandan Kumar667d3d32017-09-22 12:24:06 +053025from neutron_tempest_plugin.api import base
26from neutron_tempest_plugin.api import base_routers
27from neutron_tempest_plugin.common import utils
28from neutron_tempest_plugin import config
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000029
30CONF = config.CONF
31
32
Ihar Hrachyshka44d1d3f2016-06-14 11:51:37 +020033class RoutersTest(base_routers.BaseRouterTest):
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000034
Jakub Libosvar1982aa12017-05-30 11:15:33 +000035 required_extensions = ['router']
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000036
37 @classmethod
38 def resource_setup(cls):
39 super(RoutersTest, cls).resource_setup()
40 cls.tenant_cidr = (
41 config.safe_get_config_value('network', 'project_network_cidr')
42 if cls._ip_version == 4 else
43 config.safe_get_config_value('network', 'project_network_v6_cidr'))
44
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000045 @decorators.idempotent_id('c72c1c0c-2193-4aca-eeee-b1442640eeee')
Chandan Kumarc125fd12017-11-15 19:41:01 +053046 @tutils.requires_ext(extension="standard-attr-description",
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000047 service="network")
48 def test_create_update_router_description(self):
49 body = self.create_router(description='d1', router_name='test')
50 self.assertEqual('d1', body['description'])
51 body = self.client.show_router(body['id'])['router']
52 self.assertEqual('d1', body['description'])
53 body = self.client.update_router(body['id'], description='d2')
54 self.assertEqual('d2', body['router']['description'])
55 body = self.client.show_router(body['router']['id'])['router']
56 self.assertEqual('d2', body['description'])
57
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000058 @decorators.idempotent_id('847257cc-6afd-4154-b8fb-af49f5670ce8')
Chandan Kumarc125fd12017-11-15 19:41:01 +053059 @tutils.requires_ext(extension='ext-gw-mode', service='network')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000060 def test_create_router_with_default_snat_value(self):
61 # Create a router with default snat rule
62 name = data_utils.rand_name('router')
63 router = self._create_router(
64 name, external_network_id=CONF.network.public_network_id)
65 self._verify_router_gateway(
66 router['id'], {'network_id': CONF.network.public_network_id,
67 'enable_snat': True})
68
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +000069 @decorators.idempotent_id('ea74068d-09e9-4fd7-8995-9b6a1ace920f')
Chandan Kumarc125fd12017-11-15 19:41:01 +053070 @tutils.requires_ext(extension='ext-gw-mode', service='network')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000071 def test_create_router_with_snat_explicit(self):
72 name = data_utils.rand_name('snat-router')
73 # Create a router enabling snat attributes
74 enable_snat_states = [False, True]
75 for enable_snat in enable_snat_states:
76 external_gateway_info = {
77 'network_id': CONF.network.public_network_id,
78 'enable_snat': enable_snat}
Brian Haleyee000852019-08-29 17:27:38 -040079 router = self._create_admin_router(
80 name, external_network_id=CONF.network.public_network_id,
81 enable_snat=enable_snat)
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000082 # Verify snat attributes after router creation
Brian Haleyee000852019-08-29 17:27:38 -040083 self._verify_router_gateway(router['id'],
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000084 exp_ext_gw_info=external_gateway_info)
85
86 def _verify_router_gateway(self, router_id, exp_ext_gw_info=None):
87 show_body = self.admin_client.show_router(router_id)
88 actual_ext_gw_info = show_body['router']['external_gateway_info']
89 if exp_ext_gw_info is None:
90 self.assertIsNone(actual_ext_gw_info)
91 return
92 # Verify only keys passed in exp_ext_gw_info
fpxieaa3bace2017-04-07 17:12:15 +080093 for k, v in exp_ext_gw_info.items():
Daniel Mellado3c0aeab2016-01-29 11:30:25 +000094 self.assertEqual(v, actual_ext_gw_info[k])
95
96 def _verify_gateway_port(self, router_id):
97 list_body = self.admin_client.list_ports(
98 network_id=CONF.network.public_network_id,
99 device_id=router_id)
100 self.assertEqual(len(list_body['ports']), 1)
101 gw_port = list_body['ports'][0]
102 fixed_ips = gw_port['fixed_ips']
103 self.assertGreaterEqual(len(fixed_ips), 1)
104 public_net_body = self.admin_client.show_network(
105 CONF.network.public_network_id)
Chandan Kumarc125fd12017-11-15 19:41:01 +0530106 public_subnet_ids = public_net_body['network']['subnets']
107 for fixed_ip in fixed_ips:
108 self.assertIn(fixed_ip['subnet_id'],
109 public_subnet_ids)
Daniel Mellado3c0aeab2016-01-29 11:30:25 +0000110
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000111 @decorators.idempotent_id('b386c111-3b21-466d-880c-5e72b01e1a33')
Chandan Kumarc125fd12017-11-15 19:41:01 +0530112 @tutils.requires_ext(extension='ext-gw-mode', service='network')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +0000113 def test_update_router_set_gateway_with_snat_explicit(self):
Chandan Kumarc125fd12017-11-15 19:41:01 +0530114 router = self._create_router(data_utils.rand_name('router'))
Daniel Mellado3c0aeab2016-01-29 11:30:25 +0000115 self.admin_client.update_router_with_snat_gw_info(
116 router['id'],
117 external_gateway_info={
118 'network_id': CONF.network.public_network_id,
119 'enable_snat': True})
120 self._verify_router_gateway(
121 router['id'],
122 {'network_id': CONF.network.public_network_id,
123 'enable_snat': True})
124 self._verify_gateway_port(router['id'])
125
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000126 @decorators.idempotent_id('96536bc7-8262-4fb2-9967-5c46940fa279')
Chandan Kumarc125fd12017-11-15 19:41:01 +0530127 @tutils.requires_ext(extension='ext-gw-mode', service='network')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +0000128 def test_update_router_set_gateway_without_snat(self):
Chandan Kumarc125fd12017-11-15 19:41:01 +0530129 router = self._create_router(data_utils.rand_name('router'))
Daniel Mellado3c0aeab2016-01-29 11:30:25 +0000130 self.admin_client.update_router_with_snat_gw_info(
131 router['id'],
132 external_gateway_info={
133 'network_id': CONF.network.public_network_id,
134 'enable_snat': False})
135 self._verify_router_gateway(
136 router['id'],
137 {'network_id': CONF.network.public_network_id,
138 'enable_snat': False})
139 self._verify_gateway_port(router['id'])
140
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000141 @decorators.idempotent_id('f2faf994-97f4-410b-a831-9bc977b64374')
Chandan Kumarc125fd12017-11-15 19:41:01 +0530142 @tutils.requires_ext(extension='ext-gw-mode', service='network')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +0000143 def test_update_router_reset_gateway_without_snat(self):
144 router = self._create_router(
Chandan Kumarc125fd12017-11-15 19:41:01 +0530145 data_utils.rand_name('router'),
Daniel Mellado3c0aeab2016-01-29 11:30:25 +0000146 external_network_id=CONF.network.public_network_id)
147 self.admin_client.update_router_with_snat_gw_info(
148 router['id'],
149 external_gateway_info={
150 'network_id': CONF.network.public_network_id,
151 'enable_snat': False})
152 self._verify_router_gateway(
153 router['id'],
154 {'network_id': CONF.network.public_network_id,
155 'enable_snat': False})
156 self._verify_gateway_port(router['id'])
157
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000158 @decorators.idempotent_id('db3093b1-93b6-4893-be83-c4716c251b3e')
Kevin Bentonc66aa802016-07-23 22:36:37 -0700159 def test_router_interface_status(self):
160 network = self.create_network()
161 subnet = self.create_subnet(network)
162 # Add router interface with subnet id
Chandan Kumarc125fd12017-11-15 19:41:01 +0530163 router = self._create_router(data_utils.rand_name('router'), True)
Kevin Bentonc66aa802016-07-23 22:36:37 -0700164 intf = self.create_router_interface(router['id'], subnet['id'])
Brian Haley33ef4602018-04-26 14:37:49 -0400165
166 def _status_active():
167 return self.client.show_port(
168 intf['port_id'])['port']['status'] == 'ACTIVE'
169
170 utils.wait_until_true(_status_active, exception=AssertionError)
Kevin Bentonc66aa802016-07-23 22:36:37 -0700171
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000172 @decorators.idempotent_id('c86ac3a8-50bd-4b00-a6b8-62af84a0765c')
Chandan Kumarc125fd12017-11-15 19:41:01 +0530173 @tutils.requires_ext(extension='extraroute', service='network')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +0000174 def test_update_extra_route(self):
175 self.network = self.create_network()
176 self.name = self.network['name']
177 self.subnet = self.create_subnet(self.network)
178 # Add router interface with subnet id
179 self.router = self._create_router(
180 data_utils.rand_name('router-'), True)
181 self.create_router_interface(self.router['id'], self.subnet['id'])
182 self.addCleanup(
183 self._delete_extra_routes,
184 self.router['id'])
185 # Update router extra route, second ip of the range is
186 # used as next hop
187 cidr = netaddr.IPNetwork(self.subnet['cidr'])
188 next_hop = str(cidr[2])
189 destination = str(self.subnet['cidr'])
190 extra_route = self.client.update_extra_routes(self.router['id'],
191 next_hop, destination)
192 self.assertEqual(1, len(extra_route['router']['routes']))
193 self.assertEqual(destination,
194 extra_route['router']['routes'][0]['destination'])
195 self.assertEqual(next_hop,
196 extra_route['router']['routes'][0]['nexthop'])
197 show_body = self.client.show_router(self.router['id'])
198 self.assertEqual(destination,
199 show_body['router']['routes'][0]['destination'])
200 self.assertEqual(next_hop,
201 show_body['router']['routes'][0]['nexthop'])
202
203 def _delete_extra_routes(self, router_id):
204 self.client.delete_extra_routes(router_id)
205
Bence Romsics46bd3af2019-09-13 10:52:41 +0200206 @decorators.idempotent_id('b29d1698-d603-11e9-9c66-079cc4aec539')
207 @tutils.requires_ext(extension='extraroute-atomic', service='network')
208 def test_extra_routes_atomic(self):
209 self.network = self.create_network()
210 self.subnet = self.create_subnet(self.network)
211 self.router = self._create_router(
212 data_utils.rand_name('router-'), True)
213 self.create_router_interface(self.router['id'], self.subnet['id'])
214 self.addCleanup(
215 self._delete_extra_routes,
216 self.router['id'])
217
218 if self._ip_version == 6:
219 dst = '2001:db8:%s::/64'
220 else:
221 dst = '10.0.%s.0/24'
222
223 cidr = netaddr.IPNetwork(self.subnet['cidr'])
224
225 routes = [
226 {'destination': dst % 2, 'nexthop': cidr[2]},
227 ]
228 resp = self.client.add_extra_routes_atomic(
229 self.router['id'], routes)
230 self.assertEqual(1, len(resp['router']['routes']))
231
232 routes = [
233 {'destination': dst % 2, 'nexthop': cidr[2]},
234 {'destination': dst % 3, 'nexthop': cidr[3]},
235 ]
236 resp = self.client.add_extra_routes_atomic(
237 self.router['id'], routes)
238 self.assertEqual(2, len(resp['router']['routes']))
239
240 routes = [
241 {'destination': dst % 3, 'nexthop': cidr[3]},
242 {'destination': dst % 4, 'nexthop': cidr[4]},
243 ]
244 resp = self.client.remove_extra_routes_atomic(
245 self.router['id'], routes)
246 self.assertEqual(1, len(resp['router']['routes']))
247
248 routes = [
249 {'destination': dst % 2, 'nexthop': cidr[5]},
250 ]
251 resp = self.client.add_extra_routes_atomic(
252 self.router['id'], routes)
253 self.assertEqual(2, len(resp['router']['routes']))
254
255 routes = [
256 {'destination': dst % 2, 'nexthop': cidr[5]},
257 ]
258 resp = self.client.remove_extra_routes_atomic(
259 self.router['id'], routes)
260 self.assertEqual(1, len(resp['router']['routes']))
261
262 routes = [
263 {'destination': dst % 2, 'nexthop': cidr[2]},
264 {'destination': dst % 3, 'nexthop': cidr[3]},
265 {'destination': dst % 2, 'nexthop': cidr[5]},
266 ]
267 resp = self.client.remove_extra_routes_atomic(
268 self.router['id'], routes)
269 self.assertEqual(0, len(resp['router']['routes']))
270
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000271 @decorators.idempotent_id('01f185d1-d1a6-4cf9-abf7-e0e1384c169c')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +0000272 def test_network_attached_with_two_routers(self):
273 network = self.create_network(data_utils.rand_name('network1'))
274 self.create_subnet(network)
275 port1 = self.create_port(network)
276 port2 = self.create_port(network)
277 router1 = self._create_router(data_utils.rand_name('router1'))
278 router2 = self._create_router(data_utils.rand_name('router2'))
279 self.client.add_router_interface_with_port_id(
280 router1['id'], port1['id'])
281 self.client.add_router_interface_with_port_id(
282 router2['id'], port2['id'])
283 self.addCleanup(self.client.remove_router_interface_with_port_id,
284 router1['id'], port1['id'])
285 self.addCleanup(self.client.remove_router_interface_with_port_id,
286 router2['id'], port2['id'])
287 body = self.client.show_port(port1['id'])
288 port_show1 = body['port']
289 body = self.client.show_port(port2['id'])
290 port_show2 = body['port']
291 self.assertEqual(port_show1['network_id'], network['id'])
292 self.assertEqual(port_show2['network_id'], network['id'])
293 self.assertEqual(port_show1['device_id'], router1['id'])
294 self.assertEqual(port_show2['device_id'], router2['id'])
295
296
297class RoutersIpV6Test(RoutersTest):
298 _ip_version = 6
299
300
Ihar Hrachyshka44d1d3f2016-06-14 11:51:37 +0200301class DvrRoutersTest(base_routers.BaseRouterTest):
Daniel Mellado3c0aeab2016-01-29 11:30:25 +0000302
Jakub Libosvar1982aa12017-05-30 11:15:33 +0000303 required_extensions = ['dvr']
Daniel Mellado3c0aeab2016-01-29 11:30:25 +0000304
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000305 @decorators.idempotent_id('141297aa-3424-455d-aa8d-f2d95731e00a')
Daniel Mellado3c0aeab2016-01-29 11:30:25 +0000306 def test_create_distributed_router(self):
307 name = data_utils.rand_name('router')
Brian Haleyee000852019-08-29 17:27:38 -0400308 router = self._create_admin_router(name, distributed=True)
309 self.assertTrue(router['distributed'])
Daniel Mellado3c0aeab2016-01-29 11:30:25 +0000310
Dongcan Yea71b8342018-05-02 06:56:26 +0000311
312class DvrRoutersTestToCentralized(base_routers.BaseRouterTest):
313
314 required_extensions = ['dvr', 'l3-ha']
315
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000316 @decorators.idempotent_id('644d7a4a-01a1-4b68-bb8d-0c0042cb1729')
Kailun Qince246d02018-07-20 21:38:07 +0800317 def test_convert_distributed_router_back_to_centralized(self):
318 # Convert a centralized router to distributed firstly
Brian Haley198a2d92017-06-16 16:23:44 -0400319 router_args = {'tenant_id': self.client.tenant_id,
320 'distributed': False, 'ha': False}
Brian Haleyee000852019-08-29 17:27:38 -0400321 router = self._create_admin_router(
Brian Haley198a2d92017-06-16 16:23:44 -0400322 data_utils.rand_name('router'), admin_state_up=False,
Brian Haleyee000852019-08-29 17:27:38 -0400323 **router_args)
Brian Haley198a2d92017-06-16 16:23:44 -0400324 self.assertFalse(router['distributed'])
325 self.assertFalse(router['ha'])
Daniel Mellado3c0aeab2016-01-29 11:30:25 +0000326 update_body = self.admin_client.update_router(router['id'],
327 distributed=True)
328 self.assertTrue(update_body['router']['distributed'])
329 show_body = self.admin_client.show_router(router['id'])
330 self.assertTrue(show_body['router']['distributed'])
Kailun Qince246d02018-07-20 21:38:07 +0800331 self.assertFalse(show_body['router']['ha'])
332 # Then convert the distributed router back to centralized
333 update_body = self.admin_client.update_router(router['id'],
334 distributed=False)
335 self.assertFalse(update_body['router']['distributed'])
336 show_body = self.admin_client.show_router(router['id'])
337 self.assertFalse(show_body['router']['distributed'])
338 self.assertFalse(show_body['router']['ha'])
Daniel Mellado3c0aeab2016-01-29 11:30:25 +0000339 show_body = self.client.show_router(router['id'])
340 self.assertNotIn('distributed', show_body['router'])
Brian Haley198a2d92017-06-16 16:23:44 -0400341 self.assertNotIn('ha', show_body['router'])
Ihar Hrachyshka44d1d3f2016-06-14 11:51:37 +0200342
343
Matt Welchffe9be82019-07-02 13:24:29 +0000344class DvrRoutersTestUpdateDistributedExtended(base_routers.BaseRouterTest):
345
346 required_extensions = ['dvr', 'l3-ha',
347 'router-admin-state-down-before-update']
348
349 @decorators.idempotent_id('0ffb9973-0c1a-4b76-a1f2-060178057661')
350 def test_convert_centralized_router_to_distributed_extended(self):
351 router_args = {'tenant_id': self.client.tenant_id,
352 'distributed': False, 'ha': False}
Brian Haleyee000852019-08-29 17:27:38 -0400353 router = self._create_admin_router(
Matt Welchffe9be82019-07-02 13:24:29 +0000354 data_utils.rand_name('router'), admin_state_up=True,
Brian Haleyee000852019-08-29 17:27:38 -0400355 **router_args)
Matt Welchffe9be82019-07-02 13:24:29 +0000356 self.assertTrue(router['admin_state_up'])
357 self.assertFalse(router['distributed'])
358 # take router down to allow setting the router to distributed
359 update_body = self.admin_client.update_router(router['id'],
360 admin_state_up=False)
361 self.assertFalse(update_body['router']['admin_state_up'])
362 # set the router to distributed
363 update_body = self.admin_client.update_router(router['id'],
364 distributed=True)
365 self.assertTrue(update_body['router']['distributed'])
366 # bring the router back up
367 update_body = self.admin_client.update_router(router['id'],
368 admin_state_up=True)
369 self.assertTrue(update_body['router']['admin_state_up'])
370 self.assertTrue(update_body['router']['distributed'])
371
372 @decorators.idempotent_id('e9a8f55b-c535-44b7-8b0a-20af6a7c2921')
373 def test_convert_distributed_router_to_centralized_extended(self):
374 router_args = {'tenant_id': self.client.tenant_id,
375 'distributed': True, 'ha': False}
Brian Haleyee000852019-08-29 17:27:38 -0400376 router = self._create_admin_router(
Matt Welchffe9be82019-07-02 13:24:29 +0000377 data_utils.rand_name('router'), admin_state_up=True,
Brian Haleyee000852019-08-29 17:27:38 -0400378 **router_args)
Matt Welchffe9be82019-07-02 13:24:29 +0000379 self.assertTrue(router['admin_state_up'])
380 self.assertTrue(router['distributed'])
381 # take router down to allow setting the router to centralized
382 update_body = self.admin_client.update_router(router['id'],
383 admin_state_up=False)
384 self.assertFalse(update_body['router']['admin_state_up'])
385 # set router to centralized
386 update_body = self.admin_client.update_router(router['id'],
387 distributed=False)
388 self.assertFalse(update_body['router']['distributed'])
389 # bring router back up
390 update_body = self.admin_client.update_router(router['id'],
391 admin_state_up=True)
392 self.assertTrue(update_body['router']['admin_state_up'])
393 self.assertFalse(update_body['router']['distributed'])
394
395
Dongcan Ye6d8ec4a2017-05-03 15:07:36 +0800396class HaRoutersTest(base_routers.BaseRouterTest):
397
Jakub Libosvar1982aa12017-05-30 11:15:33 +0000398 required_extensions = ['l3-ha']
Dongcan Ye6d8ec4a2017-05-03 15:07:36 +0800399
400 @decorators.idempotent_id('77db8eae-3aa3-4e61-bf2a-e739ce042e53')
401 def test_convert_legacy_router(self):
402 router = self._create_router(data_utils.rand_name('router'))
403 self.assertNotIn('ha', router)
404 update_body = self.admin_client.update_router(router['id'],
405 ha=True)
406 self.assertTrue(update_body['router']['ha'])
407 show_body = self.admin_client.show_router(router['id'])
408 self.assertTrue(show_body['router']['ha'])
409 show_body = self.client.show_router(router['id'])
410 self.assertNotIn('ha', show_body['router'])
411
412
Ihar Hrachyshka44d1d3f2016-06-14 11:51:37 +0200413class RoutersSearchCriteriaTest(base.BaseSearchCriteriaTest):
414
Jakub Libosvar1982aa12017-05-30 11:15:33 +0000415 required_extensions = ['router']
Ihar Hrachyshka44d1d3f2016-06-14 11:51:37 +0200416 resource = 'router'
417
418 @classmethod
Ihar Hrachyshka44d1d3f2016-06-14 11:51:37 +0200419 def resource_setup(cls):
420 super(RoutersSearchCriteriaTest, cls).resource_setup()
421 for name in cls.resource_names:
422 cls.create_router(router_name=name)
423
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000424 @decorators.idempotent_id('03a69efb-90a7-435b-bb5c-3add3612085a')
Ihar Hrachyshka44d1d3f2016-06-14 11:51:37 +0200425 def test_list_sorts_asc(self):
426 self._test_list_sorts_asc()
427
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000428 @decorators.idempotent_id('95913d30-ff41-4b17-9f44-5258c651e78c')
Ihar Hrachyshka44d1d3f2016-06-14 11:51:37 +0200429 def test_list_sorts_desc(self):
430 self._test_list_sorts_desc()
431
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000432 @decorators.idempotent_id('7f7d40b1-e165-4817-8dc5-02f8e2f0dff3')
Ihar Hrachyshka44d1d3f2016-06-14 11:51:37 +0200433 def test_list_pagination(self):
434 self._test_list_pagination()
435
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000436 @decorators.idempotent_id('a5b83e83-3d98-45bb-a2c7-0ee179ffd42c')
Ihar Hrachyshka44d1d3f2016-06-14 11:51:37 +0200437 def test_list_pagination_with_marker(self):
438 self._test_list_pagination_with_marker()
439
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000440 @decorators.idempotent_id('40804af8-c25d-45f8-b8a8-b4c70345215d')
Ihar Hrachyshka44d1d3f2016-06-14 11:51:37 +0200441 def test_list_pagination_with_href_links(self):
442 self._test_list_pagination_with_href_links()
443
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000444 @decorators.idempotent_id('77b9676c-d3cb-43af-a0e8-a5b8c6099e70')
Ihar Hrachyshka44d1d3f2016-06-14 11:51:37 +0200445 def test_list_pagination_page_reverse_asc(self):
446 self._test_list_pagination_page_reverse_asc()
447
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000448 @decorators.idempotent_id('3133a2c5-1bb9-4fc7-833e-cf9a1d160255')
Ihar Hrachyshka44d1d3f2016-06-14 11:51:37 +0200449 def test_list_pagination_page_reverse_desc(self):
450 self._test_list_pagination_page_reverse_desc()
451
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000452 @decorators.idempotent_id('8252e2f0-b3da-4738-8e25-f6f8d878a2da')
Ihar Hrachyshka44d1d3f2016-06-14 11:51:37 +0200453 def test_list_pagination_page_reverse_with_href_links(self):
454 self._test_list_pagination_page_reverse_with_href_links()
455
Sławek Kapłońskic0caa2e2017-02-25 10:11:32 +0000456 @decorators.idempotent_id('fb102124-20f8-4cb3-8c81-f16f5e41d192')
Ihar Hrachyshka44d1d3f2016-06-14 11:51:37 +0200457 def test_list_no_pagination_limit_0(self):
458 self._test_list_no_pagination_limit_0()
Arkady Shtemplerb667ac32020-11-17 20:23:41 +0200459
460
461class RoutersDeleteTest(base_routers.BaseRouterTest):
462 """The only test in this class is a test that removes router!
463
464 * We cannot delete common and mandatory resources (router in this case)
465 * using the existing classes, as it will cause failure in other tests
466 * running in parallel.
467 """
468 @classmethod
469 def resource_setup(cls):
470 super(RoutersDeleteTest, cls).resource_setup()
471 cls.secgroup = cls.create_security_group(
472 name=data_utils.rand_name("test_port_secgroup"))
473 router_kwargs = {
474 'router_name': data_utils.rand_name('router_to_delete'),
475 'external_network_id': CONF.network.public_network_id}
476 cls.router = cls.create_router(**router_kwargs)
477
478 @decorators.idempotent_id('dbbc5c74-63c8-11eb-8881-74e5f9e2a801')
479 def test_delete_router(self):
480 # Create a port on tenant network and associate to the router.
481 # Try to delete router. Expected result: "Conflict Error" is raised.
482 network = self.create_network()
483 subnet = self.create_subnet(network)
484 self.create_router_interface(self.router['id'], subnet['id'])
485 port = self.create_port(
486 network, name=data_utils.rand_name("port"),
487 security_groups=[self.secgroup['id']])
488 self.create_floatingip(port=port)
489 self.assertRaises(
490 lib_exc.Conflict, self.client.delete_router, self.router['id'])
491 # Delete the associated port
492 # Try to delete router. Expected result: "Conflict Error" is raised.
493 # Note: there are still interfaces in use.
494 self.client.delete_port(port['id'])
495 self.assertRaises(
496 lib_exc.Conflict, self.client.delete_router, self.router['id'])
497 # Delete the rest of the router's ports
498 # Try to delete router. Expected result: "PASS"
499 interfaces = [
500 port for port in self.client.list_router_interfaces(
501 self.router['id'])['ports']
502 if port['device_owner'] in const.ROUTER_INTERFACE_OWNERS]
503 for i in interfaces:
504 try:
505 self.assertRaises(
506 lib_exc.Conflict, self.client.delete_router,
507 self.router['id'])
508 self.client.remove_router_interface_with_subnet_id(
509 self.router['id'], i['fixed_ips'][0]['subnet_id'])
510 except lib_exc.NotFound:
511 pass
512 self.client.delete_router(self.router['id'])