Bug 1439694 - Fix jsonschema import error when running talos locally; r=jmaher
authorRob Wood <rwood@mozilla.com>
Mon, 26 Feb 2018 16:43:09 -0500
changeset 411554 f249c97b9d353223ed0b660822759018470b7395
parent 411553 eb8d9a01fee300b56e0e62d810969fefff049d49
child 411555 8f3d33f7c72babbf232f1938e982d4dd5f54f142
push id101686
push useraciure@mozilla.com
push dateTue, 03 Apr 2018 21:59:31 +0000
treeherdermozilla-inbound@8d846598d35d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmaher
bugs1439694
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1439694 - Fix jsonschema import error when running talos locally; r=jmaher MozReview-Commit-ID: HK3wMVBzQXR
testing/mozharness/mozharness/mozilla/testing/talos.py
testing/talos/mach_commands.py
--- 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,