Unit tests: Don't leave RPC server running

Several tests started an RPC server (sometimes unnecessarily) and left it
running after the test had concluded. This resulted in messy logs
("Exception in thread Thread-1 (most likely raised during interpreter
shutdown)" and so on) in the console when the test worker exited. Avoid
these by either not starting the RPC server or ensuring it is stopped
before the end of the test.

Change-Id: I8a506c6b83801cc90ad2268875f848b6d73fdea6
changes/36/513536/1
Zane Bitter 5 years ago
parent 3545caac56
commit 23c62e30fb
  1. 12
      heat/tests/engine/service/test_service_engine.py
  2. 12
      heat/tests/engine/service/test_stack_delete.py

@ -310,6 +310,8 @@ class ServiceEngineTest(common.HeatTestCase):
self.patchobject(self.eng.manage_thread_grp, 'stop',
new=mock.Mock(wraps=self.eng.manage_thread_grp.stop))
self.patchobject(self.eng, '_stop_rpc_server',
new=mock.Mock(wraps=self.eng._stop_rpc_server))
orig_stop = self.eng.thread_group_mgr.stop
with mock.patch.object(self.eng.thread_group_mgr, 'stop') as stop:
@ -340,8 +342,6 @@ class ServiceEngineTest(common.HeatTestCase):
self.eng.service_id
)
@mock.patch.object(service.EngineService,
'_stop_rpc_server')
@mock.patch.object(worker.WorkerService,
'stop')
@mock.patch('heat.common.context.get_admin_context',
@ -352,15 +352,13 @@ class ServiceEngineTest(common.HeatTestCase):
self,
service_delete_method,
admin_context_method,
worker_service_stop,
rpc_server_stop):
worker_service_stop):
cfg.CONF.set_default('convergence_engine', True)
self._test_engine_service_stop(
service_delete_method,
admin_context_method
)
@mock.patch.object(service.EngineService, '_stop_rpc_server')
@mock.patch('heat.common.context.get_admin_context',
return_value=mock.Mock())
@mock.patch('heat.objects.service.Service.delete',
@ -368,8 +366,7 @@ class ServiceEngineTest(common.HeatTestCase):
def test_engine_service_stop_in_non_convergence_mode(
self,
service_delete_method,
admin_context_method,
rpc_server_stop):
admin_context_method):
cfg.CONF.set_default('convergence_engine', False)
self._test_engine_service_stop(
service_delete_method,
@ -401,6 +398,7 @@ class ServiceEngineTest(common.HeatTestCase):
thread_group_manager_class,
sample_uuid_method,
rpc_client_class):
self.addCleanup(self.eng._stop_rpc_server)
self.eng.start()
self.assertEqual(cfg.CONF.executor_thread_pool_size,
cfg.CONF.database.max_overflow)

@ -104,7 +104,7 @@ class StackDeleteTest(common.HeatTestCase):
mock_acquire, mock_try,
mock_load):
cfg.CONF.set_override('error_wait_time', 0)
self.man.start()
self.man.engine_id = service_utils.generate_engine_id()
stack_name = 'service_delete_test_stack_current_active_lock'
stack = tools.get_stack(stack_name, self.ctx)
sid = stack.store()
@ -144,7 +144,10 @@ class StackDeleteTest(common.HeatTestCase):
mock_load):
cfg.CONF.set_override('error_wait_time', 0)
OTHER_ENGINE = "other-engine-fake-uuid"
self.man.start()
self.man.engine_id = service_utils.generate_engine_id()
self.man.listener = service.EngineListener(self.man.host,
self.man.engine_id,
self.man.thread_group_mgr)
stack_name = 'service_delete_test_stack_other_engine_lock_fail'
stack = tools.get_stack(stack_name, self.ctx)
sid = stack.store()
@ -184,7 +187,10 @@ class StackDeleteTest(common.HeatTestCase):
cfg.CONF.set_override('error_wait_time', 0)
OTHER_ENGINE = "other-engine-fake-uuid"
self.man.start()
self.man.engine_id = service_utils.generate_engine_id()
self.man.listener = service.EngineListener(self.man.host,
self.man.engine_id,
self.man.thread_group_mgr)
stack_name = 'service_delete_test_stack_other_engine_lock'
stack = tools.get_stack(stack_name, self.ctx)
sid = stack.store()

Loading…
Cancel
Save