Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Executable #316

Merged
merged 2 commits into from
May 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,15 @@ CHANGELOG
unreleased
-------

- [bugfix] Handle properly elasticsearch versions with two-digit minor version
Features
++++++++

- Add command line and ini configuration option for the executable.

Bugfix
++++++

- Handle properly elasticsearch versions with two-digit minor version

2.0.1
-------
Expand Down
7 changes: 7 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

.. image:: https://raw.githubusercontent.com/ClearcodeHQ/pytest-elasticsearch/master/logo.png
:width: 100px
:height: 100px
Expand Down Expand Up @@ -105,6 +106,12 @@ You can pick which you prefer, but remember that these settings are handled in t
- pytest.ini option
- Noop process fixture
- Default
* - Elasticsearch executable
- executable
- --elasticsearch_executable
- elasticsearch_executable
-
- /usr/share/elasticsearch/bin/elasticsearch
* - logs directory
- logsdir
- --elasticsearch-logsdir
Expand Down
8 changes: 5 additions & 3 deletions src/pytest_elasticsearch/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def return_config(request):
options = [
'port', 'transport_tcp_port', 'host', 'cluster_name',
'network_publish_host',
'index_store_type', 'logs_prefix', 'logsdir'
'index_store_type', 'logs_prefix', 'logsdir', 'executable'
]
for option in options:
option_name = 'elasticsearch_' + option
Expand All @@ -47,11 +47,12 @@ def return_config(request):
return config


def elasticsearch_proc(executable='/usr/share/elasticsearch/bin/elasticsearch',
def elasticsearch_proc(executable=None,
host=None, port=-1, transport_tcp_port=None,
cluster_name=None, network_publish_host=None,
index_store_type=None, logs_prefix=None,
elasticsearch_logsdir=None):

"""
Create elasticsearch process fixture.

Expand Down Expand Up @@ -83,6 +84,7 @@ def elasticsearch_proc_fixture(request):
"""Elasticsearch process starting fixture."""
config = return_config(request)
elasticsearch_host = host or config['host']
elasticsearch_executable = executable or config['executable']

elasticsearch_port = get_port(port) or get_port(config['port'])
elasticsearch_transport_port = get_port(transport_tcp_port) or \
Expand Down Expand Up @@ -110,7 +112,7 @@ def elasticsearch_proc_fixture(request):
gettempdir(), 'elasticsearch_{0}_tmp'.format(elasticsearch_port))

elasticsearch_executor = ElasticSearchExecutor(
executable,
elasticsearch_executable,
elasticsearch_host,
elasticsearch_port,
elasticsearch_transport_port,
Expand Down
17 changes: 15 additions & 2 deletions src/pytest_elasticsearch/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
# pylint:disable=invalid-name
_help_logsdir = 'Elasticsearch logs directory'
_help_host = 'Elasticsearch host'
_help_executable = 'Elasticsearch executable'
_help_port = 'Elasticsearch port'
_help_cluster_name = 'Cluster name of the elasticsearch process fixture'
_help_index_store_type = \
Expand All @@ -49,6 +50,12 @@ def pytest_addoption(parser):
default='127.0.0.1'
)

parser.addini(
name='elasticsearch_executable',
help=_help_executable,
default='/usr/share/elasticsearch/bin/elasticsearch'
)

parser.addini(
name='elasticsearch_cluster_name',
help=_help_cluster_name,
Expand All @@ -68,8 +75,7 @@ def pytest_addoption(parser):
)

parser.addini(
name='elasticsearch_logs_prefix',
help=_help_logs_prefix,
name='elasticsearch_logs_prefix', help=_help_logs_prefix,
default=''
)

Expand Down Expand Up @@ -100,6 +106,13 @@ def pytest_addoption(parser):
help=_help_host,
)

parser.addoption(
'--elasticsearch_executable',
action='store',
dest='elasticsearch_executable',
help=_help_executable,
)

parser.addoption(
'--elasticsearch-cluster-name',
action='store',
Expand Down