commit d151c1720d9b0e975fc3aaaffde27f04cfb52d62
parent ad73aa66b4a127c3533ea656c9f5abe7495d5f8e
Author: Euclid Ye <yezhizhenjiakang@gmail.com>
Date: Mon, 17 Nov 2025 21:50:27 +0000
Bug 1998658 [wpt PR 55907] - servodriver: Shut down Servo elegantly when all tests finish, a=testonly
Automatic update from web-platform-tests
Normally shutdown Servo with retry
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
--
Do not reuse connection
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
--
- Use `requests` to clean resources
- Add retry
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
--
Fixing TIMEOUT
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
--
Apply review suggestions
Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
--
Remove whitespace.
Signed-off-by: Josh Matthews <josh@joshmatthews.net>
--
wpt-commits: a3e53a5df241b899520164d16bcc1f6075106cf2, 5cb518e92dbab9f14875a2d248fe0c061d4260c0, e65552fa2203d050f8559f7459bbc8ebe61e48da, 1814af953987eb277a1b7db1a8b22ffcfadeb237, 8226fedfa3279fdc636b5e3730bb08c568b343f8, c900d9690d8c1a7f1904d69c134860e44ed8a704
wpt-pr: 55907
Diffstat:
1 file changed, 46 insertions(+), 1 deletion(-)
diff --git a/testing/web-platform/tests/tools/wptrunner/wptrunner/browsers/servodriver.py b/testing/web-platform/tests/tools/wptrunner/wptrunner/browsers/servodriver.py
@@ -1,7 +1,9 @@
# mypy: allow-untyped-defs
import os
+import requests
import tempfile
+import time
from tools.serve.serve import make_hosts_file
@@ -79,6 +81,7 @@ def write_hosts_file(config):
class ServoWebDriverBrowser(WebDriverBrowser):
init_timeout = 300 # Large timeout for cases where we're booting an Android emulator
+ shutdown_retry_attempts = 3
def __init__(self, logger, binary, debug_info=None, webdriver_host="127.0.0.1",
server_config=None, binary_args=None,
@@ -126,9 +129,51 @@ class ServoWebDriverBrowser(WebDriverBrowser):
return [self.webdriver_binary, f"--webdriver={self.port}"] + self.webdriver_args
def cleanup(self):
- super().cleanup()
os.remove(self.hosts_path)
+ def is_alive(self):
+ # This is broken. It is always True.
+ if not super().is_alive():
+ return False
+ try:
+ requests.get(f"http://{self.host}:{self.port}/status", timeout=3)
+ except requests.exceptions.Timeout:
+ # FIXME: This indicates a hanged browser. Reasons need to be investigated further.
+ # It happens with ~0.1% probability in our CI runs.
+ self.logger.debug("Servo webdriver status request timed out.")
+ return True
+ except Exception as exception:
+ self.logger.debug(f"Servo has shut down normally. {exception}")
+ return False
+
+ return True
+
+ def stop(self, force=False):
+ retry_cnt = 0
+ while self.is_alive():
+ self.logger.info("Trying to shut down gracefully by extension command")
+ try:
+ requests.delete(
+ f"http://{self.host}:{self.port}/session/dummy-session-id/servo/shutdown",
+ timeout=3
+ )
+ except requests.exceptions.ConnectionError:
+ self.logger.debug("Browser already shut down (connection refused)")
+ break
+ except requests.exceptions.RequestException as exeception:
+ self.logger.debug(f"Request exception: {exeception}")
+ break
+ except requests.exceptions.Timeout:
+ self.logger.debug("Request timed out")
+ break
+
+ retry_cnt += 1
+ if retry_cnt >= self.shutdown_retry_attempts:
+ self.logger.warn("Max retry exceeded to normally shut down. Killing instead.")
+ break
+ time.sleep(1)
+ super().stop(force)
+
def find_wpt_prefs(self, logger):
default_path = os.path.join("resources", "wpt-prefs.json")
# The cwd is the servo repo for `./mach test-wpt`, but on WPT runners