Bug 1409046 - Prevent re-creating virtualenv everytime ./mach talos is run. r=rwood draft
authorAlexandre Poirot <poirot.alex@gmail.com>
Wed, 10 Jan 2018 01:59:53 -0800
changeset 718651 3b0ec966919c497da01fdd7075a80666d6c4de9e
parent 717183 ca379fcca95b1f4a3744242ea8647004b99b3507
child 745574 864da3ddd4bdcecddc04fe6825a902cce118bf80
push id95020
push userbmo:poirot.alex@gmail.com
push dateWed, 10 Jan 2018 19:25:48 +0000
reviewersrwood
bugs1409046
milestone59.0a1
Bug 1409046 - Prevent re-creating virtualenv everytime ./mach talos is run. r=rwood MozReview-Commit-ID: CsspY1DIS4t
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
@@ -402,26 +402,29 @@ class Talos(TestingMixin, MercurialScrip
 
         # now that have the suite name, check if pageset is required, if so download it
         # the --no-download option will override this
         if self.query_pagesets_name():
             if '--no-download' not in self.config.get('talos_extra_options', []):
                 self.info("Downloading pageset with tooltool...")
                 self.src_talos_webdir = os.path.join(self.talos_path, 'talos')
                 src_talos_pageset = os.path.join(self.src_talos_webdir, 'tests')
-                manifest_file = os.path.join(self.talos_path, 'tp5n-pageset.manifest')
-                self.tooltool_fetch(
-                    manifest_file,
-                    output_dir=src_talos_pageset,
-                    cache=self.config.get('tooltool_cache')
-                )
-                archive = os.path.join(src_talos_pageset, self.pagesets_name)
-                unzip = self.query_exe('unzip')
-                unzip_cmd = [unzip, '-q', '-o', archive, '-d', src_talos_pageset]
-                self.run_command(unzip_cmd, halt_on_failure=True)
+                if not os.path.exists(os.path.join(src_talos_pageset, self.pagesets_name)):
+                    manifest_file = os.path.join(self.talos_path, 'tp5n-pageset.manifest')
+                    self.tooltool_fetch(
+                        manifest_file,
+                        output_dir=src_talos_pageset,
+                        cache=self.config.get('tooltool_cache')
+                    )
+                    archive = os.path.join(src_talos_pageset, self.pagesets_name)
+                    unzip = self.query_exe('unzip')
+                    unzip_cmd = [unzip, '-q', '-o', archive, '-d', src_talos_pageset]
+                    self.run_command(unzip_cmd, halt_on_failure=True)
+                else:
+                    self.info("pageset already available")
             else:
                 self.info("Not downloading pageset because the no-download option was specified")
 
         # if running speedometer locally, need to copy speedometer source into talos/tests
         if self.config.get('run_local') and 'speedometer' in self.suite:
             self.get_speedometer_source()
 
     def get_speedometer_source(self):
--- a/testing/talos/mach_commands.py
+++ b/testing/talos/mach_commands.py
@@ -43,37 +43,39 @@ class TalosRunner(MozbuildObject):
         self.virtualenv_script = os.path.join(self.topsrcdir, 'third_party', 'python',
                                               '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([
+            'setup-mitmproxy',
+            'run-tests',
+        ])
         self.config = {
             'run_local': True,
             'talos_json': self.talos_json,
             'binary_path': self.binary_path,
             'repo_path': self.topsrcdir,
             'obj_path': self.topobjdir,
             'log_name': 'talos',
             'virtualenv_path': self.virtualenv_path,
             'pypi_url': 'http://pypi.python.org/simple',
             'base_work_dir': self.mozharness_dir,
             'exes': {
                 'python': self.python_interp,
                 'virtualenv': [self.python_interp, self.virtualenv_script]
             },
             'title': socket.gethostname(),
-            'default_actions': [
-                'populate-webroot',
-                'create-virtualenv',
-                'setup-mitmproxy',
-                'run-tests',
-            ],
+            'default_actions': default_actions,
             'download_tooltool': True,
             'talos_extra_options': ['--develop'] + self.talos_args,
             'python3_manifest': {
                 'win32': 'python3.manifest',
                 'win64': 'python3_x64.manifest',
             }
         }