-
Notifications
You must be signed in to change notification settings - Fork 59
/
locustfile.py
62 lines (50 loc) · 1.02 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
import random
from locust import HttpUser, between, task
WORDS = [
"function",
"where",
"display",
"print",
"handle",
"test",
"component",
"user",
"basket",
"execute",
"compute",
"store",
"api",
"endpoint",
"request",
"response",
"mobile",
"document",
"interface",
"web",
"database",
"source",
"deploy",
"library",
"framework",
"method",
"protocol",
"route",
]
def random_phrase():
phrase_length = random.randint(3, 15)
return " ".join(random.choices(WORDS, k=phrase_length))
class BaseUser(HttpUser):
@task(8)
def query_endpoint(self):
phrase = random_phrase()
self.client.get(f"/query/{phrase}")
class ShortWaitUser(BaseUser):
wait_time = between(0.3, 1.2)
@task(4)
def execute_tasks_short_wait(self):
self.query_endpoint()
class LongWaitUser(BaseUser):
wait_time = between(1.2, 15)
@task(6)
def execute_tasks_long_wait(self):
self.query_endpoint()