Merge "fix check_ports_exist_on_l3agent in no subnet case"
This commit is contained in:
commit
f4e08b1381
@ -385,6 +385,8 @@ class L3AgentSchedulerDbMixin(l3agentscheduler.L3AgentSchedulerPluginBase,
|
|||||||
ports on the host, running the input l3agent.
|
ports on the host, running the input l3agent.
|
||||||
"""
|
"""
|
||||||
subnet_ids = self.get_subnet_ids_on_router(context, router_id)
|
subnet_ids = self.get_subnet_ids_on_router(context, router_id)
|
||||||
|
if not subnet_ids:
|
||||||
|
return False
|
||||||
|
|
||||||
core_plugin = manager.NeutronManager.get_plugin()
|
core_plugin = manager.NeutronManager.get_plugin()
|
||||||
filter = {'fixed_ips': {'subnet_id': subnet_ids}}
|
filter = {'fixed_ips': {'subnet_id': subnet_ids}}
|
||||||
|
@ -667,33 +667,45 @@ class L3SchedulerTestBaseMixin(object):
|
|||||||
|
|
||||||
def test_check_ports_exist_on_l3agent_no_subnets(self):
|
def test_check_ports_exist_on_l3agent_no_subnets(self):
|
||||||
l3_agent, router = self._prepare_check_ports_exist_tests()
|
l3_agent, router = self._prepare_check_ports_exist_tests()
|
||||||
# no subnets
|
with mock.patch.object(manager.NeutronManager,
|
||||||
val = self.check_ports_exist_on_l3agent(self.adminContext,
|
'get_plugin') as getp:
|
||||||
l3_agent, router['id'])
|
getp.return_value = self.plugin
|
||||||
self.assertFalse(val)
|
# no subnets
|
||||||
|
self.get_subnet_ids_on_router.return_value = set()
|
||||||
|
val = self.check_ports_exist_on_l3agent(self.adminContext,
|
||||||
|
l3_agent, router['id'])
|
||||||
|
self.assertFalse(self.plugin.get_ports.called)
|
||||||
|
self.assertFalse(val)
|
||||||
|
|
||||||
def test_check_ports_exist_on_l3agent_no_subnet_match(self):
|
def test_check_ports_exist_on_l3agent_no_subnet_match(self):
|
||||||
l3_agent, router = self._prepare_check_ports_exist_tests()
|
l3_agent, router = self._prepare_check_ports_exist_tests()
|
||||||
# no matching subnet
|
with mock.patch.object(manager.NeutronManager,
|
||||||
self.plugin.get_subnet_ids_on_router = mock.Mock(
|
'get_plugin') as getp:
|
||||||
return_value=[str(uuid.uuid4())])
|
getp.return_value = self.plugin
|
||||||
val = self.check_ports_exist_on_l3agent(self.adminContext,
|
# no matching subnet
|
||||||
l3_agent, router['id'])
|
self.get_subnet_ids_on_router.return_value = [str(uuid.uuid4())]
|
||||||
self.assertFalse(val)
|
val = self.check_ports_exist_on_l3agent(self.adminContext,
|
||||||
|
l3_agent, router['id'])
|
||||||
|
self.assertTrue(self.plugin.get_ports.called)
|
||||||
|
self.assertFalse(val)
|
||||||
|
|
||||||
def test_check_ports_exist_on_l3agent_subnet_match(self):
|
def test_check_ports_exist_on_l3agent_subnet_match(self):
|
||||||
l3_agent, router = self._prepare_check_ports_exist_tests()
|
l3_agent, router = self._prepare_check_ports_exist_tests()
|
||||||
# matching subnet
|
with mock.patch.object(manager.NeutronManager,
|
||||||
port = {'subnet_id': str(uuid.uuid4()),
|
'get_plugin') as getp:
|
||||||
'binding:host_id': 'host_1',
|
getp.return_value = self.plugin
|
||||||
'device_owner': 'compute:',
|
# matching subnet
|
||||||
'id': 1234}
|
port = {'subnet_id': str(uuid.uuid4()),
|
||||||
self.plugin.get_ports.return_value = [port]
|
'binding:host_id': 'host_1',
|
||||||
self.plugin.get_subnet_ids_on_router = mock.Mock(
|
'device_owner': 'compute:',
|
||||||
return_value=[port['subnet_id']])
|
'id': 1234}
|
||||||
val = self.check_ports_exist_on_l3agent(self.adminContext,
|
self.plugin.get_ports.return_value = [port]
|
||||||
l3_agent, router['id'])
|
self.get_subnet_ids_on_router = mock.Mock(
|
||||||
self.assertTrue(val)
|
return_value=[port['subnet_id']])
|
||||||
|
val = self.check_ports_exist_on_l3agent(self.adminContext,
|
||||||
|
l3_agent, router['id'])
|
||||||
|
self.assertTrue(self.plugin.get_ports.called)
|
||||||
|
self.assertTrue(val)
|
||||||
|
|
||||||
|
|
||||||
class L3SchedulerTestCase(l3_agentschedulers_db.L3AgentSchedulerDbMixin,
|
class L3SchedulerTestCase(l3_agentschedulers_db.L3AgentSchedulerDbMixin,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user