|
|
@ -14,8 +14,7 @@ import subprocess
|
|
|
|
from tests import RQTestCase, slow
|
|
|
|
from tests import RQTestCase, slow
|
|
|
|
from tests.fixtures import (create_file, create_file_after_timeout,
|
|
|
|
from tests.fixtures import (create_file, create_file_after_timeout,
|
|
|
|
div_by_zero, do_nothing, say_hello, say_pid,
|
|
|
|
div_by_zero, do_nothing, say_hello, say_pid,
|
|
|
|
run_dummy_heroku_worker, access_self,
|
|
|
|
run_dummy_heroku_worker, access_self)
|
|
|
|
long_running_job)
|
|
|
|
|
|
|
|
from tests.helpers import strip_microseconds
|
|
|
|
from tests.helpers import strip_microseconds
|
|
|
|
|
|
|
|
|
|
|
|
from rq import (get_failed_queue, Queue, SimpleWorker, Worker,
|
|
|
|
from rq import (get_failed_queue, Queue, SimpleWorker, Worker,
|
|
|
@ -733,6 +732,10 @@ class HerokuWorkerShutdownTestCase(TimeoutTestCase, RQTestCase):
|
|
|
|
self.assertEqual(p.exitcode, 1)
|
|
|
|
self.assertEqual(p.exitcode, 1)
|
|
|
|
self.assertTrue(os.path.exists(os.path.join(self.sandbox, 'started')))
|
|
|
|
self.assertTrue(os.path.exists(os.path.join(self.sandbox, 'started')))
|
|
|
|
self.assertFalse(os.path.exists(os.path.join(self.sandbox, 'finished')))
|
|
|
|
self.assertFalse(os.path.exists(os.path.join(self.sandbox, 'finished')))
|
|
|
|
|
|
|
|
with open(os.path.join(self.sandbox, 'stderr.log')) as f:
|
|
|
|
|
|
|
|
stderr = f.read().strip('\n')
|
|
|
|
|
|
|
|
err = 'ShutDownImminentException: shut down imminent (signal: SIGRTMIN)'
|
|
|
|
|
|
|
|
self.assertTrue(stderr.endswith(err), stderr)
|
|
|
|
|
|
|
|
|
|
|
|
@slow
|
|
|
|
@slow
|
|
|
|
def test_1_sec_shutdown(self):
|
|
|
|
def test_1_sec_shutdown(self):
|
|
|
@ -749,6 +752,10 @@ class HerokuWorkerShutdownTestCase(TimeoutTestCase, RQTestCase):
|
|
|
|
|
|
|
|
|
|
|
|
self.assertTrue(os.path.exists(os.path.join(self.sandbox, 'started')))
|
|
|
|
self.assertTrue(os.path.exists(os.path.join(self.sandbox, 'started')))
|
|
|
|
self.assertFalse(os.path.exists(os.path.join(self.sandbox, 'finished')))
|
|
|
|
self.assertFalse(os.path.exists(os.path.join(self.sandbox, 'finished')))
|
|
|
|
|
|
|
|
with open(os.path.join(self.sandbox, 'stderr.log')) as f:
|
|
|
|
|
|
|
|
stderr = f.read().strip('\n')
|
|
|
|
|
|
|
|
err = 'ShutDownImminentException: shut down imminent (signal: SIGALRM)'
|
|
|
|
|
|
|
|
self.assertTrue(stderr.endswith(err), stderr)
|
|
|
|
|
|
|
|
|
|
|
|
@slow
|
|
|
|
@slow
|
|
|
|
def test_shutdown_double_sigrtmin(self):
|
|
|
|
def test_shutdown_double_sigrtmin(self):
|
|
|
@ -766,6 +773,10 @@ class HerokuWorkerShutdownTestCase(TimeoutTestCase, RQTestCase):
|
|
|
|
|
|
|
|
|
|
|
|
self.assertTrue(os.path.exists(os.path.join(self.sandbox, 'started')))
|
|
|
|
self.assertTrue(os.path.exists(os.path.join(self.sandbox, 'started')))
|
|
|
|
self.assertFalse(os.path.exists(os.path.join(self.sandbox, 'finished')))
|
|
|
|
self.assertFalse(os.path.exists(os.path.join(self.sandbox, 'finished')))
|
|
|
|
|
|
|
|
with open(os.path.join(self.sandbox, 'stderr.log')) as f:
|
|
|
|
|
|
|
|
stderr = f.read().strip('\n')
|
|
|
|
|
|
|
|
err = 'ShutDownImminentException: shut down imminent (signal: SIGRTMIN)'
|
|
|
|
|
|
|
|
self.assertTrue(stderr.endswith(err), stderr)
|
|
|
|
|
|
|
|
|
|
|
|
def test_handle_shutdown_request(self):
|
|
|
|
def test_handle_shutdown_request(self):
|
|
|
|
"""Mutate HerokuWorker so _horse_pid refers to an artificial process
|
|
|
|
"""Mutate HerokuWorker so _horse_pid refers to an artificial process
|
|
|
|