Skip to content

Commit

Permalink
Not every composable template has a top-level template
Browse files Browse the repository at this point in the history
  • Loading branch information
cavokz committed May 16, 2022
1 parent 2b0eb0c commit 7b31dec
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
6 changes: 2 additions & 4 deletions esrally/track/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,10 +444,8 @@ def __init__(self, track, params, templates, **kwargs):
template_definitions = []
for template in templates:
if not filter_template or template.name == filter_template:
body = template.content
if body and "template" in body:
body = CreateComposableTemplateParamSource._create_or_merge(template.content, ["template", "settings"], settings)
template_definitions.append((template.name, body))
body = self._create_or_merge(template.content, ["template", "settings"], settings)
template_definitions.append((template.name, body))
if filter_template and not template_definitions:
template_names = ", ".join([template.name for template in templates])
raise exceptions.InvalidSyntax(
Expand Down
29 changes: 29 additions & 0 deletions tests/track/params_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2161,6 +2161,35 @@ def test_create_composable_index_template_from_track_wrong_filter(self):
"Unknown template: t3. Available templates: t1, t2."
)

def test_create_composable_index_template_from_track_no_template(self):
tpl = track.IndexTemplate(
name="default",
pattern="*",
content={
"index_patterns": ["my*"],
"composed_of": ["ct1", "ct2"],
},
)

source = params.CreateComposableTemplateParamSource(
track=track.Track(name="unit-test", composable_templates=[tpl]),
params={
"settings": {"index.number_of_replicas": 1},
},
)

p = source.params()

assert len(p["templates"]) == 1
assert p["request-params"] == {}
template, body = p["templates"][0]
assert template == "default"
assert body == {
"index_patterns": ["my*"],
"template": {"settings": {"index.number_of_replicas": 1}},
"composed_of": ["ct1", "ct2"],
}

def test_create_or_merge(self):
content = params.CreateComposableTemplateParamSource._create_or_merge(
{"parent": {}},
Expand Down

0 comments on commit 7b31dec

Please sign in to comment.