Bug 1304046 - Add wdspec support to mozharness, r=ahal draft
authorJames Graham <james@hoppipolla.co.uk>
Wed, 21 Sep 2016 14:14:14 +0100
changeset 418485 c31d8a89b0f87a277c3b180a78ac363136726e01
parent 418484 10243fd520cacbf3008d6679694e1d54de69b0cf
child 418486 1357a05c341c73bcedb1ce3790f9275619cecfc1
push id30687
push userbmo:james@hoppipolla.co.uk
push dateWed, 28 Sep 2016 14:58:09 +0000
reviewersahal
bugs1304046
milestone52.0a1
Bug 1304046 - Add wdspec support to mozharness, r=ahal Downloads geckodriver from tooltool when wdspec tests are being run, and adds the --webdriver-binary argument MozReview-Commit-ID: AJeP0YDk7Yl
testing/config/tooltool-manifests/linux64/geckodriver.manifest
testing/mozharness/configs/web_platform_tests/prod_config.py
testing/mozharness/scripts/web_platform_tests.py
new file mode 100644
--- /dev/null
+++ b/testing/config/tooltool-manifests/linux64/geckodriver.manifest
@@ -0,0 +1,9 @@
+[
+{
+"size": 1379434,
+"visibility": "public",
+"digest": "cafa23466e283bccb6f89db9606da281877a87e3f22439c25655767fedc118df6961d9c34fc52eb4e747d48a66acd8c15d7c8c07b8f36e2e7db4ad8826742bfd",
+"algorithm": "sha512",
+"filename": "geckodriver-v0.10.0-linux64.tar.gz"
+}
+]
--- a/testing/mozharness/configs/web_platform_tests/prod_config.py
+++ b/testing/mozharness/configs/web_platform_tests/prod_config.py
@@ -34,12 +34,14 @@ config = {
     "default_blob_upload_servers": [
          "https://blobupload.elasticbeanstalk.com",
     ],
 
     "blob_uploader_auth_file" : os.path.join(os.getcwd(), "oauth.txt"),
 
     "download_minidump_stackwalk": True,
 
+    "download_tooltool": True,
+
     "tooltool_cache": "/builds/tooltool_cache",
 
 }
 
--- a/testing/mozharness/scripts/web_platform_tests.py
+++ b/testing/mozharness/scripts/web_platform_tests.py
@@ -1,25 +1,27 @@
 #!/usr/bin/env python
 # ***** BEGIN LICENSE BLOCK *****
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
 # You can obtain one at http://mozilla.org/MPL/2.0/.
 # ***** END LICENSE BLOCK *****
+import copy
+import glob
+import json
 import os
 import sys
-import copy
 
 # load modules from parent dir
 sys.path.insert(1, os.path.dirname(sys.path[0]))
 
 from mozharness.base.script import PreScriptAction
 from mozharness.base.vcs.vcsbase import MercurialScript
 from mozharness.mozilla.blob_upload import BlobUploadMixin, blobupload_config_options
-from mozharness.mozilla.testing.testbase import TestingMixin, testing_config_options
+from mozharness.mozilla.testing.testbase import TestingMixin, testing_config_options, TOOLTOOL_PLATFORM_DIR
 
 from mozharness.mozilla.structuredlog import StructuredOutputParser
 from mozharness.base.log import INFO
 
 class WebPlatformTest(TestingMixin, MercurialScript, BlobUploadMixin):
     config_options = [
         [['--test-type'], {
             "action": "extend",
@@ -52,32 +54,34 @@ class WebPlatformTest(TestingMixin, Merc
 
     def __init__(self, require_config_file=True):
         super(WebPlatformTest, self).__init__(
             config_options=self.config_options,
             all_actions=[
                 'clobber',
                 'read-buildbot-config',
                 'download-and-extract',
+                'fetch-geckodriver',
                 'create-virtualenv',
                 'pull',
                 'install',
                 'run-tests',
             ],
             require_config_file=require_config_file,
             config={'require_test_zip': True})
 
         # Surely this should be in the superclass
         c = self.config
         self.installer_url = c.get('installer_url')
         self.test_url = c.get('test_url')
         self.test_packages_url = c.get('test_packages_url')
         self.installer_path = c.get('installer_path')
         self.binary_path = c.get('binary_path')
         self.abs_app_dir = None
+        self.geckodriver_path = None
 
     def query_abs_app_dir(self):
         """We can't set this in advance, because OSX install directories
         change depending on branding and opt/debug.
         """
         if self.abs_app_dir:
             return self.abs_app_dir
         if not self.binary_path:
@@ -145,16 +149,20 @@ class WebPlatformTest(TestingMixin, Merc
         if not c["e10s"]:
             cmd.append("--disable-e10s")
 
         for opt in ["total_chunks", "this_chunk"]:
             val = c.get(opt)
             if val:
                 cmd.append("--%s=%s" % (opt.replace("_", "-"), val))
 
+        if "wdspec" in c.get("test_type", []):
+            assert self.geckodriver_path is not None
+            cmd.append("--webdriver-binary=%s" % self.geckodriver_path)
+
         options = list(c.get("options", []))
 
         str_format_values = {
             'binary_path': self.binary_path,
             'test_path': dirs["abs_wpttest_dir"],
             'test_install_path': dirs["abs_test_install_dir"],
             'abs_app_dir': abs_app_dir,
             'abs_work_dir': dirs["abs_work_dir"]
@@ -175,16 +183,53 @@ class WebPlatformTest(TestingMixin, Merc
             extract_dirs=["bin/*",
                           "config/*",
                           "mozbase/*",
                           "marionette/*",
                           "tools/wptserve/*",
                           "web-platform/*"],
             suite_categories=["web-platform"])
 
+    def fetch_geckodriver(self):
+        c = self.config
+        dirs = self.query_abs_dirs()
+
+        platform_name = self.platform_name()
+
+        if "wdspec" not in c.get("test_type", []):
+            return
+
+        if platform_name != "linux64":
+            self.fatal("Don't have a geckodriver for %s" % platform_name)
+
+        tooltool_path = os.path.join(dirs["abs_test_install_dir"],
+                                     "config",
+                                     "tooltool-manifests",
+                                     TOOLTOOL_PLATFORM_DIR[platform_name],
+                                     "geckodriver.manifest")
+
+        with open(tooltool_path) as f:
+            manifest = json.load(f)
+
+        assert len(manifest) == 1
+        geckodriver_filename = manifest[0]["filename"]
+        assert geckodriver_filename.endswith(".tar.gz")
+
+        self.tooltool_fetch(
+            manifest=tooltool_path,
+            output_dir=dirs['abs_work_dir'],
+            cache=c.get('tooltool_cache')
+        )
+
+        compressed_path = os.path.join(dirs['abs_work_dir'], geckodriver_filename)
+        tar = self.query_exe('tar', return_type="list")
+        self.run_command(tar + ["xf", compressed_path], cwd=dirs['abs_work_dir'],
+                         halt_on_failure=True, fatal_exit_code=3)
+        self.geckodriver_path = os.path.join(dirs['abs_work_dir'], "geckodriver")
+
     def run_tests(self):
         dirs = self.query_abs_dirs()
         cmd = self._query_cmd()
 
         parser = StructuredOutputParser(config=self.config,
                                         log_obj=self.log_obj,
                                         log_compact=True)