From: armando-migliaccio Date: Tue, 24 Mar 2015 22:09:35 +0000 (-0700) Subject: Fix intermittent failure in TestNetworksFailover UT X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=c0289458fa9055ee488989828951d15fa2a06da3;p=openstack-build%2Fneutron-build.git Fix intermittent failure in TestNetworksFailover UT Ensure that the periodic check does not get in the way of method calls being tested, by stopping the periodic task from running. This patch moves the mock for the periodic check into the setup_coreplugin call so it gets called by unit tests that use the core plugin. The previous location after the construction of the API router was too late because the core plugin was already constructed by the neutron manager. This led to random failures because the periodic tasks leaked by all of the unit tests would occasionally preempt test_reschedule_network_from_down_agent in automatically removing a network from an agent. Co-Author: Jenkins Change-Id: I60ad7fa8ca874f93b7f806a0e035be84180a5de9 Closes-bug: #1432958 --- diff --git a/neutron/tests/unit/test_db_plugin.py b/neutron/tests/unit/test_db_plugin.py index ec8acc59a..9daff9282 100644 --- a/neutron/tests/unit/test_db_plugin.py +++ b/neutron/tests/unit/test_db_plugin.py @@ -123,11 +123,6 @@ class NeutronDbPluginV2TestCase(testlib_api.WebTestCase, self.net_create_status = 'ACTIVE' self.port_create_status = 'ACTIVE' - self.dhcp_periodic_p = mock.patch( - 'neutron.db.agentschedulers_db.DhcpAgentSchedulerDbMixin.' - 'start_periodic_dhcp_agent_status_check') - self.patched_dhcp_periodic = self.dhcp_periodic_p.start() - def _is_native_bulk_supported(): plugin_obj = manager.NeutronManager.get_plugin() native_bulk_attr_name = ("_%s__native_bulk_support" diff --git a/neutron/tests/unit/testlib_plugin.py b/neutron/tests/unit/testlib_plugin.py index 3f07e61f5..6bf97d4e2 100644 --- a/neutron/tests/unit/testlib_plugin.py +++ b/neutron/tests/unit/testlib_plugin.py @@ -55,6 +55,10 @@ class PluginSetupHelper(object): self.fail('The plugin for this test was not deallocated.') def setup_coreplugin(self, core_plugin=None): + self.dhcp_periodic_p = mock.patch( + 'neutron.db.agentschedulers_db.DhcpAgentSchedulerDbMixin.' + 'start_periodic_dhcp_agent_status_check') + self.patched_dhcp_periodic = self.dhcp_periodic_p.start() # Plugin cleanup should be triggered last so that # test-specific cleanup has a chance to release references. self.addCleanup(self.cleanup_core_plugin)