-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlocustfile.py
76 lines (69 loc) · 2 KB
/
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# https://docs.locust.io/en/latest/writing-a-locustfile.html
# https://docs.locust.io/en/latest/installation.html
from locust import HttpUser, task, between
# # necessary imports
# from locust import HttpLocust, TaskSet, task
# # your own custom task set
# class CustomTaskSet(TaskSet):
# # your task
# @task(1) # how many times to run per execution cycle
# def index(self): # task function definition
# self.client.get('/') # hit '/' with a get request
# # task runner
# class LocustRunner(HttpLocust):
# task_set = CustomTaskSet # add your set to the task runner
# min_wait = 5000
# max_wait = 15000
class BoustonPredictionTestUser(HttpUser):
wait_time = between(0.5, 3.0)
def on_start(self):
self.client.post("/login", json={"username":"foo", "password":"bar"})
print('Locust test is starting!')
def on_stop(self):
print('Locust test is stopping!')
@task(1)
def hello_world(self):
self.client.get("/")
@task(10)
def predict(self):
self.client.post("/predict", json={
"CHAS":{
"0":0
},
"RM":{
"0":6.575
},
"TAX":{
"0":296.0
},
"PTRATIO":{
"0":15.3
},
"B":{
"0":396.9
},
"LSTAT":{
"0":4.98
},
"LAWN": {
"0": 29
},
"FEE": {
"0": 300
},
"CAPE": {
"0": 29
},
"TIO": {
"0": 75.3
},
"J": {
"0": 299
},
"PT": {
"0": 88
},
"TEST": {
"0": 89
}
})