Skip to content

Commit

Permalink
Allow to override plugin variables
Browse files Browse the repository at this point in the history
Closes #398
  • Loading branch information
danielmitterdorfer committed Jan 17, 2018
1 parent 902da82 commit 9925597
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 6 deletions.
10 changes: 10 additions & 0 deletions docs/command_line_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,16 @@ Example::

In this example, Rally will install the ``analysis-icu`` plugin and the ``x-pack`` plugin with the ``security`` configuration. See the reference documentation about :doc:`Elasticsearch plugins </elasticsearch_plugins>` for more details.

``plugin-params``
~~~~~~~~~~~~~~~~~

Allows to override variables of Elasticsearch plugins.

Example::

esrally --distribution-version=6.1.1. --elasticsearch-plugins="x-pack:monitoring-http" --plugin-params="monitoring_type:'https',monitoring_host:'some_remote_host',monitoring_port:10200,monitoring_user:'rally',monitoring_password:'m0n1t0r1ng'"

This enables the HTTP exporter of `X-Pack Monitoring <https://www.elastic.co/products/x-pack/monitoring>`_ and exports the data to the configured monitoring host.

``pipeline``
~~~~~~~~~~~~
Expand Down
8 changes: 8 additions & 0 deletions docs/elasticsearch_plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ To see which plugins are available, run ``esrally list elasticsearch-plugins``::
repository-s3
store-smb
x-pack monitoring-local
x-pack monitoring-http
x-pack security

Rally supports plugins only for Elasticsearch 5.0 or better. As the availability of plugins may change from release to release we recommend that you include the ``--distribution-version`` parameter when listing plugins. By default Rally assumes that you want to benchmark the latest master version of Elasticsearch.
Expand Down Expand Up @@ -72,6 +73,12 @@ As mentioned above, Rally also allows you to specify a plugin configuration and
.. note::
To benchmark the ``security`` configuration of ``x-pack`` you need to add the following command line options: ``--client-options="use_ssl:true,verify_certs:false,basic_auth_user:'rally',basic_auth_password:'rally-password'" --cluster-health=yellow``

You can also override plugin variables with ``--plugin-params`` which is needed for example if you want to use the ``monitoring-http`` configuration in order to export monitoring data. You can export monitoring data e.g. with the following configuration::

--elasticsearch-plugins="x-pack:monitoring-http" --plugin-params="monitoring_type:'https',monitoring_host:'some_remote_host',monitoring_port:10200,monitoring_user:'rally',monitoring_password:'m0n1t0r1ng'"

The ``monitoring_user`` and ``monitoring_password`` parameters are optional, the other parameters are mandatory. For more details on the configuration options, please see the `Monitoring plugin documentation <https://www.elastic.co/guide/en/x-pack/current/monitoring-production.html>`_.

If you are behind a proxy, please set the environment variable ``ES_JAVA_OPTS`` accordingly on each target machine as described in the `Elasticsearch plugin documentation <https://www.elastic.co/guide/en/elasticsearch/plugins/current/_other_command_line_parameters.html#_proxy_settings>`_.

Building plugins from sources
Expand Down Expand Up @@ -217,6 +224,7 @@ Rally will now know about ``myplugin`` and its two configurations. Let's check t
repository-s3
store-smb
x-pack monitoring-local
x-pack monitoring-http
x-pack security

As ``myplugin`` is not a core plugin, the Elasticsearch plugin manager does not know from where to install it, so we need to add the download URL to ``~/.rally/rally.ini`` as before::
Expand Down
2 changes: 1 addition & 1 deletion esrally/mechanic/mechanic.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ def create(cfg, metrics_store, all_node_ips, cluster_settings=None, sources=Fals
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"))
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)
Expand Down
12 changes: 7 additions & 5 deletions esrally/mechanic/team.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ def list_plugins(cfg):
console.println("No Elasticsearch plugins are available.\n")


def load_plugin(repo, name, config):
def load_plugin(repo, name, config, plugin_params={}):
if config is not None:
logger.info("Loading plugin [%s] with configuration(s) [%s]." % (name, config))
else:
logger.info("Loading plugin [%s] with default configuration." % name)
return PluginLoader(repo).load_plugin(name, config)
return PluginLoader(repo).load_plugin(name, config, plugin_params)


def load_plugins(repo, plugin_names):
def load_plugins(repo, plugin_names, plugin_params={}):
def name_and_config(p):
plugin_spec = p.split(":")
if len(plugin_spec) == 1:
Expand All @@ -79,7 +79,7 @@ def name_and_config(p):
plugins = []
for plugin in plugin_names:
plugin_name, plugin_config = name_and_config(plugin)
plugins.append(load_plugin(repo, plugin_name, plugin_config))
plugins.append(load_plugin(repo, plugin_name, plugin_config, plugin_params))
return plugins


Expand Down Expand Up @@ -251,7 +251,7 @@ def _plugin_name_to_file(self, plugin_name):
def _core_plugin(self, name):
return next((p for p in self._core_plugins() if p.name == name and p.config is None), None)

def load_plugin(self, name, config_names):
def load_plugin(self, name, config_names, plugin_params={}):
root_path = self._plugin_root_path(name)
if not config_names:
# maybe we only have a config folder but nothing else (e.g. if there is only an install hook)
Expand Down Expand Up @@ -300,6 +300,8 @@ def load_plugin(self, name, config_names):
if "variables" in config.sections():
for k, v in config["variables"].items():
variables[k] = v
# add all plugin params here to override any defaults
variables.update(plugin_params)

# maybe one of the configs is really just for providing variables. However, we still require one config base overall.
if len(config_paths) == 0:
Expand Down
6 changes: 6 additions & 0 deletions esrally/rally.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,11 @@ def positive_number(v):
"--elasticsearch-plugins",
help="define the Elasticsearch plugins to install. (default: install no plugins).",
default="")
p.add_argument(
"--plugin-params",
help="define a comma-separate list of key:value pairs that are injected verbatim to all plugins as variables",
default=""
)
p.add_argument(
"--target-hosts",
help="define a comma-separated list of host:port pairs which should be targeted iff using the pipeline 'benchmark-only' "
Expand Down Expand Up @@ -649,6 +654,7 @@ def main():
cfg.add(config.Scope.applicationOverride, "mechanic", "repository.name", args.team_repository)
cfg.add(config.Scope.applicationOverride, "mechanic", "car.names", csv_to_list(args.car))
cfg.add(config.Scope.applicationOverride, "mechanic", "car.plugins", csv_to_list(args.elasticsearch_plugins))
cfg.add(config.Scope.applicationOverride, "mechanic", "plugin.params", kv_to_map(csv_to_list(args.plugin_params)))
cfg.add(config.Scope.applicationOverride, "mechanic", "node.datapaths", csv_to_list(args.data_paths))
if args.keep_cluster_running:
cfg.add(config.Scope.applicationOverride, "mechanic", "keep.running", True)
Expand Down

0 comments on commit 9925597

Please sign in to comment.