mirror of
https://git.freebsd.org/ports.git
synced 2025-04-30 10:36:38 -04:00
Locust is an easy-to-use, distributed, user load testing tool. It is intended for load-testing web sites (or other systems) and figuring out how many concurrent users a system can handle. The behavior of each locust (or test user if you will) is defined by you and the swarming process is monitored from a web UI in real-time. This will help you battle test and identify bottlenecks in your code before letting real users in. WWW: https://locust.io/ Approved by: araujo (mentor), rene (mentor) Sponsored by: cleverbridge AG Differential Revision: https://reviews.freebsd.org/D18895
25 lines
568 B
Python
25 lines
568 B
Python
from locust import HttpLocust, TaskSet, task, events
|
|
|
|
from gevent.coros import Semaphore
|
|
all_locusts_spawned = Semaphore()
|
|
all_locusts_spawned.acquire()
|
|
|
|
def on_hatch_complete(**kw):
|
|
all_locusts_spawned.release()
|
|
|
|
events.hatch_complete += on_hatch_complete
|
|
|
|
class UserTasks(TaskSet):
|
|
def on_start(self):
|
|
all_locusts_spawned.wait()
|
|
self.wait()
|
|
|
|
@task
|
|
def index(self):
|
|
self.client.get("/")
|
|
|
|
class WebsiteUser(HttpLocust):
|
|
host = "http://127.0.0.1:8089"
|
|
min_wait = 2000
|
|
max_wait = 5000
|
|
task_set = UserTasks
|