-
Notifications
You must be signed in to change notification settings - Fork 178
/
Copy pathlocustfile.py
41 lines (30 loc) · 893 Bytes
/
locustfile.py
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
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/python
import json
import random
import urllib3
from locust import HttpLocust, TaskSet
clientErrorCodes = [400, 403, 404]
serverErrorCodes = [500, 503]
def index(l):
l.client.get("/")
def clientErrors(l):
l.client.get("/httpbin/status/" + str(random.choice(clientErrorCodes)))
def serverErrors(l):
l.client.get("/httpbin/status/" + str(random.choice(serverErrorCodes)))
def responseSize(l):
l.client.get("/httpbin/bytes/" + str(random.randint(100, 500000)))
class DemoBehavior(TaskSet):
def on_start(self):
self.client.verify = False
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
index(self)
tasks = {
index: 3,
clientErrors: 6,
serverErrors: 4,
responseSize: 2,
}
class WebsiteUser(HttpLocust):
task_set = DemoBehavior
min_wait = 1000
max_wait = 10000