From e83cf3d9a8cb6247760cc3da45ee0b1f723e7b25 Mon Sep 17 00:00:00 2001 From: Gareth Ellis Date: Wed, 29 Jan 2025 15:34:21 +0100 Subject: [PATCH 1/3] Improve error messages regarding track syntax errors --- esrally/track/loader.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/esrally/track/loader.py b/esrally/track/loader.py index 010117af1..069108eb2 100644 --- a/esrally/track/loader.py +++ b/esrally/track/loader.py @@ -1120,6 +1120,10 @@ def read(self, track_name, track_spec_file, mapping_dir): f.write(rendered) self.logger.info("Final rendered track for '%s' has been written to '%s'.", track_spec_file, tmp.name) track_spec = json.loads(rendered) + except jinja2.exceptions.TemplateSyntaxError as te: + self.logger.exception("Could not load [%s] due to Jinja Syntax Exception.", track_spec_file) + msg = f"Could not load '{track_spec_file}' due to Jinja Syntax Exception. The track file ({tmp.name}) likely hasn't been writen" + raise TrackSyntaxError(msg, te) except jinja2.exceptions.TemplateNotFound: self.logger.exception("Could not load [%s]", track_spec_file) raise exceptions.SystemSetupError(f"Track {track_name} does not exist") @@ -1697,6 +1701,8 @@ def parse_task( default_ramp_up_time_period=None, completed_by_name=None, ): + if "operation" not in task_spec: + raise TrackSyntaxError("Operation missing from task spec %s in challenge '%s'.", task_spec, challenge_name) op_spec = task_spec["operation"] if isinstance(op_spec, str) and op_spec in ops: op = ops[op_spec] From 7eec6aa1bad62709bcd9c070d88344bc11289544 Mon Sep 17 00:00:00 2001 From: Gareth Ellis Date: Wed, 29 Jan 2025 15:43:55 +0100 Subject: [PATCH 2/3] lint --- esrally/track/loader.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/esrally/track/loader.py b/esrally/track/loader.py index 069108eb2..d209b80f9 100644 --- a/esrally/track/loader.py +++ b/esrally/track/loader.py @@ -1122,7 +1122,8 @@ def read(self, track_name, track_spec_file, mapping_dir): track_spec = json.loads(rendered) except jinja2.exceptions.TemplateSyntaxError as te: self.logger.exception("Could not load [%s] due to Jinja Syntax Exception.", track_spec_file) - msg = f"Could not load '{track_spec_file}' due to Jinja Syntax Exception. The track file ({tmp.name}) likely hasn't been writen" + msg = f"Could not load '{track_spec_file}' due to Jinja Syntax Exception." + msg += f"The track file ({tmp.name}) likely hasn't been writen" raise TrackSyntaxError(msg, te) except jinja2.exceptions.TemplateNotFound: self.logger.exception("Could not load [%s]", track_spec_file) @@ -1702,7 +1703,7 @@ def parse_task( completed_by_name=None, ): if "operation" not in task_spec: - raise TrackSyntaxError("Operation missing from task spec %s in challenge '%s'.", task_spec, challenge_name) + raise TrackSyntaxError("Operation missing from task spec %s in challenge '%s'." % (task_spec, challenge_name)) op_spec = task_spec["operation"] if isinstance(op_spec, str) and op_spec in ops: op = ops[op_spec] From dbd778e81716790b280011c6cf0721f324822a6b Mon Sep 17 00:00:00 2001 From: Gareth Ellis Date: Wed, 29 Jan 2025 20:31:53 +0100 Subject: [PATCH 3/3] Add space, typo, full stop --- esrally/track/loader.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/esrally/track/loader.py b/esrally/track/loader.py index d209b80f9..e350381a5 100644 --- a/esrally/track/loader.py +++ b/esrally/track/loader.py @@ -1122,8 +1122,8 @@ def read(self, track_name, track_spec_file, mapping_dir): track_spec = json.loads(rendered) except jinja2.exceptions.TemplateSyntaxError as te: self.logger.exception("Could not load [%s] due to Jinja Syntax Exception.", track_spec_file) - msg = f"Could not load '{track_spec_file}' due to Jinja Syntax Exception." - msg += f"The track file ({tmp.name}) likely hasn't been writen" + msg = f"Could not load '{track_spec_file}' due to Jinja Syntax Exception. " + msg += f"The track file ({tmp.name}) likely hasn't been written." raise TrackSyntaxError(msg, te) except jinja2.exceptions.TemplateNotFound: self.logger.exception("Could not load [%s]", track_spec_file)