if not self.__started:
raise Exception("Component failed during startup");
else:
- if self.ccs is not None:
- self.ccs.stop()
self.runnable = False
def shutdown(self):
"""Stop the BoB instance."""
logger.info(BIND10_SHUTDOWN)
- # first try using the BIND 10 request to stop
+ # If ccsession is still there, inform rest of the system this module
+ # is stopping. Since everything will be stopped shortly, this is not
+ # really necessary, but this is done to reflect that boss is also
+ # 'just' a module.
+ if self.ccs is not None:
+ self.ccs.stop()
+
+ # try using the BIND 10 request to stop
try:
self._component_configurator.shutdown()
except:
self.assertTrue(type(pi.pid) is int)
self.assertNotEqual(pi.pid, old_pid)
+class MockCCSession:
+ """Simple test class to check whether 'shutdown' calls stop()"""
+ def __init__(self):
+ self.stopped = False
+
+ def stop(self):
+ self.stopped = True
+
class TestCacheCommands(unittest.TestCase):
"""
Test methods of boss related to the socket cache and socket handling.
bob._component_configurator.shutdown = self.__nullary_hook
self.__called = False
+ bob.ccs = MockCCSession()
+ self.assertFalse(bob.ccs.stopped)
+
bob.shutdown()
+ self.assertTrue(bob.ccs.stopped)
self.assertEqual([False, True], killed)
self.assertTrue(self.__called)
import isc
import stats_httpd
import stats
-from test_utils import BaseModules, ThreadingServerManager, MyStats, MyStatsHttpd, SignalHandler, send_command, send_shutdown
+from test_utils import BaseModules, ThreadingServerManager, MyStats,\
+ MyStatsHttpd, SignalHandler, MyModuleCCSession,\
+ send_command, send_shutdown
DUMMY_DATA = {
'Boss' : {
def test_openclose_mccs(self):
self.stats_httpd = MyStatsHttpd(get_availaddr())
+ mccs = MyModuleCCSession()
+ self.stats_httpd.mccs = mccs
+ self.assertFalse(self.stats_httpd.mccs.stopped)
+ self.assertFalse(self.stats_httpd.mccs.closed)
self.stats_httpd.close_mccs()
+ self.assertTrue(mccs.stopped)
+ self.assertTrue(mccs.closed)
self.assertEqual(self.stats_httpd.mccs, None)
self.stats_httpd.open_mccs()
self.assertIsNotNone(self.stats_httpd.mccs)
def shutdown(self):
self.command_shutdown()
+class MyModuleCCSession():
+ def __init__(self):
+ self.stopped = False
+ self.closed = False
+
+ def stop(self):
+ self.stopped = True
+
+ def close(self):
+ self.closed = True
+
class MyStatsHttpd(stats_httpd.StatsHttpd):
ORIG_SPECFILE_LOCATION = stats_httpd.SPECFILE_LOCATION
def __init__(self, *server_address):
self.mcd.remove_specification(module_spec.get_module_name())
self.assertFalse(self.mcd.have_specification(module_spec.get_module_name()))
+ def test_clear_specifications(self):
+ self.assertEqual(0, len(self.mcd._specifications))
+ module_spec = isc.config.module_spec_from_file(self.data_path +
+ os.sep +
+ "spec1.spec")
+ self.mcd.set_specification(module_spec)
+ self.assertEqual(1, len(self.mcd._specifications))
+ self.mcd.clear_specifications()
+ self.assertEqual(0, len(self.mcd._specifications))
+
def test_get_module_spec(self):
module_spec = isc.config.module_spec_from_file(self.data_path + os.sep + "spec1.spec")
self.mcd.set_specification(module_spec)