Bug 1500242 - [marionette] Obey the extended shutdown timeout for Firefox ASAN builds. r=ato
authorHenrik Skupin <mail@hskupin.info>
Fri, 19 Oct 2018 11:52:42 +0000
changeset 500633 9a2be0efbc4c4f1931f39a1dfe4a082cec09b2e0
parent 500632 9645a734546be91c08cdba441d7003259e51bda8
child 500634 59fed9e69c53f229e240d0bdfb0b5ca2d3afeb67
push id1864
push userffxbld-merge
push dateMon, 03 Dec 2018 15:51:40 +0000
treeherdermozilla-release@f040763d99ad [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersato
bugs1500242
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1500242 - [marionette] Obey the extended shutdown timeout for Firefox ASAN builds. r=ato Firefox uses different shutdown timeouts for the terminator thread depending on the build type. For opt/debug builds this will be 60s, while for ASAN builds 180s are used. Currently Marionette only takes the 60s into account, and always kills the binary after 70s if a shutdown hasn't happened by that time. This actually prevents the background hang monitor to kill Firefox for ASAN builds, and to report a meaningful crash report for the shutdown hang. To inform clients about the correct shutdown timeout, a new vendor specific capability with the name `moz:shutdownTimeout` is used as part of the new session capabilities. Depends on D9227 Differential Revision: https://phabricator.services.mozilla.com/D9228
testing/marionette/capabilities.js
testing/marionette/client/marionette_driver/marionette.py
testing/marionette/harness/marionette_harness/tests/unit/test_quit_restart.py
--- a/testing/marionette/capabilities.js
+++ b/testing/marionette/capabilities.js
@@ -402,16 +402,17 @@ class Capabilities extends Map {
       // features
       ["rotatable", appinfo.name == "B2G"],
 
       // proprietary
       ["moz:accessibilityChecks", false],
       ["moz:headless", Cc["@mozilla.org/gfx/info;1"].getService(Ci.nsIGfxInfo).isHeadless],
       ["moz:processID", Services.appinfo.processID],
       ["moz:profile", maybeProfile()],
+      ["moz:shutdownTimeout", Services.prefs.getIntPref("toolkit.asyncshutdown.crash_timeout")],
       ["moz:useNonSpecCompliantPointerOrigin", false],
       ["moz:webdriverClick", true],
     ]);
   }
 
   /**
    * @param {string} key
    *     Capability key.
--- a/testing/marionette/client/marionette_driver/marionette.py
+++ b/testing/marionette/client/marionette_driver/marionette.py
@@ -1298,16 +1298,20 @@ class Marionette(object):
         resp = self._send_message("WebDriver:NewSession",
                                   body)
         self.session_id = resp["sessionId"]
         self.session = resp["capabilities"]
         # fallback to processId can be removed in Firefox 55
         self.process_id = self.session.get("moz:processID", self.session.get("processId"))
         self.profile = self.session.get("moz:profile")
 
+        timeout = self.session.get("moz:shutdownTimeout")
+        if timeout is not None:
+            self.shutdown_timeout = timeout / 1000 + 10
+
         return self.session
 
     @property
     def test_name(self):
         return self._test_name
 
     @test_name.setter
     def test_name(self, test_name):
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_quit_restart.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_quit_restart.py
@@ -195,25 +195,18 @@ class TestQuitRestart(MarionetteTestCase
                             "about:about")
 
     def test_in_app_restart_with_callback_not_callable(self):
         with self.assertRaisesRegexp(ValueError, "is not callable"):
             self.marionette.restart(in_app=True, callback=4)
 
     @unittest.skipIf(sys.platform.startswith("win"), "Bug 1493796")
     def test_in_app_restart_with_callback_but_process_quit(self):
-        timeout_shutdown = self.marionette.shutdown_timeout
-        # Wait at least 70s for the hang monitor in case of a shutdown hang
-        self.marionette.shutdown_timeout = 70
-
-        try:
-            with self.assertRaisesRegexp(IOError, "Process unexpectedly quit without restarting"):
-                self.marionette.restart(in_app=True, callback=lambda: self.shutdown(restart=False))
-        finally:
-            self.marionette.shutdown_timeout = timeout_shutdown
+        with self.assertRaisesRegexp(IOError, "Process unexpectedly quit without restarting"):
+            self.marionette.restart(in_app=True, callback=lambda: self.shutdown(restart=False))
 
     @unittest.skipIf(sys.platform.startswith("win"), "Bug 1493796")
     def test_in_app_restart_with_callback_missing_shutdown(self):
         try:
             timeout_shutdown = self.marionette.shutdown_timeout
             self.marionette.shutdown_timeout = 5
 
             with self.assertRaisesRegexp(IOError, "the connection to Marionette server is lost"):