diff --git a/docs/command_line_reference.rst b/docs/command_line_reference.rst index 34d79f199..b68162864 100644 --- a/docs/command_line_reference.rst +++ b/docs/command_line_reference.rst @@ -272,6 +272,26 @@ A unique identifier for an installation. This id is automatically generated by R Used to specify the current node's name in the cluster when it is setup via the ``install`` subcommand. +``cluster-name`` +~~~~~~~~~~~~~~~~ + +.. warning:: + + This command line parameter is experimental. Expect the functionality and the command line interface to change significantly even in patch releases. + +This parameter is useful in benchmarks involved multiple Elasticsearch clusters. It's used to configure the cluster name of the current Elasticsearch node when it is setup via the ``install`` or ``race`` subcommand. The following example sets up two Elasticsearch clusters: ``cluster-1`` and ``cluster-2``, and each has two nodes:: + + # install node-1 in cluster-1 + esrally install --quiet --distribution-version=8.2.2 --node-name="node-1" --cluster-name=cluster-1 --network-host="192.168.1.1" --http-port=39200 --master-nodes="node-1" --seed-hosts="192.168.1.1:39300,192.168.1.2:39300" + # install node-2 in cluster-1 + esrally install --quiet --distribution-version=8.2.2 --node-name="node-2" --cluster-name=cluster-1 --network-host="192.168.1.2" --http-port=39200 --master-nodes="node-1" --seed-hosts="192.168.1.1:39300,192.168.1.2:39300" + # install node-3 in cluster-2 + esrally install --quiet --distribution-version=8.2.2 --node-name="node-3" --cluster-name=cluster-2 --network-host="192.168.1.3" --http-port=39200 --master-nodes="node-3" --seed-hosts="192.168.1.3:39300,192.168.1.4:39300" + # install node-4 in cluster-2 + esrally install --quiet --distribution-version=8.2.2 --node-name="node-4" --cluster-name=cluster-2 --network-host="192.168.1.4" --http-port=39200 --master-nodes="node-3" --seed-hosts="192.168.1.3:39300,192.168.1.4:39300" + +If the ``cluster-name`` parameter is not specified, Rally will use ``rally-benchmark`` as the default cluster name. + ``network-host`` ~~~~~~~~~~~~~~~~ diff --git a/esrally/mechanic/provisioner.py b/esrally/mechanic/provisioner.py index 6dc829be8..66c5da40b 100644 --- a/esrally/mechanic/provisioner.py +++ b/esrally/mechanic/provisioner.py @@ -31,6 +31,7 @@ def local(cfg, car, plugins, ip, http_port, all_node_ips, all_node_names, target_root, node_name): distribution_version = cfg.opts("mechanic", "distribution.version", mandatory=False) + cluster_name = cfg.opts("mechanic", "cluster.name") node_root_dir = os.path.join(target_root, node_name) @@ -38,7 +39,9 @@ def local(cfg, car, plugins, ip, http_port, all_node_ips, all_node_names, target runtime_jdk = car.mandatory_var("runtime.jdk") _, java_home = java_resolver.java_home(runtime_jdk, cfg.opts("mechanic", "runtime.jdk"), runtime_jdk_bundled) - es_installer = ElasticsearchInstaller(car, java_home, node_name, node_root_dir, all_node_ips, all_node_names, ip, http_port) + es_installer = ElasticsearchInstaller( + car, java_home, node_name, cluster_name, node_root_dir, all_node_ips, all_node_names, ip, http_port + ) plugin_installers = [PluginInstaller(plugin, java_home) for plugin in plugins] return BareProvisioner(es_installer, plugin_installers, distribution_version=distribution_version) @@ -46,11 +49,12 @@ def local(cfg, car, plugins, ip, http_port, all_node_ips, all_node_names, target def docker(cfg, car, ip, http_port, target_root, node_name): distribution_version = cfg.opts("mechanic", "distribution.version", mandatory=False) + cluster_name = cfg.opts("mechanic", "cluster.name") rally_root = cfg.opts("node", "rally.root") node_root_dir = os.path.join(target_root, node_name) - return DockerProvisioner(car, node_name, ip, http_port, node_root_dir, distribution_version, rally_root) + return DockerProvisioner(car, node_name, cluster_name, ip, http_port, node_root_dir, distribution_version, rally_root) class NodeConfiguration: @@ -250,6 +254,7 @@ def __init__( car, java_home, node_name, + cluster_name, node_root_dir, all_node_ips, all_node_names, @@ -260,6 +265,7 @@ def __init__( self.car = car self.java_home = java_home self.node_name = node_name + self.cluster_name = cluster_name self.node_root_dir = node_root_dir self.install_dir = os.path.join(node_root_dir, "install") self.node_log_dir = os.path.join(node_root_dir, "logs", "server") @@ -303,7 +309,7 @@ def variables(self): network_host = self.node_ip defaults = { - "cluster_name": "rally-benchmark", + "cluster_name": self.cluster_name, "node_name": self.node_name, "data_paths": self.data_paths, "log_path": self.node_log_dir, @@ -404,9 +410,10 @@ def sub_plugin_name(self): class DockerProvisioner: - def __init__(self, car, node_name, ip, http_port, node_root_dir, distribution_version, rally_root): + def __init__(self, car, node_name, cluster_name, ip, http_port, node_root_dir, distribution_version, rally_root): self.car = car self.node_name = node_name + self.cluster_name = cluster_name self.node_ip = ip self.http_port = http_port self.node_root_dir = node_root_dir @@ -420,7 +427,7 @@ def __init__(self, car, node_name, ip, http_port, node_root_dir, distribution_ve self.logger = logging.getLogger(__name__) provisioner_defaults = { - "cluster_name": "rally-benchmark", + "cluster_name": self.cluster_name, "node_name": self.node_name, # we bind-mount the directories below on the host to these ones. "install_root_path": "/usr/share/elasticsearch", diff --git a/esrally/rally.py b/esrally/rally.py index dc38fea95..58a068081 100644 --- a/esrally/rally.py +++ b/esrally/rally.py @@ -400,6 +400,12 @@ def add_track_source(subparser): help="A comma-separated list of the initial seed host IPs", default="", ) + for p in [race_parser, install_parser]: + p.add_argument( + "--cluster-name", + help="The name of this Elasticsearch cluster", + default="rally-benchmark", + ) start_parser = subparsers.add_parser("start", help="Starts an Elasticsearch node locally") start_parser.add_argument( @@ -927,6 +933,7 @@ def dispatch_sub_command(arg_parser, args, cfg): cfg.add(config.Scope.applicationOverride, "mechanic", "build.type", args.build_type) cfg.add(config.Scope.applicationOverride, "mechanic", "runtime.jdk", args.runtime_jdk) cfg.add(config.Scope.applicationOverride, "mechanic", "node.name", args.node_name) + cfg.add(config.Scope.applicationOverride, "mechanic", "cluster.name", args.cluster_name) cfg.add(config.Scope.applicationOverride, "mechanic", "master.nodes", opts.csv_to_list(args.master_nodes)) cfg.add(config.Scope.applicationOverride, "mechanic", "seed.hosts", opts.csv_to_list(args.seed_hosts)) cfg.add(config.Scope.applicationOverride, "mechanic", "car.plugins", opts.csv_to_list(args.elasticsearch_plugins)) @@ -970,6 +977,7 @@ def dispatch_sub_command(arg_parser, args, cfg): cfg.add(config.Scope.applicationOverride, "mechanic", "plugin.params", opts.to_dict(args.plugin_params)) cfg.add(config.Scope.applicationOverride, "mechanic", "preserve.install", convert.to_bool(args.preserve_install)) cfg.add(config.Scope.applicationOverride, "mechanic", "skip.rest.api.check", convert.to_bool(args.skip_rest_api_check)) + cfg.add(config.Scope.applicationOverride, "mechanic", "cluster.name", args.cluster_name) configure_reporting_params(args, cfg) race(cfg, args.kill_running_processes) diff --git a/it/__init__.py b/it/__init__.py index fb88c9a03..852388d07 100644 --- a/it/__init__.py +++ b/it/__init__.py @@ -160,7 +160,7 @@ def install(self, distribution_version, node_name, car, http_port): output = process.run_subprocess_with_output( "esrally install --configuration-name={cfg} --quiet --distribution-version={dist} --build-type=tar " "--http-port={http_port} --node={node_name} --master-nodes={node_name} --car={car} " - '--seed-hosts="127.0.0.1:{transport_port}"'.format( + '--seed-hosts="127.0.0.1:{transport_port}" --cluster-name={cfg}'.format( cfg=self.cfg, dist=distribution_version, http_port=http_port, @@ -179,6 +179,7 @@ def start(self, race_id): raise AssertionError("Failed to start Elasticsearch test cluster.") es = client.EsClientFactory(hosts=[{"host": "127.0.0.1", "port": self.http_port}], client_options={}).create() client.wait_for_rest_layer(es) + assert es.info()["cluster_name"] == self.cfg def stop(self): if self.installation_id: diff --git a/tests/mechanic/provisioner_test.py b/tests/mechanic/provisioner_test.py index 5be00f02c..c3778b2a7 100644 --- a/tests/mechanic/provisioner_test.py +++ b/tests/mechanic/provisioner_test.py @@ -52,6 +52,7 @@ def null_apply_config(source_root_path, target_root_path, config_vars): ), java_home="/usr/local/javas/java8", node_name="rally-node-0", + cluster_name="rally-benchmark", node_root_dir=HOME_DIR + "/.rally/benchmarks/races/unittest", all_node_ips=["10.17.22.22", "10.17.22.23"], all_node_names=["rally-node-0", "rally-node-1"], @@ -157,6 +158,7 @@ def null_apply_config(source_root_path, target_root_path, config_vars): ), java_home="/usr/local/javas/java8", node_name="rally-node-0", + cluster_name="rally-benchmark", node_root_dir=HOME_DIR + "/.rally/benchmarks/races/unittest", all_node_ips=["10.17.22.22", "10.17.22.23"], all_node_names=["rally-node-0", "rally-node-1"], @@ -242,6 +244,7 @@ def null_apply_config(source_root_path, target_root_path, config_vars): ), java_home="/usr/local/javas/java8", node_name="rally-node-0", + cluster_name="rally-benchmark", node_root_dir=HOME_DIR + "/.rally/benchmarks/races/unittest", all_node_ips=["10.17.22.22", "10.17.22.23"], all_node_names=["rally-node-0", "rally-node-1"], @@ -322,6 +325,7 @@ def test_prepare_default_data_paths(self, mock_rm, mock_ensure_dir, mock_decompr car=team.Car(names="defaults", root_path=None, config_paths="/tmp"), java_home="/usr/local/javas/java8", node_name="rally-node-0", + cluster_name="rally-benchmark", all_node_ips=["10.17.22.22", "10.17.22.23"], all_node_names=["rally-node-0", "rally-node-1"], ip="10.17.22.23", @@ -366,6 +370,7 @@ def test_prepare_user_provided_data_path(self, mock_rm, mock_ensure_dir, mock_de ), java_home="/usr/local/javas/java8", node_name="rally-node-0", + cluster_name="rally-benchmark", all_node_ips=["10.17.22.22", "10.17.22.23"], all_node_names=["rally-node-0", "rally-node-1"], ip="10.17.22.23", @@ -406,6 +411,7 @@ def test_invokes_hook_with_java_home(self): ), java_home="/usr/local/javas/java8", node_name="rally-node-0", + cluster_name="rally-benchmark", all_node_ips=["10.17.22.22", "10.17.22.23"], all_node_names=["rally-node-0", "rally-node-1"], ip="10.17.22.23", @@ -432,6 +438,7 @@ def test_invokes_hook_no_java_home(self): ), java_home=None, node_name="rally-node-0", + cluster_name="rally-benchmark", all_node_ips=["10.17.22.22", "10.17.22.23"], all_node_names=["rally-node-0", "rally-node-1"], ip="10.17.22.23", @@ -618,6 +625,7 @@ def test_provisioning_with_defaults(self, uuid4): docker = provisioner.DockerProvisioner( car=c, node_name="rally-node-0", + cluster_name="rally-benchmark", ip=node_ip, http_port=39200, node_root_dir=node_root_dir, @@ -711,6 +719,7 @@ def test_provisioning_with_variables(self, uuid4): docker = provisioner.DockerProvisioner( car=c, node_name="rally-node-0", + cluster_name="rally-benchmark", ip=node_ip, http_port=39200, node_root_dir=node_root_dir,