-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlocustfile.py
59 lines (53 loc) · 1.92 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
import time
import random
from locust import HttpUser, task, between
class GatekeeperApiUser(HttpUser):
wait_time = between(1, 2.5)
@task
def process_activities(self):
insert_payload = {
"activities": [
{
"operation": "insert",
"table": "table1",
"col_names": ["a", "b", "c"],
"col_types": ["INTEGER", "TEXT", "TEXT"],
"col_values": [1, "Backup and Restore", "2018-03-27 11:58:28.988414"]
}
]
}
delete_payload = {
"activities": [
{
"operation": "delete",
"table": "table1",
"value_to_delete": {
"col_names": ["a", "c", "e"],
"col_types": ["INTEGER", "TEXT", "TEXT"],
"col_values": [3, "2019-04-28 10:24:30.183414", "something"]
}
}
]
}
full_payload = {
"activities": [
{
"operation": "delete",
"table": "table1",
"value_to_delete": {
"col_names": ["a", "c", "e"],
"col_types": ["INTEGER", "TEXT", "TEXT"],
"col_values": [3, "2019-04-28 10:24:30.183414", "something"]
}
},
{
"operation": "insert",
"table": "table1",
"col_names": ["a", "b", "c"],
"col_types": ["INTEGER", "TEXT", "TEXT"],
"col_values": [1, "Backup and Restore", "2018-03-27 11:58:28.988414"]
}
]
}
data = [insert_payload, delete_payload, full_payload]
self.client.post("/api/activities", json=random.choice(data))