예제 #1
0
파일: racecontrol.py 프로젝트: karmi/rally
    def setup(self, sources=False):
        # to load the track we need to know the correct cluster distribution version. Usually, this value should be set
        # but there are rare cases (external pipeline and user did not specify the distribution version) where we need
        # to derive it ourselves. For source builds we always assume "master"
        if not sources and not self.cfg.exists("mechanic", "distribution.version"):
            distribution_version = mechanic.cluster_distribution_version(self.cfg)
            self.logger.info("Automatically derived distribution version [%s]", distribution_version)
            self.cfg.add(config.Scope.benchmark, "mechanic", "distribution.version", distribution_version)
            min_es_version = versions.Version.from_string(version.minimum_es_version())
            specified_version = versions.Version.from_string(distribution_version)
            if specified_version < min_es_version:
                raise exceptions.SystemSetupError(f"Cluster version must be at least [{min_es_version}] but was [{distribution_version}]")

        self.current_track = track.load_track(self.cfg)
        self.track_revision = self.cfg.opts("track", "repository.revision", mandatory=False)
        challenge_name = self.cfg.opts("track", "challenge.name")
        self.current_challenge = self.current_track.find_challenge_or_default(challenge_name)
        if self.current_challenge is None:
            raise exceptions.SystemSetupError(
                "Track [{}] does not provide challenge [{}]. List the available tracks with {} list tracks.".format(
                    self.current_track.name, challenge_name, PROGRAM_NAME))
        if self.current_challenge.user_info:
            console.info(self.current_challenge.user_info)
        self.race = metrics.create_race(self.cfg, self.current_track, self.current_challenge, self.track_revision)

        self.metrics_store = metrics.metrics_store(
            self.cfg,
            track=self.race.track_name,
            challenge=self.race.challenge_name,
            read_only=False
        )
        self.race_store = metrics.race_store(self.cfg)
예제 #2
0
    def __init__(self,
                 cfg,
                 sources=False,
                 build=False,
                 distribution=False,
                 external=False,
                 docker=False):
        self.cfg = cfg
        # we preload the track here but in rare cases (external pipeline and user did not specify the distribution version) we might need
        # to reload the track again. We are assuming that a track always specifies the same challenges for each version (i.e. branch).
        t = self._load_track()
        challenge = self._find_challenge(t)

        self.race = metrics.create_race(self.cfg, t, challenge)

        self.metrics_store = metrics.metrics_store(
            self.cfg,
            track=self.race.track_name,
            challenge=self.race.challenge_name,
            read_only=False)
        self.race_store = metrics.race_store(self.cfg)
        self.sources = sources
        self.build = build
        self.distribution = distribution
        self.external = external
        self.docker = docker
        self.actor_system = None
        self.mechanic = None
        self.ignore_unknown_return = self.cfg.opts("system",
                                                   "ignore.unknown.return")
예제 #3
0
파일: reporter.py 프로젝트: elastic/rally
def compare(cfg, baseline_id, contender_id):
    if not baseline_id or not contender_id:
        raise exceptions.SystemSetupError(
            "compare needs baseline and a contender")
    race_store = metrics.race_store(cfg)
    ComparisonReporter(cfg).report(race_store.find_by_race_id(baseline_id),
                                   race_store.find_by_race_id(contender_id))
예제 #4
0
 def __init__(self,
              cfg,
              sources=False,
              build=False,
              distribution=False,
              external=False,
              docker=False):
     self.cfg = cfg
     self.track = track.load_track(self.cfg)
     challenge_name = self.cfg.opts("track", "challenge.name")
     challenge = self.track.find_challenge_or_default(challenge_name)
     if challenge is None:
         raise exceptions.SystemSetupError(
             "Track [%s] does not provide challenge [%s]. List the available tracks with %s list tracks."
             % (self.track.name, challenge_name, PROGRAM_NAME))
     self.metrics_store = metrics.metrics_store(self.cfg,
                                                track=self.track.name,
                                                challenge=challenge.name,
                                                read_only=False)
     self.race_store = metrics.race_store(self.cfg)
     self.sources = sources
     self.build = build
     self.distribution = distribution
     self.external = external
     self.docker = docker
     self.actor_system = None
     self.mechanic = None
예제 #5
0
def compare(cfg):
    baseline_ts = cfg.opts("reporting", "baseline.timestamp")
    contender_ts = cfg.opts("reporting", "contender.timestamp")

    if not baseline_ts or not contender_ts:
        raise exceptions.SystemSetupError(
            "compare needs baseline and a contender")
    race_store = metrics.race_store(cfg)
    ComparisonReporter(cfg).report(race_store.find_by_timestamp(baseline_ts),
                                   race_store.find_by_timestamp(contender_ts))
예제 #6
0
def compare(cfg):
    baseline_ts = cfg.opts("report", "comparison.baseline.timestamp")
    contender_ts = cfg.opts("report", "comparison.contender.timestamp")

    if not baseline_ts or not contender_ts:
        raise exceptions.ImproperlyConfigured(
            "compare needs baseline and a contender")
    race_store = metrics.race_store(cfg)
    ComparisonReporter(cfg).report(race_store.find_by_timestamp(baseline_ts),
                                   race_store.find_by_timestamp(contender_ts))
예제 #7
0
파일: reporter.py 프로젝트: joshuar/rally
def compare(cfg):
    baseline_ts = cfg.opts("report", "comparison.baseline.timestamp")
    contender_ts = cfg.opts("report", "comparison.contender.timestamp")

    if not baseline_ts or not contender_ts:
        raise exceptions.ImproperlyConfigured("compare needs baseline and a contender")
    race_store = metrics.race_store(cfg)
    ComparisonReporter(cfg).report(
        race_store.find_by_timestamp(baseline_ts),
        race_store.find_by_timestamp(contender_ts))
예제 #8
0
def compare(cfg):
    baseline_id = cfg.opts("reporting", "baseline.id")
    contender_id = cfg.opts("reporting", "contender.id")

    if not baseline_id or not contender_id:
        raise exceptions.SystemSetupError(
            "compare needs baseline and a contender")
    race_store = metrics.race_store(cfg)
    ComparisonReporter(cfg).report(race_store.find_by_race_id(baseline_id),
                                   race_store.find_by_race_id(contender_id))
예제 #9
0
def compare(cfg):
    baseline_ts = cfg.opts("reporting", "baseline.timestamp")
    contender_ts = cfg.opts("reporting", "contender.timestamp")

    if not baseline_ts or not contender_ts:
        raise exceptions.SystemSetupError("compare needs baseline and a contender")
    race_store = metrics.race_store(cfg)
    ComparisonReporter(cfg).report(
        race_store.find_by_timestamp(baseline_ts),
        race_store.find_by_timestamp(contender_ts))
예제 #10
0
    def setup(self, msg, sender):
        self.start_sender = sender
        self.cfg = msg.cfg
        # to load the track we need to know the correct cluster distribution version. Usually, this value should be set but there are rare
        # cases (external pipeline and user did not specify the distribution version) where we need to derive it ourselves. For source
        # builds we always assume "master"
        if not msg.sources and not self.cfg.exists("mechanic",
                                                   "distribution.version"):
            distribution_version = mechanic.cluster_distribution_version(
                self.cfg)
            if not distribution_version:
                raise exceptions.SystemSetupError(
                    "A distribution version is required. Please specify it with --distribution-version."
                )
            self.logger.info("Automatically derived distribution version [%s]",
                             distribution_version)
            self.cfg.add(config.Scope.benchmark, "mechanic",
                         "distribution.version", distribution_version)

        t = track.load_track(self.cfg)
        self.track_revision = self.cfg.opts("track",
                                            "repository.revision",
                                            mandatory=False)
        challenge_name = self.cfg.opts("track", "challenge.name")
        challenge = t.find_challenge_or_default(challenge_name)
        if challenge is None:
            raise exceptions.SystemSetupError(
                "Track [%s] does not provide challenge [%s]. List the available tracks with %s list tracks."
                % (t.name, challenge_name, PROGRAM_NAME))
        if challenge.user_info:
            console.info(challenge.user_info)
        self.race = metrics.create_race(self.cfg, t, challenge,
                                        self.track_revision)

        self.metrics_store = metrics.metrics_store(
            self.cfg,
            track=self.race.track_name,
            challenge=self.race.challenge_name,
            read_only=False)
        self.race_store = metrics.race_store(self.cfg)
        self.logger.info("Asking mechanic to start the engine.")
        cluster_settings = challenge.cluster_settings
        self.mechanic = self.createActor(
            mechanic.MechanicActor,
            targetActorRequirements={"coordinator": True})
        self.send(
            self.mechanic,
            mechanic.StartEngine(self.cfg, self.metrics_store.open_context,
                                 cluster_settings, msg.sources, msg.build,
                                 msg.distribution, msg.external, msg.docker))
예제 #11
0
def stop(cfg):
    root_path = paths.install_root(cfg)
    node_config = provisioner.load_node_configuration(root_path)
    if node_config.build_type == "tar":
        node_launcher = launcher.ProcessLauncher(cfg)
    elif node_config.build_type == "docker":
        node_launcher = launcher.DockerLauncher(cfg)
    else:
        raise exceptions.SystemSetupError("Unknown build type [{}]".format(
            node_config.build_type))

    nodes, race_id = _load_node_file(root_path)

    cls = metrics.metrics_store_class(cfg)
    metrics_store = cls(cfg)

    race_store = metrics.race_store(cfg)
    try:
        current_race = race_store.find_by_race_id(race_id)
    except exceptions.NotFound:
        logging.getLogger(__name__).info(
            "Could not find race [%s] most likely because an in-memory metrics store is "
            "used across multiple machines. Use an Elasticsearch metrics store to persist "
            "results.", race_id)
        # we are assuming here that we use an Elasticsearch metrics store... . If we use a file race store (across
        # multiple machines) we will not be able to retrieve a race. In that case we open our in-memory metrics store
        # with settings derived from startup parameters (because we can't store system metrics persistently anyway).
        current_race = metrics.create_race(cfg, track=None, challenge=None)

    metrics_store.open(race_id=current_race.race_id,
                       race_timestamp=current_race.race_timestamp,
                       track_name=current_race.track_name,
                       challenge_name=current_race.challenge_name)

    node_launcher.stop(nodes, metrics_store)
    _delete_node_file(root_path)

    metrics_store.flush(refresh=True)
    for node in nodes:
        results = metrics.calculate_system_results(metrics_store,
                                                   node.node_name)
        current_race.add_results(results)
        metrics.results_store(cfg).store_results(current_race)

    metrics_store.close()

    # TODO: Do we need to expose this as a separate command as well?
    provisioner.cleanup(preserve=cfg.opts("mechanic", "preserve.install"),
                        install_dir=node_config.binary_path,
                        data_paths=node_config.data_paths)
예제 #12
0
파일: mechanic.py 프로젝트: yuerl/rally
def stop(cfg):
    root_path = paths.install_root(cfg)
    node_config = provisioner.load_node_configuration(root_path)
    if node_config.build_type == "tar":
        node_launcher = launcher.ProcessLauncher(cfg)
    elif node_config.build_type == "docker":
        node_launcher = launcher.DockerLauncher(cfg)
    else:
        raise exceptions.SystemSetupError("Unknown build type [{}]".format(
            node_config.build_type))

    nodes, race_id = _load_node_file(root_path)

    cls = metrics.metrics_store_class(cfg)
    metrics_store = cls(cfg)

    race_store = metrics.race_store(cfg)
    try:
        current_race = race_store.find_by_race_id(race_id)
        metrics_store.open(race_id=current_race.race_id,
                           race_timestamp=current_race.race_timestamp,
                           track_name=current_race.track_name,
                           challenge_name=current_race.challenge_name)
    except exceptions.NotFound:
        logging.getLogger(__name__).info(
            "Could not find race [%s] and will thus not persist system metrics.",
            race_id)
        # Don't persist system metrics if we can't retrieve the race as we cannot derive the required meta-data.
        current_race = None
        metrics_store = None

    node_launcher.stop(nodes, metrics_store)
    _delete_node_file(root_path)

    if current_race:
        metrics_store.flush(refresh=True)
        for node in nodes:
            results = metrics.calculate_system_results(metrics_store,
                                                       node.node_name)
            current_race.add_results(results)
            metrics.results_store(cfg).store_results(current_race)

        metrics_store.close()

    # TODO: Do we need to expose this as a separate command as well?
    provisioner.cleanup(preserve=cfg.opts("mechanic", "preserve.install"),
                        install_dir=node_config.binary_path,
                        data_paths=node_config.data_paths)
예제 #13
0
    def setup(self, msg):
        self.mechanic = self.createActor(mechanic.MechanicActor,
                                         #globalName="/rally/mechanic/coordinator",
                                         targetActorRequirements={"coordinator": True})

        self.cfg = msg.cfg
        # to load the track we need to know the correct cluster distribution version. Usually, this value should be set but there are rare
        # cases (external pipeline and user did not specify the distribution version) where we need to derive it ourselves. For source
        # builds we always assume "master"
        if not msg.sources and not self.cfg.exists("mechanic", "distribution.version"):
            distribution_version = mechanic.cluster_distribution_version(self.cfg)
            if not distribution_version:
                raise exceptions.SystemSetupError("A distribution version is required. Please specify it with --distribution-version.")
            logger.info("Automatically derived distribution version [%s]" % distribution_version)
            self.cfg.add(config.Scope.benchmark, "mechanic", "distribution.version", distribution_version)

        t = track.load_track(self.cfg)
        challenge_name = self.cfg.opts("track", "challenge.name")
        challenge = t.find_challenge_or_default(challenge_name)
        if challenge is None:
            raise exceptions.SystemSetupError("Track [%s] does not provide challenge [%s]. List the available tracks with %s list tracks."
                                              % (t.name, challenge_name, PROGRAM_NAME))
        if challenge.user_info:
            console.info(challenge.user_info, logger=logger)
        self.race = metrics.create_race(self.cfg, t, challenge)

        self.metrics_store = metrics.metrics_store(
            self.cfg,
            track=self.race.track_name,
            challenge=self.race.challenge_name,
            read_only=False
        )
        self.lap_counter = LapCounter(self.race, self.metrics_store, self.cfg)
        self.race_store = metrics.race_store(self.cfg)
        logger.info("Asking mechanic to start the engine.")
        cluster_settings = self.race.challenge.cluster_settings
        self.send(self.mechanic, mechanic.StartEngine(self.cfg, self.metrics_store.open_context, cluster_settings, msg.sources, msg.build,
                                                      msg.distribution, msg.external, msg.docker))
예제 #14
0
 def __init__(self,
              cfg,
              sources=False,
              build=False,
              distribution=False,
              external=False,
              docker=False):
     self.cfg = cfg
     self.track = track.load_track(self.cfg)
     self.metrics_store = metrics.metrics_store(
         self.cfg,
         track=self.track.name,
         challenge=self.track.find_challenge_or_default(
             self.cfg.opts("track", "challenge.name")).name,
         read_only=False)
     self.race_store = metrics.race_store(self.cfg)
     self.sources = sources
     self.build = build
     self.distribution = distribution
     self.external = external
     self.docker = docker
     self.actor_system = None
     self.mechanic = None
예제 #15
0
 def _current_race(self):
     race_id = self.cfg.opts("system", "race.id")
     return metrics.race_store(self.cfg).find_by_race_id(race_id)
예제 #16
0
 def setup(self):
     self.actor_system = thespian.actors.ActorSystem()
     self.mechanic.start_engine()
     self.track = track.load_track(self.cfg)
     metrics.race_store(self.cfg).store_race(self.track)
예제 #17
0
 def setup(self):
     self.mechanic.prepare_candidate()
     self.cluster = self.mechanic.start_engine()
     self.track = track.load_track(self.cfg)
     metrics.race_store(self.cfg).store_race(self.track)
     self.actor_system = thespian.actors.ActorSystem()
예제 #18
0
def store_race(ctx):
    metrics.race_store(ctx.config).store_race(ctx.track)
예제 #19
0
def store_race(ctx):
    metrics.race_store(ctx.config).store_race(ctx.track)