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

Elastic client now uses url_prefix from host dictionary. #1869

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion esrally/client/factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def __init__(self, hosts, client_options, distribution_version=None, distributio
def host_string(host):
# protocol can be set at either host or client opts level
protocol = "https" if client_options.get("use_ssl") or host.get("use_ssl") else "http"
return f"{protocol}://{host['host']}:{host['port']}"
path = host.get("url_prefix", "")
return f"{protocol}://{host['host']}:{host['port']}{path}"

self.hosts = [host_string(h) for h in hosts]
self.client_options = dict(client_options)
Expand Down
14 changes: 14 additions & 0 deletions tests/client/factory_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,20 @@ def test_check_hostname_false_when_host_is_ip(self):
assert f.ssl_context.check_hostname is False
assert f.ssl_context.verify_mode == ssl.CERT_REQUIRED

def test_create_http_connection_with_path(self):
hosts = [{"host": "localhost", "port": 9200, "url_prefix": "/path"}]
client_options = {}
# make a copy so we can verify later that the factory did not modify it
original_client_options = dict(client_options)

f = client.EsClientFactory(hosts, client_options)

assert f.hosts == ["http://localhost:9200/path"]
assert f.ssl_context is None
assert "basic_auth" not in f.client_options

assert client_options == original_client_options

@mock.patch("esrally.client.asynchronous.RallyAsyncElasticsearch")
def test_create_async_client_with_api_key_auth_override(self, es):
hosts = [{"host": "localhost", "port": 9200}]
Expand Down
Loading