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 <jenkins@review.openstack.org> Change-Id: I60ad7fa8ca874f93b7f806a0e035be84180a5de9 Closes-bug: #1432958
This commit is contained in:
parent
ddf7a29e48
commit
c0289458fa
|
@ -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"
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue