Example #1
0
def race(cfg):
    logger = logging.getLogger(__name__)

    kill_running_processes = cfg.opts("system", "kill.running.processes")

    if kill_running_processes:
        logger.info("Killing running Rally processes")

        # Kill any lingering Rally processes before attempting to continue - the actor system needs to be a singleton on this machine
        # noinspection PyBroadException
        try:
            process.kill_running_rally_instances()
        except BaseException:
            logger.exception(
                "Could not terminate potentially running Rally instances correctly. Attempting to go on anyway.")
    else:
        other_rally_processes = process.find_all_other_rally_processes()
        if other_rally_processes:
            pids = [p.pid for p in other_rally_processes]

            msg = f"There are other Rally processes running on this machine (PIDs: {pids}) but only one Rally " \
                  f"benchmark is allowed to run at the same time.\n\nYou can use --kill-running-processes flag " \
                  f"to kill running processes automatically and allow Rally to continue to run a new benchmark. " \
                  f"Otherwise, you need to manually kill them."
            raise exceptions.RallyError(msg)

    with_actor_system(racecontrol.run, cfg)
Example #2
0
def race(cfg):
    other_rally_processes = process.find_all_other_rally_processes()
    if other_rally_processes:
        pids = [p.pid for p in other_rally_processes]
        msg = "There are other Rally processes running on this machine (PIDs: %s) but only one Rally benchmark is allowed to run at " \
              "the same time. Please check and terminate these processes and retry again." % pids
        raise exceptions.RallyError(msg)

    with_actor_system(lambda c: racecontrol.run(c), cfg)
Example #3
0
    def test_find_other_rally_processes(self, process_iter):
        rally_es_5_process = ProcessTests.Process(100, "java", [
            "/usr/lib/jvm/java-8-oracle/bin/java", "-Xms2g", "-Xmx2g",
            "-Enode.name=rally-node0",
            "org.elasticsearch.bootstrap.Elasticsearch"
        ])
        rally_es_1_process = ProcessTests.Process(101, "java", [
            "/usr/lib/jvm/java-8-oracle/bin/java", "-Xms2g", "-Xmx2g",
            "-Des.node.name=rally-node0",
            "org.elasticsearch.bootstrap.Elasticsearch"
        ])
        metrics_store_process = ProcessTests.Process(102, "java", [
            "/usr/lib/jvm/java-8-oracle/bin/java", "-Xms2g", "-Xmx2g",
            "-Des.path.home=~/rally/metrics/",
            "org.elasticsearch.bootstrap.Elasticsearch"
        ])
        random_python = ProcessTests.Process(103, "python3",
                                             ["/some/django/app"])
        other_process = ProcessTests.Process(104, "init", ["/usr/sbin/init"])
        rally_process_p = ProcessTests.Process(
            105, "python3", ["/usr/bin/python3", "~/.local/bin/esrally"])
        rally_process_r = ProcessTests.Process(
            106, "rally", ["/usr/bin/python3", "~/.local/bin/esrally"])
        rally_process_e = ProcessTests.Process(
            107, "esrally", ["/usr/bin/python3", "~/.local/bin/esrally"])
        rally_process_mac = ProcessTests.Process(
            108, "Python",
            ["/Python.app/Contents/MacOS/Python", "~/.local/bin/esrally"])
        # fake own process by determining our pid
        own_rally_process = ProcessTests.Process(
            os.getpid(), "Python",
            ["/Python.app/Contents/MacOS/Python", "~/.local/bin/esrally"])
        night_rally_process = ProcessTests.Process(
            110, "Python",
            ["/Python.app/Contents/MacOS/Python", "~/.local/bin/night_rally"])

        process_iter.return_value = [
            rally_es_1_process,
            rally_es_5_process,
            metrics_store_process,
            random_python,
            other_process,
            rally_process_p,
            rally_process_r,
            rally_process_e,
            rally_process_mac,
            own_rally_process,
            night_rally_process,
        ]

        self.assertEqual([
            rally_process_p, rally_process_r, rally_process_e,
            rally_process_mac
        ], process.find_all_other_rally_processes())
Example #4
0
    def test_find_no_other_rally_process_running(self, process_iter):
        metrics_store_process = ProcessTests.Process(102, "java", [
            "/usr/lib/jvm/java-8-oracle/bin/java", "-Xms2g", "-Xmx2g",
            "-Des.path.home=~/rally/metrics/",
            "org.elasticsearch.bootstrap.Elasticsearch"
        ])
        random_python = ProcessTests.Process(103, "python3",
                                             ["/some/django/app"])

        process_iter.return_value = [metrics_store_process, random_python]

        self.assertEqual(0, len(process.find_all_other_rally_processes()))