diff --git a/esrally/track/params.py b/esrally/track/params.py index 71c2ef48d..0c24e67b7 100644 --- a/esrally/track/params.py +++ b/esrally/track/params.py @@ -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( diff --git a/tests/track/params_test.py b/tests/track/params_test.py index e8d36c583..32bdf1d3b 100644 --- a/tests/track/params_test.py +++ b/tests/track/params_test.py @@ -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": {}},