2017-03-10 21:33:19 +03:00
|
|
|
#!/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 *****
|
|
|
|
"""
|
|
|
|
run awsy tests in a virtualenv
|
|
|
|
"""
|
|
|
|
|
2017-05-23 04:57:57 +03:00
|
|
|
import copy
|
2017-03-29 11:47:45 +03:00
|
|
|
import json
|
2017-03-10 21:33:19 +03:00
|
|
|
import os
|
2017-05-23 04:57:57 +03:00
|
|
|
import re
|
2017-03-10 21:33:19 +03:00
|
|
|
import sys
|
|
|
|
|
|
|
|
# load modules from parent dir
|
|
|
|
sys.path.insert(1, os.path.dirname(sys.path[0]))
|
|
|
|
|
2018-06-15 19:59:18 +03:00
|
|
|
import mozinfo
|
|
|
|
|
2017-03-10 21:33:19 +03:00
|
|
|
from mozharness.base.script import PreScriptAction
|
2017-05-23 04:57:57 +03:00
|
|
|
from mozharness.base.log import INFO, ERROR
|
2017-03-10 21:33:19 +03:00
|
|
|
from mozharness.mozilla.testing.testbase import TestingMixin, testing_config_options
|
|
|
|
from mozharness.base.vcs.vcsbase import MercurialScript
|
|
|
|
from mozharness.mozilla.tooltool import TooltoolMixin
|
|
|
|
from mozharness.mozilla.structuredlog import StructuredOutputParser
|
2017-06-12 23:19:38 +03:00
|
|
|
from mozharness.mozilla.testing.codecoverage import (
|
|
|
|
CodeCoverageMixin,
|
|
|
|
code_coverage_config_options
|
|
|
|
)
|
2017-03-10 21:33:19 +03:00
|
|
|
|
2017-10-25 03:21:41 +03:00
|
|
|
|
2018-05-12 01:16:08 +03:00
|
|
|
class AWSY(TestingMixin, MercurialScript, TooltoolMixin, CodeCoverageMixin):
|
2017-03-10 21:33:19 +03:00
|
|
|
config_options = [
|
|
|
|
[["--e10s"],
|
2017-10-25 03:21:41 +03:00
|
|
|
{"action": "store_true",
|
|
|
|
"dest": "e10s",
|
|
|
|
"default": False,
|
|
|
|
"help": "Run tests with multiple processes. (Desktop builds only)",
|
|
|
|
}],
|
2017-08-02 01:59:22 +03:00
|
|
|
[["--single-stylo-traversal"],
|
2017-10-25 03:21:41 +03:00
|
|
|
{"action": "store_true",
|
|
|
|
"dest": "single_stylo_traversal",
|
|
|
|
"default": False,
|
|
|
|
"help": "Set STYLO_THREADS=1.",
|
2018-02-21 16:52:04 +03:00
|
|
|
}],
|
|
|
|
[["--enable-webrender"],
|
|
|
|
{"action": "store_true",
|
|
|
|
"dest": "enable_webrender",
|
|
|
|
"default": False,
|
|
|
|
"help": "Tries to enable the WebRender compositor.",
|
2018-05-09 02:05:33 +03:00
|
|
|
}],
|
|
|
|
[["--base"],
|
|
|
|
{"action": "store_true",
|
|
|
|
"dest": "test_about_blank",
|
|
|
|
"default": False,
|
|
|
|
"help": "Runs the about:blank base case memory test.",
|
2018-10-04 22:43:32 +03:00
|
|
|
}],
|
|
|
|
[["--dmd"],
|
|
|
|
{"action": "store_true",
|
|
|
|
"dest": "dmd",
|
|
|
|
"default": False,
|
|
|
|
"help": "Runs tests with DMD enabled.",
|
2017-10-25 03:21:41 +03:00
|
|
|
}]
|
2018-05-12 01:16:08 +03:00
|
|
|
] + testing_config_options + copy.deepcopy(code_coverage_config_options)
|
2017-03-10 21:33:19 +03:00
|
|
|
|
2017-05-23 04:57:57 +03:00
|
|
|
error_list = [
|
|
|
|
{'regex': re.compile(r'''(TEST-UNEXPECTED|PROCESS-CRASH)'''), 'level': ERROR},
|
|
|
|
]
|
|
|
|
|
2017-03-10 21:33:19 +03:00
|
|
|
def __init__(self, **kwargs):
|
|
|
|
|
|
|
|
kwargs.setdefault('config_options', self.config_options)
|
|
|
|
kwargs.setdefault('all_actions', ['clobber',
|
|
|
|
'download-and-extract',
|
|
|
|
'populate-webroot',
|
|
|
|
'create-virtualenv',
|
|
|
|
'install',
|
|
|
|
'run-tests',
|
|
|
|
])
|
|
|
|
kwargs.setdefault('default_actions', ['clobber',
|
|
|
|
'download-and-extract',
|
|
|
|
'populate-webroot',
|
|
|
|
'create-virtualenv',
|
|
|
|
'install',
|
|
|
|
'run-tests',
|
|
|
|
])
|
|
|
|
kwargs.setdefault('config', {})
|
|
|
|
super(AWSY, self).__init__(**kwargs)
|
|
|
|
self.installer_url = self.config.get("installer_url")
|
|
|
|
self.tests = None
|
|
|
|
|
2018-01-30 17:39:56 +03:00
|
|
|
self.testdir = self.query_abs_dirs()['abs_test_install_dir']
|
2017-03-29 11:47:45 +03:00
|
|
|
self.awsy_path = os.path.join(self.testdir, 'awsy')
|
2017-03-10 21:33:19 +03:00
|
|
|
self.awsy_libdir = os.path.join(self.awsy_path, 'awsy')
|
2017-03-29 11:47:47 +03:00
|
|
|
self.webroot_dir = os.path.join(self.testdir, 'html')
|
|
|
|
self.results_dir = os.path.join(self.testdir, 'results')
|
2017-03-10 21:33:19 +03:00
|
|
|
self.binary_path = self.config.get('binary_path')
|
|
|
|
|
|
|
|
def query_abs_dirs(self):
|
|
|
|
if self.abs_dirs:
|
|
|
|
return self.abs_dirs
|
|
|
|
abs_dirs = super(AWSY, self).query_abs_dirs()
|
|
|
|
|
|
|
|
dirs = {}
|
|
|
|
dirs['abs_blob_upload_dir'] = os.path.join(abs_dirs['abs_work_dir'], 'blobber_upload_dir')
|
2018-01-30 17:39:56 +03:00
|
|
|
dirs['abs_test_install_dir'] = os.path.join(abs_dirs['abs_work_dir'], 'tests')
|
2017-03-10 21:33:19 +03:00
|
|
|
abs_dirs.update(dirs)
|
|
|
|
self.abs_dirs = abs_dirs
|
|
|
|
return self.abs_dirs
|
|
|
|
|
|
|
|
def download_and_extract(self, extract_dirs=None, suite_categories=None):
|
|
|
|
ret = super(AWSY, self).download_and_extract(
|
|
|
|
suite_categories=['common', 'awsy']
|
|
|
|
)
|
|
|
|
return ret
|
|
|
|
|
|
|
|
@PreScriptAction('create-virtualenv')
|
|
|
|
def _pre_create_virtualenv(self, action):
|
|
|
|
requirements_files = [os.path.join(self.testdir,
|
|
|
|
'config',
|
|
|
|
'marionette_requirements.txt')]
|
|
|
|
|
|
|
|
for requirements_file in requirements_files:
|
|
|
|
self.register_virtualenv_module(requirements=[requirements_file],
|
|
|
|
two_pass=True)
|
|
|
|
|
|
|
|
self.register_virtualenv_module('awsy', self.awsy_path)
|
|
|
|
|
|
|
|
def populate_webroot(self):
|
|
|
|
"""Populate the production test slaves' webroots"""
|
|
|
|
self.info("Downloading pageset with tooltool...")
|
|
|
|
manifest_file = os.path.join(self.awsy_path, 'tp5n-pageset.manifest')
|
2017-03-29 11:47:45 +03:00
|
|
|
page_load_test_dir = os.path.join(self.webroot_dir, 'page_load_test')
|
|
|
|
if not os.path.isdir(page_load_test_dir):
|
|
|
|
self.mkdir_p(page_load_test_dir)
|
2017-03-10 21:33:19 +03:00
|
|
|
self.tooltool_fetch(
|
|
|
|
manifest_file,
|
2017-03-29 11:47:45 +03:00
|
|
|
output_dir=page_load_test_dir,
|
2017-03-10 21:33:19 +03:00
|
|
|
cache=self.config.get('tooltool_cache')
|
|
|
|
)
|
2017-03-29 11:47:45 +03:00
|
|
|
archive = os.path.join(page_load_test_dir, 'tp5n.zip')
|
2017-03-10 21:33:19 +03:00
|
|
|
unzip = self.query_exe('unzip')
|
2017-03-29 11:47:45 +03:00
|
|
|
unzip_cmd = [unzip, '-q', '-o', archive, '-d', page_load_test_dir]
|
2018-10-02 15:03:00 +03:00
|
|
|
self.run_command(unzip_cmd, halt_on_failure=False)
|
2017-03-29 11:47:45 +03:00
|
|
|
self.run_command("ls %s" % page_load_test_dir)
|
2017-03-10 21:33:19 +03:00
|
|
|
|
|
|
|
def run_tests(self, args=None, **kw):
|
|
|
|
'''
|
|
|
|
AWSY test should be implemented here
|
|
|
|
'''
|
|
|
|
dirs = self.abs_dirs
|
|
|
|
env = {}
|
|
|
|
error_summary_file = os.path.join(dirs['abs_blob_upload_dir'],
|
|
|
|
'marionette_errorsummary.log')
|
|
|
|
|
2017-03-29 11:47:45 +03:00
|
|
|
runtime_testvars = {'webRootDir': self.webroot_dir,
|
|
|
|
'resultsDir': self.results_dir}
|
2018-06-15 19:59:18 +03:00
|
|
|
|
|
|
|
# Check if this is a DMD build and if so enable it.
|
2018-06-25 21:52:21 +03:00
|
|
|
dmd_enabled = False
|
2018-06-15 19:59:18 +03:00
|
|
|
dmd_py_lib_dir = os.path.dirname(self.binary_path)
|
|
|
|
if mozinfo.os == 'mac':
|
|
|
|
# On mac binary is in MacOS and dmd.py is in Resources, ie:
|
|
|
|
# Name.app/Contents/MacOS/libdmd.dylib
|
|
|
|
# Name.app/Contents/Resources/dmd.py
|
|
|
|
dmd_py_lib_dir = os.path.join(dmd_py_lib_dir, "../Resources/")
|
|
|
|
|
|
|
|
dmd_path = os.path.join(dmd_py_lib_dir, "dmd.py")
|
2018-10-04 22:43:32 +03:00
|
|
|
if self.config['dmd'] and os.path.isfile(dmd_path):
|
2018-06-25 21:52:21 +03:00
|
|
|
dmd_enabled = True
|
2018-06-15 19:59:18 +03:00
|
|
|
runtime_testvars['dmd'] = True
|
|
|
|
|
|
|
|
# Allow the child process to import dmd.py
|
|
|
|
python_path = os.environ.get('PYTHONPATH')
|
|
|
|
|
|
|
|
if python_path:
|
|
|
|
os.environ['PYTHONPATH'] = "%s%s%s" % (python_path, os.pathsep, dmd_py_lib_dir)
|
|
|
|
else:
|
|
|
|
os.environ['PYTHONPATH'] = dmd_py_lib_dir
|
|
|
|
|
2018-06-22 22:13:35 +03:00
|
|
|
env['DMD'] = "--mode=dark-matter --stacks=full"
|
2018-06-15 19:59:18 +03:00
|
|
|
|
2017-03-29 11:47:45 +03:00
|
|
|
runtime_testvars_path = os.path.join(self.awsy_path, 'runtime-testvars.json')
|
|
|
|
runtime_testvars_file = open(runtime_testvars_path, 'wb')
|
|
|
|
runtime_testvars_file.write(json.dumps(runtime_testvars, indent=2))
|
|
|
|
runtime_testvars_file.close()
|
|
|
|
|
2017-03-10 21:33:19 +03:00
|
|
|
cmd = ['marionette']
|
2018-05-12 00:33:12 +03:00
|
|
|
|
|
|
|
if self.config['test_about_blank']:
|
2018-05-12 04:04:17 +03:00
|
|
|
cmd.append("--testvars=%s" % os.path.join(self.awsy_path, "conf",
|
|
|
|
"base-testvars.json"))
|
2018-05-12 00:33:12 +03:00
|
|
|
else:
|
|
|
|
cmd.append("--testvars=%s" % os.path.join(self.awsy_path, "conf", "testvars.json"))
|
|
|
|
|
2017-03-29 11:47:45 +03:00
|
|
|
cmd.append("--testvars=%s" % runtime_testvars_path)
|
2017-03-10 21:33:19 +03:00
|
|
|
cmd.append("--log-raw=-")
|
|
|
|
cmd.append("--log-errorsummary=%s" % error_summary_file)
|
|
|
|
cmd.append("--binary=%s" % self.binary_path)
|
|
|
|
cmd.append("--profile=%s" % (os.path.join(dirs['abs_work_dir'], 'profile')))
|
|
|
|
if not self.config['e10s']:
|
|
|
|
cmd.append('--disable-e10s')
|
|
|
|
cmd.append('--gecko-log=%s' % os.path.join(dirs["abs_blob_upload_dir"],
|
|
|
|
'gecko.log'))
|
2017-05-25 12:41:22 +03:00
|
|
|
# TestingMixin._download_and_extract_symbols() should set
|
|
|
|
# self.symbols_path
|
|
|
|
cmd.append('--symbols-path=%s' % self.symbols_path)
|
2017-03-10 21:33:19 +03:00
|
|
|
|
2018-05-09 02:05:33 +03:00
|
|
|
if self.config['test_about_blank']:
|
|
|
|
test_file = os.path.join(self.awsy_libdir, 'test_base_memory_usage.py')
|
|
|
|
prefs_file = "base-prefs.json"
|
|
|
|
else:
|
|
|
|
test_file = os.path.join(self.awsy_libdir, 'test_memory_usage.py')
|
|
|
|
prefs_file = "prefs.json"
|
|
|
|
|
|
|
|
cmd.append("--preferences=%s" % os.path.join(self.awsy_path, "conf", prefs_file))
|
2018-06-25 21:52:21 +03:00
|
|
|
if dmd_enabled:
|
|
|
|
cmd.append("--pref=security.sandbox.content.level:0")
|
2017-03-10 21:33:19 +03:00
|
|
|
cmd.append(test_file)
|
|
|
|
|
2017-08-25 01:48:58 +03:00
|
|
|
if self.config['single_stylo_traversal']:
|
|
|
|
env['STYLO_THREADS'] = '1'
|
|
|
|
else:
|
|
|
|
env['STYLO_THREADS'] = '4'
|
|
|
|
|
2018-02-08 21:50:11 +03:00
|
|
|
# TODO: consider getting rid of this as stylo is enabled by default
|
|
|
|
env['STYLO_FORCE_ENABLED'] = '1'
|
2017-08-25 01:48:58 +03:00
|
|
|
|
2018-02-21 16:52:04 +03:00
|
|
|
if self.config['enable_webrender']:
|
|
|
|
env['MOZ_WEBRENDER'] = '1'
|
|
|
|
env['MOZ_ACCELERATED'] = '1'
|
|
|
|
|
2017-03-10 21:33:19 +03:00
|
|
|
env['MOZ_UPLOAD_DIR'] = dirs['abs_blob_upload_dir']
|
|
|
|
if not os.path.isdir(env['MOZ_UPLOAD_DIR']):
|
|
|
|
self.mkdir_p(env['MOZ_UPLOAD_DIR'])
|
2017-05-23 04:57:57 +03:00
|
|
|
if self.query_minidump_stackwalk():
|
|
|
|
env['MINIDUMP_STACKWALK'] = self.minidump_stackwalk_path
|
|
|
|
env['MINIDUMP_SAVE_PATH'] = dirs['abs_blob_upload_dir']
|
|
|
|
env['RUST_BACKTRACE'] = '1'
|
2017-03-10 21:33:19 +03:00
|
|
|
env = self.query_env(partial_env=env)
|
|
|
|
parser = StructuredOutputParser(config=self.config,
|
2017-03-29 11:47:45 +03:00
|
|
|
log_obj=self.log_obj,
|
2017-05-23 04:57:57 +03:00
|
|
|
error_list=self.error_list,
|
2017-03-29 11:47:45 +03:00
|
|
|
strict=False)
|
2017-03-10 21:33:19 +03:00
|
|
|
return_code = self.run_command(command=cmd,
|
|
|
|
cwd=self.awsy_path,
|
|
|
|
output_timeout=self.config.get("cmd_timeout"),
|
|
|
|
env=env,
|
|
|
|
output_parser=parser)
|
|
|
|
|
|
|
|
level = INFO
|
2018-05-01 21:04:24 +03:00
|
|
|
tbpl_status, log_level, summary = parser.evaluate_parser(
|
2017-03-10 21:33:19 +03:00
|
|
|
return_code=return_code)
|
|
|
|
|
|
|
|
self.log("AWSY exited with return code %s: %s" % (return_code, tbpl_status),
|
|
|
|
level=level)
|
2018-05-16 19:51:37 +03:00
|
|
|
self.record_status(tbpl_status)
|
2017-03-10 21:33:19 +03:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
awsy_test = AWSY()
|
|
|
|
awsy_test.run_and_exit()
|