Skip to content

Commit

Permalink
Unit test swarm/stop/swarm in web UI
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberw committed Feb 3, 2022
1 parent 30d7028 commit f7b281e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions locust/test/test_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,20 @@ def my_task(self):
self.assertEqual(200, response.status_code)
self.assertEqual("https://localhost", response.json()["host"])
self.assertEqual(self.environment.host, "https://localhost")
# stop
gevent.sleep(1)
response = requests.get("http://127.0.0.1:%i/stop" % self.web_port)
self.assertEqual(response.json()["message"], "Test stopped")
# and swarm again, with new host
gevent.sleep(1)
response = requests.post(
"http://127.0.0.1:%i/swarm" % self.web_port,
data={"user_count": 5, "spawn_rate": 5, "host": "https://localhost/other"},
)
gevent.sleep(1)
self.assertEqual(200, response.status_code)
self.assertEqual("https://localhost/other", response.json()["host"])
self.assertEqual(self.environment.host, "https://localhost/other")

def test_swarm_custom_argument(self):
my_dict = {}
Expand Down

0 comments on commit f7b281e

Please sign in to comment.