From acea6831396271b1fb18c5c807bce1168c0ad2eb Mon Sep 17 00:00:00 2001 From: Dmitri Bogomolov <4glitch@gmail.com> Date: Thu, 7 Mar 2019 12:18:45 +0200 Subject: [PATCH] Test SIGTERM signal handling --- src/tests/test_process.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/tests/test_process.py b/src/tests/test_process.py index 5033045e..c03754a9 100644 --- a/src/tests/test_process.py +++ b/src/tests/test_process.py @@ -89,6 +89,24 @@ class TestProcessProto(unittest.TestCase): len(self.process.threads()), self._threads_count) +class TestProcessShutdown(TestProcessProto): + """Separate test case for SIGTERM""" + def test_shutdown(self): + """Send to pybitmessage SIGTERM and ensure it stopped""" + self.process.send_signal(signal.SIGTERM) + try: + # longer wait time because it's not a benchmark + self.process.wait(10) + except psutil.TimeoutExpired: + self.fail( + '%s has not stopped in 10 sec' % ' '.join(self._process_cmd)) + + @classmethod + def tearDownClass(cls): + """Special teardown because pybitmessage is already stopped""" + cls._cleanup_files() + + class TestProcess(TestProcessProto): """A test case for pybitmessage process""" def test_process_name(self):