Wait for L3 agents to be configured as master/backup
In the L3HA router test don't fail imediately when there is no master router found. Sometimes it may take a while before keepalived will negotiate proper statuses on nodes. This patch adds retry mechanism to the function which gets master and backup agents and waits 60 seconds for agents with correct statuses. Change-Id: Ic8c053a2cd4994f0ad7757670835ffa84dfa06cc
This commit is contained in:
parent
8a54914f92
commit
aa817c0913
|
@ -28,6 +28,19 @@ from tobiko.openstack import topology
|
|||
CONF = config.CONF
|
||||
|
||||
|
||||
def get_master_and_backup_agents(router_id, timeout=60., interval=2.):
|
||||
for attempt in tobiko.retry(timeout=timeout, interval=interval):
|
||||
try:
|
||||
router_agents = neutron.list_l3_agent_hosting_routers(
|
||||
router_id)
|
||||
master_agent = router_agents.with_items(ha_state='active').unique
|
||||
backup_agents = router_agents.with_items(ha_state='standby')
|
||||
return master_agent, backup_agents
|
||||
except Exception:
|
||||
attempt.check_limits()
|
||||
continue
|
||||
|
||||
|
||||
class RouterTest(testtools.TestCase):
|
||||
"""Test Neutron routers"""
|
||||
|
||||
|
@ -121,10 +134,8 @@ class L3HARouterTest(RouterTest):
|
|||
|
||||
@neutron.skip_if_missing_networking_extensions('l3_agent_scheduler')
|
||||
def test_router_is_scheduled_on_l3_agents(self):
|
||||
router_agents = neutron.list_l3_agent_hosting_routers(
|
||||
master_agent, backup_agents = get_master_and_backup_agents(
|
||||
self.router['id'])
|
||||
master_agent = router_agents.with_items(ha_state='active').unique
|
||||
backup_agents = router_agents.with_items(ha_state='standby')
|
||||
self.assertGreaterEqual(len(backup_agents), 1)
|
||||
self._check_routers_namespace_on_host(master_agent['host'])
|
||||
for backup_agent in backup_agents:
|
||||
|
|
Loading…
Reference in New Issue