From 387f396db83179ce109162022ab23e0c8b59c9bf Mon Sep 17 00:00:00 2001 From: Kevin Benton Date: Wed, 18 Mar 2015 08:14:09 -0700 Subject: [PATCH] Make DHCP tests cleanup neutron manager reference The DHCP scheduler unit tests occasionally call methods on the core plugin via the neutron manager (e.g. in report_state). However, they weren't calling the normal unit test cleanup routines for tests that call the core plugin so they were leaving stale references in the manager. This patch uses the setup_coreplugin helper that sets up the configuration for the core plugin and adds the cleanup call to ensure that the neutron manager is cleaned up at the end of each test. Closes-Bug: #1434278 Change-Id: Ic35629659574121c739574c1ed39364d6977c3ea --- neutron/tests/unit/test_dhcp_scheduler.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/neutron/tests/unit/test_dhcp_scheduler.py b/neutron/tests/unit/test_dhcp_scheduler.py index 36a2ba1306d..144d5563af2 100644 --- a/neutron/tests/unit/test_dhcp_scheduler.py +++ b/neutron/tests/unit/test_dhcp_scheduler.py @@ -31,6 +31,7 @@ from neutron.db import models_v2 from neutron.extensions import dhcpagentscheduler from neutron.scheduler import dhcp_agent_scheduler from neutron.tests.unit import testlib_api +from neutron.tests.unit import testlib_plugin # Required to generate tests from scenarios. Not compatible with nose. load_tests = testscenarios.load_tests_apply_scenarios @@ -268,7 +269,8 @@ class TestNetworksFailover(TestDhcpSchedulerBaseTestCase, self.assertIn('foo4', res_ids) -class DHCPAgentWeightSchedulerTestCase(TestDhcpSchedulerBaseTestCase): +class DHCPAgentWeightSchedulerTestCase(TestDhcpSchedulerBaseTestCase, + testlib_plugin.PluginSetupHelper): """Unit test scenarios for WeightScheduler.schedule.""" hostc = { @@ -294,7 +296,7 @@ class DHCPAgentWeightSchedulerTestCase(TestDhcpSchedulerBaseTestCase): def setUp(self): super(DHCPAgentWeightSchedulerTestCase, self).setUp() DB_PLUGIN_KLASS = 'neutron.plugins.ml2.plugin.Ml2Plugin' - cfg.CONF.set_override("core_plugin", DB_PLUGIN_KLASS) + self.setup_coreplugin(DB_PLUGIN_KLASS) cfg.CONF.set_override("network_scheduler_driver", 'neutron.scheduler.dhcp_agent_scheduler.WeightScheduler') self.dhcp_periodic_p = mock.patch(