Skip to content

Commit

Permalink
Enable artifact downloads via S3 and GS (#1293)
Browse files Browse the repository at this point in the history
With this commit we add a query parameter that is used to correct telemetry only
if artifacts are downloaded via http(s). For other protocols, such as S3, we
don't add it, as query parameters are not supported.
  • Loading branch information
Hendrik Muhs authored Jun 28, 2021
1 parent d9402ec commit 44fda0c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 6 additions & 1 deletion esrally/utils/net.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,13 @@ def download_http(url, local_path, expected_size_in_bytes=None, progress_indicat
progress_indicator(bytes_read, size_from_content_header)
return expected_size_in_bytes


def add_url_param_elastic_no_kpi(url):
return _add_url_param(url, {"x-elastic-no-kpi": "true"})
scheme = urllib3.util.parse_url(url).scheme
if scheme.startswith("http"):
return _add_url_param(url, {"x-elastic-no-kpi": "true"})
else:
return url


def _add_url_param(url, params):
Expand Down
5 changes: 5 additions & 0 deletions tests/utils/net_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ def test_add_url_param_elastic_no_kpi(self):
assert net.add_url_param_elastic_no_kpi(url) == \
"https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.2.0.tar.gz?x-elastic-no-kpi=true"

def test_add_url_param_elastic_no_kpi_no_http(self):
url = "gs://my_bucket/builds/elasticsearch/elasticsearch-8.0.0-SNAPSHOT.tar.gz"
assert net.add_url_param_elastic_no_kpi(url) == \
"gs://my_bucket/builds/elasticsearch/elasticsearch-8.0.0-SNAPSHOT.tar.gz"

def test_add_url_param_encoding_and_update(self):
url = "https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.2.0.tar.gz?flag1=true"
params = {"flag1": "test me", "flag2": "test@me"}
Expand Down

0 comments on commit 44fda0c

Please sign in to comment.