Use _create_admin_router() where possible
It will automatically set the router for cleanup, so use
it instead of admin_client.create_router().
Trivialfix
Change-Id: I7cff3f164dd76ba5e160cee4566732be10e9276d
diff --git a/neutron_tempest_plugin/api/admin/test_routers_dvr.py b/neutron_tempest_plugin/api/admin/test_routers_dvr.py
index 8d80ba6..ab25a3f 100644
--- a/neutron_tempest_plugin/api/admin/test_routers_dvr.py
+++ b/neutron_tempest_plugin/api/admin/test_routers_dvr.py
@@ -55,10 +55,8 @@
set to True
"""
name = data_utils.rand_name('router')
- router = self.admin_client.create_router(name, distributed=True)
- self.addCleanup(self.admin_client.delete_router,
- router['router']['id'])
- self.assertTrue(router['router']['distributed'])
+ router = self._create_admin_router(name, distributed=True)
+ self.assertTrue(router['distributed'])
@decorators.idempotent_id('8a0a72b4-7290-4677-afeb-b4ffe37bc352')
def test_centralized_router_creation(self):
@@ -74,10 +72,8 @@
as opposed to a "Distributed Virtual Router"
"""
name = data_utils.rand_name('router')
- router = self.admin_client.create_router(name, distributed=False)
- self.addCleanup(self.admin_client.delete_router,
- router['router']['id'])
- self.assertFalse(router['router']['distributed'])
+ router = self._create_admin_router(name, distributed=False)
+ self.assertFalse(router['distributed'])
class RouterTestCentralizedToDVR(RoutersTestDVRBase):
@@ -100,13 +96,10 @@
"""
name = data_utils.rand_name('router')
# router needs to be in admin state down in order to be upgraded to DVR
- router = self.admin_client.create_router(name, distributed=False,
- ha=False,
- admin_state_up=False)
- self.addCleanup(self.admin_client.delete_router,
- router['router']['id'])
- self.assertFalse(router['router']['distributed'])
- self.assertFalse(router['router']['ha'])
- router = self.admin_client.update_router(router['router']['id'],
+ router = self._create_admin_router(name, distributed=False,
+ ha=False, admin_state_up=False)
+ self.assertFalse(router['distributed'])
+ self.assertFalse(router['ha'])
+ router = self.admin_client.update_router(router['id'],
distributed=True)
self.assertTrue(router['router']['distributed'])
diff --git a/neutron_tempest_plugin/api/test_routers.py b/neutron_tempest_plugin/api/test_routers.py
index ab6b0f6..3b9867b 100644
--- a/neutron_tempest_plugin/api/test_routers.py
+++ b/neutron_tempest_plugin/api/test_routers.py
@@ -73,12 +73,11 @@
external_gateway_info = {
'network_id': CONF.network.public_network_id,
'enable_snat': enable_snat}
- create_body = self.admin_client.create_router(
- name, external_gateway_info=external_gateway_info)
- self.addCleanup(self.admin_client.delete_router,
- create_body['router']['id'])
+ router = self._create_admin_router(
+ name, external_network_id=CONF.network.public_network_id,
+ enable_snat=enable_snat)
# Verify snat attributes after router creation
- self._verify_router_gateway(create_body['router']['id'],
+ self._verify_router_gateway(router['id'],
exp_ext_gw_info=external_gateway_info)
def _verify_router_gateway(self, router_id, exp_ext_gw_info=None):
@@ -238,12 +237,8 @@
@decorators.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'])
+ router = self._create_admin_router(name, distributed=True)
+ self.assertTrue(router['distributed'])
class DvrRoutersTestToCentralized(base_routers.BaseRouterTest):
@@ -255,11 +250,9 @@
# Convert a centralized router to distributed firstly
router_args = {'tenant_id': self.client.tenant_id,
'distributed': False, 'ha': False}
- router = self.admin_client.create_router(
+ router = self._create_admin_router(
data_utils.rand_name('router'), admin_state_up=False,
- **router_args)['router']
- self.addCleanup(self.admin_client.delete_router,
- router['id'])
+ **router_args)
self.assertFalse(router['distributed'])
self.assertFalse(router['ha'])
update_body = self.admin_client.update_router(router['id'],
@@ -289,11 +282,9 @@
def test_convert_centralized_router_to_distributed_extended(self):
router_args = {'tenant_id': self.client.tenant_id,
'distributed': False, 'ha': False}
- router = self.admin_client.create_router(
+ router = self._create_admin_router(
data_utils.rand_name('router'), admin_state_up=True,
- **router_args)['router']
- self.addCleanup(self.admin_client.delete_router,
- router['id'])
+ **router_args)
self.assertTrue(router['admin_state_up'])
self.assertFalse(router['distributed'])
# take router down to allow setting the router to distributed
@@ -314,11 +305,9 @@
def test_convert_distributed_router_to_centralized_extended(self):
router_args = {'tenant_id': self.client.tenant_id,
'distributed': True, 'ha': False}
- router = self.admin_client.create_router(
+ router = self._create_admin_router(
data_utils.rand_name('router'), admin_state_up=True,
- **router_args)['router']
- self.addCleanup(self.admin_client.delete_router,
- router['id'])
+ **router_args)
self.assertTrue(router['admin_state_up'])
self.assertTrue(router['distributed'])
# take router down to allow setting the router to centralized
diff --git a/neutron_tempest_plugin/api/test_routers_negative.py b/neutron_tempest_plugin/api/test_routers_negative.py
index f085fc9..5f24732 100644
--- a/neutron_tempest_plugin/api/test_routers_negative.py
+++ b/neutron_tempest_plugin/api/test_routers_negative.py
@@ -90,9 +90,9 @@
# create a centralized router
router_args = {'tenant_id': self.client.tenant_id,
'distributed': False}
- router = self.admin_client.create_router(
+ router = self._create_admin_router(
data_utils.rand_name('router'), admin_state_up=True,
- **router_args)['router']
+ **router_args)
self.assertTrue(router['admin_state_up'])
self.assertFalse(router['distributed'])
# attempt to set the router to distributed, catch BadRequest exception
@@ -107,9 +107,9 @@
# create a centralized router
router_args = {'tenant_id': self.client.tenant_id,
'distributed': False}
- router = self.admin_client.create_router(
+ router = self._create_admin_router(
data_utils.rand_name('router'), admin_state_up=True,
- **router_args)['router']
+ **router_args)
self.assertTrue(router['admin_state_up'])
self.assertFalse(router['distributed'])
# take the router down to modify distributed->True