From ceffa158967d949c0ff54dfff13d177b15a1a55c Mon Sep 17 00:00:00 2001
From: stanislawskwark <46684704+stanislawskwark@users.noreply.github.com>
Date: Mon, 4 Jan 2021 12:20:31 +0100
Subject: [PATCH] /swarm adjusted for tests with shape class

for web /swarm endpoint moved extracting user_count and spawn_rate after checking if shape_class is used. if shape class is used these values are ignored
---
 locust/web.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/locust/web.py b/locust/web.py
index 79b3d074ae..86dfea1f92 100644
--- a/locust/web.py
+++ b/locust/web.py
@@ -134,8 +134,6 @@ def index():
         @self.auth_required_if_enabled
         def swarm():
             assert request.method == "POST"
-            user_count = int(request.form["user_count"])
-            spawn_rate = float(request.form["spawn_rate"])
 
             if request.form.get("host"):
                 # Replace < > to guard against XSS
@@ -146,6 +144,8 @@ def swarm():
                 return jsonify(
                     {"success": True, "message": "Swarming started using shape class", "host": environment.host}
                 )
+            user_count = int(request.form["user_count"])
+            spawn_rate = float(request.form["spawn_rate"])
 
             environment.runner.start(user_count, spawn_rate)
             return jsonify({"success": True, "message": "Swarming started", "host": environment.host})