Commit 3d7ea0c3 authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner
Browse files

[1596] Send pid with a shutdown command

May break something. It is needed to go through applications and check
their shutdown handlers.
parent ed110c7f
......@@ -649,14 +649,17 @@ class BoB:
self.__started = True
return None
def stop_process(self, process, recipient):
def stop_process(self, process, recipient, pid):
Stop the given process, friendly-like. The process is the name it has
(in logs, etc), the recipient is the address on msgq.
(in logs, etc), the recipient is the address on msgq. The pid is the
pid of the process (if we have multiple processes of the same name,
it might want to choose if it is for this one).
""", process)
self.cc_session.group_sendmsg({'command': ['shutdown']}, recipient,
create_command('shutdown', {'pid': pid}),
recipient, recipient)
def component_shutdown(self, exitcode=0):
......@@ -459,6 +459,22 @@ class TestBoB(unittest.TestCase):
# The drop_socket is not tested here, but in TestCacheCommands.
# It needs the cache mocks to be in place and they are there.
def test_stop_process(self):
Test checking the stop_process method sends the right message over
the message bus.
class DummySession():
def group_sendmsg(self, msg, group, instance="*"):
(self.msg,, self.instance) = (msg, group, instance)
bob = BoB()
bob.cc_session = DummySession()
bob.stop_process('process', 'address', 42)
self.assertEqual('address', bob.cc_session.instance)
self.assertEqual({'command': ['shutdown', {'pid': 42}]},
# Class for testing the BoB without actually starting processes.
# This is used for testing the start/stop components routines and
# the BoB commands.
......@@ -597,7 +613,7 @@ class MockBob(BoB): = 14
return procinfo
def stop_process(self, process, recipient):
def stop_process(self, process, recipient, pid):
procmap = { 'b10-auth': self.stop_auth,
'b10-resolver': self.stop_resolver,
'b10-xfrout': self.stop_xfrout,
......@@ -408,7 +408,7 @@ class Component(BaseComponent):
self._boss.register_process(, self)
def _stop_internal(self):
self._boss.stop_process(self._process, self._address)
self._boss.stop_process(self._process, self._address,
# TODO Some way to wait for the process that doesn't want to
# terminate and kill it would prove nice (or add it to boss somewhere?)
......@@ -553,11 +553,11 @@ class ComponentTests(BossUtils, unittest.TestCase):
self.assertEqual(component, self.__registered_processes.get(42))
def stop_process(self, process, address):
def stop_process(self, process, address, pid):
Part of pretending to be boss.
self.__stop_process_params = (process, address)
self.__stop_process_params = (process, address, pid)
def start_simple(self, process):
......@@ -575,7 +575,9 @@ class ComponentTests(BossUtils, unittest.TestCase):
self.assertEqual('component', self.__start_simple_params)
self.assertEqual(('component', 'Address'), self.__stop_process_params)
# The PID is None, as we don't give it one when faking the start
self.assertEqual(('component', 'Address', None),
def test_component_kill(self):
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment