From 140913b1cbddbdfc4c9a899b73b12624d62446ab Mon Sep 17 00:00:00 2001 From: Tyson Smith Date: Tue, 5 Dec 2023 17:46:52 -0800 Subject: [PATCH] Handle target hangs immediately after launch This is a workaround to prevent grizzly from hanging. A more complete solution should be created. --- grizzly/common/bugzilla.py | 1 + grizzly/common/runner.py | 17 ++++++++++++----- grizzly/common/test_runner.py | 2 ++ 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/grizzly/common/bugzilla.py b/grizzly/common/bugzilla.py index 90e87e1b..3221e893 100644 --- a/grizzly/common/bugzilla.py +++ b/grizzly/common/bugzilla.py @@ -18,6 +18,7 @@ # attachments that can be ignored IGNORE_EXTS = frozenset({"c", "cpp", "diff", "exe", "log", "patch", "php", "py", "txt"}) +# TODO: support all target assets KNOWN_ASSETS = {"prefs": "prefs.js"} LOG = getLogger(__name__) diff --git a/grizzly/common/runner.py b/grizzly/common/runner.py index 0eb4ec14..572b23d3 100644 --- a/grizzly/common/runner.py +++ b/grizzly/common/runner.py @@ -230,9 +230,12 @@ def post_launch(self, delay=-1): srv_map = ServerMap() srv_map.set_redirect("grz_start", content.entry_point, required=False) srv_map.set_redirect("grz_continue", "grz_start", required=True) - # temporarily disable server timeout - srv_timeout = self._server.timeout - self._server.timeout = 0 + # temporarily override server timeout + org_timeout = self._server.timeout + # add time buffer to redirect delay + # in practice this should take a few seconds (~10s) + # in extreme cases ~40s (slow build + debugger) + self._server.timeout = delay + 180 if delay > 0: LOG.info("Browser launched, continuing in %ds...", delay) # serve prompt page @@ -241,12 +244,16 @@ def post_launch(self, delay=-1): continue_cb=self._target.monitor.is_healthy, server_map=srv_map, ) - # reset server timeout - self._server.timeout = srv_timeout + # restore server timeout + self._server.timeout = org_timeout if server_status != Served.ALL: self.startup_failure = True + if server_status == Served.TIMEOUT: + # this should never happen with a correctly functioning build + LOG.warning("Target hung after launch") if self.startup_failure: + # TODO: we need a better way to handle delayed startup failures LOG.warning("Post launch check failed!") def run( diff --git a/grizzly/common/test_runner.py b/grizzly/common/test_runner.py index d43d5b2c..0cbfaa55 100644 --- a/grizzly/common/test_runner.py +++ b/grizzly/common/test_runner.py @@ -394,6 +394,8 @@ def test_runner_11(mocker): (-1, None, False), # startup failure (0, (Served.NONE, None), True), + # target hang while loading content + (0, (Served.TIMEOUT, None), True), ], ) def test_runner_12(mocker, delay, srv_result, startup_failure):