Exemplo n.º 1
0
 def test_raises_error_on_unknown_car(self):
     with self.assertRaises(exceptions.SystemSetupError) as ctx:
         team.load_car(self.team_dir, ["don_t-know-you"])
     self.assertRegex(
         ctx.exception.args[0],
         r"Unknown car \[don_t-know-you\]. List the available cars with [^\s]+ list cars."
     )
Exemplo n.º 2
0
 def test_load_car_with_mixin_single_config_base(self):
     car = team.load_car(self.team_dir, ["32gheap", "ea"])
     assert car.name == "32gheap+ea"
     assert car.config_paths == [os.path.join(current_dir, "data", "cars", "v1", "vanilla", "templates")]
     assert car.root_path is None
     assert car.variables == {"heap_size": "32g", "clean_command": "./gradlew clean", "assertions": "true"}
     assert car.root_path is None
Exemplo n.º 3
0
 def test_load_known_car(self):
     car = team.load_car(self.team_dir, ["default"], car_params={"data_paths": ["/mnt/disk0", "/mnt/disk1"]})
     assert car.name == "default"
     assert car.config_paths == [os.path.join(current_dir, "data", "cars", "v1", "vanilla", "templates")]
     assert car.root_path is None
     assert car.variables == {"heap_size": "1g", "clean_command": "./gradlew clean", "data_paths": ["/mnt/disk0", "/mnt/disk1"]}
     assert car.root_path is None
Exemplo n.º 4
0
 def test_load_known_car(self):
     car = team.load_car(self.repo, ["default"])
     self.assertEqual("default", car.name)
     self.assertEqual(
         [os.path.join(current_dir, "data", "cars", "vanilla")],
         car.config_paths)
     self.assertEqual({"heap_size": "1g"}, car.variables)
     self.assertEqual({}, car.env)
Exemplo n.º 5
0
 def test_load_car_with_install_hook(self):
     car = team.load_car(self.team_dir, ["default", "with_hook"], car_params={"data_paths": ["/mnt/disk0", "/mnt/disk1"]})
     assert car.name == "default+with_hook"
     assert car.config_paths == [
         os.path.join(current_dir, "data", "cars", "v1", "vanilla", "templates"),
         os.path.join(current_dir, "data", "cars", "v1", "with_hook", "templates"),
     ]
     assert car.root_path == os.path.join(current_dir, "data", "cars", "v1", "with_hook")
     assert car.variables == {"heap_size": "1g", "clean_command": "./gradlew clean", "data_paths": ["/mnt/disk0", "/mnt/disk1"]}
Exemplo n.º 6
0
 def test_load_car_with_mixin_multiple_config_bases(self):
     car = team.load_car(self.repo, ["32gheap", "ea", "verbose"])
     self.assertEqual("32gheap+ea+verbose", car.name)
     self.assertEqual([
         os.path.join(current_dir, "data", "cars", "vanilla"),
         os.path.join(current_dir, "data", "cars", "verbose_logging"),
     ], car.config_paths)
     self.assertEqual({"heap_size": "32g", "assertions": "true"}, car.variables)
     self.assertEqual({"JAVA_TOOL_OPTS": "A B C D E F G H I"}, car.env)
Exemplo n.º 7
0
 def test_load_car_with_mixin_multiple_config_bases(self):
     car = team.load_car(self.repo, ["32gheap", "ea", "verbose"])
     self.assertEqual("32gheap+ea+verbose", car.name)
     self.assertEqual([
         os.path.join(current_dir, "data", "cars", "vanilla"),
         os.path.join(current_dir, "data", "cars", "verbose_logging"),
     ], car.config_paths)
     self.assertEqual({"heap_size": "32g", "assertions": "true"}, car.variables)
     self.assertEqual({"JAVA_TOOL_OPTS": "A B C D E F G H I"}, car.env)
Exemplo n.º 8
0
 def test_load_car_with_multiple_bases_referring_same_install_hook(self):
     car = team.load_car(self.team_dir, ["with_hook", "another_with_hook"])
     assert car.name == "with_hook+another_with_hook"
     assert car.config_paths == [
         os.path.join(current_dir, "data", "cars", "v1", "vanilla", "templates"),
         os.path.join(current_dir, "data", "cars", "v1", "with_hook", "templates"),
         os.path.join(current_dir, "data", "cars", "v1", "verbose_logging", "templates"),
     ]
     assert car.root_path == os.path.join(current_dir, "data", "cars", "v1", "with_hook")
     assert car.variables == {"heap_size": "16g", "clean_command": "./gradlew clean", "verbose_logging": "true"}
Exemplo n.º 9
0
def load_team(cfg, external):
    # externally provisioned clusters do not support cars / plugins
    if external:
        car = None
        plugins = []
    else:
        team_path = team.team_path(cfg)
        car = team.load_car(team_path, cfg.opts("mechanic", "car.names"), cfg.opts("mechanic", "car.params"))
        plugins = team.load_plugins(team_path, cfg.opts("mechanic", "car.plugins"), cfg.opts("mechanic", "plugin.params"))
    return car, plugins
Exemplo n.º 10
0
 def test_load_car_with_mixin_single_config_base(self):
     car = team.load_car(self.team_dir, ["32gheap", "ea"])
     self.assertEqual("32gheap+ea", car.name)
     self.assertEqual(
         [os.path.join(current_dir, "data", "cars", "vanilla")],
         car.config_paths)
     self.assertEqual({
         "heap_size": "32g",
         "assertions": "true"
     }, car.variables)
     self.assertEqual({"JAVA_TOOL_OPTS": "A B C D E F"}, car.env)
Exemplo n.º 11
0
 def test_load_known_car(self):
     car = team.load_car(self.team_dir, ["default"], car_params={"data_paths": ["/mnt/disk0", "/mnt/disk1"]})
     self.assertEqual("default", car.name)
     self.assertEqual([os.path.join(current_dir, "data", "cars", "v1", "vanilla", "templates")], car.config_paths)
     self.assertIsNone(car.root_path)
     self.assertDictEqual({
         "heap_size": "1g",
         "clean_command": "./gradlew clean",
         "data_paths": ["/mnt/disk0", "/mnt/disk1"]
     }, car.variables)
     self.assertEqual({}, car.env)
     self.assertIsNone(car.root_path)
Exemplo n.º 12
0
 def test_load_known_car(self):
     car = team.load_car(
         self.team_dir, ["default"],
         car_params={"data_paths": ["/mnt/disk0", "/mnt/disk1"]})
     self.assertEqual("default", car.name)
     self.assertEqual(
         [os.path.join(current_dir, "data", "cars", "vanilla")],
         car.config_paths)
     self.assertDictEqual(
         {
             "heap_size": "1g",
             "data_paths": ["/mnt/disk0", "/mnt/disk1"]
         }, car.variables)
     self.assertEqual({}, car.env)
Exemplo n.º 13
0
 def test_load_car_with_multiple_bases_referring_same_install_hook(self):
     car = team.load_car(self.team_dir, ["with_hook", "another_with_hook"])
     self.assertEqual("with_hook+another_with_hook", car.name)
     self.assertEqual([
         os.path.join(current_dir, "data", "cars", "v1", "vanilla", "templates"),
         os.path.join(current_dir, "data", "cars", "v1", "with_hook", "templates"),
         os.path.join(current_dir, "data", "cars", "v1", "verbose_logging", "templates")
     ], car.config_paths)
     self.assertEqual(os.path.join(current_dir, "data", "cars", "v1", "with_hook"), car.root_path)
     self.assertDictEqual({
         "heap_size": "16g",
         "clean_command": "./gradlew clean",
         "verbose_logging": "true"
     }, car.variables)
     self.assertEqual({}, car.env)
Exemplo n.º 14
0
 def test_load_car_with_mixin_multiple_config_bases(self):
     car = team.load_car(self.team_dir, ["32gheap", "ea", "verbose"])
     self.assertEqual("32gheap+ea+verbose", car.name)
     self.assertEqual([
         os.path.join(current_dir, "data", "cars", "v1", "vanilla", "templates"),
         os.path.join(current_dir, "data", "cars", "v1", "verbose_logging", "templates"),
     ], car.config_paths)
     self.assertIsNone(car.root_path)
     self.assertEqual({
         "heap_size": "32g",
         "clean_command": "./gradlew clean",
         "verbose_logging": "true",
         "assertions": "true"
     }, car.variables)
     self.assertEqual({"JAVA_TOOL_OPTS": "A B C D E F G H I"}, car.env)
Exemplo n.º 15
0
 def test_load_car_with_mixin_single_config_base(self):
     car = team.load_car(self.team_dir, ["32gheap", "ea"])
     self.assertEqual("32gheap+ea", car.name)
     self.assertEqual([
         os.path.join(current_dir, "data", "cars", "v1", "vanilla",
                      "templates")
     ], car.config_paths)
     self.assertIsNone(car.root_path)
     self.assertEqual(
         {
             "heap_size": "32g",
             "clean_command": "./gradlew clean",
             "assertions": "true"
         }, car.variables)
     self.assertIsNone(car.root_path)
Exemplo n.º 16
0
def create(cfg, metrics_store, all_node_ips, cluster_settings=None, sources=False, build=False, distribution=False, external=False,
           docker=False):
    races_root = paths.races_root(cfg)
    challenge_root_path = paths.race_root(cfg)
    node_ids = cfg.opts("provisioning", "node.ids", mandatory=False)
    # externally provisioned clusters do not support cars / plugins
    if external:
        car = None
        plugins = []
    else:
        repo = team.team_repo(cfg)
        car = team.load_car(repo, cfg.opts("mechanic", "car.names"))
        plugins = team.load_plugins(repo, cfg.opts("mechanic", "car.plugins"), cfg.opts("mechanic", "plugin.params"))

    if sources or distribution:
        s = supplier.create(cfg, sources, distribution, build, challenge_root_path, plugins)
        p = []
        for node_id in node_ids:
            p.append(provisioner.local_provisioner(cfg, car, plugins, cluster_settings, all_node_ips, challenge_root_path, node_id))
        l = launcher.InProcessLauncher(cfg, metrics_store, races_root)
    elif external:
        if cluster_settings:
            logger.warning("Cannot apply challenge-specific cluster settings [%s] for an externally provisioned cluster. Please ensure "
                           "that the cluster settings are present or the benchmark may fail or behave unexpectedly." % cluster_settings)
        if len(plugins) > 0:
            raise exceptions.SystemSetupError("You cannot specify any plugins for externally provisioned clusters. Please remove "
                                              "\"--elasticsearch-plugins\" and try again.")

        s = lambda: None
        p = [provisioner.no_op_provisioner()]
        l = launcher.ExternalLauncher(cfg, metrics_store)
    elif docker:
        if len(plugins) > 0:
            raise exceptions.SystemSetupError("You cannot specify any plugins for Docker clusters. Please remove "
                                              "\"--elasticsearch-plugins\" and try again.")
        s = lambda: None
        p = []
        for node_id in node_ids:
            p.append(provisioner.docker_provisioner(cfg, car, cluster_settings, challenge_root_path, node_id))
        l = launcher.DockerLauncher(cfg, metrics_store)
    else:
        # It is a programmer error (and not a user error) if this function is called with wrong parameters
        raise RuntimeError("One of sources, distribution, docker or external must be True")

    return Mechanic(s, p, l)
Exemplo n.º 17
0
def create(cfg,
           metrics_store,
           all_node_ips,
           cluster_settings=None,
           sources=False,
           build=False,
           distribution=False,
           external=False,
           docker=False):
    races_root = paths.races_root(cfg)
    challenge_root_path = paths.race_root(cfg)
    node_ids = cfg.opts("provisioning", "node.ids", mandatory=False)
    repo = team.team_repo(cfg)
    # externally provisioned clusters do not support cars / plugins
    if external:
        car = None
        plugins = []
    else:
        car = team.load_car(repo, cfg.opts("mechanic", "car.names"))
        plugins = team.load_plugins(repo, cfg.opts("mechanic", "car.plugins"))

    if sources:
        try:
            src_dir = cfg.opts("node", "src.root.dir")
        except config.ConfigError:
            logger.exception("Cannot determine source directory")
            raise exceptions.SystemSetupError(
                "You cannot benchmark Elasticsearch from sources. Did you install Gradle? Please install"
                " all prerequisites and reconfigure Rally with %s configure" %
                PROGRAM_NAME)

        remote_url = cfg.opts("source", "remote.repo.url")
        revision = cfg.opts("mechanic", "source.revision")
        gradle = cfg.opts("build", "gradle.bin")
        java_home = cfg.opts("runtime", "java.home")
        src_config = cfg.all_opts("source")
        s = lambda: supplier.from_sources(
            remote_url, src_dir, revision, gradle, java_home,
            challenge_root_path, plugins, src_config, build)
        p = []
        for node_id in node_ids:
            p.append(
                provisioner.local_provisioner(cfg, car, plugins,
                                              cluster_settings, all_node_ips,
                                              challenge_root_path, node_id))
        l = launcher.InProcessLauncher(cfg, metrics_store, races_root)
    elif distribution:
        version = cfg.opts("mechanic", "distribution.version")
        repo_name = cfg.opts("mechanic", "distribution.repository")
        distributions_root = "%s/%s" % (cfg.opts(
            "node", "root.dir"), cfg.opts("source", "distribution.dir"))
        distribution_cfg = cfg.all_opts("distributions")

        s = lambda: supplier.from_distribution(
            version=version,
            repo_name=repo_name,
            distribution_config=distribution_cfg,
            distributions_root=distributions_root,
            plugins=plugins)
        p = []
        for node_id in node_ids:
            p.append(
                provisioner.local_provisioner(cfg, car, plugins,
                                              cluster_settings, all_node_ips,
                                              challenge_root_path, node_id))
        l = launcher.InProcessLauncher(cfg, metrics_store, races_root)
    elif external:
        if cluster_settings:
            logger.warning(
                "Cannot apply challenge-specific cluster settings [%s] for an externally provisioned cluster. Please ensure "
                "that the cluster settings are present or the benchmark may fail or behave unexpectedly."
                % cluster_settings)
        if len(plugins) > 0:
            raise exceptions.SystemSetupError(
                "You cannot specify any plugins for externally provisioned clusters. Please remove "
                "\"--elasticsearch-plugins\" and try again.")

        s = lambda: None
        p = [provisioner.no_op_provisioner()]
        l = launcher.ExternalLauncher(cfg, metrics_store)
    elif docker:
        if len(plugins) > 0:
            raise exceptions.SystemSetupError(
                "You cannot specify any plugins for Docker clusters. Please remove "
                "\"--elasticsearch-plugins\" and try again.")
        s = lambda: None
        p = []
        for node_id in node_ids:
            p.append(
                provisioner.docker_provisioner(cfg, car, cluster_settings,
                                               challenge_root_path, node_id))
        l = launcher.DockerLauncher(cfg, metrics_store)
    else:
        # It is a programmer error (and not a user error) if this function is called with wrong parameters
        raise RuntimeError(
            "One of sources, distribution, docker or external must be True")

    return Mechanic(s, p, l)
Exemplo n.º 18
0
 def test_raises_error_on_missing_config_base(self):
     with self.assertRaises(exceptions.SystemSetupError) as ctx:
         team.load_car(self.repo, ["missing_config_base"])
     self.assertEqual("At least one config base is required for car ['missing_config_base']", ctx.exception.args[0])
Exemplo n.º 19
0
 def test_raises_error_on_missing_config_base(self):
     with pytest.raises(
         exceptions.SystemSetupError,
         match=r"At least one config base is required for car \['missing_cfg_base'\]",
     ):
         team.load_car(self.team_dir, ["missing_cfg_base"])
Exemplo n.º 20
0
 def test_raises_error_on_missing_config_base(self):
     with self.assertRaises(exceptions.SystemSetupError) as ctx:
         team.load_car(self.repo, ["missing_config_base"])
     self.assertEqual("At least one config base is required for car ['missing_config_base']", ctx.exception.args[0])
Exemplo n.º 21
0
def create(cfg, metrics_store, all_node_ips, cluster_settings=None, sources=False, build=False, distribution=False, external=False,
           docker=False):
    races_root = paths.races_root(cfg)
    challenge_root_path = paths.race_root(cfg)
    node_ids = cfg.opts("provisioning", "node.ids", mandatory=False)
    repo = team.team_repo(cfg)
    # externally provisioned clusters do not support cars / plugins
    if external:
        car = None
        plugins = []
    else:
        car = team.load_car(repo, cfg.opts("mechanic", "car.names"))
        plugins = team.load_plugins(repo, cfg.opts("mechanic", "car.plugins"))

    if sources:
        try:
            src_dir = cfg.opts("node", "src.root.dir")
        except config.ConfigError:
            logger.exception("Cannot determine source directory")
            raise exceptions.SystemSetupError("You cannot benchmark Elasticsearch from sources. Did you install Gradle? Please install"
                                              " all prerequisites and reconfigure Rally with %s configure" % PROGRAM_NAME)

        remote_url = cfg.opts("source", "remote.repo.url")
        revision = cfg.opts("mechanic", "source.revision")
        gradle = cfg.opts("build", "gradle.bin")
        java_home = cfg.opts("runtime", "java.home")
        src_config = cfg.all_opts("source")
        s = lambda: supplier.from_sources(remote_url, src_dir, revision, gradle, java_home, challenge_root_path, plugins, src_config, build)
        p = []
        for node_id in node_ids:
            p.append(provisioner.local_provisioner(cfg, car, plugins, cluster_settings, all_node_ips, challenge_root_path, node_id))
        l = launcher.InProcessLauncher(cfg, metrics_store, races_root)
    elif distribution:
        version = cfg.opts("mechanic", "distribution.version")
        repo_name = cfg.opts("mechanic", "distribution.repository")
        distributions_root = "%s/%s" % (cfg.opts("node", "root.dir"), cfg.opts("source", "distribution.dir"))
        distribution_cfg = cfg.all_opts("distributions")

        s = lambda: supplier.from_distribution(version=version, repo_name=repo_name, distribution_config=distribution_cfg,
                                               distributions_root=distributions_root, plugins=plugins)
        p = []
        for node_id in node_ids:
            p.append(provisioner.local_provisioner(cfg, car, plugins, cluster_settings, all_node_ips, challenge_root_path, node_id))
        l = launcher.InProcessLauncher(cfg, metrics_store, races_root)
    elif external:
        if cluster_settings:
            logger.warning("Cannot apply challenge-specific cluster settings [%s] for an externally provisioned cluster. Please ensure "
                           "that the cluster settings are present or the benchmark may fail or behave unexpectedly." % cluster_settings)
        if len(plugins) > 0:
            raise exceptions.SystemSetupError("You cannot specify any plugins for externally provisioned clusters. Please remove "
                                              "\"--elasticsearch-plugins\" and try again.")

        s = lambda: None
        p = [provisioner.no_op_provisioner()]
        l = launcher.ExternalLauncher(cfg, metrics_store)
    elif docker:
        if len(plugins) > 0:
            raise exceptions.SystemSetupError("You cannot specify any plugins for Docker clusters. Please remove "
                                              "\"--elasticsearch-plugins\" and try again.")
        s = lambda: None
        p = []
        for node_id in node_ids:
            p.append(provisioner.docker_provisioner(cfg, car, cluster_settings, challenge_root_path, node_id))
        l = launcher.DockerLauncher(cfg, metrics_store)
    else:
        # It is a programmer error (and not a user error) if this function is called with wrong parameters
        raise RuntimeError("One of sources, distribution, docker or external must be True")

    return Mechanic(s, p, l)
Exemplo n.º 22
0
 def test_raises_error_on_unknown_car(self):
     with self.assertRaises(exceptions.SystemSetupError) as ctx:
         team.load_car(self.repo, ["don_t-know-you"])
     self.assertRegex(ctx.exception.args[0], r"Unknown car \[don_t-know-you\]. List the available cars with [^\s]+ list cars.")
Exemplo n.º 23
0
 def test_raises_error_if_more_than_one_different_install_hook(self):
     with pytest.raises(
         exceptions.SystemSetupError,
         match=r"Invalid car: \['multi_hook'\]. Multiple bootstrap hooks are forbidden.",
     ):
         team.load_car(self.team_dir, ["multi_hook"])
Exemplo n.º 24
0
 def test_load_known_car(self):
     car = team.load_car(self.repo, ["default"])
     self.assertEqual("default", car.name)
     self.assertEqual([os.path.join(current_dir, "data", "cars", "vanilla")], car.config_paths)
     self.assertEqual({"heap_size": "1g"}, car.variables)
     self.assertEqual({}, car.env)
Exemplo n.º 25
0
 def test_raises_error_if_more_than_one_different_install_hook(self):
     with self.assertRaises(exceptions.SystemSetupError) as ctx:
         team.load_car(self.team_dir, ["multi_hook"])
     self.assertEqual(
         "Invalid car: ['multi_hook']. Multiple bootstrap hooks are forbidden.",
         ctx.exception.args[0])
Exemplo n.º 26
0
 def test_raises_error_on_unknown_car(self):
     with pytest.raises(
         exceptions.SystemSetupError,
         match=r"Unknown car \[don_t-know-you\]. List the available cars with [^\s]+ list cars.",
     ):
         team.load_car(self.team_dir, ["don_t-know-you"])