forked from microservices-demo/load-test
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathlocustfile.py
More file actions
30 lines (22 loc) · 871 Bytes
/
locustfile.py
File metadata and controls
30 lines (22 loc) · 871 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import base64
from locust import HttpLocust, TaskSet, task
from random import randint, choice
class WebTasks(TaskSet):
@task
def load(self):
base64string = base64.encodestring('%s:%s' % ('user', 'password')).replace('\n', '')
catalogue = self.client.get("/catalogue").json()
category_item = choice(catalogue)
item_id = category_item["id"]
self.client.get("/")
self.client.get("/login", headers={"Authorization":"Basic %s" % base64string})
self.client.get("/category.html")
self.client.get("/detail.html?id={}".format(item_id))
self.client.delete("/cart")
self.client.post("/cart", json={"id": item_id, "quantity": 1})
self.client.get("/basket.html")
self.client.post("/orders")
class Web(HttpLocust):
task_set = WebTasks
min_wait = 0
max_wait = 0