Bug 1439694 - Fix jsonschema import error when running talos locally; r?jmaher
MozReview-Commit-ID: HK3wMVBzQXR
--- a/testing/mozharness/mozharness/mozilla/testing/talos.py
+++ b/testing/mozharness/mozharness/mozilla/testing/talos.py
@@ -579,16 +579,37 @@ class Talos(TestingMixin, MercurialScrip
return super(Talos, self).download_and_extract(
suite_categories=['common', 'talos']
)
def create_virtualenv(self, **kwargs):
"""VirtualenvMixin.create_virtualenv() assuemes we're using
self.config['virtualenv_modules']. Since we are installing
talos 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
+ _virtualenv_path = self.config.get("virtualenv_path")
+
+ if self.run_local and os.path.exists(_virtualenv_path):
+ self.info("Virtualenv already exists, skipping creation")
+ _python_interp = self.config.get('exes')['python']
+
+ if 'win' in self.platform_name():
+ _path = os.path.join(_virtualenv_path,
+ 'Lib',
+ 'site-packages')
+ else:
+ _path = os.path.join(_virtualenv_path,
+ 'lib',
+ os.path.basename(_python_interp),
+ 'site-packages')
+ sys.path.append(_path)
+ return
+
+ # virtualenv doesn't already exist so create it
# 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'],
'config',
'mozbase_requirements.txt'
)
else:
@@ -607,18 +628,16 @@ class Talos(TestingMixin, MercurialScrip
modules=['pip>=1.5']
)
# talos in harness requires what else is
# listed in talos requirements.txt file.
self.install_module(
requirements=[os.path.join(self.talos_path,
'requirements.txt')]
)
- # install jsonschema for perfherder validation
- self.install_module(module="jsonschema")
def _validate_treeherder_data(self, parser):
# late import is required, because install is done in create_virtualenv
import jsonschema
if len(parser.found_perf_data) != 1:
self.critical("PERFHERDER_DATA was seen %d times, expected 1."
% len(parser.found_perf_data))
--- a/testing/talos/mach_commands.py
+++ b/testing/talos/mach_commands.py
@@ -44,19 +44,18 @@ class TalosRunner(MozbuildObject):
'virtualenv', 'virtualenv.py')
self.virtualenv_path = os.path.join(self._topobjdir, 'testing',
'talos-venv')
self.python_interp = sys.executable
self.talos_args = talos_args
def make_config(self):
default_actions = ['populate-webroot']
- if not os.path.exists(self.virtualenv_path):
- default_actions.append('create-virtualenv')
default_actions.extend([
+ 'create-virtualenv',
'setup-mitmproxy',
'run-tests',
])
self.config = {
'run_local': True,
'talos_json': self.talos_json,
'binary_path': self.binary_path,
'repo_path': self.topsrcdir,