Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 1 | # 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 | |
| 16 | import netaddr |
Dongcan Ye | a71b834 | 2018-05-02 06:56:26 +0000 | [diff] [blame] | 17 | |
Chandan Kumar | c125fd1 | 2017-11-15 19:41:01 +0530 | [diff] [blame] | 18 | from tempest.common import utils as tutils |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 19 | from tempest.lib.common.utils import data_utils |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 20 | from tempest.lib import decorators |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 21 | |
Chandan Kumar | 667d3d3 | 2017-09-22 12:24:06 +0530 | [diff] [blame] | 22 | from neutron_tempest_plugin.api import base |
| 23 | from neutron_tempest_plugin.api import base_routers |
| 24 | from neutron_tempest_plugin.common import utils |
| 25 | from neutron_tempest_plugin import config |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 26 | |
| 27 | CONF = config.CONF |
| 28 | |
| 29 | |
Ihar Hrachyshka | 44d1d3f | 2016-06-14 11:51:37 +0200 | [diff] [blame] | 30 | class RoutersTest(base_routers.BaseRouterTest): |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 31 | |
Jakub Libosvar | 1982aa1 | 2017-05-30 11:15:33 +0000 | [diff] [blame] | 32 | required_extensions = ['router'] |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 33 | |
| 34 | @classmethod |
| 35 | def resource_setup(cls): |
| 36 | super(RoutersTest, cls).resource_setup() |
| 37 | cls.tenant_cidr = ( |
| 38 | config.safe_get_config_value('network', 'project_network_cidr') |
| 39 | if cls._ip_version == 4 else |
| 40 | config.safe_get_config_value('network', 'project_network_v6_cidr')) |
| 41 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 42 | @decorators.idempotent_id('c72c1c0c-2193-4aca-eeee-b1442640eeee') |
Chandan Kumar | c125fd1 | 2017-11-15 19:41:01 +0530 | [diff] [blame] | 43 | @tutils.requires_ext(extension="standard-attr-description", |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 44 | service="network") |
| 45 | def test_create_update_router_description(self): |
| 46 | body = self.create_router(description='d1', router_name='test') |
| 47 | self.assertEqual('d1', body['description']) |
| 48 | body = self.client.show_router(body['id'])['router'] |
| 49 | self.assertEqual('d1', body['description']) |
| 50 | body = self.client.update_router(body['id'], description='d2') |
| 51 | self.assertEqual('d2', body['router']['description']) |
| 52 | body = self.client.show_router(body['router']['id'])['router'] |
| 53 | self.assertEqual('d2', body['description']) |
| 54 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 55 | @decorators.idempotent_id('847257cc-6afd-4154-b8fb-af49f5670ce8') |
Chandan Kumar | c125fd1 | 2017-11-15 19:41:01 +0530 | [diff] [blame] | 56 | @tutils.requires_ext(extension='ext-gw-mode', service='network') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 57 | def test_create_router_with_default_snat_value(self): |
| 58 | # Create a router with default snat rule |
| 59 | name = data_utils.rand_name('router') |
| 60 | router = self._create_router( |
| 61 | name, external_network_id=CONF.network.public_network_id) |
| 62 | self._verify_router_gateway( |
| 63 | router['id'], {'network_id': CONF.network.public_network_id, |
| 64 | 'enable_snat': True}) |
| 65 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 66 | @decorators.idempotent_id('ea74068d-09e9-4fd7-8995-9b6a1ace920f') |
Chandan Kumar | c125fd1 | 2017-11-15 19:41:01 +0530 | [diff] [blame] | 67 | @tutils.requires_ext(extension='ext-gw-mode', service='network') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 68 | def test_create_router_with_snat_explicit(self): |
| 69 | name = data_utils.rand_name('snat-router') |
| 70 | # Create a router enabling snat attributes |
| 71 | enable_snat_states = [False, True] |
| 72 | for enable_snat in enable_snat_states: |
| 73 | external_gateway_info = { |
| 74 | 'network_id': CONF.network.public_network_id, |
| 75 | 'enable_snat': enable_snat} |
Brian Haley | ee00085 | 2019-08-29 17:27:38 -0400 | [diff] [blame] | 76 | router = self._create_admin_router( |
| 77 | name, external_network_id=CONF.network.public_network_id, |
| 78 | enable_snat=enable_snat) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 79 | # Verify snat attributes after router creation |
Brian Haley | ee00085 | 2019-08-29 17:27:38 -0400 | [diff] [blame] | 80 | self._verify_router_gateway(router['id'], |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 81 | exp_ext_gw_info=external_gateway_info) |
| 82 | |
| 83 | def _verify_router_gateway(self, router_id, exp_ext_gw_info=None): |
| 84 | show_body = self.admin_client.show_router(router_id) |
| 85 | actual_ext_gw_info = show_body['router']['external_gateway_info'] |
| 86 | if exp_ext_gw_info is None: |
| 87 | self.assertIsNone(actual_ext_gw_info) |
| 88 | return |
| 89 | # Verify only keys passed in exp_ext_gw_info |
fpxie | aa3bace | 2017-04-07 17:12:15 +0800 | [diff] [blame] | 90 | for k, v in exp_ext_gw_info.items(): |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 91 | self.assertEqual(v, actual_ext_gw_info[k]) |
| 92 | |
| 93 | def _verify_gateway_port(self, router_id): |
| 94 | list_body = self.admin_client.list_ports( |
| 95 | network_id=CONF.network.public_network_id, |
| 96 | device_id=router_id) |
| 97 | self.assertEqual(len(list_body['ports']), 1) |
| 98 | gw_port = list_body['ports'][0] |
| 99 | fixed_ips = gw_port['fixed_ips'] |
| 100 | self.assertGreaterEqual(len(fixed_ips), 1) |
| 101 | public_net_body = self.admin_client.show_network( |
| 102 | CONF.network.public_network_id) |
Chandan Kumar | c125fd1 | 2017-11-15 19:41:01 +0530 | [diff] [blame] | 103 | public_subnet_ids = public_net_body['network']['subnets'] |
| 104 | for fixed_ip in fixed_ips: |
| 105 | self.assertIn(fixed_ip['subnet_id'], |
| 106 | public_subnet_ids) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 107 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 108 | @decorators.idempotent_id('b386c111-3b21-466d-880c-5e72b01e1a33') |
Chandan Kumar | c125fd1 | 2017-11-15 19:41:01 +0530 | [diff] [blame] | 109 | @tutils.requires_ext(extension='ext-gw-mode', service='network') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 110 | def test_update_router_set_gateway_with_snat_explicit(self): |
Chandan Kumar | c125fd1 | 2017-11-15 19:41:01 +0530 | [diff] [blame] | 111 | router = self._create_router(data_utils.rand_name('router')) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 112 | self.admin_client.update_router_with_snat_gw_info( |
| 113 | router['id'], |
| 114 | external_gateway_info={ |
| 115 | 'network_id': CONF.network.public_network_id, |
| 116 | 'enable_snat': True}) |
| 117 | self._verify_router_gateway( |
| 118 | router['id'], |
| 119 | {'network_id': CONF.network.public_network_id, |
| 120 | 'enable_snat': True}) |
| 121 | self._verify_gateway_port(router['id']) |
| 122 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 123 | @decorators.idempotent_id('96536bc7-8262-4fb2-9967-5c46940fa279') |
Chandan Kumar | c125fd1 | 2017-11-15 19:41:01 +0530 | [diff] [blame] | 124 | @tutils.requires_ext(extension='ext-gw-mode', service='network') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 125 | def test_update_router_set_gateway_without_snat(self): |
Chandan Kumar | c125fd1 | 2017-11-15 19:41:01 +0530 | [diff] [blame] | 126 | router = self._create_router(data_utils.rand_name('router')) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 127 | self.admin_client.update_router_with_snat_gw_info( |
| 128 | router['id'], |
| 129 | external_gateway_info={ |
| 130 | 'network_id': CONF.network.public_network_id, |
| 131 | 'enable_snat': False}) |
| 132 | self._verify_router_gateway( |
| 133 | router['id'], |
| 134 | {'network_id': CONF.network.public_network_id, |
| 135 | 'enable_snat': False}) |
| 136 | self._verify_gateway_port(router['id']) |
| 137 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 138 | @decorators.idempotent_id('f2faf994-97f4-410b-a831-9bc977b64374') |
Chandan Kumar | c125fd1 | 2017-11-15 19:41:01 +0530 | [diff] [blame] | 139 | @tutils.requires_ext(extension='ext-gw-mode', service='network') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 140 | def test_update_router_reset_gateway_without_snat(self): |
| 141 | router = self._create_router( |
Chandan Kumar | c125fd1 | 2017-11-15 19:41:01 +0530 | [diff] [blame] | 142 | data_utils.rand_name('router'), |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 143 | external_network_id=CONF.network.public_network_id) |
| 144 | self.admin_client.update_router_with_snat_gw_info( |
| 145 | router['id'], |
| 146 | external_gateway_info={ |
| 147 | 'network_id': CONF.network.public_network_id, |
| 148 | 'enable_snat': False}) |
| 149 | self._verify_router_gateway( |
| 150 | router['id'], |
| 151 | {'network_id': CONF.network.public_network_id, |
| 152 | 'enable_snat': False}) |
| 153 | self._verify_gateway_port(router['id']) |
| 154 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 155 | @decorators.idempotent_id('db3093b1-93b6-4893-be83-c4716c251b3e') |
Kevin Benton | c66aa80 | 2016-07-23 22:36:37 -0700 | [diff] [blame] | 156 | def test_router_interface_status(self): |
| 157 | network = self.create_network() |
| 158 | subnet = self.create_subnet(network) |
| 159 | # Add router interface with subnet id |
Chandan Kumar | c125fd1 | 2017-11-15 19:41:01 +0530 | [diff] [blame] | 160 | router = self._create_router(data_utils.rand_name('router'), True) |
Kevin Benton | c66aa80 | 2016-07-23 22:36:37 -0700 | [diff] [blame] | 161 | intf = self.create_router_interface(router['id'], subnet['id']) |
Brian Haley | 33ef460 | 2018-04-26 14:37:49 -0400 | [diff] [blame] | 162 | |
| 163 | def _status_active(): |
| 164 | return self.client.show_port( |
| 165 | intf['port_id'])['port']['status'] == 'ACTIVE' |
| 166 | |
| 167 | utils.wait_until_true(_status_active, exception=AssertionError) |
Kevin Benton | c66aa80 | 2016-07-23 22:36:37 -0700 | [diff] [blame] | 168 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 169 | @decorators.idempotent_id('c86ac3a8-50bd-4b00-a6b8-62af84a0765c') |
Chandan Kumar | c125fd1 | 2017-11-15 19:41:01 +0530 | [diff] [blame] | 170 | @tutils.requires_ext(extension='extraroute', service='network') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 171 | def test_update_extra_route(self): |
| 172 | self.network = self.create_network() |
| 173 | self.name = self.network['name'] |
| 174 | self.subnet = self.create_subnet(self.network) |
| 175 | # Add router interface with subnet id |
| 176 | self.router = self._create_router( |
| 177 | data_utils.rand_name('router-'), True) |
| 178 | self.create_router_interface(self.router['id'], self.subnet['id']) |
| 179 | self.addCleanup( |
| 180 | self._delete_extra_routes, |
| 181 | self.router['id']) |
| 182 | # Update router extra route, second ip of the range is |
| 183 | # used as next hop |
| 184 | cidr = netaddr.IPNetwork(self.subnet['cidr']) |
| 185 | next_hop = str(cidr[2]) |
| 186 | destination = str(self.subnet['cidr']) |
| 187 | extra_route = self.client.update_extra_routes(self.router['id'], |
| 188 | next_hop, destination) |
| 189 | self.assertEqual(1, len(extra_route['router']['routes'])) |
| 190 | self.assertEqual(destination, |
| 191 | extra_route['router']['routes'][0]['destination']) |
| 192 | self.assertEqual(next_hop, |
| 193 | extra_route['router']['routes'][0]['nexthop']) |
| 194 | show_body = self.client.show_router(self.router['id']) |
| 195 | self.assertEqual(destination, |
| 196 | show_body['router']['routes'][0]['destination']) |
| 197 | self.assertEqual(next_hop, |
| 198 | show_body['router']['routes'][0]['nexthop']) |
| 199 | |
| 200 | def _delete_extra_routes(self, router_id): |
| 201 | self.client.delete_extra_routes(router_id) |
| 202 | |
Bence Romsics | 46bd3af | 2019-09-13 10:52:41 +0200 | [diff] [blame] | 203 | @decorators.idempotent_id('b29d1698-d603-11e9-9c66-079cc4aec539') |
| 204 | @tutils.requires_ext(extension='extraroute-atomic', service='network') |
| 205 | def test_extra_routes_atomic(self): |
| 206 | self.network = self.create_network() |
| 207 | self.subnet = self.create_subnet(self.network) |
| 208 | self.router = self._create_router( |
| 209 | data_utils.rand_name('router-'), True) |
| 210 | self.create_router_interface(self.router['id'], self.subnet['id']) |
| 211 | self.addCleanup( |
| 212 | self._delete_extra_routes, |
| 213 | self.router['id']) |
| 214 | |
| 215 | if self._ip_version == 6: |
| 216 | dst = '2001:db8:%s::/64' |
| 217 | else: |
| 218 | dst = '10.0.%s.0/24' |
| 219 | |
| 220 | cidr = netaddr.IPNetwork(self.subnet['cidr']) |
| 221 | |
| 222 | routes = [ |
| 223 | {'destination': dst % 2, 'nexthop': cidr[2]}, |
| 224 | ] |
| 225 | resp = self.client.add_extra_routes_atomic( |
| 226 | self.router['id'], routes) |
| 227 | self.assertEqual(1, len(resp['router']['routes'])) |
| 228 | |
| 229 | routes = [ |
| 230 | {'destination': dst % 2, 'nexthop': cidr[2]}, |
| 231 | {'destination': dst % 3, 'nexthop': cidr[3]}, |
| 232 | ] |
| 233 | resp = self.client.add_extra_routes_atomic( |
| 234 | self.router['id'], routes) |
| 235 | self.assertEqual(2, len(resp['router']['routes'])) |
| 236 | |
| 237 | routes = [ |
| 238 | {'destination': dst % 3, 'nexthop': cidr[3]}, |
| 239 | {'destination': dst % 4, 'nexthop': cidr[4]}, |
| 240 | ] |
| 241 | resp = self.client.remove_extra_routes_atomic( |
| 242 | self.router['id'], routes) |
| 243 | self.assertEqual(1, len(resp['router']['routes'])) |
| 244 | |
| 245 | routes = [ |
| 246 | {'destination': dst % 2, 'nexthop': cidr[5]}, |
| 247 | ] |
| 248 | resp = self.client.add_extra_routes_atomic( |
| 249 | self.router['id'], routes) |
| 250 | self.assertEqual(2, len(resp['router']['routes'])) |
| 251 | |
| 252 | routes = [ |
| 253 | {'destination': dst % 2, 'nexthop': cidr[5]}, |
| 254 | ] |
| 255 | resp = self.client.remove_extra_routes_atomic( |
| 256 | self.router['id'], routes) |
| 257 | self.assertEqual(1, len(resp['router']['routes'])) |
| 258 | |
| 259 | routes = [ |
| 260 | {'destination': dst % 2, 'nexthop': cidr[2]}, |
| 261 | {'destination': dst % 3, 'nexthop': cidr[3]}, |
| 262 | {'destination': dst % 2, 'nexthop': cidr[5]}, |
| 263 | ] |
| 264 | resp = self.client.remove_extra_routes_atomic( |
| 265 | self.router['id'], routes) |
| 266 | self.assertEqual(0, len(resp['router']['routes'])) |
| 267 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 268 | @decorators.idempotent_id('01f185d1-d1a6-4cf9-abf7-e0e1384c169c') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 269 | def test_network_attached_with_two_routers(self): |
| 270 | network = self.create_network(data_utils.rand_name('network1')) |
| 271 | self.create_subnet(network) |
| 272 | port1 = self.create_port(network) |
| 273 | port2 = self.create_port(network) |
| 274 | router1 = self._create_router(data_utils.rand_name('router1')) |
| 275 | router2 = self._create_router(data_utils.rand_name('router2')) |
| 276 | self.client.add_router_interface_with_port_id( |
| 277 | router1['id'], port1['id']) |
| 278 | self.client.add_router_interface_with_port_id( |
| 279 | router2['id'], port2['id']) |
| 280 | self.addCleanup(self.client.remove_router_interface_with_port_id, |
| 281 | router1['id'], port1['id']) |
| 282 | self.addCleanup(self.client.remove_router_interface_with_port_id, |
| 283 | router2['id'], port2['id']) |
| 284 | body = self.client.show_port(port1['id']) |
| 285 | port_show1 = body['port'] |
| 286 | body = self.client.show_port(port2['id']) |
| 287 | port_show2 = body['port'] |
| 288 | self.assertEqual(port_show1['network_id'], network['id']) |
| 289 | self.assertEqual(port_show2['network_id'], network['id']) |
| 290 | self.assertEqual(port_show1['device_id'], router1['id']) |
| 291 | self.assertEqual(port_show2['device_id'], router2['id']) |
| 292 | |
| 293 | |
| 294 | class RoutersIpV6Test(RoutersTest): |
| 295 | _ip_version = 6 |
| 296 | |
| 297 | |
Ihar Hrachyshka | 44d1d3f | 2016-06-14 11:51:37 +0200 | [diff] [blame] | 298 | class DvrRoutersTest(base_routers.BaseRouterTest): |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 299 | |
Jakub Libosvar | 1982aa1 | 2017-05-30 11:15:33 +0000 | [diff] [blame] | 300 | required_extensions = ['dvr'] |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 301 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 302 | @decorators.idempotent_id('141297aa-3424-455d-aa8d-f2d95731e00a') |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 303 | def test_create_distributed_router(self): |
| 304 | name = data_utils.rand_name('router') |
Brian Haley | ee00085 | 2019-08-29 17:27:38 -0400 | [diff] [blame] | 305 | router = self._create_admin_router(name, distributed=True) |
| 306 | self.assertTrue(router['distributed']) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 307 | |
Dongcan Ye | a71b834 | 2018-05-02 06:56:26 +0000 | [diff] [blame] | 308 | |
| 309 | class DvrRoutersTestToCentralized(base_routers.BaseRouterTest): |
| 310 | |
| 311 | required_extensions = ['dvr', 'l3-ha'] |
| 312 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 313 | @decorators.idempotent_id('644d7a4a-01a1-4b68-bb8d-0c0042cb1729') |
Kailun Qin | ce246d0 | 2018-07-20 21:38:07 +0800 | [diff] [blame] | 314 | def test_convert_distributed_router_back_to_centralized(self): |
| 315 | # Convert a centralized router to distributed firstly |
Brian Haley | 198a2d9 | 2017-06-16 16:23:44 -0400 | [diff] [blame] | 316 | router_args = {'tenant_id': self.client.tenant_id, |
| 317 | 'distributed': False, 'ha': False} |
Brian Haley | ee00085 | 2019-08-29 17:27:38 -0400 | [diff] [blame] | 318 | router = self._create_admin_router( |
Brian Haley | 198a2d9 | 2017-06-16 16:23:44 -0400 | [diff] [blame] | 319 | data_utils.rand_name('router'), admin_state_up=False, |
Brian Haley | ee00085 | 2019-08-29 17:27:38 -0400 | [diff] [blame] | 320 | **router_args) |
Brian Haley | 198a2d9 | 2017-06-16 16:23:44 -0400 | [diff] [blame] | 321 | self.assertFalse(router['distributed']) |
| 322 | self.assertFalse(router['ha']) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 323 | update_body = self.admin_client.update_router(router['id'], |
| 324 | distributed=True) |
| 325 | self.assertTrue(update_body['router']['distributed']) |
| 326 | show_body = self.admin_client.show_router(router['id']) |
| 327 | self.assertTrue(show_body['router']['distributed']) |
Kailun Qin | ce246d0 | 2018-07-20 21:38:07 +0800 | [diff] [blame] | 328 | self.assertFalse(show_body['router']['ha']) |
| 329 | # Then convert the distributed router back to centralized |
| 330 | update_body = self.admin_client.update_router(router['id'], |
| 331 | distributed=False) |
| 332 | self.assertFalse(update_body['router']['distributed']) |
| 333 | show_body = self.admin_client.show_router(router['id']) |
| 334 | self.assertFalse(show_body['router']['distributed']) |
| 335 | self.assertFalse(show_body['router']['ha']) |
Daniel Mellado | 3c0aeab | 2016-01-29 11:30:25 +0000 | [diff] [blame] | 336 | show_body = self.client.show_router(router['id']) |
| 337 | self.assertNotIn('distributed', show_body['router']) |
Brian Haley | 198a2d9 | 2017-06-16 16:23:44 -0400 | [diff] [blame] | 338 | self.assertNotIn('ha', show_body['router']) |
Ihar Hrachyshka | 44d1d3f | 2016-06-14 11:51:37 +0200 | [diff] [blame] | 339 | |
| 340 | |
Matt Welch | ffe9be8 | 2019-07-02 13:24:29 +0000 | [diff] [blame] | 341 | class DvrRoutersTestUpdateDistributedExtended(base_routers.BaseRouterTest): |
| 342 | |
| 343 | required_extensions = ['dvr', 'l3-ha', |
| 344 | 'router-admin-state-down-before-update'] |
| 345 | |
| 346 | @decorators.idempotent_id('0ffb9973-0c1a-4b76-a1f2-060178057661') |
| 347 | def test_convert_centralized_router_to_distributed_extended(self): |
| 348 | router_args = {'tenant_id': self.client.tenant_id, |
| 349 | 'distributed': False, 'ha': False} |
Brian Haley | ee00085 | 2019-08-29 17:27:38 -0400 | [diff] [blame] | 350 | router = self._create_admin_router( |
Matt Welch | ffe9be8 | 2019-07-02 13:24:29 +0000 | [diff] [blame] | 351 | data_utils.rand_name('router'), admin_state_up=True, |
Brian Haley | ee00085 | 2019-08-29 17:27:38 -0400 | [diff] [blame] | 352 | **router_args) |
Matt Welch | ffe9be8 | 2019-07-02 13:24:29 +0000 | [diff] [blame] | 353 | self.assertTrue(router['admin_state_up']) |
| 354 | self.assertFalse(router['distributed']) |
| 355 | # take router down to allow setting the router to distributed |
| 356 | update_body = self.admin_client.update_router(router['id'], |
| 357 | admin_state_up=False) |
| 358 | self.assertFalse(update_body['router']['admin_state_up']) |
| 359 | # set the router to distributed |
| 360 | update_body = self.admin_client.update_router(router['id'], |
| 361 | distributed=True) |
| 362 | self.assertTrue(update_body['router']['distributed']) |
| 363 | # bring the router back up |
| 364 | update_body = self.admin_client.update_router(router['id'], |
| 365 | admin_state_up=True) |
| 366 | self.assertTrue(update_body['router']['admin_state_up']) |
| 367 | self.assertTrue(update_body['router']['distributed']) |
| 368 | |
| 369 | @decorators.idempotent_id('e9a8f55b-c535-44b7-8b0a-20af6a7c2921') |
| 370 | def test_convert_distributed_router_to_centralized_extended(self): |
| 371 | router_args = {'tenant_id': self.client.tenant_id, |
| 372 | 'distributed': True, 'ha': False} |
Brian Haley | ee00085 | 2019-08-29 17:27:38 -0400 | [diff] [blame] | 373 | router = self._create_admin_router( |
Matt Welch | ffe9be8 | 2019-07-02 13:24:29 +0000 | [diff] [blame] | 374 | data_utils.rand_name('router'), admin_state_up=True, |
Brian Haley | ee00085 | 2019-08-29 17:27:38 -0400 | [diff] [blame] | 375 | **router_args) |
Matt Welch | ffe9be8 | 2019-07-02 13:24:29 +0000 | [diff] [blame] | 376 | self.assertTrue(router['admin_state_up']) |
| 377 | self.assertTrue(router['distributed']) |
| 378 | # take router down to allow setting the router to centralized |
| 379 | update_body = self.admin_client.update_router(router['id'], |
| 380 | admin_state_up=False) |
| 381 | self.assertFalse(update_body['router']['admin_state_up']) |
| 382 | # set router to centralized |
| 383 | update_body = self.admin_client.update_router(router['id'], |
| 384 | distributed=False) |
| 385 | self.assertFalse(update_body['router']['distributed']) |
| 386 | # bring router back up |
| 387 | update_body = self.admin_client.update_router(router['id'], |
| 388 | admin_state_up=True) |
| 389 | self.assertTrue(update_body['router']['admin_state_up']) |
| 390 | self.assertFalse(update_body['router']['distributed']) |
| 391 | |
| 392 | |
Dongcan Ye | 6d8ec4a | 2017-05-03 15:07:36 +0800 | [diff] [blame] | 393 | class HaRoutersTest(base_routers.BaseRouterTest): |
| 394 | |
Jakub Libosvar | 1982aa1 | 2017-05-30 11:15:33 +0000 | [diff] [blame] | 395 | required_extensions = ['l3-ha'] |
Dongcan Ye | 6d8ec4a | 2017-05-03 15:07:36 +0800 | [diff] [blame] | 396 | |
| 397 | @decorators.idempotent_id('77db8eae-3aa3-4e61-bf2a-e739ce042e53') |
| 398 | def test_convert_legacy_router(self): |
| 399 | router = self._create_router(data_utils.rand_name('router')) |
| 400 | self.assertNotIn('ha', router) |
| 401 | update_body = self.admin_client.update_router(router['id'], |
| 402 | ha=True) |
| 403 | self.assertTrue(update_body['router']['ha']) |
| 404 | show_body = self.admin_client.show_router(router['id']) |
| 405 | self.assertTrue(show_body['router']['ha']) |
| 406 | show_body = self.client.show_router(router['id']) |
| 407 | self.assertNotIn('ha', show_body['router']) |
| 408 | |
| 409 | |
Ihar Hrachyshka | 44d1d3f | 2016-06-14 11:51:37 +0200 | [diff] [blame] | 410 | class RoutersSearchCriteriaTest(base.BaseSearchCriteriaTest): |
| 411 | |
Jakub Libosvar | 1982aa1 | 2017-05-30 11:15:33 +0000 | [diff] [blame] | 412 | required_extensions = ['router'] |
Ihar Hrachyshka | 44d1d3f | 2016-06-14 11:51:37 +0200 | [diff] [blame] | 413 | resource = 'router' |
| 414 | |
| 415 | @classmethod |
Ihar Hrachyshka | 44d1d3f | 2016-06-14 11:51:37 +0200 | [diff] [blame] | 416 | def resource_setup(cls): |
| 417 | super(RoutersSearchCriteriaTest, cls).resource_setup() |
| 418 | for name in cls.resource_names: |
| 419 | cls.create_router(router_name=name) |
| 420 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 421 | @decorators.idempotent_id('03a69efb-90a7-435b-bb5c-3add3612085a') |
Ihar Hrachyshka | 44d1d3f | 2016-06-14 11:51:37 +0200 | [diff] [blame] | 422 | def test_list_sorts_asc(self): |
| 423 | self._test_list_sorts_asc() |
| 424 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 425 | @decorators.idempotent_id('95913d30-ff41-4b17-9f44-5258c651e78c') |
Ihar Hrachyshka | 44d1d3f | 2016-06-14 11:51:37 +0200 | [diff] [blame] | 426 | def test_list_sorts_desc(self): |
| 427 | self._test_list_sorts_desc() |
| 428 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 429 | @decorators.idempotent_id('7f7d40b1-e165-4817-8dc5-02f8e2f0dff3') |
Ihar Hrachyshka | 44d1d3f | 2016-06-14 11:51:37 +0200 | [diff] [blame] | 430 | def test_list_pagination(self): |
| 431 | self._test_list_pagination() |
| 432 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 433 | @decorators.idempotent_id('a5b83e83-3d98-45bb-a2c7-0ee179ffd42c') |
Ihar Hrachyshka | 44d1d3f | 2016-06-14 11:51:37 +0200 | [diff] [blame] | 434 | def test_list_pagination_with_marker(self): |
| 435 | self._test_list_pagination_with_marker() |
| 436 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 437 | @decorators.idempotent_id('40804af8-c25d-45f8-b8a8-b4c70345215d') |
Ihar Hrachyshka | 44d1d3f | 2016-06-14 11:51:37 +0200 | [diff] [blame] | 438 | def test_list_pagination_with_href_links(self): |
| 439 | self._test_list_pagination_with_href_links() |
| 440 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 441 | @decorators.idempotent_id('77b9676c-d3cb-43af-a0e8-a5b8c6099e70') |
Ihar Hrachyshka | 44d1d3f | 2016-06-14 11:51:37 +0200 | [diff] [blame] | 442 | def test_list_pagination_page_reverse_asc(self): |
| 443 | self._test_list_pagination_page_reverse_asc() |
| 444 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 445 | @decorators.idempotent_id('3133a2c5-1bb9-4fc7-833e-cf9a1d160255') |
Ihar Hrachyshka | 44d1d3f | 2016-06-14 11:51:37 +0200 | [diff] [blame] | 446 | def test_list_pagination_page_reverse_desc(self): |
| 447 | self._test_list_pagination_page_reverse_desc() |
| 448 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 449 | @decorators.idempotent_id('8252e2f0-b3da-4738-8e25-f6f8d878a2da') |
Ihar Hrachyshka | 44d1d3f | 2016-06-14 11:51:37 +0200 | [diff] [blame] | 450 | def test_list_pagination_page_reverse_with_href_links(self): |
| 451 | self._test_list_pagination_page_reverse_with_href_links() |
| 452 | |
Sławek Kapłoński | c0caa2e | 2017-02-25 10:11:32 +0000 | [diff] [blame] | 453 | @decorators.idempotent_id('fb102124-20f8-4cb3-8c81-f16f5e41d192') |
Ihar Hrachyshka | 44d1d3f | 2016-06-14 11:51:37 +0200 | [diff] [blame] | 454 | def test_list_no_pagination_limit_0(self): |
| 455 | self._test_list_no_pagination_limit_0() |