BIND 10 trac640, updated. df25eedae7f4e65ed0a8ecd2f95722061335d498 [640] additional tests

BIND 10 source code commits bind10-changes at lists.isc.org
Wed Feb 1 22:17:02 UTC 2012


The branch, trac640 has been updated
       via  df25eedae7f4e65ed0a8ecd2f95722061335d498 (commit)
      from  4e8a429913d5ecf888ec95d5d337f4ebc5c1976a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit df25eedae7f4e65ed0a8ecd2f95722061335d498
Author: Jelte Jansen <jelte at isc.org>
Date:   Wed Feb 1 23:16:47 2012 +0100

    [640] additional tests

-----------------------------------------------------------------------

Summary of changes:
 src/bin/bind10/bind10_src.py.in                    |   11 ++++++++---
 src/bin/bind10/tests/bind10_test.py.in             |   12 ++++++++++++
 src/bin/stats/tests/b10-stats-httpd_test.py        |   10 +++++++++-
 src/bin/stats/tests/test_utils.py                  |   11 +++++++++++
 .../python/isc/config/tests/config_data_test.py    |   10 ++++++++++
 5 files changed, 50 insertions(+), 4 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/bin/bind10/bind10_src.py.in b/src/bin/bind10/bind10_src.py.in
index c1b2154..5c7dc93 100755
--- a/src/bin/bind10/bind10_src.py.in
+++ b/src/bin/bind10/bind10_src.py.in
@@ -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:
diff --git a/src/bin/bind10/tests/bind10_test.py.in b/src/bin/bind10/tests/bind10_test.py.in
index 018a3b9..d330bc8 100644
--- a/src/bin/bind10/tests/bind10_test.py.in
+++ b/src/bin/bind10/tests/bind10_test.py.in
@@ -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)
 
diff --git a/src/bin/stats/tests/b10-stats-httpd_test.py b/src/bin/stats/tests/b10-stats-httpd_test.py
index b6847bd..f1c28f7 100644
--- a/src/bin/stats/tests/b10-stats-httpd_test.py
+++ b/src/bin/stats/tests/b10-stats-httpd_test.py
@@ -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)
diff --git a/src/bin/stats/tests/test_utils.py b/src/bin/stats/tests/test_utils.py
index 3f6ff33..4f4659a 100644
--- a/src/bin/stats/tests/test_utils.py
+++ b/src/bin/stats/tests/test_utils.py
@@ -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):
diff --git a/src/lib/python/isc/config/tests/config_data_test.py b/src/lib/python/isc/config/tests/config_data_test.py
index bede625..d10804b 100644
--- a/src/lib/python/isc/config/tests/config_data_test.py
+++ b/src/lib/python/isc/config/tests/config_data_test.py
@@ -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)




More information about the bind10-changes mailing list