Commit df25eeda authored by Jelte Jansen's avatar Jelte Jansen
Browse files

[640] additional tests

parent 4e8a4299
......@@ -674,14 +674,19 @@ class BoB:
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:
......
......@@ -103,6 +103,14 @@ class TestProcessInfo(unittest.TestCase):
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.
......@@ -1171,8 +1179,12 @@ class TestBossComponents(unittest.TestCase):
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)
......
......@@ -37,7 +37,9 @@ import random
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' : {
......@@ -676,7 +678,13 @@ class TestStatsHttpd(unittest.TestCase):
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)
......
......@@ -349,6 +349,17 @@ class MyStats(stats.Stats):
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):
......
......@@ -312,6 +312,16 @@ class TestMultiConfigData(unittest.TestCase):
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)
......
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