WebDriver: add timeout option to run-webdriver-tests script
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Nov 2017 12:45:30 +0000 (12:45 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 28 Nov 2017 12:45:30 +0000 (12:45 +0000)
https://bugs.webkit.org/show_bug.cgi?id=179940

Reviewed by Carlos Alberto Lopez Perez.

Tools:

We need to handle timeouts to be able to run the tests in the bots. pytest doesn't support timeouts, but there's
a plugin pytest_timeout that can be used for that.

* Scripts/run-webdriver-tests: Add --timeout command line option.
* Scripts/webkitpy/thirdparty/__init__.py:
(AutoinstallImportHook.find_module): Check if pytest_timeout is imported to install it.
(AutoinstallImportHook._install_pytest_timeout): Install pytest_timeout from pypi.
* Scripts/webkitpy/webdriver_tests/webdriver_test_runner_w3c.py:
(WebDriverTestRunnerW3C.__init__): Set PYTEST_TIMEOUT env var with the timeout given.
* Scripts/webkitpy/webdriver_tests/webdriver_w3c_executor.py:
(WebDriverW3CExecutor.run): Clarify that the timeout received by do_wdspec() is ignored, and pass 0 instead of 25.

WebDriverTests:

Add a base conftest.py to load pytest_timeout plugin.

* imported/w3c/conftest.py: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@225211 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/Scripts/run-webdriver-tests
Tools/Scripts/webkitpy/thirdparty/__init__.py
Tools/Scripts/webkitpy/webdriver_tests/webdriver_test_runner_w3c.py
Tools/Scripts/webkitpy/webdriver_tests/webdriver_w3c_executor.py
WebDriverTests/ChangeLog
WebDriverTests/imported/w3c/conftest.py [new file with mode: 0644]

index fdddbeb..b6116d6 100644 (file)
@@ -1,3 +1,22 @@
+2017-11-28  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        WebDriver: add timeout option to run-webdriver-tests script
+        https://bugs.webkit.org/show_bug.cgi?id=179940
+
+        Reviewed by Carlos Alberto Lopez Perez.
+
+        We need to handle timeouts to be able to run the tests in the bots. pytest doesn't support timeouts, but there's
+        a plugin pytest_timeout that can be used for that.
+
+        * Scripts/run-webdriver-tests: Add --timeout command line option.
+        * Scripts/webkitpy/thirdparty/__init__.py:
+        (AutoinstallImportHook.find_module): Check if pytest_timeout is imported to install it.
+        (AutoinstallImportHook._install_pytest_timeout): Install pytest_timeout from pypi.
+        * Scripts/webkitpy/webdriver_tests/webdriver_test_runner_w3c.py:
+        (WebDriverTestRunnerW3C.__init__): Set PYTEST_TIMEOUT env var with the timeout given.
+        * Scripts/webkitpy/webdriver_tests/webdriver_w3c_executor.py:
+        (WebDriverW3CExecutor.run): Clarify that the timeout received by do_wdspec() is ignored, and pass 0 instead of 25.
+
 2017-11-27  Aakash Jain  <aakash_jain@apple.com>
 
         Do not run webkitpy tests on multiple EWSes
index f7534ac..2e601cf 100755 (executable)
@@ -45,6 +45,8 @@ option_parser.add_option('--release', action='store_const', const='Release', des
                          help='Set the configuration to Release')
 option_parser.add_option('--debug', action='store_const', const='Debug', dest="configuration",
                          help='Set the configuration to Debug')
+option_parser.add_option('--timeout', action='store', type='int', dest='timeout', default=10,
+                         help='Time in seconds until a test times out (use 0 to disable)')
 option_parser.add_option('--display-server', choices=['xvfb', 'xorg', 'weston', 'wayland'], default='xvfb',
                          help='"xvfb": Use a virtualized X11 server. "xorg": Use the current X11 session. '
                               '"weston": Use a virtualized Weston server. "wayland": Use the current wayland session.')
index 742fc29..d70c1bf 100644 (file)
@@ -110,6 +110,8 @@ class AutoinstallImportHook(object):
             self._install_mozlog()
         elif '.mozprocess' in fullname:
             self._install_mozprocess()
+        elif '.pytest_timeout' in fullname:
+            self._install_pytest_timeout()
 
     def _install_mechanize(self):
         self._install("https://pypi.python.org/packages/source/m/mechanize/mechanize-0.2.5.tar.gz",
@@ -133,6 +135,10 @@ class AutoinstallImportHook(object):
         self._install("https://pypi.python.org/packages/cb/26/144dbc28d1f40e392f8a0cbee771ba624a61017f016c77ad88424d84b230/mozprocess-0.25.tar.gz#md5=07a04e6ae1a705705e4b44969fe7a182",
                               "mozprocess-0.25/mozprocess")
 
+    def _install_pytest_timeout(self):
+        self._install("https://pypi.python.org/packages/cc/b7/b2a61365ea6b6d2e8881360ae7ed8dad0327ad2df89f2f0be4a02304deb2/pytest-timeout-1.2.0.tar.gz#md5=83607d91aa163562c7ee835da57d061d",
+                              "pytest-timeout-1.2.0/pytest_timeout.py")
+
     def _install_pylint(self):
         self._ensure_autoinstalled_dir_is_in_sys_path()
         if (not self._fs.exists(self._fs.join(_AUTOINSTALLED_DIR, "pylint")) or
index 6c9ab14..0bdd93f 100644 (file)
@@ -44,6 +44,10 @@ class WebDriverTestRunnerW3C(object):
         _log.info('Using driver at %s' % (self._driver.binary_path()))
         _log.info('Browser: %s' % (self._driver.browser_name()))
 
+        timeout = self._port.get_option('timeout')
+        if timeout > 0:
+            os.environ['PYTEST_TIMEOUT'] = str(timeout)
+
         self._results = []
         self._server = WebDriverW3CWebServer(self._port)
 
index 93517bd..953a005 100644 (file)
@@ -41,6 +41,7 @@ _ensure_directory_in_path(os.path.join(w3c_tools_dir, 'webdriver'))
 _ensure_directory_in_path(os.path.join(w3c_tools_dir, 'wptrunner'))
 _ensure_directory_in_path(os.path.join(w3c_tools_dir, "webdriver"))
 
+import webkitpy.thirdparty.autoinstalled.pytest_timeout
 from wptrunner.executors.base import WdspecExecutor, WebDriverProtocol
 from wptrunner.webdriver_server import WebDriverServer
 
@@ -136,4 +137,5 @@ class WebDriverW3CExecutor(WdspecExecutor):
         self.protocol.teardown()
 
     def run(self, path):
-        return self.do_wdspec(self.protocol.session_config, path, 25)
+        # Timeout here doesn't really matter because it's ignored, so we pass 0.
+        return self.do_wdspec(self.protocol.session_config, path, 0)
index a2fd1ff..77f16a2 100644 (file)
@@ -1,3 +1,14 @@
+2017-11-28  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        WebDriver: add timeout option to run-webdriver-tests script
+        https://bugs.webkit.org/show_bug.cgi?id=179940
+
+        Reviewed by Carlos Alberto Lopez Perez.
+
+        Add a base conftest.py to load pytest_timeout plugin.
+
+        * imported/w3c/conftest.py: Added.
+
 2017-11-21  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         Unreviewed. Update W3C WebDriver imported tests.
diff --git a/WebDriverTests/imported/w3c/conftest.py b/WebDriverTests/imported/w3c/conftest.py
new file mode 100644 (file)
index 0000000..9101e55
--- /dev/null
@@ -0,0 +1 @@
+pytest_plugins = 'pytest_timeout',