def test_conflicting_pipeline_and_distribution_version(self): mock_pipeline = mock.Mock() test_pipeline_name = "unit-test-pipeline" rnd_pipeline_name = False while not rnd_pipeline_name or rnd_pipeline_name == "from-distribution": rnd_pipeline_name = random.choice( racecontrol.available_pipelines())[0] racecontrol.Pipeline(test_pipeline_name, "Pipeline intended for unit-testing", mock_pipeline) cfg = config.Config() cfg.add(config.Scope.benchmark, "race", "pipeline", rnd_pipeline_name) cfg.add(config.Scope.benchmark, "mechanic", "distribution.version", "6.5.3") with self.assertRaises(exceptions.SystemSetupError) as ctx: racecontrol.run(cfg) self.assertRegex( ctx.exception.args[0], r"--distribution-version can only be used together with pipeline from-distribution, " "but you specified {}.\n" "If you intend to benchmark an externally provisioned cluster, don't specify --distribution-version otherwise\n" "please read the docs for from-distribution pipeline at " "{}/pipelines.html#from-distribution".format( rnd_pipeline_name, DOC_LINK)) # ensure we remove it again from the list of registered pipelines to avoid unwanted side effects del racecontrol.pipelines[test_pipeline_name]
def dispatch_sub_command(cfg, sub_command): try: if sub_command == "compare": reporter.compare(cfg) elif sub_command == "list": list(cfg) elif sub_command == "race": racecontrol.run(cfg) else: raise exceptions.ImproperlyConfigured("Unknown subcommand [%s]" % sub_command) return True except exceptions.RallyError as e: logging.exception("Cannot run subcommand [%s]." % sub_command) print("\nERROR: Cannot %s\n\nReason: %s" % (sub_command, e)) print("") print_help_on_errors(cfg) return False except BaseException as e: logging.exception( "A fatal error occurred while running subcommand [%s]." % sub_command) print("\nFATAL: Cannot %s\n\nReason: %s" % (sub_command, e)) print("") print_help_on_errors(cfg) return False
def dispatch_sub_command(cfg, sub_command): try: if sub_command == "compare": reporter.compare(cfg) elif sub_command == "list": list(cfg) elif sub_command == "race": racecontrol.run(cfg) else: raise exceptions.SystemSetupError("Unknown subcommand [%s]" % sub_command) return True except exceptions.RallyError as e: logging.exception("Cannot run subcommand [%s]." % sub_command) console.error("Cannot %s. %s." % (sub_command, e)) console.println("") print_help_on_errors(cfg) return False except BaseException as e: logging.exception( "A fatal error occurred while running subcommand [%s]." % sub_command) console.error("Cannot %s. %s." % (sub_command, e)) console.println("") print_help_on_errors(cfg) return False
def test_prevents_running_an_unknown_pipeline(self): cfg = config.Config() cfg.add(config.Scope.benchmark, "system", "pipeline", "invalid") cfg.add(config.Scope.benchmark, "source", "distribution.version", "5.0.0") with self.assertRaises(exceptions.SystemSetupError) as ctx: racecontrol.run(cfg) self.assertEqual("Unknown pipeline [invalid]. List the available pipelines with esrally list pipelines.", ctx.exception.args[0])
def test_prevents_running_an_unknown_pipeline(self): cfg = config.Config() cfg.add(config.Scope.benchmark, "race", "pipeline", "invalid") cfg.add(config.Scope.benchmark, "mechanic", "distribution.version", "5.0.0") with self.assertRaises(exceptions.SystemSetupError) as ctx: racecontrol.run(cfg) self.assertRegex(ctx.exception.args[0], r"Unknown pipeline \[invalid\]. List the available pipelines with [\S]+? list pipelines.")
def test_passes_benchmark_only_pipeline_in_docker(running_in_docker, benchmark_only_pipeline): cfg = config.Config() cfg.add(config.Scope.benchmark, "race", "pipeline", "benchmark-only") racecontrol.run(cfg) benchmark_only_pipeline.target.assert_called_once_with(cfg)
def test_runs_a_known_pipeline(unittest_pipeline): cfg = config.Config() cfg.add(config.Scope.benchmark, "race", "pipeline", "unit-test-pipeline") cfg.add(config.Scope.benchmark, "mechanic", "distribution.version", "") racecontrol.run(cfg) unittest_pipeline.target.assert_called_once_with(cfg)
def test_passes_benchmark_only_pipeline_in_docker(running_in_docker, benchmark_only_pipeline): cfg = config.Config() cfg.add(config.Scope.benchmark, "system", "race.id", "28a032d1-0b03-4579-ad2a-c65316f126e9") cfg.add(config.Scope.benchmark, "race", "pipeline", "benchmark-only") racecontrol.run(cfg) benchmark_only_pipeline.target.assert_called_once_with(cfg)
def test_runs_a_known_pipeline(unittest_pipeline): cfg = config.Config() cfg.add(config.Scope.benchmark, "system", "race.id", "28a032d1-0b03-4579-ad2a-c65316f126e9") cfg.add(config.Scope.benchmark, "race", "pipeline", "unit-test-pipeline") cfg.add(config.Scope.benchmark, "mechanic", "distribution.version", "") racecontrol.run(cfg) unittest_pipeline.target.assert_called_once_with(cfg)
def test_prevents_running_an_unknown_pipeline(): cfg = config.Config() cfg.add(config.Scope.benchmark, "system", "race.id", "28a032d1-0b03-4579-ad2a-c65316f126e9") cfg.add(config.Scope.benchmark, "race", "pipeline", "invalid") cfg.add(config.Scope.benchmark, "mechanic", "distribution.version", "5.0.0") with pytest.raises( exceptions.SystemSetupError, match=r"Unknown pipeline \[invalid]. List the available pipelines with [\S]+? list pipelines." ): racecontrol.run(cfg)
def test_prevents_running_an_unknown_pipeline(self): cfg = config.Config() cfg.add(config.Scope.benchmark, "system", "pipeline", "invalid") cfg.add(config.Scope.benchmark, "source", "distribution.version", "5.0.0") with self.assertRaises(exceptions.SystemSetupError) as ctx: racecontrol.run(cfg) self.assertEqual( "Unknown pipeline [invalid]. List the available pipelines with esrally list pipelines.", ctx.exception.args[0])
def test_passes_benchmark_only_pipeline_in_docker(self): mock_pipeline = mock.Mock() test_pipeline_name = "benchmark-only" racecontrol.Pipeline("benchmark-only", "Mocked benchmark-only pipeline for unittest", mock_pipeline) cfg = config.Config() cfg.add(config.Scope.benchmark, "race", "pipeline", "benchmark-only") racecontrol.run(cfg) mock_pipeline.assert_called_once_with(cfg) del racecontrol.pipelines[test_pipeline_name]
def test_fails_without_benchmark_only_pipeline_in_docker( running_in_docker, unittest_pipeline): cfg = config.Config() cfg.add(config.Scope.benchmark, "race", "pipeline", "unit-test-pipeline") with pytest.raises( exceptions.SystemSetupError, match=re.escape( "Only the [benchmark-only] pipeline is supported by the Rally Docker image.\n" "Add --pipeline=benchmark-only in your Rally arguments and try again.\n" "For more details read the docs for the benchmark-only pipeline in " "https://esrally.readthedocs.io/en/latest/pipelines.html#benchmark-only\n" )): racecontrol.run(cfg)
def test_runs_a_known_pipeline(self): mock_pipeline = mock.Mock() p = racecontrol.Pipeline("unit-test-pipeline", "Pipeline intended for unit-testing", mock_pipeline) cfg = config.Config() cfg.add(config.Scope.benchmark, "race", "pipeline", "unit-test-pipeline") cfg.add(config.Scope.benchmark, "mechanic", "distribution.version", "") racecontrol.run(cfg) mock_pipeline.assert_called_once_with(cfg) # ensure we remove it again from the list of registered pipelines to avoid unwanted side effects del p
def test_runs_a_known_pipeline(self): mock_pipeline = mock.Mock() p = racecontrol.Pipeline("unit-test-pipeline", "Pipeline intended for unit-testing", mock_pipeline) cfg = config.Config() cfg.add(config.Scope.benchmark, "system", "pipeline", "unit-test-pipeline") cfg.add(config.Scope.benchmark, "source", "distribution.version", "") racecontrol.run(cfg) mock_pipeline.assert_called_once_with(cfg) # ensure we remove it again from the list of registered pipelines to avoid unwanted side effects del p
def test_fails_without_benchmark_only_pipeline_in_docker(self): mock_pipeline = mock.Mock() test_pipeline_name = "unit-test-pipeline" racecontrol.Pipeline("unit-test-pipeline", "Pipeline intended for unit-testing", mock_pipeline) cfg = config.Config() cfg.add(config.Scope.benchmark, "race", "pipeline", "unit-test-pipeline") with self.assertRaises(exceptions.SystemSetupError) as ctx: racecontrol.run(cfg) self.assertEqual( "Only the [benchmark-only] pipeline is supported by the Rally Docker image.\n" "Add --pipeline=benchmark-only in your Rally arguments and try again.\n" "For more details read the docs for the benchmark-only pipeline in https://esrally.readthedocs.io/en/latest/pipelines.html#benchmark-only\n", ctx.exception.args[0]) del racecontrol.pipelines[test_pipeline_name]
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)
def dispatch_sub_command(cfg, sub_command): try: if sub_command == "compare": reporter.compare(cfg) elif sub_command == "list": list(cfg) elif sub_command == "race": racecontrol.run(cfg) else: raise exceptions.ImproperlyConfigured("Unknown subcommand [%s]" % sub_command) return True except exceptions.RallyError as e: logging.exception("Cannot run subcommand [%s]." % sub_command) print("\nERROR: Cannot %s\n\nReason: %s" % (sub_command, e)) return False except BaseException as e: logging.exception("A fatal error occurred while running subcommand [%s]." % sub_command) raise e
def dispatch_sub_command(cfg, sub_command): try: if sub_command == "compare": reporter.compare(cfg) elif sub_command == "list": list(cfg) elif sub_command == "race": racecontrol.run(cfg) else: raise exceptions.SystemSetupError("Unknown subcommand [%s]" % sub_command) return True except exceptions.RallyError as e: logging.exception("Cannot run subcommand [%s]." % sub_command) console.error("Cannot %s. %s." % (sub_command, e)) console.println("") print_help_on_errors(cfg) return False except BaseException as e: logging.exception("A fatal error occurred while running subcommand [%s]." % sub_command) console.error("Cannot %s. %s." % (sub_command, e)) console.println("") print_help_on_errors(cfg) return False
def race(cfg): with_actor_system(lambda c: racecontrol.run(c), cfg)