dumbhttp: use IPv6 if HGIPV6 is set to 1
authorJun Wu <quark@fb.com>
Wed, 15 Feb 2017 21:09:00 -0800
changeset 31024 d05fefbb5ab3
parent 31023 225f574e0645
child 31025 d8d698bcdcd6
dumbhttp: use IPv6 if HGIPV6 is set to 1 This will fix flaky tests using dumbhttp. The patch was tested on gcc112.fsffrance.org using the following command: ./run-tests.py -j 40 --runs-per-test 120 test-bundle2-remote-changegroup.t
tests/dumbhttp.py
--- a/tests/dumbhttp.py	Wed Feb 15 21:03:42 2017 -0800
+++ b/tests/dumbhttp.py	Wed Feb 15 21:09:00 2017 -0800
@@ -7,7 +7,9 @@
 """
 
 import optparse
+import os
 import signal
+import socket
 import sys
 
 from mercurial import (
@@ -18,11 +20,17 @@
 httpserver = util.httpserver
 OptionParser = optparse.OptionParser
 
+if os.environ.get('HGIPV6', '0') == '1':
+    class simplehttpserver(httpserver.httpserver):
+        address_family = socket.AF_INET6
+else:
+    simplehttpserver = httpserver.httpserver
+
 class simplehttpservice(object):
     def __init__(self, host, port):
         self.address = (host, port)
     def init(self):
-        self.httpd = httpserver.httpserver(
+        self.httpd = simplehttpserver(
             self.address, httpserver.simplehttprequesthandler)
     def run(self):
         self.httpd.serve_forever()