From 39f25321181cf442863be7763e18e256db4bf613 Mon Sep 17 00:00:00 2001 From: Slawek Kaplonski Date: Tue, 26 Feb 2019 12:44:07 +0100 Subject: [PATCH] Fix L3 agent scheduler tests in multinode environments Test will now first try to remove router from all agents on which it was hosted and then add it to one of agents again. Change-Id: I3a836c08aa700056597a3f72c2e314d3c43994c0 Closes-Bug: #1817696 --- .../api/admin/test_l3_agent_scheduler.py | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/neutron_tempest_plugin/api/admin/test_l3_agent_scheduler.py b/neutron_tempest_plugin/api/admin/test_l3_agent_scheduler.py index 3981dfbd..105112d7 100644 --- a/neutron_tempest_plugin/api/admin/test_l3_agent_scheduler.py +++ b/neutron_tempest_plugin/api/admin/test_l3_agent_scheduler.py @@ -68,18 +68,30 @@ class L3AgentSchedulerTestJSON(base.BaseAdminNetworkTest): @decorators.idempotent_id('9464e5e7-8625-49c3-8fd1-89c52be59d66') def test_add_list_remove_router_on_l3_agent(self): l3_agent_ids = list() + + # First list agents which host router + body = self.admin_client.list_l3_agents_hosting_router( + self.router['id']) + # Now remove router from all agents + for agent in body['agents']: + self.admin_client.remove_router_from_l3_agent( + agent['id'], self.router['id']) + + # Now list agents which host router again - list should be empty + body = self.admin_client.list_l3_agents_hosting_router( + self.router['id']) + self.assertEqual([], body['agents']) + + # Now add router to one of agents self.admin_client.add_router_to_l3_agent( self.agent['id'], + router_id=self.router['id']) + + # And check that router is hosted by this agent + body = self.admin_client.list_l3_agents_hosting_router( self.router['id']) - body = ( - self.admin_client.list_l3_agents_hosting_router(self.router['id'])) for agent in body['agents']: l3_agent_ids.append(agent['id']) self.assertIn('agent_type', agent) self.assertEqual('L3 agent', agent['agent_type']) self.assertIn(self.agent['id'], l3_agent_ids) - body = self.admin_client.remove_router_from_l3_agent( - self.agent['id'], - self.router['id']) - # NOTE(afazekas): The deletion not asserted, because neutron - # is not forbidden to reschedule the router to the same agent