Skip to content

Commit

Permalink
Promote user count, spawn rate and host to parsed options dict
Browse files Browse the repository at this point in the history
So they can be accessed from LoadTestShapes
  • Loading branch information
cyberw committed May 8, 2024
1 parent 4770e61 commit b2e7f12
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions locust/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,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 Down

0 comments on commit b2e7f12

Please sign in to comment.