summaryrefslogtreecommitdiff
path: root/benchmarks/py-locust/files/extra-EXAMPLES-dynamice_user_credentials.py
diff options
context:
space:
mode:
authorVinícius Zavam <egypcio@FreeBSD.org>2019-01-20 12:54:30 +0000
committerVinícius Zavam <egypcio@FreeBSD.org>2019-01-20 12:54:30 +0000
commitf20baa6ebd75e5a55ec1d3755ef4c61b83fd5924 (patch)
treecf48db9b35cfc5a7de462164883277362c465afe /benchmarks/py-locust/files/extra-EXAMPLES-dynamice_user_credentials.py
parentUpdate files/patch-spe-config (and with that our local adjustments to (diff)
[NEW] benchmarks/py-locust: Python utility for doing distributed load tests
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
Diffstat (limited to 'benchmarks/py-locust/files/extra-EXAMPLES-dynamice_user_credentials.py')
-rw-r--r--benchmarks/py-locust/files/extra-EXAMPLES-dynamice_user_credentials.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/benchmarks/py-locust/files/extra-EXAMPLES-dynamice_user_credentials.py b/benchmarks/py-locust/files/extra-EXAMPLES-dynamice_user_credentials.py
new file mode 100644
index 000000000000..6f8f66baa5ca
--- /dev/null
+++ b/benchmarks/py-locust/files/extra-EXAMPLES-dynamice_user_credentials.py
@@ -0,0 +1,25 @@
+# locustfile.py
+
+from locust import HttpLocust, TaskSet, task
+
+USER_CREDENTIALS = [
+ ("user1", "password"),
+ ("user2", "password"),
+ ("user3", "password"),
+]
+
+class UserBehaviour(TaskSet):
+ def on_start(self):
+ if len(USER_CREDENTIALS) > 0:
+ user, passw = USER_CREDENTIALS.pop()
+ self.client.post("/login", {"username":user, "password":passw})
+
+ @task
+ def some_task(self):
+ # user should be logged in here (unless the USER_CREDENTIALS ran out)
+ self.client.get("/protected/resource")
+
+class User(HttpLocust):
+ task_set = UserBehaviour
+ min_wait = 5000
+ max_wait = 60000