Bug 1433361 - Switch external_host to host_ip, r=maja_zf
When running tests in Firefox we don't require that the hostname is
actually resolvable since we set up some internal DNS overrides. This
means that we don't actually need to have web-platform.test defined in
/etc/hosts. As a consequence when we check the server is responding,
the check will typically fail for Firefox developers if we try to
access by hostname. Previously we made use of a special dance in which
external_host held the ip at the point of the check and was later
replaced by host to actually run tests. But that changed, and instead
we relied on the fact that we (accidentially) didn't actually fail in
the case the servers couldn't be reached by host name. However in some
cases things still failed because local DNS resolved web-patform.test
to some ip address, causing hangs or other badness.
In this patch we simply add a host_ip property to the config, and
connect to that to test the servers are repopnsing rather than the
hostname. We also actually fil if we didn't manage to connect to all
the servers.
MozReview-Commit-ID: BRIOwybGtjx
--- a/testing/web-platform/tests/config.default.json
+++ b/testing/web-platform/tests/config.default.json
@@ -1,12 +1,12 @@
{"host": "web-platform.test",
"doc_root": null,
"ws_doc_root": null,
- "external_host": null,
+ "host_ip": null,
"ports":{"http":[8000, "auto"],
"https":[8443],
"ws":["auto"],
"wss":["auto"]},
"check_subdomains": true,
"log_level":"debug",
"bind_hostname": true,
"ssl": {"type": "pregenerated",
--- a/testing/web-platform/tests/tools/serve/serve.py
+++ b/testing/web-platform/tests/tools/serve/serve.py
@@ -619,35 +619,33 @@ def get_ports(config, ssl_environment):
else:
port = port
rv[scheme].append(port)
return rv
def normalise_config(config, ports):
- host = config["external_host"] if config["external_host"] else config["host"]
- domains = get_subdomains(host)
+ domains = get_subdomains(config["host"])
ports_ = {}
for scheme, ports_used in ports.iteritems():
ports_[scheme] = ports_used
for key, value in domains.iteritems():
domains[key] = ".".join(value)
- domains[""] = host
+ domains[""] = config["host"]
ports_ = {}
for scheme, ports_used in ports.iteritems():
ports_[scheme] = ports_used
# 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_["host"] = host
config_["domains"] = domains
config_["ports"] = ports_
return config_
def get_paths(config):
return {"doc_root": config["doc_root"],
"ws_doc_root": config["ws_doc_root"]}
@@ -655,16 +653,17 @@ def get_paths(config):
def get_ssl_config(config, ssl_environment):
external_domains = config["domains"].values()
key_path, cert_path = ssl_environment.host_cert_path(external_domains)
return {"key_path": key_path,
"cert_path": cert_path,
"encrypt_after_connect": config["ssl"]["encrypt_after_connect"]}
+
def start(config, ssl_environment, routes, **kwargs):
host = config["host"]
ports = get_ports(config, ssl_environment)
paths = get_paths(config)
bind_hostname = config["bind_hostname"]
ssl_config = get_ssl_config(config, ssl_environment)
servers = start_servers(host, ports, paths, routes, bind_hostname, config,
--- a/testing/web-platform/tests/tools/wptrunner/wptrunner/browsers/firefox.py
+++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/browsers/firefox.py
@@ -112,18 +112,18 @@ def executor_kwargs(test_type, server_co
return executor_kwargs
def env_extras(**kwargs):
return []
def env_options():
- return {"host": "127.0.0.1",
- "external_host": "web-platform.test",
+ return {"host_ip": "127.0.0.1",
+ "host": "web-platform.test",
"bind_hostname": "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
@@ -47,18 +47,18 @@ def executor_kwargs(test_type, server_co
return rv
def env_extras(**kwargs):
return []
def env_options():
- return {"host": "127.0.0.1",
- "external_host": "web-platform.test",
+ return {"host": "web-platform.test",
+ "host_ip": "127.0.0.1",
"bind_hostname": "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/servodriver.py
+++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/browsers/servodriver.py
@@ -53,18 +53,18 @@ def executor_kwargs(test_type, server_co
return rv
def env_extras(**kwargs):
return []
def env_options():
- return {"host": "127.0.0.1",
- "external_host": "web-platform.test",
+ return {"host_ip": "127.0.0.1",
+ "host": "web-platform.test",
"bind_hostname": "true",
"testharnessreport": "testharnessreport-servodriver.js",
"supports_debugger": True}
def update_properties():
return ["debug", "os", "version", "processor", "bits"], None
--- a/testing/web-platform/tests/tools/wptrunner/wptrunner/environment.py
+++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/environment.py
@@ -134,19 +134,19 @@ class TestEnvironment(object):
with open(default_config_path) as f:
default_config = json.load(f)
with open(local_config_path) as f:
data = f.read()
local_config = json.loads(data % self.options)
- #TODO: allow non-default configuration for ssl
+ # TODO: allow non-default configuration for ssl
- local_config["external_host"] = self.options.get("external_host", None)
+ 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)
config["doc_root"] = serve_path(self.test_paths)
if not self.ssl_env.ssl_enabled:
config["ports"]["https"] = [None]
@@ -211,25 +211,28 @@ class TestEnvironment(object):
def ensure_started(self):
# Pause for a while to ensure that the server has a chance to start
for _ in xrange(20):
failed = self.test_servers()
if not failed:
return
time.sleep(0.5)
- raise EnvironmentError("Servers failed to start (scheme:port): %s" % ("%s:%s" for item in failed))
+ raise EnvironmentError("Servers failed to start: %s" %
+ ", ".join("%s:%s" % item for item in failed))
def test_servers(self):
failed = []
+ host = self.config.get("host_ip") or self.config.get("host")
for scheme, servers in self.servers.iteritems():
for port, server in servers:
if self.test_server_port:
s = socket.socket()
try:
- s.connect((self.config["host"], port))
+ s.connect((host, port))
except socket.error:
- failed.append((scheme, port))
+ failed.append((host, port))
finally:
s.close()
if not server.is_alive():
failed.append((scheme, port))
+ return failed