BIND 10 trac640, updated. 2da5a3de561484f902aa7fb8475551217b9535b9 [640] fix race condition in stats test

BIND 10 source code commits bind10-changes at lists.isc.org
Thu Feb 9 21:56:18 UTC 2012


The branch, trac640 has been updated
       via  2da5a3de561484f902aa7fb8475551217b9535b9 (commit)
      from  f328341c1cfed8e5ca0479619e9d12d3b4907c86 (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 2da5a3de561484f902aa7fb8475551217b9535b9
Author: Jelte Jansen <jelte at isc.org>
Date:   Thu Feb 9 22:56:03 2012 +0100

    [640] fix race condition in stats test

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

Summary of changes:
 src/bin/stats/tests/b10-stats_test.py |    7 +++++--
 src/bin/stats/tests/test_utils.py     |   14 ++++++++++++--
 2 files changed, 17 insertions(+), 4 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/bin/stats/tests/b10-stats_test.py b/src/bin/stats/tests/b10-stats_test.py
index f5a9c48..a506160 100644
--- a/src/bin/stats/tests/b10-stats_test.py
+++ b/src/bin/stats/tests/b10-stats_test.py
@@ -205,9 +205,12 @@ class TestStats(unittest.TestCase):
         # Override moduleCCSession so we can check if send_stopping is called
         self.stats.mccs = MockModuleCCSession()
         self.assertEqual(send_shutdown("Stats"), (0, None))
-        self.assertTrue(self.stats.mccs.stopped)
         self.assertFalse(self.stats.running)
-        self.stats_server.shutdown()
+        # Call server.shutdown with argument True so the thread.join() call
+        # blocks and we are sure the main loop has finished (and set
+        # mccs.stopped)
+        self.stats_server.shutdown(True)
+        self.assertTrue(self.stats.mccs.stopped)
 
         # start with err
         self.stats = stats.Stats()
diff --git a/src/bin/stats/tests/test_utils.py b/src/bin/stats/tests/test_utils.py
index 3f6ff33..29fc785 100644
--- a/src/bin/stats/tests/test_utils.py
+++ b/src/bin/stats/tests/test_utils.py
@@ -72,9 +72,19 @@ class ThreadingServerManager:
         self.server._started.wait()
         self.server._started.clear()
 
-    def shutdown(self):
+    def shutdown(self, blocking=False):
+        """Shut down the server by calling its own shutdown() method.
+           Then wait for its thread to finish. If blocking is True,
+           the thread.join() blocks until the thread finishes. If not,
+           it uses a zero timeout. The latter is necessary in a number
+           of existing tests. We should redo this part (we should not
+           even need threads in most, if not all, of these threads, see
+           ticket #1668)"""
         self.server.shutdown()
-        self.server._thread.join(0) # timeout is 0
+        if blocking:
+            self.server._thread.join()
+        else:
+            self.server._thread.join(0) # timeout is 0
 
 def do_nothing(*args, **kwargs): pass
 




More information about the bind10-changes mailing list