diff --git a/neutron/tests/fullstack/base.py b/neutron/tests/fullstack/base.py index c45dea75fe7..6fe81a37c87 100644 --- a/neutron/tests/fullstack/base.py +++ b/neutron/tests/fullstack/base.py @@ -97,13 +97,12 @@ class BaseFullStackTestCase(testlib_api.MySQLTestCaseMixin, def _assert_ping_during_agents_restart( self, agents, src_namespace, ips, restart_timeout=10, - ping_timeout=1, count=10, max_workers=None): - max_workers = max_workers or len(agents) + ping_timeout=1, count=10): with net_helpers.async_ping( src_namespace, ips, timeout=ping_timeout, count=count) as done: LOG.debug("Restarting agents") - executor = futures.ThreadPoolExecutor(max_workers=max_workers) + executor = futures.ThreadPoolExecutor(max_workers=len(agents)) restarts = [agent.restart(executor=executor) for agent in agents] diff --git a/neutron/tests/fullstack/test_l3_agent.py b/neutron/tests/fullstack/test_l3_agent.py index 21100711b00..9b7fc0c9196 100644 --- a/neutron/tests/fullstack/test_l3_agent.py +++ b/neutron/tests/fullstack/test_l3_agent.py @@ -318,6 +318,19 @@ class TestHAL3Agent(TestL3Agent): if self._get_keepalived_state(keepalived_state_file) == "master": return keepalived_state_file + def _get_l3_agents_with_ha_state(self, l3_agents, router_id, ha_state): + found_agents = [] + agents_hosting_router = self.client.list_l3_agent_hosting_routers( + router_id)['agents'] + for agent in l3_agents: + agent_host = agent.neutron_cfg_fixture.get_host() + for agent_hosting_router in agents_hosting_router: + if (agent_hosting_router['host'] == agent_host and + agent_hosting_router['ha_state'] == ha_state): + found_agents.append(agent) + break + return found_agents + def test_keepalived_multiple_sighups_does_not_forfeit_mastership(self): """Setup a complete "Neutron stack" - both an internal and an external network+subnet, and a router connected to both. @@ -397,10 +410,16 @@ class TestHAL3Agent(TestL3Agent): external_vm.block_until_ping(router_ip) l3_agents = [host.agents['l3'] for host in self.environment.hosts] + l3_standby_agents = self._get_l3_agents_with_ha_state( + l3_agents, router['id'], 'standby') + l3_active_agents = self._get_l3_agents_with_ha_state( + l3_agents, router['id'], 'active') self._assert_ping_during_agents_restart( - l3_agents, external_vm.namespace, [router_ip], count=60, - max_workers=1) + l3_standby_agents, external_vm.namespace, [router_ip], count=60) + + self._assert_ping_during_agents_restart( + l3_active_agents, external_vm.namespace, [router_ip], count=60) def test_gateway_ip_changed(self): self._test_gateway_ip_changed()