def symbolicate(self, cycle): """ Symbolicate Gecko profiling data for one cycle. :param cycle: the number of the cycle of the test currently run. """ symbolicator = ProfileSymbolicator({ # Trace-level logging (verbose) "enableTracing": 0, # Fallback server if symbol is not found locally "remoteSymbolServer": "https://symbols.mozilla.org/symbolicate/v4", # Maximum number of symbol files to keep in memory "maxCacheEntries": 2000000, # Frequency of checking for recent symbols to # cache (in hours) "prefetchInterval": 12, # Oldest file age to prefetch (in hours) "prefetchThreshold": 48, # Maximum number of library versions to pre-fetch # per library "prefetchMaxSymbolsPerLib": 3, # Default symbol lookup directories "defaultApp": "FIREFOX", "defaultOs": "WINDOWS", # Paths to .SYM files, expressed internally as a # mapping of app or platform names to directories # Note: App & OS names from requests are converted # to all-uppercase internally "symbolPaths": self.symbol_paths }) if self.browser_config['symbols_path']: if mozfile.is_url(self.browser_config['symbols_path']): symbolicator.integrate_symbol_zip_from_url( self.browser_config['symbols_path']) elif os.path.isfile(self.browser_config['symbols_path']): symbolicator.integrate_symbol_zip_from_file( self.browser_config['symbols_path']) elif os.path.isdir(self.browser_config['symbols_path']): sym_path = self.browser_config['symbols_path'] symbolicator.options["symbolPaths"]["FIREFOX"] = sym_path self.cleanup = False missing_symbols_zip = os.path.join(self.upload_dir, "missingsymbols.zip") try: mode = zipfile.ZIP_DEFLATED except NameError: mode = zipfile.ZIP_STORED gecko_profile_dir = self.option('dir') with zipfile.ZipFile(self.profile_arcname, 'a', mode) as arc: # Collect all individual profiles that the test # has put into gecko_profile_dir. for profile_filename in os.listdir(gecko_profile_dir): testname = profile_filename if testname.endswith(".profile"): testname = testname[0:-8] profile_path = os.path.join(gecko_profile_dir, profile_filename) self._save_gecko_profile(cycle, symbolicator, missing_symbols_zip, profile_path) # Our zip will contain one directory per subtest, # and each subtest directory will contain one or # more cycle_i.profile files. For example, with # test_config['name'] == 'tscrollx', # profile_filename == 'iframe.svg.profile', i == 0, # we'll get path_in_zip == # 'profile_tscrollx/iframe.svg/cycle_0.profile'. cycle_name = "cycle_{0}.profile".format(cycle) path_in_zip = \ os.path.join( "profile_{0}".format(self.test_config['name']), testname, cycle_name ) LOG.info("Adding profile {0} to archive {1}".format( path_in_zip, self.profile_arcname)) try: arc.write(profile_path, path_in_zip) except Exception: LOG.exception("Failed to copy profile {0} as {1} to" " archive {2}".format( profile_path, path_in_zip, self.profile_arcname)) # save the latest gecko profile archive to an env var, so later on # it can be viewed automatically via the view-gecko-profile tool os.environ[ 'TALOS_LATEST_GECKO_PROFILE_ARCHIVE'] = self.profile_arcname
def symbolicate(self): """ Symbolicate Gecko profiling data for one pagecycle. """ profiles = self.collect_profiles() if len(profiles) == 0: LOG.error("No profiles collected") return symbolicator = ProfileSymbolicator({ # Trace-level logging (verbose) "enableTracing": 0, # Fallback server if symbol is not found locally "remoteSymbolServer": "https://symbols.mozilla.org/symbolicate/v4", # Maximum number of symbol files to keep in memory "maxCacheEntries": 2000000, # Frequency of checking for recent symbols to # cache (in hours) "prefetchInterval": 12, # Oldest file age to prefetch (in hours) "prefetchThreshold": 48, # Maximum number of library versions to pre-fetch # per library "prefetchMaxSymbolsPerLib": 3, # Default symbol lookup directories "defaultApp": "FIREFOX", "defaultOs": "WINDOWS", # Paths to .SYM files, expressed internally as a # mapping of app or platform names to directories # Note: App & OS names from requests are converted # to all-uppercase internally "symbolPaths": self.symbol_paths, }) if self.raptor_config.get("symbols_path") is not None: if mozfile.is_url(self.raptor_config["symbols_path"]): symbolicator.integrate_symbol_zip_from_url( self.raptor_config["symbols_path"]) elif os.path.isfile(self.raptor_config["symbols_path"]): symbolicator.integrate_symbol_zip_from_file( self.raptor_config["symbols_path"]) elif os.path.isdir(self.raptor_config["symbols_path"]): sym_path = self.raptor_config["symbols_path"] symbolicator.options["symbolPaths"]["FIREFOX"] = sym_path self.cleanup = False missing_symbols_zip = os.path.join(self.upload_dir, "missingsymbols.zip") try: mode = zipfile.ZIP_DEFLATED except NameError: mode = zipfile.ZIP_STORED with zipfile.ZipFile(self.profile_arcname, "a", mode) as arc: for profile_filename in profiles: testname = profile_filename if testname.endswith(".profile"): testname = testname[0:-8] profile_path = os.path.join(self.gecko_profile_dir, profile_filename) self._save_gecko_profile(symbolicator, missing_symbols_zip, profile_path) # Our zip will contain one directory per test, # and each directory will contain one or more # *.profile files - one for each pagecycle path_in_zip = os.path.join( "profile_{0}".format(self.test_config["name"]), testname + ".profile", ) LOG.info("Adding profile {0} to archive {1}".format( path_in_zip, self.profile_arcname)) try: arc.write(profile_path, path_in_zip) except Exception: LOG.exception("Failed to copy profile {0} as {1} to" " archive {2}".format( profile_path, path_in_zip, self.profile_arcname)) # save the latest gecko profile archive to an env var, so later on # it can be viewed automatically via the view-gecko-profile tool os.environ[ "RAPTOR_LATEST_GECKO_PROFILE_ARCHIVE"] = self.profile_arcname
def symbolicate(self): """ Symbolicate Gecko profiling data for one pagecycle. """ profiles = self.collect_profiles() if len(profiles) == 0: LOG.error("No profiles collected") return symbolicator = ProfileSymbolicator({ # Trace-level logging (verbose) "enableTracing": 0, # Fallback server if symbol is not found locally "remoteSymbolServer": "https://symbols.mozilla.org/symbolicate/v4", # Maximum number of symbol files to keep in memory "maxCacheEntries": 2000000, # Frequency of checking for recent symbols to # cache (in hours) "prefetchInterval": 12, # Oldest file age to prefetch (in hours) "prefetchThreshold": 48, # Maximum number of library versions to pre-fetch # per library "prefetchMaxSymbolsPerLib": 3, # Default symbol lookup directories "defaultApp": "FIREFOX", "defaultOs": "WINDOWS", # Paths to .SYM files, expressed internally as a # mapping of app or platform names to directories # Note: App & OS names from requests are converted # to all-uppercase internally "symbolPaths": self.symbol_paths, }) if self.raptor_config.get("symbols_path") is not None: if mozfile.is_url(self.raptor_config["symbols_path"]): symbolicator.integrate_symbol_zip_from_url( self.raptor_config["symbols_path"]) elif os.path.isfile(self.raptor_config["symbols_path"]): symbolicator.integrate_symbol_zip_from_file( self.raptor_config["symbols_path"]) elif os.path.isdir(self.raptor_config["symbols_path"]): sym_path = self.raptor_config["symbols_path"] symbolicator.options["symbolPaths"]["FIREFOX"] = sym_path self.cleanup = False missing_symbols_zip = os.path.join(self.upload_dir, "missingsymbols.zip") try: mode = zipfile.ZIP_DEFLATED except NameError: mode = zipfile.ZIP_STORED with zipfile.ZipFile(self.profile_arcname, "a", mode) as arc: for profile_info in profiles: profile_path = profile_info["path"] LOG.info("Opening profile at %s" % profile_path) profile = self._open_gecko_profile(profile_path) LOG.info("Symbolicating profile from %s" % profile_path) symbolicated_profile = self._symbolicate_profile( profile, missing_symbols_zip, symbolicator) try: # Write the profiles into a set of folders formatted as: # <TEST-NAME>-<TEST_TYPE>. The file names have a count prefixed # to them to prevent any naming conflicts. The count is the # number of files already in the folder. folder_name = "%s-%s" % ( self.test_config["name"], profile_info["type"], ) profile_name = "-".join([ str( len([ f for f in arc.namelist() if folder_name in f ]) + 1), os.path.split(profile_path)[-1], ]) path_in_zip = os.path.join(folder_name, profile_name) LOG.info("Adding profile %s to archive %s as %s" % (profile_path, self.profile_arcname, path_in_zip)) arc.writestr( path_in_zip, json.dumps(symbolicated_profile, ensure_ascii=False).encode("utf-8"), ) except Exception: LOG.exception( "Failed to add symbolicated profile %s to archive %s" % (profile_path, self.profile_arcname)) raise # save the latest gecko profile archive to an env var, so later on # it can be viewed automatically via the view-gecko-profile tool os.environ[ "RAPTOR_LATEST_GECKO_PROFILE_ARCHIVE"] = self.profile_arcname