Bug 1445281 [wpt PR 9998] - Rename bind_hostname to bind_address, a=testonly
authorGeoffrey Sneddon <me@gsnedders.com>
Mon, 09 Apr 2018 16:57:36 +0000
changeset 467064 a9e3992d7141ccfe0f200a97b77c0768e94eb730
parent 467063 d5dffa2fbb4e5cf38cc74bbe411ee2b0d6233c91
child 467065 7d79c07c9e3948a76c92cbf2a22167f5a4d00e0d
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1445281
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1445281 [wpt PR 9998] - Rename bind_hostname to bind_address, a=testonly Automatic update from web-platform-testsRename bind_hostname to bind_address This keeps on confusing me; hopefully this will stop that. -- Remove duplicate code wpt-commits: 24da741d3c5bba4110f590c1faf771596d543482, ec54ac4479d66e039809ac65026a12eb9529d34a wpt-pr: 9998 wpt-commits: 24da741d3c5bba4110f590c1faf771596d543482, ec54ac4479d66e039809ac65026a12eb9529d34a wpt-pr: 9998
testing/web-platform/meta/MANIFEST.json
testing/web-platform/tests/config.default.json
testing/web-platform/tests/tools/serve/serve.py
testing/web-platform/tests/tools/wptrunner/wptrunner/browsers/firefox.py
testing/web-platform/tests/tools/wptrunner/wptrunner/browsers/servo.py
testing/web-platform/tests/tools/wptrunner/wptrunner/browsers/webkit.py
testing/web-platform/tests/tools/wptrunner/wptrunner/environment.py
testing/web-platform/tests/tools/wptrunner/wptrunner/tests/test_products.py
testing/web-platform/tests/tools/wptserve/wptserve/server.py
--- a/testing/web-platform/meta/MANIFEST.json
+++ b/testing/web-platform/meta/MANIFEST.json
@@ -391322,17 +391322,17 @@
    "23780fdf7eea63c82965c8d5d4d847c0b9752c7e",
    "support"
   ],
   "./check_stability.ini": [
    "f8af4287f3b0f6925a2a6c5c75b3788e24de1680",
    "support"
   ],
   "./config.default.json": [
-   "73b96319b21810d51a230d475b5d5fe4e1181a69",
+   "939f06a73458155a62c9d81f198ac0194ad26234",
    "support"
   ],
   "./lint.whitelist": [
    "b35324fd499dcb7ba0a9deedc794bb13ee62e175",
    "support"
   ],
   "./serve.py": [
    "0efa39b1f26f86d73f2fce4f9e46003d62057b41",
--- a/testing/web-platform/tests/config.default.json
+++ b/testing/web-platform/tests/config.default.json
@@ -3,17 +3,17 @@
  "ws_doc_root": null,
  "host_ip": null,
  "ports":{"http":[8000, "auto"],
           "https":[8443],
           "ws":["auto"],
           "wss":["auto"]},
  "check_subdomains": true,
  "log_level":"debug",
- "bind_hostname": true,
+ "bind_address": true,
  "ssl": {"type": "pregenerated",
          "encrypt_after_connect": false,
          "openssl": {
              "openssl_binary": "openssl",
              "base_path": "_certs",
              "force_regenerate": false,
              "base_conf_path": null
          },
--- a/testing/web-platform/tests/tools/serve/serve.py
+++ b/testing/web-platform/tests/tools/serve/serve.py
@@ -382,29 +382,29 @@ def get_port():
 
 
 class ServerProc(object):
     def __init__(self):
         self.proc = None
         self.daemon = None
         self.stop = Event()
 
-    def start(self, init_func, host, port, paths, routes, bind_hostname, config,
+    def start(self, init_func, host, port, paths, routes, bind_address, config,
               ssl_config, **kwargs):
         self.proc = Process(target=self.create_daemon,
-                            args=(init_func, host, port, paths, routes, bind_hostname,
+                            args=(init_func, host, port, paths, routes, bind_address,
                                   config, ssl_config),
                             kwargs=kwargs)
         self.proc.daemon = True
         self.proc.start()
 
-    def create_daemon(self, init_func, host, port, paths, routes, bind_hostname,
+    def create_daemon(self, init_func, host, port, paths, routes, bind_address,
                       config, ssl_config, **kwargs):
         try:
-            self.daemon = init_func(host, port, paths, routes, bind_hostname, config,
+            self.daemon = init_func(host, port, paths, routes, bind_address, config,
                                     ssl_config, **kwargs)
         except socket.error:
             print("Socket error on port %s" % port, file=sys.stderr)
             raise
         except Exception:
             print(traceback.format_exc(), file=sys.stderr)
             raise
 
@@ -427,22 +427,22 @@ class ServerProc(object):
         self.stop.set()
         self.proc.terminate()
         self.proc.join()
 
     def is_alive(self):
         return self.proc.is_alive()
 
 
-def check_subdomains(host, paths, bind_hostname, ssl_config, aliases):
+def check_subdomains(host, paths, bind_address, ssl_config, aliases):
     port = get_port()
     subdomains = get_subdomains(host)
 
     wrapper = ServerProc()
-    wrapper.start(start_http_server, host, port, paths, build_routes(aliases), bind_hostname,
+    wrapper.start(start_http_server, host, port, paths, build_routes(aliases), bind_address,
                   None, ssl_config)
 
     connected = False
     for i in range(10):
         try:
             urllib2.urlopen("http://%s:%d/" % (host, port))
             connected = True
             break
@@ -485,71 +485,71 @@ def make_hosts_file(config, host):
         rv.append("%s\t%s\n" % (host, domain))
 
     for not_domain in config.get("not_domains", {}).values():
         rv.append("0.0.0.0\t%s\n" % not_domain)
 
     return "".join(rv)
 
 
-def start_servers(host, ports, paths, routes, bind_hostname, config, ssl_config,
+def start_servers(host, ports, paths, routes, bind_address, config, ssl_config,
                   **kwargs):
     servers = defaultdict(list)
     for scheme, ports in ports.iteritems():
         assert len(ports) == {"http":2}.get(scheme, 1)
 
         for port in ports:
             if port is None:
                 continue
             init_func = {"http":start_http_server,
                          "https":start_https_server,
                          "ws":start_ws_server,
                          "wss":start_wss_server}[scheme]
 
             server_proc = ServerProc()
-            server_proc.start(init_func, host, port, paths, routes, bind_hostname,
+            server_proc.start(init_func, host, port, paths, routes, bind_address,
                               config, ssl_config, **kwargs)
             servers[scheme].append((port, server_proc))
 
     return servers
 
 
-def start_http_server(host, port, paths, routes, bind_hostname, config, ssl_config,
+def start_http_server(host, port, paths, routes, bind_address, config, ssl_config,
                       **kwargs):
     return wptserve.WebTestHttpd(host=host,
                                  port=port,
                                  doc_root=paths["doc_root"],
                                  routes=routes,
                                  rewrites=rewrites,
-                                 bind_hostname=bind_hostname,
+                                 bind_address=bind_address,
                                  config=config,
                                  use_ssl=False,
                                  key_file=None,
                                  certificate=None,
                                  latency=kwargs.get("latency"))
 
 
-def start_https_server(host, port, paths, routes, bind_hostname, config, ssl_config,
+def start_https_server(host, port, paths, routes, bind_address, config, ssl_config,
                        **kwargs):
     return wptserve.WebTestHttpd(host=host,
                                  port=port,
                                  doc_root=paths["doc_root"],
                                  routes=routes,
                                  rewrites=rewrites,
-                                 bind_hostname=bind_hostname,
+                                 bind_address=bind_address,
                                  config=config,
                                  use_ssl=True,
                                  key_file=ssl_config["key_path"],
                                  certificate=ssl_config["cert_path"],
                                  encrypt_after_connect=ssl_config["encrypt_after_connect"],
                                  latency=kwargs.get("latency"))
 
 
 class WebSocketDaemon(object):
-    def __init__(self, host, port, doc_root, handlers_root, log_level, bind_hostname,
+    def __init__(self, host, port, doc_root, handlers_root, log_level, bind_address,
                  ssl_config):
         self.host = host
         cmd_args = ["-p", port,
                     "-d", doc_root,
                     "-w", handlers_root,
                     "--log-level", log_level]
 
         if ssl_config is not None:
@@ -564,17 +564,17 @@ class WebSocketDaemon(object):
                 print("No SSL module available")
                 sys.exit(1)
 
             cmd_args += ["--tls",
                          "--private-key", ssl_config["key_path"],
                          "--certificate", ssl_config["cert_path"],
                          "--tls-module", tls_module]
 
-        if (bind_hostname):
+        if (bind_address):
             cmd_args = ["-H", host] + cmd_args
         opts, args = pywebsocket._parse_args_and_config(cmd_args)
         opts.cgi_directories = []
         opts.is_executable_method = None
         self.server = pywebsocket.WebSocketServer(opts)
         ports = [item[0].getsockname()[1] for item in self.server._sockets]
         assert all(item == ports[0] for item in ports)
         self.port = ports[0]
@@ -603,35 +603,35 @@ class WebSocketDaemon(object):
                 self.server_thread.join()
                 self.server_thread = None
             except AttributeError:
                 pass
             self.started = False
         self.server = None
 
 
-def start_ws_server(host, port, paths, routes, bind_hostname, config, ssl_config,
+def start_ws_server(host, port, paths, routes, bind_address, config, ssl_config,
                     **kwargs):
     return WebSocketDaemon(host,
                            str(port),
                            repo_root,
                            paths["ws_doc_root"],
                            "debug",
-                           bind_hostname,
+                           bind_address,
                            ssl_config = None)
 
 
-def start_wss_server(host, port, paths, routes, bind_hostname, config, ssl_config,
+def start_wss_server(host, port, paths, routes, bind_address, config, ssl_config,
                      **kwargs):
     return WebSocketDaemon(host,
                            str(port),
                            repo_root,
                            paths["ws_doc_root"],
                            "debug",
-                           bind_hostname,
+                           bind_address,
                            ssl_config)
 
 
 def get_ports(config, ssl_environment):
     rv = defaultdict(list)
     for scheme, ports in config["ports"].iteritems():
         for i, port in enumerate(ports):
             if scheme in ["wss", "https"] and not ssl_environment.ssl_enabled:
@@ -657,26 +657,29 @@ def normalise_config(config, ports):
     for key, value in domains.iteritems():
         domains[key] = ".".join(value)
 
     for key, value in not_domains.iteritems():
         not_domains[key] = ".".join(value)
 
     domains[""] = host
 
-    ports_ = {}
-    for scheme, ports_used in ports.iteritems():
-        ports_[scheme] = ports_used
+    if "bind_hostname" in config:
+        logger.warning("bind_hostname in config is deprecated; use bind_address instead")
+        bind_address = config["bind_hostname"]
+    else:
+        bind_address = config["bind_address"]
 
     # make a (shallow) copy of the config and update that, so that the
     # normalized config can be used in place of the original one.
     config_ = config.copy()
     config_["domains"] = domains
     config_["not_domains"] = not_domains
     config_["ports"] = ports_
+    config_["bind_address"] = bind_address
     return config_
 
 
 def get_paths(config):
     return {"doc_root": config["doc_root"],
             "ws_doc_root": config["ws_doc_root"]}
 
 
@@ -687,20 +690,20 @@ def get_ssl_config(config, ssl_environme
             "cert_path": cert_path,
             "encrypt_after_connect": config["ssl"]["encrypt_after_connect"]}
 
 
 def start(config, ssl_environment, routes, **kwargs):
     host = config.get("host_ip") or config["host"]
     ports = get_ports(config, ssl_environment)
     paths = get_paths(config)
-    bind_hostname = config["bind_hostname"]
+    bind_address = config["bind_address"]
     ssl_config = get_ssl_config(config, ssl_environment)
 
-    servers = start_servers(host, ports, paths, routes, bind_hostname, config,
+    servers = start_servers(host, ports, paths, routes, bind_address, config,
                             ssl_config, **kwargs)
 
     return servers
 
 
 def iter_procs(servers):
     for servers in servers.values():
         for port, server in servers:
@@ -808,25 +811,25 @@ def run(**kwargs):
                          **kwargs)
 
     setup_logger(config["log_level"])
 
     with get_ssl_environment(config) as ssl_env:
         ports = get_ports(config, ssl_env)
         config = normalise_config(config, ports)
         host = config["host"]
-        bind_hostname = config["bind_hostname"]
+        bind_address = config["bind_address"]
 
         if config["check_subdomains"]:
             paths = get_paths(config)
             ssl_config = get_ssl_config(config, ssl_env)
-            check_subdomains(host, paths, bind_hostname, ssl_config, config["aliases"])
+            check_subdomains(host, paths, bind_address, ssl_config, config["aliases"])
 
         stash_address = None
-        if bind_hostname:
+        if bind_address:
             stash_address = (host, get_port())
 
         with stash.StashServer(stash_address, authkey=str(uuid.uuid4())):
             servers = start(config, ssl_env, build_routes(config["aliases"]), **kwargs)
 
             try:
                 while any(item.is_alive() for item in iter_procs(servers)):
                     for item in iter_procs(servers):
--- a/testing/web-platform/tests/tools/wptrunner/wptrunner/browsers/firefox.py
+++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/browsers/firefox.py
@@ -119,17 +119,17 @@ def env_extras(**kwargs):
 def env_options():
     # The server host is set to 127.0.0.1 as Firefox is configured (through the
     # network.dns.localDomains preference set below) to resolve the test
     # domains to localhost without relying on the network stack.
     #
     # https://github.com/w3c/web-platform-tests/pull/9480
     return {"host_ip": "127.0.0.1",
             "host": "web-platform.test",
-            "bind_hostname": False,
+            "bind_address": False,
             "certificate_domain": "web-platform.test",
             "supports_debugger": True}
 
 
 def run_info_extras(**kwargs):
     return {"e10s": kwargs["gecko_e10s"],
             "headless": "MOZ_HEADLESS" in os.environ}
 
--- a/testing/web-platform/tests/tools/wptrunner/wptrunner/browsers/servo.py
+++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/browsers/servo.py
@@ -49,17 +49,17 @@ def executor_kwargs(test_type, server_co
 
 def env_extras(**kwargs):
     return []
 
 
 def env_options():
     return {"host": "web-platform.test",
             "host_ip": "127.0.0.1",
-            "bind_hostname": False,
+            "bind_address": False,
             "testharnessreport": "testharnessreport-servo.js",
             "supports_debugger": True}
 
 
 def update_properties():
     return ["debug", "os", "version", "processor", "bits"], None
 
 
--- a/testing/web-platform/tests/tools/wptrunner/wptrunner/browsers/webkit.py
+++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/browsers/webkit.py
@@ -56,17 +56,17 @@ def executor_kwargs(test_type, server_co
     return executor_kwargs
 
 
 def env_extras(**kwargs):
     return []
 
 
 def env_options():
-    return {"bind_hostname": "true"}
+    return {}
 
 
 class WebKitBrowser(Browser):
     """Generic WebKit browser is backed by WebKit's WebDriver implementation,
     which is supplied through ``wptrunner.webdriver.WebKitDriverServer``.
     """
 
     def __init__(self, logger, binary, webdriver_binary=None,
--- a/testing/web-platform/tests/tools/wptrunner/wptrunner/environment.py
+++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/environment.py
@@ -145,18 +145,18 @@ class TestEnvironment(object):
             },
             "check_subdomains": False,
             "ssl": {}
         }
 
         if "host" in self.options:
             local_config["host"] = self.options["host"]
 
-        if "bind_hostname" in self.options:
-            local_config["bind_hostname"] = self.options["bind_hostname"]
+        if "bind_address" in self.options:
+            local_config["bind_address"] = self.options["bind_address"]
 
         with open(default_config_path) as f:
             default_config = json.load(f)
 
         local_config["host_ip"] = self.options.get("host_ip", None)
         local_config["ssl"]["encrypt_after_connect"] = self.options.get("encrypt_after_connect", False)
 
         config = serve.merge_json(default_config, local_config)
--- a/testing/web-platform/tests/tools/wptrunner/wptrunner/tests/test_products.py
+++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/tests/test_products.py
@@ -55,9 +55,9 @@ def test_server_start_config(product):
                                          None,
                                          env_options,
                                          env_extras) as test_environment:
             start.assert_called_once()
             args = start.call_args
             config = args[0][0]
             if "host" in env_options:
                 assert config["host"] == env_options["host"]
-            assert isinstance(config["bind_hostname"], bool)
+            assert isinstance(config["bind_address"], bool)
--- a/testing/web-platform/tests/tools/wptserve/wptserve/server.py
+++ b/testing/web-platform/tests/tools/wptserve/wptserve/server.py
@@ -106,17 +106,17 @@ class WebTestServer(ThreadingMixIn, Base
     allow_reuse_address = True
     acceptable_errors = (errno.EPIPE, errno.ECONNABORTED)
     request_queue_size = 2000
 
     # Ensure that we don't hang on shutdown waiting for requests
     daemon_threads = True
 
     def __init__(self, server_address, request_handler_cls,
-                 router, rewriter, bind_hostname,
+                 router, rewriter, bind_address,
                  config=None, use_ssl=False, key_file=None, certificate=None,
                  encrypt_after_connect=False, latency=None, **kwargs):
         """Server for HTTP(s) Requests
 
         :param server_address: tuple of (server_name, port)
 
         :param request_handler_cls: BaseHTTPRequestHandler-like class to use for
                                     handling requests.
@@ -136,32 +136,32 @@ class WebTestServer(ThreadingMixIn, Base
 
         :param certificate: Path to certificate to use if SSL is enabled.
 
         :param encrypt_after_connect: For each connection, don't start encryption
                                       until a CONNECT message has been received.
                                       This enables the server to act as a
                                       self-proxy.
 
-        :param bind_hostname True to bind the server to both the hostname and
-                             port specified in the server_address parameter.
-                             False to bind the server only to the port in the
-                             server_address parameter, but not to the hostname.
+        :param bind_address True to bind the server to both the IP address and
+                            port specified in the server_address parameter.
+                            False to bind the server only to the port in the
+                            server_address parameter, but not to the address.
         :param latency: Delay in ms to wait before seving each response, or
                         callable that returns a delay in ms
         """
         self.router = router
         self.rewriter = rewriter
 
         self.scheme = "https" if use_ssl else "http"
         self.logger = get_logger()
 
         self.latency = latency
 
-        if bind_hostname:
+        if bind_address:
             hostname_port = server_address
         else:
             hostname_port = ("",server_address[1])
 
         #super doesn't work here because BaseHTTPServer.HTTPServer is old-style
         BaseHTTPServer.HTTPServer.__init__(self, hostname_port, request_handler_cls, **kwargs)
 
         if config is not None:
@@ -338,17 +338,17 @@ class WebTestHttpd(object):
                                   self-proxy.
     :param router_cls: Router class to use when matching URLs to handlers
     :param doc_root: Document root for serving files
     :param routes: List of routes with which to initialize the router
     :param rewriter_cls: Class to use for request rewriter
     :param rewrites: List of rewrites with which to initialize the rewriter_cls
     :param config: Dictionary holding environment configuration settings for
                    handlers to read, or None to use the default values.
-    :param bind_hostname: Boolean indicating whether to bind server to hostname.
+    :param bind_address: Boolean indicating whether to bind server to IP address.
     :param latency: Delay in ms to wait before seving each response, or
                     callable that returns a delay in ms
 
     HTTP server designed for testing scenarios.
 
     Takes a router class which provides one method get_handler which takes a Request
     and returns a handler function.
 
@@ -376,17 +376,17 @@ class WebTestHttpd(object):
 
       Boolean indictaing whether the server is running
 
     """
     def __init__(self, host="127.0.0.1", port=8000,
                  server_cls=None, handler_cls=WebTestRequestHandler,
                  use_ssl=False, key_file=None, certificate=None, encrypt_after_connect=False,
                  router_cls=Router, doc_root=os.curdir, routes=None,
-                 rewriter_cls=RequestRewriter, bind_hostname=True, rewrites=None,
+                 rewriter_cls=RequestRewriter, bind_address=True, rewrites=None,
                  latency=None, config=None):
 
         if routes is None:
             routes = default_routes.routes
 
         self.host = host
 
         self.router = router_cls(doc_root, routes)
@@ -405,17 +405,17 @@ class WebTestHttpd(object):
                 raise ValueError("SSL key not found: {}".format(certificate))
 
         try:
             self.httpd = server_cls((host, port),
                                     handler_cls,
                                     self.router,
                                     self.rewriter,
                                     config=config,
-                                    bind_hostname=bind_hostname,
+                                    bind_address=bind_address,
                                     use_ssl=use_ssl,
                                     key_file=key_file,
                                     certificate=certificate,
                                     encrypt_after_connect=encrypt_after_connect,
                                     latency=latency)
             self.started = False
 
             _host, self.port = self.httpd.socket.getsockname()