Skip to content

Commit

Permalink
Merge pull request #2656 from raulparada/fix/parsed_options_run_time
Browse files Browse the repository at this point in the history
fix: update `parsed_options` `run_time`
  • Loading branch information
cyberw authored May 8, 2024
2 parents c861a74 + b2e7f12 commit f33275d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions locust/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,14 @@ def swarm() -> Response:
for key, value in request.form.items():
if key == "user_count": # if we just renamed this field to "users" we wouldn't need this
user_count = int(value)
parsed_options_dict["users"] = user_count
elif key == "spawn_rate":
spawn_rate = float(value)
parsed_options_dict[key] = spawn_rate
elif key == "host":
# Replace < > to guard against XSS
environment.host = str(request.form["host"]).replace("<", "").replace(">", "")
parsed_options_dict[key] = environment.host
elif key == "user_classes":
# Set environment.parsed_options.user_classes to the selected user_classes
parsed_options_dict[key] = request.form.getlist("user_classes")
Expand All @@ -224,6 +227,7 @@ def swarm() -> Response:
continue
try:
run_time = parse_timespan(value)
parsed_options_dict[key] = run_time
except ValueError:
err_msg = "Valid run_time formats are : 20, 20s, 3m, 2h, 1h20m, 3h30m10s, etc."
logger.error(err_msg)
Expand Down

0 comments on commit f33275d

Please sign in to comment.