Remove unnecessary mocking of get_admin_context
Because: - They are not necessary. - Neutron agent scheduler code (reschedule_resources_from_down_agents) seems to (correctly) assume each get_admin_context() call returns a fresh context. This mocking breaks it. - Right now, Neutron agentdb uses the new engine facade [1] and Neutron agent scheduler doesn't. It causes caching issue in our unit tests. (See the Related-Bug) Stopping reusing contexts (thus sessions) would prevent the issue. [1] https://review.openstack.org/#/c/611462/ Related-Bug: #1803745 Change-Id: Ia986f98f8bda9c7cde33af3dfdf2e45a2685fd6d
This commit is contained in:
parent
17e823e33a
commit
7f82a19155
|
@ -90,10 +90,6 @@ class TestSchedulerCallback(TestBgpDrAgentSchedulerBaseTestCase):
|
|||
bgp_notify_p.start()
|
||||
rpc_conn_p = mock.patch('neutron.common.rpc.Connection')
|
||||
rpc_conn_p.start()
|
||||
admin_ctx_p = mock.patch('neutron_lib.context.get_admin_context')
|
||||
admin_ctx_p = mock.patch('neutron_lib.context.get_admin_context')
|
||||
self.admin_ctx_m = admin_ctx_p.start()
|
||||
self.admin_ctx_m.return_value = self.ctx
|
||||
self.plugin = bgp_plugin.BgpPlugin()
|
||||
self.scheduler = bgp_dras.ChanceScheduler()
|
||||
|
||||
|
@ -127,7 +123,7 @@ class TestSchedulerCallback(TestBgpDrAgentSchedulerBaseTestCase):
|
|||
dr_resources.BGP_SPEAKER,
|
||||
events.AFTER_CREATE,
|
||||
self.scheduler, payload)
|
||||
sched_bgp.assert_called_once_with(self.ctx,
|
||||
sched_bgp.assert_called_once_with(mock.ANY,
|
||||
payload['bgp_speaker'])
|
||||
|
||||
def test_schedule_bgp_speaker_callback_with_invalid_event(self):
|
||||
|
@ -305,9 +301,6 @@ class TestRescheduleBgpSpeaker(TestBgpDrAgentSchedulerBaseTestCase,
|
|||
bgp_notify_p.start()
|
||||
rpc_conn_p = mock.patch('neutron.common.rpc.Connection')
|
||||
rpc_conn_p.start()
|
||||
admin_ctx_p = mock.patch('neutron_lib.context.get_admin_context')
|
||||
self.admin_ctx_m = admin_ctx_p.start()
|
||||
self.admin_ctx_m.return_value = self.ctx
|
||||
self.plugin = bgp_plugin.BgpPlugin()
|
||||
self.scheduler = bgp_dras.ChanceScheduler()
|
||||
self.host1 = 'host-a'
|
||||
|
|
Loading…
Reference in New Issue