Esempio n. 1
0
    def make_config(self):
        default_actions = [
            'populate-webroot', 'install-chromium-distribution',
            'create-virtualenv', 'run-tests'
        ]
        self.config = {
            'run_local': True,
            'binary_path': self.binary_path,
            'repo_path': self.topsrcdir,
            'raptor_path': self.raptor_dir,
            'obj_path': self.topobjdir,
            'log_name': 'raptor',
            'virtualenv_path': self.virtualenv_path,
            'pypi_url': 'http://pypi.org/simple',
            'base_work_dir': self.mozharness_dir,
            'exes': {
                'python': self.python,
                'virtualenv': [self.python, self.virtualenv_script],
            },
            'title': socket.gethostname(),
            'default_actions': default_actions,
            'raptor_cmd_line_args': self.raptor_args,
            'host': self.host,
            'power_test': self.power_test,
            'memory_test': self.memory_test,
            'cpu_test': self.cpu_test,
            'live_sites': self.live_sites,
            'disable_perf_tuning': self.disable_perf_tuning,
            'conditioned_profile_scenario': self.conditioned_profile_scenario,
            'is_release_build': self.is_release_build,
            'device_name': self.device_name,
        }

        sys.path.insert(0, os.path.join(self.topsrcdir, 'tools',
                                        'browsertime'))
        try:
            import mach_commands as browsertime
            # We don't set `browsertime_{chromedriver,geckodriver} -- those will be found by
            # browsertime in its `node_modules` directory, which is appropriate for local builds.
            # We don't set `browsertime_ffmpeg` yet: it will need to be on the path.  There is code
            # to configure the environment including the path in
            # `tools/browsertime/mach_commands.py` but integrating it here will take more effort.
            self.config.update({
                'browsertime_node':
                browsertime.node_path(),
                'browsertime_browsertimejs':
                browsertime.browsertime_path(),
            })
        finally:
            sys.path = sys.path[1:]
Esempio n. 2
0
    def make_config(self):
        default_actions = [
            "populate-webroot",
            "create-virtualenv",
            "install-chromium-distribution",
            "run-tests",
        ]
        self.config = {
            "run_local": True,
            "binary_path": self.binary_path,
            "repo_path": self.topsrcdir,
            "raptor_path": self.raptor_dir,
            "obj_path": self.topobjdir,
            "log_name": "raptor",
            "virtualenv_path": self.virtualenv_path,
            "pypi_url": "http://pypi.org/simple",
            "base_work_dir": self.mozharness_dir,
            "exes": {
                "python": self.python,
                "virtualenv": [self.python, self.virtualenv_script],
            },
            "title": socket.gethostname(),
            "default_actions": default_actions,
            "raptor_cmd_line_args": self.raptor_args,
            "host": self.host,
            "power_test": self.power_test,
            "memory_test": self.memory_test,
            "cpu_test": self.cpu_test,
            "live_sites": self.live_sites,
            "disable_perf_tuning": self.disable_perf_tuning,
            "conditioned_profile_scenario": self.conditioned_profile_scenario,
            "is_release_build": self.is_release_build,
            "device_name": self.device_name,
        }

        sys.path.insert(0, os.path.join(self.topsrcdir, "tools",
                                        "browsertime"))
        try:
            import mach_commands as browsertime

            # We don't set `browsertime_{chromedriver,geckodriver} -- those will be found by
            # browsertime in its `node_modules` directory, which is appropriate for local builds.
            # We don't set `browsertime_ffmpeg` yet: it will need to be on the path.  There is code
            # to configure the environment including the path in
            # `tools/browsertime/mach_commands.py` but integrating it here will take more effort.
            self.config.update({
                "browsertime_node":
                browsertime.node_path(),
                "browsertime_browsertimejs":
                browsertime.browsertime_path(),
                "browsertime_vismet_script":
                browsertime.visualmetrics_path(),
            })

            def _should_install():
                # If browsertime doesn't exist, install it
                if not os.path.exists(
                        self.config["browsertime_browsertimejs"]
                ) or not os.path.exists(
                        self.config["browsertime_vismet_script"]):
                    return True

                # Browsertime exists, check if it's outdated
                with open(
                        os.path.join(self.topsrcdir, "tools", "browsertime",
                                     "package.json")) as new, open(
                                         os.path.join(
                                             self.topsrcdir,
                                             "tools",
                                             "browsertime",
                                             "node_modules",
                                             "browsertime",
                                             "package.json",
                                         )) as old:
                    old_pkg = json.load(old)
                    new_pkg = json.load(new)

                return not old_pkg["_from"].endswith(
                    new_pkg["devDependencies"]["browsertime"])

            def _get_browsertime_version():
                # Returns the (current commit, version number) used
                with open(
                        os.path.join(
                            self.topsrcdir,
                            "tools",
                            "browsertime",
                            "node_modules",
                            "browsertime",
                            "package.json",
                        )) as existing:
                    package = json.load(existing)
                return package["version"], package["_from"]

            # Check if browsertime scripts exist and try to install them if
            # they aren't
            if _should_install():
                # TODO: Make this "integration" nicer in the near future
                print("Missing browsertime files...attempting to install")
                subprocess.check_call([
                    os.path.join(self.topsrcdir, "mach"),
                    "browsertime",
                    "--setup",
                    "--clobber",
                ])
                if _should_install():
                    raise Exception(
                        "Failed installation attempt. Cannot find browsertime scripts. "
                        "Run `./mach browsertime --setup --clobber` to set it up."
                    )

            print("Using browsertime version %s from %s" %
                  _get_browsertime_version())

        finally:
            sys.path = sys.path[1:]