def FetchBinaryDepdencies(platform, client_configs, fetch_reference_chrome_binary): """ Fetch all binary dependenencies for the given |platform|. Note: we don't fetch browser binaries by default because the size of the binary is about 2Gb, and it requires cloud storage permission to chrome-telemetry bucket. Args: platform: an instance of telemetry.core.platform client_configs: A list of paths (string) to dependencies json files. fetch_reference_chrome_binary: whether to fetch reference chrome binary for the given platform. """ configs = [ dependency_manager.BaseConfig(TELEMETRY_PROJECT_CONFIG), dependency_manager.BaseConfig(BATTOR_BINARY_CONFIG) ] dep_manager = dependency_manager.DependencyManager(configs) target_platform = '%s_%s' % (platform.GetOSName(), platform.GetArchName()) dep_manager.PrefetchPaths(target_platform) if platform.GetOSName() == 'android': host_platform = '%s_%s' % (platform_module.GetHostPlatform().GetOSName( ), platform_module.GetHostPlatform().GetArchName()) dep_manager.PrefetchPaths(host_platform) if fetch_reference_chrome_binary: _FetchReferenceBrowserBinary(platform) # For now, handle client config separately because the BUILD.gn & .isolate of # telemetry tests in chromium src failed to include the files specified in its # client config. # (https://github.com/catapult-project/catapult/issues/2192) # For now this is ok because the client configs usually don't include cloud # storage infos. # TODO(nednguyen): remove the logic of swallowing exception once the issue is # fixed on Chromium side. if client_configs: manager = dependency_manager.DependencyManager( list(dependency_manager.BaseConfig(c) for c in client_configs)) try: manager.PrefetchPaths(target_platform) except dependency_manager.NoPathFoundError as e: logging.error('Error when trying to prefetch paths for %s: %s', target_platform, e.message)
def __init__(self, config_files): if not config_files or not isinstance(config_files, list): raise ValueError( 'Must supply a list of config files to the BinaryManager') configs = [ dependency_manager.BaseConfig(config) for config in config_files ] self._dependency_manager = dependency_manager.DependencyManager( configs)
def __init__(self, target_platform, android_device=None, battor_path=None, battor_map_file=None, battor_map=None, serial_log_bucket=None, autoflash=True): """Constructor. Args: target_platform: Platform BattOr is attached to. android_device: Serial number of Android device. battor_path: Path to BattOr device. battor_map_file: File giving map of [device serial: BattOr path] battor_map: Map of [device serial: BattOr path] serial_log_bucket: The cloud storage bucket to which BattOr agent serial logs are uploaded on failure. Attributes: _battor_path: Path to BattOr. Typically similar to /tty/USB0. _battor_agent_binary: Path to the BattOr agent binary used to communicate with the BattOr. _tracing: A bool saying if tracing has been started. _battor_shell: A subprocess running the battor_agent_binary _trace_results_path: Path to BattOr trace results file. _serial_log_bucket: Cloud storage bucket to which BattOr agent serial logs are uploaded on failure. _serial_log_file: Temp file for the BattOr agent serial log. """ self._battor_path = self._GetBattOrPath(target_platform, android_device, battor_path, battor_map_file, battor_map) config = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'battor_binary_dependencies.json') self._dm = dependency_manager.DependencyManager( [dependency_manager.BaseConfig(config)]) self._battor_agent_binary = self._dm.FetchPath( 'battor_agent_binary', '%s_%s' % (sys.platform, platform.machine())) self._autoflash = autoflash self._serial_log_bucket = serial_log_bucket self._tracing = False self._battor_shell = None self._trace_results_path = None self._start_tracing_time = None self._stop_tracing_time = None self._trace_results = None self._serial_log_file = None self._target_platform = target_platform self._git_hash = None atexit.register(self.KillBattOrShell)
def __init__(self, target_platform, android_device=None, battor_path=None, battor_map_file=None, battor_map=None, serial_log_bucket=None): """Constructor. Args: target_platform: Platform BattOr is attached to. android_device: Serial number of Android device. battor_path: Path to BattOr device. battor_map_file: File giving map of [device serial: BattOr path] battor_map: Map of [device serial: BattOr path] serial_log_bucket: The cloud storage bucket to which BattOr agent serial logs are uploaded on failure. Attributes: _battor_path: Path to BattOr. Typically similar to /tty/USB0. _battor_agent_binary: Path to the BattOr agent binary used to communicate with the BattOr. _tracing: A bool saying if tracing has been started. _battor_shell: A subprocess running the battor_agent_binary _trace_results_path: Path to BattOr trace results file. _serial_log_bucket: Cloud storage bucket to which BattOr agent serial logs are uploaded on failure. _serial_log_file: Temp file for the BattOr agent serial log. """ self._battor_path = self._GetBattOrPath(target_platform, android_device, battor_path, battor_map_file, battor_map) config = os.path.join( os.path.dirname(os.path.abspath(__file__)), 'battor_binary_dependencies.json') dm = dependency_manager.DependencyManager( [dependency_manager.BaseConfig(config)]) self._battor_agent_binary = dm.FetchPath( 'battor_agent_binary', '%s_%s' % (sys.platform, platform.machine())) # Remove this when we have windows avrdude binary uploaded. # https://github.com/catapult-project/catapult/issues/2972 if target_platform in self._SUPPORTED_AUTOFLASHING_PLATFORMS: self._avrdude_binary = dm.FetchPath( 'avrdude_binary', '%s_%s' % (sys.platform, platform.machine())) self._serial_log_bucket = serial_log_bucket self._tracing = False self._battor_shell = None self._trace_results_path = None self._start_tracing_time = None self._stop_tracing_time = None self._trace_results = None self._serial_log_file = None self._target_platform = target_platform atexit.register(self.KillBattOrShell)
def __init__(self, target_platform, android_device=None, battor_path=None, battor_map_file=None, battor_map=None): """Constructor. Args: target_platform: Platform BattOr is attached to. android_device: Serial number of Android device. battor_path: Path to BattOr device. battor_map_file: File giving map of [device serial: BattOr path] battor_map: Map of [device serial: BattOr path] Attributes: _battor_path: Path to BattOr. Typically similar to /tty/USB0. _battor_agent_binary: Path to the BattOr agent binary used to communicate with the BattOr. _tracing: A bool saying if tracing has been started. _battor_shell: A subprocess running the bator_agent_binary _trace_results_path: Path to BattOr trace results file. """ self._battor_path = self._GetBattorPath(target_platform, android_device, battor_path, battor_map_file, battor_map) config = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'battor_binary_dependencies.json') dm = dependency_manager.DependencyManager( [dependency_manager.BaseConfig(config)]) self._battor_agent_binary = dm.FetchPath( 'battor_agent_binary', '%s_%s' % (sys.platform, platform.machine())) self._tracing = False self._battor_shell = None self._trace_results_path = None self._start_tracing_time = None self._stop_tracing_time = None self._trace_results = None
def _InitializeRecursive(self, configs=None, config_files=None): # This recurses through configs to create temporary files for each and # take advantage of context managers to appropriately close those files. # TODO(jbudorick): Remove this recursion if/when dependency_manager # supports loading configurations directly from a dict. if configs: with tempfile.NamedTemporaryFile(delete=False) as next_config_file: try: next_config_file.write(json.dumps(configs[0])) next_config_file.close() self._InitializeRecursive( configs=configs[1:], config_files=[next_config_file.name] + (config_files or [])) finally: if os.path.exists(next_config_file.name): os.remove(next_config_file.name) else: config_files = config_files or [] if 'DEVIL_ENV_CONFIG' in os.environ: config_files.append(os.environ.get('DEVIL_ENV_CONFIG')) config_files.append(_DEVIL_DEFAULT_CONFIG) self._dm = dependency_manager.DependencyManager( [dependency_manager.BaseConfig(c) for c in config_files])
def FetchBinaryDepdencies(platform, client_configs, fetch_reference_chrome_binary): """ Fetch all binary dependenencies for the given |platform|. Note: we don't fetch browser binaries by default because the size of the binary is about 2Gb, and it requires cloud storage permission to chrome-telemetry bucket. Args: platform: an instance of telemetry.core.platform client_configs: A list of paths (string) to dependencies json files. fetch_reference_chrome_binary: whether to fetch reference chrome binary for the given platform. """ configs = [ dependency_manager.BaseConfig(TELEMETRY_PROJECT_CONFIG), dependency_manager.BaseConfig(BATTOR_BINARY_CONFIG) ] dep_manager = dependency_manager.DependencyManager(configs) target_platform = '%s_%s' % (platform.GetOSName(), platform.GetArchName()) dep_manager.PrefetchPaths(target_platform) host_platform = None fetch_devil_deps = False if platform.GetOSName() == 'android': host_platform = '%s_%s' % (platform_module.GetHostPlatform().GetOSName( ), platform_module.GetHostPlatform().GetArchName()) dep_manager.PrefetchPaths(host_platform) # TODO(aiolos): this is a hack to prefetch the devil deps. if host_platform == 'linux_x86_64': fetch_devil_deps = True else: logging.error( 'Devil only supports 64 bit linux as a host platform. ' 'Android tests may fail.') if fetch_reference_chrome_binary: _FetchReferenceBrowserBinary(platform) # For now, handle client config separately because the BUILD.gn & .isolate of # telemetry tests in chromium src failed to include the files specified in its # client config. # (https://github.com/catapult-project/catapult/issues/2192) # For now this is ok because the client configs usually don't include cloud # storage infos. # TODO(nednguyen): remove the logic of swallowing exception once the issue is # fixed on Chromium side. if client_configs: manager = dependency_manager.DependencyManager( list(dependency_manager.BaseConfig(c) for c in client_configs)) try: manager.PrefetchPaths(target_platform) if host_platform is not None: manager.PrefetchPaths(host_platform) except dependency_manager.NoPathFoundError as e: logging.error('Error when trying to prefetch paths for %s: %s', target_platform, e.message) # TODO(aiolos, jbudorick): we should have a devil pre-fetch API to call here # and/or switch devil to use the same platform names so we can include it in # the primary loop. if fetch_devil_deps: devil_env.config.Initialize() devil_env.config._dm.PrefetchPaths(target_platform) devil_env.config._dm.PrefetchPaths('linux2_x86_64')
def FetchBinaryDependencies( platform, client_configs, fetch_reference_chrome_binary): """ Fetch all binary dependenencies for the given |platform|. Note: we don't fetch browser binaries by default because the size of the binary is about 2Gb, and it requires cloud storage permission to chrome-telemetry bucket. Args: platform: an instance of telemetry.core.platform client_configs: A list of paths (string) to dependencies json files. fetch_reference_chrome_binary: whether to fetch reference chrome binary for the given platform. """ configs = [ dependency_manager.BaseConfig(TELEMETRY_PROJECT_CONFIG), ] dep_manager = dependency_manager.DependencyManager(configs) os_name = platform.GetOSName() # If we're running directly on a Chrome OS device, fetch the binaries for # linux instead, which should be compatible with CrOS. Otherwise, if we're # running remotely on CrOS, fetch the binaries for the host platform like # we do with android below. if _IsChromeOSLocalMode(os_name): os_name = 'linux' target_platform = '%s_%s' % (os_name, platform.GetArchName()) dep_manager.PrefetchPaths(target_platform) host_platform = None fetch_devil_deps = False if os_name in ('android', 'chromeos'): host_platform = '%s_%s' % ( py_utils.GetHostOsName(), py_utils.GetHostArchName()) dep_manager.PrefetchPaths(host_platform) if os_name == 'android': if host_platform == 'linux_x86_64': fetch_devil_deps = True else: logging.error('Devil only supports 64 bit linux as a host platform. ' 'Android tests may fail.') if fetch_reference_chrome_binary: _FetchReferenceBrowserBinary(platform) # For now, handle client config separately because the BUILD.gn & .isolate of # telemetry tests in chromium src failed to include the files specified in its # client config. # (https://github.com/catapult-project/catapult/issues/2192) # For now this is ok because the client configs usually don't include cloud # storage infos. # TODO(nednguyen): remove the logic of swallowing exception once the issue is # fixed on Chromium side. if client_configs: manager = dependency_manager.DependencyManager( list(dependency_manager.BaseConfig(c) for c in client_configs)) try: manager.PrefetchPaths(target_platform) if host_platform is not None: manager.PrefetchPaths(host_platform) except dependency_manager.NoPathFoundError as e: logging.error('Error when trying to prefetch paths for %s: %s', target_platform, e.message) if fetch_devil_deps: devil_env.config.Initialize() devil_env.config.PrefetchPaths(arch=platform.GetArchName()) devil_env.config.PrefetchPaths()