-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsample3.py
44 lines (31 loc) · 993 Bytes
/
sample3.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
from faker import Faker
from gevent.pool import Group
from urllib import response
from locust import HttpUser, task, TaskSet
class WireMockParallelTests(TaskSet):
# PARALLEL GET all contacts for companyId=123
@task
def parallelAllContacts(self):
group = Group()
for i in range(0, 5):
group.spawn(lambda:self.client.get("/v1/contacts"))
group.join()
print("GET all contacts")
# PARALLEL POST Create company
@task
def createNewCompany(self):
group = Group()
fake = Faker()
for i in range(0, 10):
group.spawn(lambda:self.client.post("/v1/companies", json=
{
"id": fake.random_int(min=1, max=500),
"name": fake.name()
}
))
group.join()
print("POST Create company")
# Main
class LoadTest(HttpUser):
host = "http://localhost:8000"
tasks = [WireMockParallelTests]