]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Fix KeyError: 'L3_ROUTER_NAT' in l3 scheduler functional test
authorAssaf Muller <amuller@redhat.com>
Sat, 25 Jul 2015 20:14:32 +0000 (16:14 -0400)
committerAssaf Muller <amuller@redhat.com>
Mon, 27 Jul 2015 14:21:52 +0000 (10:21 -0400)
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

neutron/tests/functional/scheduler/test_l3_agent_scheduler.py

index 7c3b2e81b0c821e75bf688a75ad06ec218564949..ca89515ba556098940a8295f60e7090978d39dbc 100644 (file)
 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: