@classmethod
def create_router(cls, router_name=None, admin_state_up=False,
- external_network_id=None, enable_snat=None):
+ external_network_id=None, enable_snat=None,
+ **kwargs):
ext_gw_info = {}
if external_network_id:
ext_gw_info['network_id'] = external_network_id
ext_gw_info['enable_snat'] = enable_snat
body = cls.client.create_router(
router_name, external_gateway_info=ext_gw_info,
- admin_state_up=admin_state_up)
+ admin_state_up=admin_state_up, **kwargs)
router = body['router']
cls.routers.append(router)
return router
def resource_setup(cls):
super(BaseRouterTest, cls).resource_setup()
- def _delete_router(self, router_id):
- self.client.delete_router(router_id)
+ def _cleanup_router(self, router):
+ self.delete_router(router)
+ self.routers.remove(router)
+
+ def _create_router(self, name, admin_state_up=False,
+ external_network_id=None, enable_snat=None):
+ # associate a cleanup with created routers to avoid quota limits
+ router = self.create_router(name, admin_state_up,
+ external_network_id, enable_snat)
+ self.addCleanup(self._cleanup_router, router)
+ return router
+
+ def _delete_router(self, router_id, network_client=None):
+ client = network_client or self.client
+ client.delete_router(router_id)
# Asserting that the router is not found in the list
# after deletion
list_body = self.client.list_routers()
if cls._ip_version == 4 else
CONF.network.tenant_network_v6_cidr)
- def _cleanup_router(self, router):
- self.delete_router(router)
- self.routers.remove(router)
-
- def _create_router(self, name, admin_state_up=False,
- external_network_id=None, enable_snat=None):
- # associate a cleanup with created routers to avoid quota limits
- router = self.create_router(name, admin_state_up,
- external_network_id, enable_snat)
- self.addCleanup(self._cleanup_router, router)
- return router
-
@test.attr(type='smoke')
@test.idempotent_id('f64403e2-8483-4b34-8ccd-b09a87bcc68c')
def test_create_show_list_update_delete_router(self):
class RoutersIpV6Test(RoutersTest):
_ip_version = 6
+
+
+class DvrRoutersTest(base.BaseRouterTest):
+
+ @classmethod
+ def skip_checks(cls):
+ super(DvrRoutersTest, cls).skip_checks()
+ if not test.is_extension_enabled('dvr', 'network'):
+ msg = "DVR extension not enabled."
+ raise cls.skipException(msg)
+
+ @test.attr(type='smoke')
+ @test.idempotent_id('141297aa-3424-455d-aa8d-f2d95731e00a')
+ def test_create_distributed_router(self):
+ name = data_utils.rand_name('router')
+ create_body = self.admin_client.create_router(
+ name, distributed=True)
+ self.addCleanup(self._delete_router,
+ create_body['router']['id'],
+ self.admin_client)
+ self.assertTrue(create_body['router']['distributed'])
+
+ @test.attr(type='smoke')
+ @test.idempotent_id('644d7a4a-01a1-4b68-bb8d-0c0042cb1729')
+ def test_convert_centralized_router(self):
+ router = self._create_router(data_utils.rand_name('router'))
+ self.assertNotIn('distributed', router)
+ update_body = self.admin_client.update_router(router['id'],
+ distributed=True)
+ self.assertTrue(update_body['router']['distributed'])
+ show_body = self.admin_client.show_router(router['id'])
+ self.assertTrue(show_body['router']['distributed'])
+ show_body = self.client.show_router(router['id'])
+ self.assertNotIn('distributed', show_body['router'])
# under the License.
import netaddr
+import testtools
+
from tempest_lib.common.utils import data_utils
from tempest_lib import exceptions as lib_exc
class RoutersNegativeIpV6Test(RoutersNegativeTest):
_ip_version = 6
+
+
+class DvrRoutersNegativeTest(base.BaseRouterTest):
+
+ @classmethod
+ def skip_checks(cls):
+ super(DvrRoutersNegativeTest, cls).skip_checks()
+ if not test.is_extension_enabled('dvr', 'network'):
+ msg = "DVR extension not enabled."
+ raise cls.skipException(msg)
+
+ @classmethod
+ def resource_setup(cls):
+ super(DvrRoutersNegativeTest, cls).resource_setup()
+ cls.router = cls.create_router(data_utils.rand_name('router'))
+ cls.network = cls.create_network()
+ cls.subnet = cls.create_subnet(cls.network)
+
+ @test.attr(type=['negative', 'smoke'])
+ @test.idempotent_id('4990b055-8fc7-48ab-bba7-aa28beaad0b9')
+ def test_router_create_tenant_distributed_returns_forbidden(self):
+ with testtools.ExpectedException(lib_exc.Forbidden):
+ self.create_router(
+ data_utils.rand_name('router'), distributed=True)