зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1577909. Fix typos in mozharness' raptor.py. r=perftest-reviewers,rwood
Differential Revision: https://phabricator.services.mozilla.com/D44694 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
53e3d54cec
Коммит
9c6b27fbdb
|
@ -1,3 +1,5 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
# 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/.
|
||||
|
@ -39,17 +41,17 @@ RaptorErrorList = PythonErrorList + HarnessErrorList + [
|
|||
{'regex': re.compile(r'''No machine_name called '.*' can be found'''), 'level': CRITICAL},
|
||||
{'substr': r"""No such file or directory: 'browser_output.txt'""",
|
||||
'level': CRITICAL,
|
||||
'explanation': "Most likely the browser failed to launch, or the test was otherwise "
|
||||
"unsuccessful in even starting."},
|
||||
'explanation': "Most likely the browser failed to launch, or the test otherwise "
|
||||
"failed to start."},
|
||||
]
|
||||
|
||||
|
||||
class Raptor(TestingMixin, MercurialScript, CodeCoverageMixin, AndroidMixin):
|
||||
"""
|
||||
install and run raptor tests
|
||||
Install and run Raptor tests
|
||||
"""
|
||||
|
||||
# Options to browsertime. Paths are expected to be absolute.
|
||||
# Options to Browsertime. Paths are expected to be absolute.
|
||||
browsertime_options = [
|
||||
[["--browsertime-node"], {
|
||||
"dest": "browsertime_node",
|
||||
|
@ -89,16 +91,16 @@ class Raptor(TestingMixin, MercurialScript, CodeCoverageMixin, AndroidMixin):
|
|||
{"default": "firefox",
|
||||
"choices": ["firefox", "chrome", "chromium", "fennec", "geckoview", "refbrow", "fenix"],
|
||||
"dest": "app",
|
||||
"help": "name of the application we are testing (default: firefox)"
|
||||
"help": "Name of the application we are testing (default: firefox)."
|
||||
}],
|
||||
[["--activity"],
|
||||
{"dest": "activity",
|
||||
"help": "the android activity used to launch the android app. "
|
||||
"ex: org.mozilla.fenix.browser.BrowserPerformanceTestActivity"
|
||||
"help": "The Android activity used to launch the Android app. "
|
||||
"e.g.: org.mozilla.fenix.browser.BrowserPerformanceTestActivity"
|
||||
}],
|
||||
[["--intent"],
|
||||
{"dest": "intent",
|
||||
"help": "name of the android intent action used to launch the android app"
|
||||
"help": "Name of the Android intent action used to launch the Android app"
|
||||
}],
|
||||
[["--is-release-build"],
|
||||
{"action": "store_true",
|
||||
|
@ -111,7 +113,7 @@ class Raptor(TestingMixin, MercurialScript, CodeCoverageMixin, AndroidMixin):
|
|||
{"action": "extend",
|
||||
"dest": "raptor_cmd_line_args",
|
||||
"default": None,
|
||||
"help": "extra options to raptor"
|
||||
"help": "Extra options to Raptor."
|
||||
}],
|
||||
[["--enable-webrender"], {
|
||||
"action": "store_true",
|
||||
|
@ -139,39 +141,39 @@ class Raptor(TestingMixin, MercurialScript, CodeCoverageMixin, AndroidMixin):
|
|||
"dest": "gecko_profile",
|
||||
"action": "store_true",
|
||||
"default": False,
|
||||
"help": "Whether or not to profile the test run and save the profile results"
|
||||
"help": "Whether to profile the test run and save the profile results."
|
||||
}],
|
||||
[["--gecko-profile-interval"], {
|
||||
"dest": "gecko_profile_interval",
|
||||
"type": "int",
|
||||
"help": "The interval between samples taken by the profiler (milliseconds)"
|
||||
"help": "The interval between samples taken by the profiler (ms)."
|
||||
}],
|
||||
[["--gecko-profile-entries"], {
|
||||
"dest": "gecko_profile_entries",
|
||||
"type": "int",
|
||||
"help": "How many samples to take with the profiler"
|
||||
"help": "How many samples to take with the profiler."
|
||||
}],
|
||||
[["--page-cycles"], {
|
||||
"dest": "page_cycles",
|
||||
"type": "int",
|
||||
"help": "How many times to repeat loading the test page (for page load tests); "
|
||||
"for benchmark tests this is how many times the benchmark test will be run"
|
||||
"for benchmark tests this is how many times the benchmark test will be run."
|
||||
}],
|
||||
[["--page-timeout"], {
|
||||
"dest": "page_timeout",
|
||||
"type": "int",
|
||||
"help": "How long to wait (ms) for one page_cycle to complete, before timing out"
|
||||
"help": "How long to wait (ms) for one page_cycle to complete, before timing out."
|
||||
}],
|
||||
[["--browser-cycles"], {
|
||||
"dest": "browser_cycles",
|
||||
"type": "int",
|
||||
"help": "The number of times a cold load test is repeated (for cold load tests only, "
|
||||
"where the browser is shutdown and restarted between test iterations)"
|
||||
"where the browser is shutdown and restarted between test iterations)."
|
||||
}],
|
||||
[["--test-url-params"], {
|
||||
"action": "store",
|
||||
"dest": "test_url_params",
|
||||
"help": "Parameters to add to the test_url query string"
|
||||
"help": "Parameters to add to the test_url query string."
|
||||
}],
|
||||
[["--host"], {
|
||||
"dest": "host",
|
||||
|
@ -183,9 +185,8 @@ class Raptor(TestingMixin, MercurialScript, CodeCoverageMixin, AndroidMixin):
|
|||
"dest": "power_test",
|
||||
"action": "store_true",
|
||||
"default": False,
|
||||
"help": "Use Raptor to measure power usage. Currently only supported for Geckoview. "
|
||||
"The host ip address must be specified either via the --host command line "
|
||||
"argument.",
|
||||
"help": "Use Raptor to measure power usage; the host IP address must be specified via "
|
||||
"the --host command-line argument.",
|
||||
}],
|
||||
[["--memory-test"], {
|
||||
"dest": "memory_test",
|
||||
|
@ -197,7 +198,7 @@ class Raptor(TestingMixin, MercurialScript, CodeCoverageMixin, AndroidMixin):
|
|||
"dest": "cpu_test",
|
||||
"action": "store_true",
|
||||
"default": False,
|
||||
"help": "Use Raptor to measure CPU usage"
|
||||
"help": "Use Raptor to measure CPU usage."
|
||||
}],
|
||||
[["--debug-mode"], {
|
||||
"dest": "debug_mode",
|
||||
|
@ -209,7 +210,7 @@ class Raptor(TestingMixin, MercurialScript, CodeCoverageMixin, AndroidMixin):
|
|||
"dest": "noinstall",
|
||||
"action": "store_true",
|
||||
"default": False,
|
||||
"help": "Do not offer to install Android APK",
|
||||
"help": "Do not offer to install Android APK.",
|
||||
}],
|
||||
[["--disable-e10s"], {
|
||||
"dest": "e10s",
|
||||
|
@ -243,17 +244,17 @@ class Raptor(TestingMixin, MercurialScript, CodeCoverageMixin, AndroidMixin):
|
|||
kwargs.setdefault('config', {})
|
||||
super(Raptor, self).__init__(**kwargs)
|
||||
|
||||
self.workdir = self.query_abs_dirs()['abs_work_dir'] # convenience
|
||||
# Convenience
|
||||
self.workdir = self.query_abs_dirs()['abs_work_dir']
|
||||
|
||||
self.run_local = self.config.get('run_local')
|
||||
|
||||
# app (browser testing on) defaults to firefox
|
||||
# App (browser testing on) defaults to firefox
|
||||
self.app = "firefox"
|
||||
|
||||
if self.run_local:
|
||||
# raptor initiated locally, get app from command line args
|
||||
# which are passed in from mach inside 'raptor_cmd_line_args'
|
||||
# cmd line args can be in two formats depending on how user entered them
|
||||
# Get app from command-line args, passed in from mach, inside 'raptor_cmd_line_args'
|
||||
# Command-line args can be in two formats depending on how the user entered them
|
||||
# i.e. "--app=geckoview" or separate as "--app", "geckoview" so we have to
|
||||
# parse carefully. It's simplest to use `argparse` to parse partially.
|
||||
self.app = "firefox"
|
||||
|
@ -276,7 +277,7 @@ class Raptor(TestingMixin, MercurialScript, CodeCoverageMixin, AndroidMixin):
|
|||
if known.activity:
|
||||
self.activity = known.activity
|
||||
else:
|
||||
# raptor initiated in production via mozharness
|
||||
# Raptor initiated in production via mozharness
|
||||
self.test = self.config['test']
|
||||
self.app = self.config.get("app", "firefox")
|
||||
self.binary_path = self.config.get("binary_path", None)
|
||||
|
@ -308,7 +309,7 @@ class Raptor(TestingMixin, MercurialScript, CodeCoverageMixin, AndroidMixin):
|
|||
self.firefox_android_browsers = ["fennec", "geckoview", "refbrow", "fenix"]
|
||||
|
||||
for (arg,), details in Raptor.browsertime_options:
|
||||
# Allow to override defaults on the `./mach raptor-test ...` command line.
|
||||
# Allow overriding defaults on the `./mach raptor-test ...` command-line.
|
||||
value = self.config.get(details['dest'])
|
||||
if value and arg not in self.config.get("raptor_cmd_line_args", []):
|
||||
setattr(self, details['dest'], value)
|
||||
|
@ -318,7 +319,7 @@ class Raptor(TestingMixin, MercurialScript, CodeCoverageMixin, AndroidMixin):
|
|||
# --geckoProfile try: <stuff>
|
||||
def query_gecko_profile_options(self):
|
||||
gecko_results = []
|
||||
# if gecko_profile is set, we add that to the raptor options
|
||||
# If gecko_profile is set, we add that to Raptor's options
|
||||
if self.gecko_profile:
|
||||
gecko_results.append('--geckoProfile')
|
||||
if self.gecko_profile_interval:
|
||||
|
@ -343,8 +344,7 @@ class Raptor(TestingMixin, MercurialScript, CodeCoverageMixin, AndroidMixin):
|
|||
return self.abs_dirs
|
||||
|
||||
def install_chromium_distribution(self):
|
||||
'''install Google Chromium distribution in production; installation
|
||||
requirements depend on the platform'''
|
||||
'''Install Google Chromium distribution in production'''
|
||||
linux, mac, win = 'linux', 'mac', 'win'
|
||||
chrome, chromium = 'chrome', 'chromium'
|
||||
|
||||
|
@ -364,7 +364,7 @@ class Raptor(TestingMixin, MercurialScript, CodeCoverageMixin, AndroidMixin):
|
|||
chromium_dist = self.app
|
||||
|
||||
if self.config.get("run_local"):
|
||||
self.info("expecting %s to be pre-installed locally" % chromium_dist)
|
||||
self.info("Expecting %s to be pre-installed locally" % chromium_dist)
|
||||
return
|
||||
|
||||
self.info("Getting fetched %s build" % chromium_dist)
|
||||
|
@ -385,20 +385,20 @@ class Raptor(TestingMixin, MercurialScript, CodeCoverageMixin, AndroidMixin):
|
|||
self.info("%s dest is: %s" % (chromium_dist, self.chromium_dist_dest))
|
||||
self.info("%s path is: %s" % (chromium_dist, self.chromium_dist_path))
|
||||
|
||||
# now ensure chrome binary exists
|
||||
# Now ensure Chromium binary exists
|
||||
if os.path.exists(self.chromium_dist_path):
|
||||
self.info("successfully installed %s to: %s"
|
||||
self.info("Successfully installed %s to: %s"
|
||||
% (chromium_dist, self.chromium_dist_path))
|
||||
else:
|
||||
self.info("abort: failed to install %s" % chromium_dist)
|
||||
self.info("Abort: failed to install %s" % chromium_dist)
|
||||
|
||||
def raptor_options(self, args=None, **kw):
|
||||
"""return options to raptor"""
|
||||
"""Return options to Raptor"""
|
||||
options = []
|
||||
kw_options = {}
|
||||
|
||||
# binary path; if testing on firefox the binary path already came from mozharness/pro;
|
||||
# otherwise the binary path is forwarded from cmd line arg (raptor_cmd_line_args)
|
||||
# If testing on Firefox, the binary path already came from mozharness/pro;
|
||||
# otherwise the binary path is forwarded from command-line arg (raptor_cmd_line_args).
|
||||
kw_options['app'] = self.app
|
||||
if self.app == "firefox" or (self.app in self.firefox_android_browsers and
|
||||
not self.run_local):
|
||||
|
@ -407,17 +407,18 @@ class Raptor(TestingMixin, MercurialScript, CodeCoverageMixin, AndroidMixin):
|
|||
self.fatal("Raptor requires a path to the binary.")
|
||||
kw_options['binary'] = binary_path
|
||||
if self.app in self.firefox_android_browsers:
|
||||
# in production ensure we have correct app name,
|
||||
# In production ensure we have correct app name,
|
||||
# i.e. fennec_aurora or fennec_release etc.
|
||||
kw_options['binary'] = self.query_package_name()
|
||||
self.info("set binary to %s instead of %s" % (kw_options['binary'], binary_path))
|
||||
else: # running on google chrome
|
||||
self.info("Set binary to %s instead of %s" % (kw_options['binary'], binary_path))
|
||||
else: # Running on Chromium
|
||||
if not self.run_local:
|
||||
# when running locally we already set the chrome binary above in init; here
|
||||
# in production we aready installed chrome, so set the binary path to our install
|
||||
# When running locally we already set the Chromium binary above, in init.
|
||||
# In production, we already installed Chromium, so set the binary path
|
||||
# to our install.
|
||||
kw_options['binary'] = self.chromium_dist_path
|
||||
|
||||
# options overwritten from **kw
|
||||
# Options overwritten from **kw
|
||||
if 'test' in self.config:
|
||||
kw_options['test'] = self.config['test']
|
||||
if self.symbols_path:
|
||||
|
@ -430,9 +431,9 @@ class Raptor(TestingMixin, MercurialScript, CodeCoverageMixin, AndroidMixin):
|
|||
kw_options.update(kw)
|
||||
if self.host:
|
||||
kw_options['host'] = self.host
|
||||
# configure profiling options
|
||||
# Configure profiling options
|
||||
options.extend(self.query_gecko_profile_options())
|
||||
# extra arguments
|
||||
# Extra arguments
|
||||
if args is not None:
|
||||
options += args
|
||||
if self.config.get('run_local', False):
|
||||
|
@ -453,7 +454,7 @@ class Raptor(TestingMixin, MercurialScript, CodeCoverageMixin, AndroidMixin):
|
|||
options.extend(['--enable-webrender'])
|
||||
|
||||
for (arg,), details in Raptor.browsertime_options:
|
||||
# Allow to override defaults on the `./mach raptor-test ...` command line.
|
||||
# Allow overriding defaults on the `./mach raptor-test ...` command-line
|
||||
value = self.config.get(details['dest'])
|
||||
if value and arg not in self.config.get("raptor_cmd_line_args", []):
|
||||
if isinstance(value, basestring):
|
||||
|
@ -474,19 +475,16 @@ class Raptor(TestingMixin, MercurialScript, CodeCoverageMixin, AndroidMixin):
|
|||
if self.config.get('run_local'):
|
||||
self.raptor_path = os.path.join(self.repo_path, 'testing', 'raptor')
|
||||
|
||||
# Action methods. {{{1
|
||||
# clobber defined in BaseScript
|
||||
|
||||
def clobber(self):
|
||||
# Recreate the upload directory for storing the logcat collected
|
||||
# during apk installation.
|
||||
# during APK installation.
|
||||
super(Raptor, self).clobber()
|
||||
upload_dir = self.query_abs_dirs()['abs_blob_upload_dir']
|
||||
if not os.path.isdir(upload_dir):
|
||||
self.mkdir_p(upload_dir)
|
||||
|
||||
def install_apk(self, apk):
|
||||
# Override AnroidMixin's install_apk in order to capture
|
||||
# Override AndroidMixin's install_apk in order to capture
|
||||
# logcat during the installation. If the installation fails,
|
||||
# the logcat file will be left in the upload directory.
|
||||
self.logcat_start()
|
||||
|
@ -501,11 +499,11 @@ class Raptor(TestingMixin, MercurialScript, CodeCoverageMixin, AndroidMixin):
|
|||
)
|
||||
|
||||
def create_virtualenv(self, **kwargs):
|
||||
"""VirtualenvMixin.create_virtualenv() assuemes we're using
|
||||
self.config['virtualenv_modules']. Since we are installing
|
||||
"""VirtualenvMixin.create_virtualenv() assumes we're using
|
||||
self.config['virtualenv_modules']. Since we're installing
|
||||
raptor from its source, we have to wrap that method here."""
|
||||
# if virtualenv already exists, just add to path and don't re-install, need it
|
||||
# in path so can import jsonschema later when validating output for perfherder
|
||||
# If virtualenv already exists, just add to path and don't re-install.
|
||||
# We need it in-path to import jsonschema later when validating output for perfherder.
|
||||
_virtualenv_path = self.config.get("virtualenv_path")
|
||||
|
||||
if self.run_local and os.path.exists(_virtualenv_path):
|
||||
|
@ -522,7 +520,7 @@ class Raptor(TestingMixin, MercurialScript, CodeCoverageMixin, AndroidMixin):
|
|||
os.path.basename(_python_interp),
|
||||
'site-packages')
|
||||
|
||||
# if running gecko profiling install the requirements
|
||||
# If running gecko profiling, install its requirements
|
||||
if self.gecko_profile:
|
||||
self._install_view_gecko_profile_req()
|
||||
|
||||
|
@ -530,7 +528,7 @@ class Raptor(TestingMixin, MercurialScript, CodeCoverageMixin, AndroidMixin):
|
|||
return
|
||||
|
||||
# virtualenv doesn't already exist so create it
|
||||
# install mozbase first, so we use in-tree versions
|
||||
# Install mozbase first, so we use in-tree versions
|
||||
if not self.run_local:
|
||||
mozbase_requirements = os.path.join(
|
||||
self.query_abs_dirs()['abs_test_install_dir'],
|
||||
|
@ -548,18 +546,17 @@ class Raptor(TestingMixin, MercurialScript, CodeCoverageMixin, AndroidMixin):
|
|||
two_pass=True,
|
||||
editable=True,
|
||||
)
|
||||
# require pip >= 1.5 so pip will prefer .whl files to install
|
||||
# Require pip >= 1.5 so pip will prefer .whl files to install
|
||||
super(Raptor, self).create_virtualenv(
|
||||
modules=['pip>=1.5']
|
||||
)
|
||||
# raptor in harness requires what else is
|
||||
# listed in raptor requirements.txt file.
|
||||
# Install Raptor dependencies
|
||||
self.install_module(
|
||||
requirements=[os.path.join(self.raptor_path,
|
||||
'requirements.txt')]
|
||||
)
|
||||
|
||||
# if running gecko profiling install the requirements
|
||||
# If we're running gecko profiling, install its requirements
|
||||
if self.gecko_profile:
|
||||
self._install_view_gecko_profile_req()
|
||||
|
||||
|
@ -571,22 +568,22 @@ class Raptor(TestingMixin, MercurialScript, CodeCoverageMixin, AndroidMixin):
|
|||
super(Raptor, self).install()
|
||||
|
||||
def _install_view_gecko_profile_req(self):
|
||||
# if running locally and gecko profiing is on, we will be using the
|
||||
# If running locally and gecko profiing is on, we will be using the
|
||||
# view-gecko-profile tool which has its own requirements too
|
||||
if self.gecko_profile and self.run_local:
|
||||
tools = os.path.join(self.config['repo_path'], 'testing', 'tools')
|
||||
view_gecko_profile_req = os.path.join(tools,
|
||||
'view_gecko_profile',
|
||||
'requirements.txt')
|
||||
self.info("installing requirements for the view-gecko-profile tool")
|
||||
self.info("Installing requirements for the view-gecko-profile tool")
|
||||
self.install_module(requirements=[view_gecko_profile_req])
|
||||
|
||||
def _artifact_perf_data(self, src, dest):
|
||||
if not os.path.isdir(os.path.dirname(dest)):
|
||||
# create upload dir if it doesn't already exist
|
||||
self.info("creating dir: %s" % os.path.dirname(dest))
|
||||
self.info("Creating dir: %s" % os.path.dirname(dest))
|
||||
os.makedirs(os.path.dirname(dest))
|
||||
self.info('copying raptor results from %s to %s' % (src, dest))
|
||||
self.info('Copying raptor results from %s to %s' % (src, dest))
|
||||
try:
|
||||
copyfile(src, dest)
|
||||
except Exception as e:
|
||||
|
@ -594,12 +591,12 @@ class Raptor(TestingMixin, MercurialScript, CodeCoverageMixin, AndroidMixin):
|
|||
self.info(str(e))
|
||||
|
||||
def run_tests(self, args=None, **kw):
|
||||
"""run raptor tests"""
|
||||
"""Run raptor tests"""
|
||||
|
||||
# get raptor options
|
||||
# Get Raptor options
|
||||
options = self.raptor_options(args=args, **kw)
|
||||
|
||||
# python version check
|
||||
# Python version check
|
||||
python = self.query_python_path()
|
||||
self.run_command([python, "--version"])
|
||||
parser = RaptorOutputParser(config=self.config, log_obj=self.log_obj,
|
||||
|
@ -626,7 +623,7 @@ class Raptor(TestingMixin, MercurialScript, CodeCoverageMixin, AndroidMixin):
|
|||
# disable "GC poisoning" Bug# 1499043
|
||||
env['JSGC_DISABLE_POISONING'] = '1'
|
||||
|
||||
# needed to load unsigned raptor webext on release builds.
|
||||
# Needed to load unsigned Raptor WebExt on release builds
|
||||
if self.is_release_build:
|
||||
env['MOZ_DISABLE_NONLOCAL_CONNECTIONS'] = '1'
|
||||
|
||||
|
@ -635,9 +632,9 @@ class Raptor(TestingMixin, MercurialScript, CodeCoverageMixin, AndroidMixin):
|
|||
if self.obj_path is not None:
|
||||
env['MOZ_DEVELOPER_OBJ_DIR'] = self.obj_path
|
||||
|
||||
# sets a timeout for how long raptor should run without output
|
||||
# Sets a timeout for how long Raptor should run without output
|
||||
output_timeout = self.config.get('raptor_output_timeout', 3600)
|
||||
# run raptor tests
|
||||
# Run Raptor tests
|
||||
run_tests = os.path.join(self.raptor_path, 'raptor', 'raptor.py')
|
||||
|
||||
mozlog_opts = ['--log-tbpl-level=debug']
|
||||
|
@ -678,15 +675,15 @@ class Raptor(TestingMixin, MercurialScript, CodeCoverageMixin, AndroidMixin):
|
|||
self.run_command(["ls", "-l", item])
|
||||
|
||||
elif not self.run_local:
|
||||
# copy results to upload dir so they are included as an artifact
|
||||
self.info("copying raptor results to upload dir:")
|
||||
# Copy results to upload dir so they are included as an artifact
|
||||
self.info("Copying Raptor results to upload dir:")
|
||||
|
||||
src = os.path.join(self.query_abs_dirs()['abs_work_dir'], 'raptor.json')
|
||||
dest = os.path.join(env['MOZ_UPLOAD_DIR'], 'perfherder-data.json')
|
||||
self.info(str(dest))
|
||||
self._artifact_perf_data(src, dest)
|
||||
|
||||
# make individual perfherder data json's for each supporting data type
|
||||
# Make individual perfherder data JSON's for each supporting data type
|
||||
for file in glob.glob(os.path.join(self.query_abs_dirs()['abs_work_dir'], '*')):
|
||||
path, filename = os.path.split(file)
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче