Browse Source

[2899] Merge branch 'trac2823-regression' into trac2899-2

JINMEI Tatuya 12 years ago
parent
commit
25e6b90892

+ 1 - 0
src/bin/stats/tests/stats-httpd_test.py

@@ -248,6 +248,7 @@ class TestHttpHandler(unittest.TestCase):
 
 
     def tearDown(self):
     def tearDown(self):
         self.client.close()
         self.client.close()
+        self.stats_httpd_server.shutdown()
         # reset the signal handler
         # reset the signal handler
         self.sig_handler.reset()
         self.sig_handler.reset()
 
 

+ 9 - 0
src/bin/stats/tests/stats_test.py

@@ -1285,6 +1285,15 @@ class TestStats(unittest.TestCase):
         """check statistics data of 'Init'."""
         """check statistics data of 'Init'."""
 
 
         stat = MyStats()
         stat = MyStats()
+        # At this point 'stat' is initialized with statistics for Stats,
+        # Init and Auth modules.  In this test, we only need to check for Init
+        # statistics, while do_polling() can ask for module statistics in an
+        # unpredictable order (if hash randomization is enabled, which is
+        # the case by default for Python 3.3).  To make it predictable and
+        # the prepared answer doesn't cause disruption, we remove the
+        # information for the Auth module for this test.
+        del stat.statistics_data['Auth']
+
         stat.update_modules = lambda: None
         stat.update_modules = lambda: None
         create_answer = isc.config.ccsession.create_answer # shortcut
         create_answer = isc.config.ccsession.create_answer # shortcut
 
 

+ 11 - 0
src/bin/stats/tests/test_utils.py

@@ -514,6 +514,14 @@ class MyStatsHttpd(stats_httpd.StatsHttpd):
         self.cc_session = self.mccs._session
         self.cc_session = self.mccs._session
         self.mccs.start = self.load_config # force reload
         self.mccs.start = self.load_config # force reload
 
 
+        # check_command could be called from the main select() loop due to
+        # Linux's bug of spurious wakeup.  We don't need the actual behavior
+        # of check_command in our tests, so we can basically replace it with a
+        # no-op mock function.
+        def mock_check_command(nonblock):
+            pass
+        self.mccs.check_command = mock_check_command
+
     def close_mccs(self):
     def close_mccs(self):
         super().close_mccs()
         super().close_mccs()
         if self.__dummy_sock is not None:
         if self.__dummy_sock is not None:
@@ -562,3 +570,6 @@ class MyStatsHttpd(stats_httpd.StatsHttpd):
     def run(self):
     def run(self):
         self._started.set()
         self._started.set()
         self.start()
         self.start()
+
+    def shutdown(self):
+        self.command_handler('shutdown', None)