]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2689] fake socket.gethostbyaddr() to avoid unexpected blocking
authorJINMEI Tatuya <jinmei@isc.org>
Wed, 20 Feb 2013 21:48:08 +0000 (13:48 -0800)
committerJINMEI Tatuya <jinmei@isc.org>
Wed, 20 Feb 2013 21:48:08 +0000 (13:48 -0800)
src/bin/stats/tests/b10-stats-httpd_test.py

index 6a035687da243275fe6d757ba6ac79013660a42b..466e4484375ce14d9deca8d4d2efd5cbd2056088 100644 (file)
@@ -609,8 +609,16 @@ class TestStatsHttpd(unittest.TestCase):
         self.stats_server.run()
         # checking IPv6 enabled on this platform
         self.ipv6_enabled = is_ipv6_enabled()
+        # instantiation of StatsHttpd indirectly calls gethostbyaddr(), which
+        # can block for an uncontrollable period, leading many undesirable
+        # results.  We should rather eliminate the reliance, but until we
+        # can make such fundamental cleanup we replace it with a faked method;
+        # in our test scenario the return value doesn't matter.
+        self.__gethostbyaddr_orig = socket.gethostbyaddr
+        socket.gethostbyaddr = lambda x: ('test.example.', [], None)
 
     def tearDown(self):
+        socket.gethostbyaddr = self.__gethostbyaddr_orig
         if hasattr(self, "stats_httpd"):
             self.stats_httpd.stop()
         self.stats_server.shutdown()