-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure that the exception dictionaries are not mutated when generating a html report #1784
Conversation
PS: I will incorporate this fix in the distribution branch because it is causing my load tests to crash (I use the html report feature quite a lot). |
locust/html.py
Outdated
@@ -36,7 +38,8 @@ def get_html_report(environment, show_download_link=True): | |||
requests_statistics = list(chain(sort_stats(stats.entries), [stats.total])) | |||
failures_statistics = sort_stats(stats.errors) | |||
exceptions_statistics = [] | |||
for exc in environment.runner.exceptions.values(): | |||
exceptions = deepcopy(environment.runner.exceptions) | |||
for exc in exceptions.values(): | |||
exc["nodes"] = ", ".join(exc["nodes"]) | |||
exceptions_statistics.append(exc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just do something like exceptions_statistics.append(", ".join(exc["nodes"]))
instead? No need to copy runner.exceptions if exceptions
is never used again, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The exceptions_statistics
must also contain the other fields of the exception dictionary as the html template also needs the other properties:
Lines 66 to 80 in 60cde73
res = render_template( | |
"report.html", | |
int=int, | |
round=round, | |
requests_statistics=requests_statistics, | |
failures_statistics=failures_statistics, | |
exceptions_statistics=exceptions_statistics, | |
start_time=start_time, | |
end_time=end_time, | |
host=host, | |
history=history, | |
static_js="\n".join(static_js), | |
static_css="\n".join(static_css), | |
show_download_link=show_download_link, | |
) |
If you prefer, it could be something like this instead of the for-loop:
exceptions_statistics = [
{**exc, "nodes": ", ".join(exc["nodes"])}
for exc in environment.runner.exceptions.values()
]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed it. Looks better now in my opinion.
Thx! |
This PR fixes the following issue:
If a user generated a html report during a load test run, then the
nodes
field in everyexception
dict was mutated to a string.This also caused the following when hovering on one of the exception in the web UI: