Skip to content

Commit

Permalink
[wptrunner] Optimize server test order (#46331)
Browse files Browse the repository at this point in the history
`TestEnvironment.ensure_started()` synchronously polls that all servers
are started. The non-webtransport-h3 servers are often tested first and
immediately fail with "Connection refused", which puts them in the
`pending` list. This spins the polling loop at least once and delays
startup by at least 0.5s.

Run the webtransport-h3 server test first, which blocks [1]. This
provides additional time for the non-webtransport-h3 servers to become
ready, which means the `TestEnvironment` often only needs to poll once.

This speeds up `ensure_started()` from ~2.2s -> ~1.7s and improves
wptrunner's interactive UX (https://crbug.com/339299999). No functional
change.

[1]: https://github.com/web-platform-tests/wpt/blob/431f8d35/tools/webtransport/h3/webtransport_h3_server.py#L593
  • Loading branch information
jonathan-j-lee committed May 16, 2024
1 parent d6b7c6e commit c6298d4
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions tools/wptrunner/wptrunner/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,18 @@ def test_servers(self):
failed.append((scheme, port))

if not failed and self.test_server_port:
# The webtransport-h3 server test blocks (i.e., doesn't fail quickly
# with "Connection refused" like the sockets do), so testing these
# first improves the likelihood the non-webtransport-h3 servers are
# ready by the time they're checked.
for port, server in self.servers.get("webtransport-h3", []):
if not webtranport_h3_server_is_running(host, port, timeout=5):
pending.append((host, port))

for scheme, servers in self.servers.items():
if scheme == "webtransport-h3":
continue
for port, server in servers:
if scheme == "webtransport-h3":
if not webtranport_h3_server_is_running(host, port, timeout=5.0):
pending.append((host, port))
continue
s = socket.socket()
s.settimeout(0.1)
try:
Expand Down

0 comments on commit c6298d4

Please sign in to comment.