Skip to content

Commit

Permalink
fixup! Fix web-platform-tests#2669: Add alternate_hosts
Browse files Browse the repository at this point in the history
  • Loading branch information
gsnedders committed Apr 30, 2018
1 parent d1cb0cb commit 81aaac8
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 20 deletions.
10 changes: 4 additions & 6 deletions tools/serve/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,13 +437,11 @@ def check_subdomains(domains, paths, bind_address, ssl_config, aliases):
def make_hosts_file(config, host):
rv = []

for per_host_domains in config["domains"].values():
for domain in per_host_domains.values():
rv.append("%s\t%s\n" % (host, domain))
for domain in config.domains_set:
rv.append("%s\t%s\n" % (host, domain))

for per_host_domains in config["not_domains"].values():
for not_domain in per_host_domains.values():
rv.append("0.0.0.0\t%s\n" % not_domain)
for not_domain in config.not_domains_set:
rv.append("0.0.0.0\t%s\n" % not_domain)

return "".join(rv)

Expand Down
4 changes: 1 addition & 3 deletions tools/wpt/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,7 @@ def check_environ(product):
if product not in ("firefox", "servo"):
config = serve.load_config(os.path.join(wpt_root, "config.default.json"),
os.path.join(wpt_root, "config.json"))
expected_hosts = set(domain
for per_host_domains in config.all_domains.itervalues()
for domain in per_host_domains.itervalues())
expected_hosts = set(config.all_domains_set)
missing_hosts = set(expected_hosts)
if platform.uname()[0] != "Windows":
hosts_path = "/etc/hosts"
Expand Down
10 changes: 2 additions & 8 deletions tools/wptrunner/wptrunner/browsers/firefox.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,7 @@ def executor_kwargs(test_type, server_config, cache_manager, run_info_data,
if kwargs["binary_args"]:
options["args"] = kwargs["binary_args"]
options["prefs"] = {
"network.dns.localDomains": ",".join(
domain
for per_host_domains in server_config.domains.itervalues()
for domain in per_host_domains.itervalues())
"network.dns.localDomains": ",".join(server_config.domains_set)
}
capabilities["moz:firefoxOptions"] = options
if kwargs["certutil_binary"] is None:
Expand Down Expand Up @@ -201,10 +198,7 @@ def start(self, **kwargs):
self.profile = FirefoxProfile(preferences=preferences)
self.profile.set_preferences({"marionette.port": self.marionette_port,
"dom.disable_open_during_load": False,
"network.dns.localDomains": ",".join(
domain
for per_host_domains in self.config.domains.itervalues()
for domain in per_host_domains.itervalues()),
"network.dns.localDomains": ",".join(self.config.domains_set),
"network.proxy.type": 0,
"places.history.enabled": False,
"dom.send_after_paint_to_content": True,
Expand Down
4 changes: 1 addition & 3 deletions tools/wptrunner/wptrunner/browsers/sauce.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,7 @@ def __enter__(self):
"--metrics-address=0.0.0.0:9876",
"--readyfile=./sauce_is_ready",
"--tunnel-domains",
",".join(domain
for per_host_domains in self.env_config.domains.itervalues()
for domain in per_host_domains.itervalues())
",".join(self.env_config.domains_set)
])

# Timeout config vars
Expand Down
50 changes: 50 additions & 0 deletions tools/wptserve/tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,56 @@ def test_all_domains():
}


def test_domains_set():
c = config.Config(browser_host="foo.bar",
alternate_hosts={"alt": "foo2.bar"},
subdomains={"a", "b"},
not_subdomains={"x", "y"})
domains_set = c.domains_set
assert domains_set == {
"foo.bar",
"a.foo.bar",
"b.foo.bar",
"foo2.bar",
"a.foo2.bar",
"b.foo2.bar",
}


def test_not_domains_set():
c = config.Config(browser_host="foo.bar",
alternate_hosts={"alt": "foo2.bar"},
subdomains={"a", "b"},
not_subdomains={"x", "y"})
not_domains_set = c.not_domains_set
assert not_domains_set == {
"x.foo.bar",
"y.foo.bar",
"x.foo2.bar",
"y.foo2.bar",
}


def test_all_domains_set():
c = config.Config(browser_host="foo.bar",
alternate_hosts={"alt": "foo2.bar"},
subdomains={"a", "b"},
not_subdomains={"x", "y"})
all_domains_set = c.all_domains_set
assert all_domains_set == {
"foo.bar",
"a.foo.bar",
"b.foo.bar",
"x.foo.bar",
"y.foo.bar",
"foo2.bar",
"a.foo2.bar",
"b.foo2.bar",
"x.foo2.bar",
"y.foo2.bar",
}


def test_ssl_env_override():
c = config.Config(override_ssl_env="foobar")
assert c.ssl_env == "foobar"
Expand Down
16 changes: 16 additions & 0 deletions tools/wptserve/wptserve/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,22 @@ def all_domains(self):
rv[host].update(nd[host])
return rv

@property
def domains_set(self):
return {domain
for per_host_domains in self.domains.itervalues()
for domain in per_host_domains.itervalues()}

@property
def not_domains_set(self):
return {domain
for per_host_domains in self.not_domains.itervalues()
for domain in per_host_domains.itervalues()}

@property
def all_domains_set(self):
return self.domains_set | self.not_domains_set

@property
def ssl_env(self):
try:
Expand Down

0 comments on commit 81aaac8

Please sign in to comment.