Merge "test_routers_ha: Unify creating routers"

This commit is contained in:
Zuul 2017-12-15 16:59:38 +00:00 committed by Gerrit Code Review
commit badccb80af

View File

@ -33,8 +33,8 @@ class RoutersTestHA(base.BaseRouterTest):
super(RoutersTestHA, cls).resource_setup() super(RoutersTestHA, cls).resource_setup()
name = data_utils.rand_name('pretest-check') name = data_utils.rand_name('pretest-check')
router = cls.admin_client.create_router(name) router = cls.admin_client.create_router(name)
if 'ha' not in router['router']:
cls.admin_client.delete_router(router['router']['id']) cls.admin_client.delete_router(router['router']['id'])
if 'ha' not in router['router']:
msg = "'ha' attribute not found. HA Possibly not enabled" msg = "'ha' attribute not found. HA Possibly not enabled"
raise cls.skipException(msg) raise cls.skipException(msg)
@ -48,10 +48,8 @@ class RoutersTestHA(base.BaseRouterTest):
The router is created and the "ha" attribute is set to True The router is created and the "ha" attribute is set to True
""" """
name = data_utils.rand_name('router') name = data_utils.rand_name('router')
router = self.admin_client.create_router(name, ha=True) router = self._create_admin_router(name, ha=True)
self.addCleanup(self.admin_client.delete_router, self.assertTrue(router['ha'])
router['router']['id'])
self.assertTrue(router['router']['ha'])
@decorators.idempotent_id('97b5f7ef-2192-4fa3-901e-979cd5c1097a') @decorators.idempotent_id('97b5f7ef-2192-4fa3-901e-979cd5c1097a')
def test_legacy_router_creation(self): def test_legacy_router_creation(self):
@ -65,10 +63,8 @@ class RoutersTestHA(base.BaseRouterTest):
as opposed to a "High Availability Router" as opposed to a "High Availability Router"
""" """
name = data_utils.rand_name('router') name = data_utils.rand_name('router')
router = self.admin_client.create_router(name, ha=False) router = self.create_admin_router(name, ha=False)
self.addCleanup(self.admin_client.delete_router, self.assertFalse(router['ha'])
router['router']['id'])
self.assertFalse(router['router']['ha'])
@decorators.idempotent_id('5a6bfe82-5b23-45a4-b027-5160997d4753') @decorators.idempotent_id('5a6bfe82-5b23-45a4-b027-5160997d4753')
def test_legacy_router_update_to_ha(self): def test_legacy_router_update_to_ha(self):
@ -84,12 +80,10 @@ class RoutersTestHA(base.BaseRouterTest):
""" """
name = data_utils.rand_name('router') name = data_utils.rand_name('router')
# router needs to be in admin state down in order to be upgraded to HA # router needs to be in admin state down in order to be upgraded to HA
router = self.admin_client.create_router(name, ha=False, router = self._create_admin_router(name, ha=False,
admin_state_up=False) admin_state_up=False)
self.addCleanup(self.admin_client.delete_router, self.assertFalse(router['ha'])
router['router']['id']) router = self.admin_client.update_router(router['id'],
self.assertFalse(router['router']['ha'])
router = self.admin_client.update_router(router['router']['id'],
ha=True) ha=True)
self.assertTrue(router['router']['ha']) self.assertTrue(router['router']['ha'])