Skip to content

Commit

Permalink
Send version with esql
Browse files Browse the repository at this point in the history
Elasticsearch version 8.14 will require a `version` parameter. This
defaults it to the first released version. That version is supported in
8.13.3, but not before that.
  • Loading branch information
nik9000 committed Apr 12, 2024
1 parent c76c90b commit 8773fa4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Once your changes and tests are ready to submit for review:

Ensure that all tests pass by running `make check-all`. This runs sequentially lint checks, unit tests and integration tests. These can be executed in isolation using `make lint`, `make test` and `make it` respectively, in case you need to iterate over a subset of tests.

Note: Integration tests are much slower than unit tests.
Note: Integration tests are much slower than unit tests and require `docker-compose`.

3. Sign the Contributor License Agreement

Expand Down
1 change: 1 addition & 0 deletions esrally/driver/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -2892,6 +2892,7 @@ async def __call__(self, es, params):
query = mandatory(params, "query", self)
body = params.get("body", {})
body["query"] = query
body["version"] = params.get("version", "2024.04.01.πŸš€")
query_filter = params.get("filter")
if query_filter:
body["filter"] = query_filter
Expand Down
17 changes: 14 additions & 3 deletions tests/driver/runner_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7686,7 +7686,7 @@ async def test_esql_without_query_filter(self, es):
esql = runner.Esql()
result = await esql(es, params={"query": "from logs-* | stats c = count(*)"})
assert result == {"weight": 1, "unit": "ops", "success": True}
expected_body = {"query": "from logs-* | stats c = count(*)"}
expected_body = {"query": "from logs-* | stats c = count(*)", "version": "2024.04.01.πŸš€"}
es.perform_request.assert_awaited_once_with(method="POST", path="/_query", headers=None, body=expected_body, params={})

@mock.patch("elasticsearch.Elasticsearch")
Expand All @@ -7698,7 +7698,7 @@ async def test_esql_with_query_filter(self, es):
query_filter = {"range": {"@timestamp": {"gte": "2023"}}}
result = await esql(es, params={"query": "from * | limit 1", "filter": query_filter})
assert result == {"weight": 1, "unit": "ops", "success": True}
expected_body = {"query": "from * | limit 1", "filter": query_filter}
expected_body = {"query": "from * | limit 1", "version": "2024.04.01.πŸš€", "filter": query_filter}
es.perform_request.assert_awaited_once_with(method="POST", path="/_query", headers=None, body=expected_body, params={})

@mock.patch("elasticsearch.Elasticsearch")
Expand All @@ -7711,5 +7711,16 @@ async def test_esql_with_body(self, es):
result = await esql(es, params={"query": "from * | limit 1", "body": {"pragma": pragma}})
assert result == {"weight": 1, "unit": "ops", "success": True}

expected_body = {"pragma": pragma, "query": "from * | limit 1"}
expected_body = {"pragma": pragma, "query": "from * | limit 1", "version": "2024.04.01.πŸš€"}
es.perform_request.assert_awaited_once_with(method="POST", path="/_query", headers=None, body=expected_body, params={})

@mock.patch("elasticsearch.Elasticsearch")
@pytest.mark.asyncio
async def test_esql_with_version(self, es):
es.options.return_value = es
es.perform_request = mock.AsyncMock()
esql = runner.Esql()
result = await esql(es, params={"query": "from * | limit 1", "version": "wow"})
assert result == {"weight": 1, "unit": "ops", "success": True}
expected_body = {"query": "from * | limit 1", "version": "wow"}
es.perform_request.assert_awaited_once_with(method="POST", path="/_query", headers=None, body=expected_body, params={})

0 comments on commit 8773fa4

Please sign in to comment.