Bug 1576220 [wpt PR 18642] - Fix WebDriver executor to actually delete the session, add debug info, a=testonly
authorSam Sneddon <me@gsnedders.com>
Wed, 28 Aug 2019 09:54:00 +0000
changeset 554515 a40980e4179ab2459051ceedfe0d08c091c6fda4
parent 554514 46ce1c209c17ce99f3090d6dbe179e018424fea7
child 554516 1cd8c72bcdebe21f24f4d24a5d4350a62beaa6e1
push id2165
push userffxbld-merge
push dateMon, 14 Oct 2019 16:30:58 +0000
treeherdermozilla-release@0eae18af659f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1576220, 18642
milestone70.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 1576220 [wpt PR 18642] - Fix WebDriver executor to actually delete the session, add debug info, a=testonly Automatic update from web-platform-tests Fix the WebDriver executor to actually delete the session webdriver.quit doesn't exist, but webdriver.end does -- Add more debug info when we timeout and when killing WebDriver -- wpt-commits: beb4659e42c41f98f21ecc22c7ed501c2b9f37f9, d746cd6ed1ec1caa0b7469d55dd3fa1a4a9305d9 wpt-pr: 18642
testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executorwebdriver.py
testing/web-platform/tests/tools/wptrunner/wptrunner/webdriver_server.py
--- a/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executorwebdriver.py
+++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/executors/executorwebdriver.py
@@ -1,11 +1,12 @@
 import json
 import os
 import socket
+import sys
 import threading
 import time
 import traceback
 import urlparse
 import uuid
 
 from .base import (CallbackHandler,
                    RefTestExecutor,
@@ -227,20 +228,24 @@ class WebDriverProtocol(Protocol):
         capabilities = {"alwaysMatch": self.capabilities}
         self.webdriver = client.Session(host, port, capabilities=capabilities)
         self.webdriver.start()
 
 
     def teardown(self):
         self.logger.debug("Hanging up on WebDriver session")
         try:
-            self.webdriver.quit()
-        except Exception:
-            pass
-        del self.webdriver
+            self.webdriver.end()
+        except Exception as e:
+            message = str(getattr(e, "message", ""))
+            if message:
+                message += "\n"
+            message += traceback.format_exc(e)
+            self.logger.debug(message)
+        self.webdriver = None
 
     def is_alive(self):
         try:
             # Get a simple property over the connection
             self.webdriver.window_handle
         except (socket.timeout, client.UnknownErrorException):
             return False
         return True
@@ -272,17 +277,20 @@ class WebDriverRun(object):
 
         flag = self.result_flag.wait(timeout + 2 * extra_timeout)
         if self.result is None:
             if flag:
                 # flag is True unless we timeout; this *shouldn't* happen, but
                 # it can if self._run fails to set self.result due to raising
                 self.result = False, ("INTERNAL-ERROR", "self._run didn't set a result")
             else:
-                self.result = False, ("EXTERNAL-TIMEOUT", None)
+                message = "Waiting on browser:\n"
+                # get a traceback for the current stack of the executor thread
+                message += "".join(traceback.format_stack(sys._current_frames()[executor.ident]))
+                self.result = False, ("EXTERNAL-TIMEOUT", message)
 
         return self.result
 
     def _run(self):
         try:
             self.result = True, self.func(self.protocol, self.url, self.timeout)
         except (client.TimeoutException, client.ScriptTimeoutException):
             self.result = False, ("EXTERNAL-TIMEOUT", None)
--- a/testing/web-platform/tests/tools/wptrunner/wptrunner/webdriver_server.py
+++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/webdriver_server.py
@@ -76,16 +76,17 @@ class WebDriverServer(object):
                 "WebDriver was not accessible "
                 "within the timeout:\n%s" % traceback.format_exc())
             raise
 
         if block:
             self._proc.wait()
 
     def stop(self, force=False):
+        self.logger.debug("Stopping WebDriver")
         if self.is_alive:
             return self._proc.kill()
         return not self.is_alive
 
     @property
     def is_alive(self):
         return hasattr(self._proc, "proc") and self._proc.poll() is None