Bug 1467827 - Port raptor firefox tp6 to linux; r=jmaher draft
authorRob Wood <rwood@mozilla.com>
Wed, 13 Jun 2018 14:04:46 -0700
changeset 808219 7c74a2a31c0fdac89b9fd0950e5a53cd64e2d7f5
parent 808144 1d03f4a4af28c1af56a183f5951a45a315a6c788
push id113321
push userrwood@mozilla.com
push dateMon, 18 Jun 2018 19:30:32 +0000
reviewersjmaher
bugs1467827
milestone62.0a1
Bug 1467827 - Port raptor firefox tp6 to linux; r=jmaher MozReview-Commit-ID: AQuWSuw7cFw
taskcluster/ci/test/raptor.yml
taskcluster/taskgraph/transforms/tests.py
testing/mozharness/configs/raptor/linux_config.py
testing/mozharness/mozharness/mozilla/testing/raptor.py
testing/raptor/raptor/playback/mitmproxy-rel-bin-linux64.manifest
testing/raptor/raptor/playback/mitmproxy.py
testing/raptor/raptor/raptor.py
testing/raptor/raptor/tests/raptor-tp6.ini
testing/raptor/raptor/utils.py
testing/raptor/test/test_playback.py
--- a/taskcluster/ci/test/raptor.yml
+++ b/taskcluster/ci/test/raptor.yml
@@ -27,16 +27,17 @@ job-defaults:
 
 raptor-firefox-tp6:
     description: "Raptor Firefox tp6"
     try-name: raptor-firefox-tp6
     treeherder-symbol: Rap(tp6)
     run-on-projects:
         by-test-platform:
             macosx.*: ['try', 'mozilla-central']
+            linux64.*: ['try', 'mozilla-central']
             default: ['try']
     max-run-time: 1200
     mozharness:
         extra-options:
             - --test=raptor-tp6
 
 raptor-firefox-speedometer:
     description: "Raptor Firefox speedometer"
--- a/taskcluster/taskgraph/transforms/tests.py
+++ b/taskcluster/taskgraph/transforms/tests.py
@@ -403,17 +403,17 @@ def set_defaults(config, tests):
             # platform phyla
             test['loopback-video'] = True
         else:
             # all non-android tests want to run the bits that require node
             test['mozharness']['set-moz-node-path'] = True
             test.setdefault('e10s', True)
 
         # software-gl-layers is only meaningful on linux unittests, where it defaults to True
-        if test['test-platform'].startswith('linux') and test['suite'] != 'talos':
+        if test['test-platform'].startswith('linux') and test['suite'] not in ['talos', 'raptor']:
             test.setdefault('allow-software-gl-layers', True)
         else:
             test['allow-software-gl-layers'] = False
 
         # Enable WebRender by default on the QuantumRender test platforms, since
         # the whole point of QuantumRender is to run with WebRender enabled.
         # This currently matches linux64-qr and windows10-64-qr; both of these
         # have /opt and /debug variants.
--- a/testing/mozharness/configs/raptor/linux_config.py
+++ b/testing/mozharness/configs/raptor/linux_config.py
@@ -9,27 +9,27 @@ else:
     TOOLTOOL_MANIFEST_PATH = "config/tooltool-manifests/linux32/releng.manifest"
     MINIDUMP_STACKWALK_PATH = "linux32-minidump_stackwalk"
 
 config = {
     "log_name": "raptor",
     "installer_path": "installer.exe",
     "virtualenv_path": VENV_PATH,
     "find_links": [
-        "http://pypi.pvt.build.mozilla.org/pub",
-        "http://pypi.pub.build.mozilla.org/pub",
+        "https://pypi.pvt.build.mozilla.org/pub",
+        "https://pypi.pub.build.mozilla.org/pub",
     ],
     "pip_index": False,
     "title": os.uname()[1].lower().split('.')[0],
     "default_actions": [
         "clobber",
         "download-and-extract",
         "populate-webroot",
+        "install-chrome",
         "create-virtualenv",
         "install",
-        "setup-mitmproxy",
         "run-tests",
     ],
     "download_minidump_stackwalk": True,
     "minidump_stackwalk_path": MINIDUMP_STACKWALK_PATH,
     "minidump_tooltool_manifest_path": TOOLTOOL_MANIFEST_PATH,
     "tooltool_cache": "/builds/tooltool_cache",
 }
--- a/testing/mozharness/mozharness/mozilla/testing/raptor.py
+++ b/testing/mozharness/mozharness/mozilla/testing/raptor.py
@@ -66,16 +66,22 @@ class Raptor(TestingMixin, MercurialScri
           "help": "branch running against"
           }],
         [["--add-option"],
          {"action": "extend",
           "dest": "raptor_cmd_line_args",
           "default": None,
           "help": "extra options to raptor"
           }],
+        [["--enable-webrender"], {
+            "action": "store_true",
+            "dest": "enable_webrender",
+            "default": False,
+            "help": "Tries to enable the WebRender compositor.",
+        }],
     ] + testing_config_options + copy.deepcopy(code_coverage_config_options)
 
     def __init__(self, **kwargs):
         kwargs.setdefault('config_options', self.config_options)
         kwargs.setdefault('all_actions', ['clobber',
                                           'download-and-extract',
                                           'populate-webroot',
                                           'install-chrome',
@@ -371,16 +377,22 @@ class Raptor(TestingMixin, MercurialScri
             self.mkdir_p(env['MOZ_UPLOAD_DIR'])
         env = self.query_env(partial_env=env, log_level=INFO)
         # adjust PYTHONPATH to be able to use raptor as a python package
         if 'PYTHONPATH' in env:
             env['PYTHONPATH'] = self.raptor_path + os.pathsep + env['PYTHONPATH']
         else:
             env['PYTHONPATH'] = self.raptor_path
 
+        # if running in production on a quantum_render build
+        if self.config['enable_webrender']:
+            self.info("webrender is enabled so setting MOZ_WEBRENDER=1 and MOZ_ACCELERATED=1")
+            env['MOZ_WEBRENDER'] = '1'
+            env['MOZ_ACCELERATED'] = '1'
+
         # mitmproxy needs path to mozharness when installing the cert, and tooltool
         env['SCRIPTSPATH'] = scripts_path
         env['EXTERNALTOOLSPATH'] = external_tools_path
 
         if self.repo_path is not None:
             env['MOZ_DEVELOPER_REPO_DIR'] = self.repo_path
         if self.obj_path is not None:
             env['MOZ_DEVELOPER_OBJ_DIR'] = self.obj_path
new file mode 100644
--- /dev/null
+++ b/testing/raptor/raptor/playback/mitmproxy-rel-bin-linux64.manifest
@@ -0,0 +1,9 @@
+[
+    {
+        "filename": "mitmproxy-2.0.2-linux.tar.gz",
+        "size": 48997542,
+        "digest": "b032e04b8763206a19f80b78062efa59dc901ad32fd8d6cf2d20e22744711352da61e75d93a0d93d645179153534f72a154f73432837db415c9b0cd9d981f012",
+        "algorithm": "sha512",
+        "unpack": true
+    }
+]
--- a/testing/raptor/raptor/playback/mitmproxy.py
+++ b/testing/raptor/raptor/playback/mitmproxy.py
@@ -1,9 +1,9 @@
-'''This helps loading mitmproxy's cert and change proxy settings for Firefox.'''
+'''Functions to download, install, setup, and use the mitmproxy playback tool'''
 # 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/.
 from __future__ import absolute_import
 
 import os
 import signal
 import subprocess
@@ -16,18 +16,23 @@ import mozinfo
 from mozlog import get_proxy_logger
 from mozprocess import ProcessHandler
 
 from .base import Playback
 
 here = os.path.dirname(os.path.realpath(__file__))
 LOG = get_proxy_logger(component='raptor-mitmproxy')
 
+# needed so unit tests can find their imports
 mozharness_dir = os.path.join(here, '../../../mozharness')
 sys.path.insert(0, mozharness_dir)
+raptor_dir = os.path.join(here, '..')
+sys.path.insert(0, raptor_dir)
+
+from utils import transform_platform
 
 external_tools_path = os.environ.get('EXTERNALTOOLSPATH', None)
 
 if external_tools_path is not None:
     # running in production via mozharness
     TOOLTOOL_PATH = os.path.join(external_tools_path, 'tooltool.py')
 else:
     # running locally via mach
@@ -112,20 +117,22 @@ class Mitmproxy(Playback):
 
     def download(self):
         # download mitmproxy binary and pageset using tooltool
         # note: tooltool automatically unpacks the files as well
         if not os.path.exists(self.raptor_dir):
             os.makedirs(self.raptor_dir)
         LOG.info("downloading mitmproxy binary")
         _manifest = os.path.join(here, self.config['playback_binary_manifest'])
-        self._tooltool_fetch(_manifest)
+        transformed_manifest = transform_platform(_manifest, self.config['platform'])
+        self._tooltool_fetch(transformed_manifest)
         LOG.info("downloading mitmproxy pageset")
         _manifest = os.path.join(here, self.config['playback_pageset_manifest'])
-        self._tooltool_fetch(_manifest)
+        transformed_manifest = transform_platform(_manifest, self.config['platform'])
+        self._tooltool_fetch(transformed_manifest)
         return
 
     def setup(self):
         # install the generated CA certificate into Firefox
         # mitmproxy cert setup needs path to mozharness install; mozharness has set this
         # value in the SCRIPTSPATH env var for us in mozharness/mozilla/testing/talos.py
         scripts_path = os.environ.get('SCRIPTSPATH')
         LOG.info('scripts_path: %s' % str(scripts_path))
--- a/testing/raptor/raptor/raptor.py
+++ b/testing/raptor/raptor/raptor.py
@@ -71,16 +71,18 @@ class Raptor(object):
         self.output_handler = OutputHandler()
         process_args = {
             'processOutputLine': [self.output_handler],
         }
         runner_cls = runners[app]
         self.runner = runner_cls(
             binary, profile=self.profile, process_args=process_args)
 
+        self.log.info("raptor config: %s" % str(self.config))
+
     @property
     def profile_data_dir(self):
         if 'MOZ_DEVELOPER_REPO_DIR' in os.environ:
             return os.path.join(os.environ['MOZ_DEVELOPER_REPO_DIR'], 'testing', 'profiles')
         if build:
             return os.path.join(build.topsrcdir, 'testing', 'profiles')
         return os.path.join(here, 'profile_data')
 
--- a/testing/raptor/raptor/tests/raptor-tp6.ini
+++ b/testing/raptor/raptor/tests/raptor-tp6.ini
@@ -2,18 +2,18 @@
 # 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/.
 
 # raptor tp6
 
 [DEFAULT]
 type =  pageload
 playback = mitmproxy
-playback_binary_manifest = mitmproxy-rel-bin-osx.manifest
-playback_binary_zip_mac = mitmproxy-2.0.2-osx.tar.gz
+playback_binary_manifest = mitmproxy-rel-bin-{platform}.manifest
+playback_binary_zip_mac = mitmproxy-2.0.2-{platform}.tar.gz
 playback_pageset_manifest = mitmproxy-playback-set.manifest
 playback_pageset_zip_mac = mitmproxy-recording-set-win10.zip
 page_cycles = 25
 unit = ms
 lower_is_better = true
 alert_threshold = 2.0
 
 [raptor-firefox-tp6-amazon]
new file mode 100644
--- /dev/null
+++ b/testing/raptor/raptor/utils.py
@@ -0,0 +1,24 @@
+'''Utility functions for Raptor'''
+# 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/.
+
+from __future__ import absolute_import
+
+from mozlog import get_proxy_logger
+
+LOG = get_proxy_logger(component="raptor-utils")
+
+
+def transform_platform(str_to_transform, config_platform):
+    # transform platform name i.e. 'mitmproxy-rel-bin-{platform}.manifest'
+    # transforms to 'mitmproxy-rel-bin-osx.manifest'
+    if '{platform}' not in str_to_transform:
+        return str_to_transform
+    if 'win' in config_platform:
+        platform_id = 'win'
+    elif config_platform == 'mac':
+        platform_id = 'osx'
+    else:
+        platform_id = 'linux64'
+    return str_to_transform.replace('{platform}', platform_id)
--- a/testing/raptor/test/test_playback.py
+++ b/testing/raptor/test/test_playback.py
@@ -1,23 +1,31 @@
 from __future__ import absolute_import, unicode_literals
 
+import os
+
+import mozinfo
 import mozunit
 
 from mozlog.structuredlog import set_default_logger, StructuredLogger
 
 set_default_logger(StructuredLogger('test_playback'))
 
 from raptor.playback import get_playback, Mitmproxy
 
-
 config = {}
 
 
 def test_get_playback(get_binary):
+    config['platform'] = mozinfo.os
+    if 'win' in config['platform']:
+        # this test is not yet supported on windows
+        assert True
+        return
+    config['obj_path'] = os.path.dirname(get_binary('firefox'))
     config['playback_tool'] = 'mitmproxy'
     config['playback_binary_manifest'] = 'mitmproxy-rel-bin-osx.manifest'
     config['playback_binary_zip_mac'] = 'mitmproxy-2.0.2-osx.tar.gz'
     config['playback_pageset_manifest'] = 'mitmproxy-playback-set.manifest'
     config['playback_pageset_zip_mac'] = 'mitmproxy-recording-set-win10.zip'
     config['playback_recordings'] = 'mitmproxy-recording-amazon.mp'
     config['binary'] = get_binary('firefox')
     playback = get_playback(config)