Bug 1425308 - Save talos gecko profiles in a local talos output folder draft
authorRob Wood <rwood@mozilla.com>
Wed, 10 Jan 2018 16:47:44 -0500
changeset 749804 39a50040a93aa1102692f810830e71d391febdc8
parent 749795 cb74f29fe44ffc85e9e63c34030b9a1cb64fc260
child 749805 e964b33164c55ef9faad57193ce6f7b7b356c6a8
child 749879 26d20255cd6a51428f278e33e23d845102226072
child 750251 f88b469271930b0c0d9f1498d115fd9e1df99d1f
push id97493
push userrwood@mozilla.com
push dateWed, 31 Jan 2018 23:45:33 +0000
bugs1425308
milestone60.0a1
Bug 1425308 - Save talos gecko profiles in a local talos output folder Currently when running talos tests with gecko profiling on, the resulting profiles are zipped up (and uploaded as an artifact if running in production). This commit creates a 'gecko_profiles_out' folder when running locally, and stores the profiles there (as well as in the zip file). This will allow devs to easily view the gecko profiles from the latest talos test run, without having to find and unzip the profiles zip. MozReview-Commit-ID: CkDy3FZILvU
.hgignore
testing/talos/talos/config.py
testing/talos/talos/gecko_profile.py
testing/talos/talos/run_tests.py
--- a/.hgignore
+++ b/.hgignore
@@ -140,16 +140,17 @@ GPATH
 ^testing/talos/include/
 ^testing/talos/lib/
 ^testing/talos/talos/tests/tp5n.zip
 ^testing/talos/talos/tests/tp5n.tar.gz
 ^testing/talos/talos/tests/tp5n
 ^testing/talos/talos/tests/devtools/damp.manifest.develop
 ^talos-venv
 ^py3venv
+^testing/talos/talos/gecko_profiles_out/
 ^testing/talos/talos/mitmproxy/mitmdump
 ^testing/talos/talos/mitmproxy/mitmproxy
 ^testing/talos/talos/mitmproxy/mitmweb
 
 # Ignore talos webkit benchmark files; source is copied from in-tree /third_party
 # into testing/talos/talos/tests/webkit/PerformanceTests/ when run locally
 # i.e. speedometer, motionmark, stylebench
 ^testing/talos/talos/tests/webkit/PerformanceTests
--- a/testing/talos/talos/config.py
+++ b/testing/talos/talos/config.py
@@ -431,16 +431,17 @@ def get_browser_config(config):
                 'test_timeout': 1200,
                 'xperf_path': None,
                 'error_filename': None,
                 'no_upload_results': False,
                 'enable_stylo': False,
                 'disable_stylo': False,
                 'stylothreads': 0,
                 'subtests': None,
+                'gecko_profiles_out_dir': '${talos}/gecko_profiles_out',
                 }
     browser_config = dict(title=config['title'])
     browser_config.update(dict([(i, config[i]) for i in required]))
     browser_config.update(dict([(i, config.get(i, j))
                           for i, j in optional.items()]))
     return browser_config
 
 
--- a/testing/talos/talos/gecko_profile.py
+++ b/testing/talos/talos/gecko_profile.py
@@ -61,16 +61,22 @@ class GeckoProfile(object):
 
         self.profiling_info = {
             "gecko_profile_interval": gecko_profile_interval,
             "gecko_profile_entries": gecko_profile_entries,
             "gecko_profile_dir": gecko_profile_dir,
             "gecko_profile_threads": gecko_profile_threads
         }
 
+        # when running locally, profiles will be zipped up, and also stored in a
+        # talos gecko profiles output folder, so they can easily be viewed later
+        if self.browser_config['develop']:
+            if os.path.exists(self.browser_config['gecko_profiles_out_dir']):
+                mozfile.remove(self.browser_config['gecko_profiles_out_dir'])
+
     def option(self, name):
         return self.profiling_info["gecko_profile_" + name]
 
     def update_env(self, env):
         """
         update the given env to update some env vars if required.
         """
         if not self.test_config.get('gecko_profile_startup'):
@@ -195,15 +201,23 @@ class GeckoProfile(object):
                 except Exception:
                     LOG.exception(
                         "Failed to copy profile {0} as {1} to"
                         " archive {2}".format(profile_path,
                                               path_in_zip,
                                               self.profile_arcname)
                     )
 
+        # we also want to keep a readable copy of our profiles so
+        # that we can view them in the gecko profiler without unzipping
+        # (only when running locally, in production the zip is uploaded)
+        if self.browser_config['develop']:
+            mozfile.extract(self.profile_arcname, self.browser_config['gecko_profiles_out_dir'])
+            LOG.info("Profiles are also available in {0}"
+                     .format(self.browser_config['gecko_profiles_out_dir']))
+
     def clean(self):
         """
         Clean up temp folders created with the instance creation.
         """
         mozfile.remove(self.option('dir'))
         for symbol_path in self.symbol_paths.values():
             mozfile.remove(symbol_path)
--- a/testing/talos/talos/run_tests.py
+++ b/testing/talos/talos/run_tests.py
@@ -141,16 +141,18 @@ def run_tests(config, browser_config):
 
     # fix paths to substitute
     # `os.path.dirname(os.path.abspath(__file__))` for ${talos}
     # https://bugzilla.mozilla.org/show_bug.cgi?id=705809
     browser_config['extensions'] = [utils.interpolate(i)
                                     for i in browser_config['extensions']]
     browser_config['bcontroller_config'] = \
         utils.interpolate(browser_config['bcontroller_config'])
+    browser_config['gecko_profiles_out_dir'] = \
+        utils.interpolate(browser_config['gecko_profiles_out_dir'])
 
     # normalize browser path to work across platforms
     browser_config['browser_path'] = \
         os.path.normpath(browser_config['browser_path'])
 
     binary = browser_config["browser_path"]
     version_info = mozversion.get_version(binary=binary)
     browser_config['browser_name'] = version_info['application_name']