Skip to content

Commit

Permalink
Fix composable templates runner (#1294)
Browse files Browse the repository at this point in the history
The `put_index_template` method is not available on the `cluster` class,
so with this commit we change this to the correct `indices` class.
  • Loading branch information
b-deam authored Jun 29, 2021
1 parent c1a792a commit 87a0a4e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion esrally/driver/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -1309,7 +1309,7 @@ async def __call__(self, es, params):
templates = mandatory(params, "templates", self)
request_params = mandatory(params, "request-params", self)
for template, body in templates:
await es.cluster.put_index_template(name=template, body=body, params=request_params)
await es.indices.put_index_template(name=template, body=body, params=request_params)

return {
"weight": len(templates),
Expand Down
8 changes: 4 additions & 4 deletions tests/driver/runner_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2895,7 +2895,7 @@ class CreateComposableTemplateRunnerTests(TestCase):
@mock.patch("elasticsearch.Elasticsearch")
@run_async
async def test_create_index_templates(self, es):
es.cluster.put_index_template.return_value = as_future()
es.indices.put_index_template.return_value = as_future()
r = runner.CreateComposableTemplate()
params = {
"templates": [
Expand All @@ -2915,7 +2915,7 @@ async def test_create_index_templates(self, es):
"unit": "ops",
"success": True
}, result)
es.cluster.put_index_template.assert_has_calls([
es.indices.put_index_template.assert_has_calls([
mock.call(name="templateA", body={"index_patterns":["logs-*"],"template":{"settings":{"index.number_of_shards":3}},
"composed_of":["ct1","ct2"]}, params=params["request-params"]),
mock.call(name="templateB", body={"index_patterns":["metrics-*"],"template":{"settings":{"index.number_of_shards":2}},
Expand All @@ -2925,7 +2925,7 @@ async def test_create_index_templates(self, es):
@mock.patch("elasticsearch.Elasticsearch")
@run_async
async def test_param_templates_mandatory(self, es):
es.cluster.put_index_template.return_value = as_future()
es.indices.put_index_template.return_value = as_future()

r = runner.CreateComposableTemplate()

Expand All @@ -2935,7 +2935,7 @@ async def test_param_templates_mandatory(self, es):
"'templates'. Add it to your parameter source and try again."):
await r(es, params)

self.assertEqual(0, es.cluster.put_index_template.call_count)
self.assertEqual(0, es.indices.put_index_template.call_count)


class DeleteComposableTemplateRunnerTests(TestCase):
Expand Down

0 comments on commit 87a0a4e

Please sign in to comment.