]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Fix intermittent failure in TestNetworksFailover UT
authorarmando-migliaccio <armamig@gmail.com>
Tue, 24 Mar 2015 22:09:35 +0000 (15:09 -0700)
committerKevin Benton <blak111@gmail.com>
Sat, 21 Mar 2015 13:09:09 +0000 (06:09 -0700)
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 <jenkins@review.openstack.org>

Change-Id: I60ad7fa8ca874f93b7f806a0e035be84180a5de9
Closes-bug: #1432958

neutron/tests/unit/test_db_plugin.py
neutron/tests/unit/testlib_plugin.py

index ec8acc59a935e501fea46c60b06ebedfdfe3e981..9daff92822e22fb06090f48e11d31bde30d7593e 100644 (file)
@@ -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"
index 3f07e61f57594560584eb76f32f68fad3438e8ca..6bf97d4e2f1ef53487df471885e8b0c819517268 100644 (file)
@@ -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)