From 5df1a72c9517ebfc90998467e72c6d999119ee68 Mon Sep 17 00:00:00 2001 From: Assaf Muller Date: Sat, 25 Jul 2015 16:14:32 -0400 Subject: [PATCH] Fix KeyError: 'L3_ROUTER_NAT' in l3 scheduler functional test The issue was introduced by commit with change ID: Ic4df299bac83c80abf0890a81d2dd36d15993b33 In Neutron-speak we define the 'core plugin' as something like ML2, while service plugins examples are L3, VPNaaS, etc. The code was initializing the L3 service plugin as the core plugin, which is unexpected behavior. The code will now use the DB core plugin base class as the core plugin, and not initialize the service plugins. The tests will manually and locally instantiate a L3 service plugin instance and use it. Change-Id: I2b7d2f6ccd5fe18e322e70b4e376db23d76b9092 Closes-Bug: #1478273 --- .../scheduler/test_l3_agent_scheduler.py | 31 +++++++------------ 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/neutron/tests/functional/scheduler/test_l3_agent_scheduler.py b/neutron/tests/functional/scheduler/test_l3_agent_scheduler.py index 7c3b2e81b..ca89515ba 100644 --- a/neutron/tests/functional/scheduler/test_l3_agent_scheduler.py +++ b/neutron/tests/functional/scheduler/test_l3_agent_scheduler.py @@ -16,10 +16,9 @@ import random import testscenarios -import neutron.extensions.l3 as l3_ext - from neutron import context from neutron.scheduler import l3_agent_scheduler +from neutron.services.l3_router import l3_router_plugin from neutron.tests.common import helpers from neutron.tests.unit.db import test_db_base_plugin_v2 @@ -34,12 +33,9 @@ class L3SchedulerBaseTest(test_db_base_plugin_v2.NeutronDbPluginV2TestCase): """ def setUp(self): - ext_mgr = l3_ext.L3() - plugin_str = ('neutron.services.l3_router.l3_router_plugin.' - 'L3RouterPlugin') - super(L3SchedulerBaseTest, self).setUp(plugin=plugin_str, - ext_mgr=ext_mgr) + super(L3SchedulerBaseTest, self).setUp() + self.l3_plugin = l3_router_plugin.L3RouterPlugin() self.adminContext = context.get_admin_context() self.adminContext.tenant_id = '_func_test_tenant_' @@ -51,14 +47,15 @@ class L3SchedulerBaseTest(test_db_base_plugin_v2.NeutronDbPluginV2TestCase): def _create_router(self, name): router = {'name': name, 'admin_state_up': True} - return self.plugin.create_router(self.adminContext, {'router': router}) + return self.l3_plugin.create_router( + self.adminContext, {'router': router}) def _create_legacy_agents(self, agent_count, down_agent_count): # Creates legacy l3 agents and sets admin state based on # down agent count. self.hosts = ['host-%s' % i for i in range(agent_count)] self.l3_agents = [self._create_l3_agent(self.hosts[i], - self.adminContext, 'legacy', self.plugin, + self.adminContext, 'legacy', self.l3_plugin, (i >= down_agent_count)) for i in range(agent_count)] def _create_routers(self, scheduled_router_count, @@ -93,10 +90,10 @@ class L3SchedulerBaseTest(test_db_base_plugin_v2.NeutronDbPluginV2TestCase): # Try scheduling on each host for host in self.hosts: did_it_schedule = self.scheduler.auto_schedule_routers( - self.plugin, - self.adminContext, - host, - router_ids) + self.l3_plugin, + self.adminContext, + host, + router_ids) if did_it_schedule: break @@ -168,9 +165,7 @@ class L3ChanceSchedulerTestCase(L3SchedulerBaseTest): self.scheduled_router_count) # schedule: actual_scheduled_agent = self.scheduler.schedule( - self.plugin, - self.adminContext, - self.routers[-1]['id']) + self.l3_plugin, self.adminContext, self.routers[-1]['id']) if self.expected_scheduled_router_count: self.assertIsNotNone(actual_scheduled_agent, @@ -255,9 +250,7 @@ class L3LeastRoutersSchedulerTestCase(L3SchedulerBaseTest): self.scheduled_router_count) actual_scheduled_agent = self.scheduler.schedule( - self.plugin, - self.adminContext, - self.routers[-1]['id']) + self.l3_plugin, self.adminContext, self.routers[-1]['id']) if self.expected_scheduled_router_count: # For case where there is just one agent: -- 2.45.2