fixing HerokuWorkerShutdownTestCase after #1194 (#1213)

main
Samuel Colvin 5 years ago committed by GitHub
parent 8a0153efc8
commit 4036471203
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -471,7 +471,7 @@ class Worker(object):
The return value indicates whether any jobs were processed. The return value indicates whether any jobs were processed.
""" """
setup_loghandlers(logging_level, date_format, log_format) setup_loghandlers(logging_level, date_format, log_format)
completed_jobs = 0 completed_jobs = 0
self.register_birth() self.register_birth()
self.log.info("Worker %s: started, version %s", self.key, VERSION) self.log.info("Worker %s: started, version %s", self.key, VERSION)

@ -1189,7 +1189,8 @@ class HerokuWorkerShutdownTestCase(TimeoutTestCase, RQTestCase):
err = 'ShutDownImminentException: shut down imminent (signal: SIGRTMIN)' err = 'ShutDownImminentException: shut down imminent (signal: SIGRTMIN)'
self.assertTrue(stderr.endswith(err), stderr) self.assertTrue(stderr.endswith(err), stderr)
def test_handle_shutdown_request(self): @mock.patch('rq.worker.logger.info')
def test_handle_shutdown_request(self, mock_logger_info):
"""Mutate HerokuWorker so _horse_pid refers to an artificial process """Mutate HerokuWorker so _horse_pid refers to an artificial process
and test handle_warm_shutdown_request""" and test handle_warm_shutdown_request"""
w = HerokuWorker('foo') w = HerokuWorker('foo')
@ -1202,8 +1203,11 @@ class HerokuWorkerShutdownTestCase(TimeoutTestCase, RQTestCase):
w._horse_pid = p.pid w._horse_pid = p.pid
w.handle_warm_shutdown_request() w.handle_warm_shutdown_request()
p.join(2) p.join(2)
self.assertEqual(p.exitcode, -34) # would expect p.exitcode to be -34 but for some reason os.waitpid is setting it to None, even though
# the process has ended
self.assertEqual(p.exitcode, None)
self.assertFalse(os.path.exists(path)) self.assertFalse(os.path.exists(path))
mock_logger_info.assert_called_with('Killed horse pid %s', p.pid)
def test_handle_shutdown_request_no_horse(self): def test_handle_shutdown_request_no_horse(self):
"""Mutate HerokuWorker so _horse_pid refers to non existent process """Mutate HerokuWorker so _horse_pid refers to non existent process

Loading…
Cancel
Save