-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlocustfile4.py
88 lines (70 loc) · 2.7 KB
/
locustfile4.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
77
78
79
80
81
82
83
84
85
86
87
88
import base64, json
import random
from locust import FastHttpUser, task, tag, between
import json
import random
class ZincUser(FastHttpUser):
# wait_time = between(1, 5) # Adjust as necessary
connection_timeout = 600.0
network_timeout = 600.0
host = "http://simd-test-openobserve-router.simdtest.svc.cluster.local:5080/api/default"
@task
def query_basic_select(self):
data = {
"query": {
"sql": "select * from default",
"from": 0,
"size": 10,
"start_time": 1719754035717000,
"end_time": 1722432435717000
}
}
user = "[email protected]"
password = "Complexpass#123"
bas64encoded_creds = base64.b64encode(bytes(f"{user}:{password}", "utf-8")).decode("utf-8")
headers = {
'Authorization': 'Basic ' + bas64encoded_creds,
'Content-Type': 'application/json'
}
self.client.post("/_search?type=logs&use_cache=false", name="/query/base-select", json=data, headers=headers)
@task
def query_match_all(self):
data = {
"query": {
"sql": "select * from default where match_all('fluent')",
"from": 0,
"size": 10,
"start_time": 1719754035717000,
"end_time": 1722432435717000
}
}
user = "[email protected]"
password = "Complexpass#123"
bas64encoded_creds = base64.b64encode(bytes(f"{user}:{password}", "utf-8")).decode("utf-8")
headers = {
'Authorization': 'Basic ' + bas64encoded_creds,
'Content-Type': 'application/json'
}
self.client.post("/_search?type=logs&use_cache=false", name="/query/match_all", json=data, headers=headers)
@task
def query_histogram(self):
data = {
"query": {
"sql": "select histogram(_timestamp, '10 second') AS zo_sql_key, count(*) AS zo_sql_num from default GROUP BY zo_sql_key ORDER BY zo_sql_key",
"from": 0,
"size": 10,
"sql_mode": "full",
"start_time": 1719754035717000,
"end_time": 1722432435717000
}
}
user = "[email protected]"
password = "Complexpass#123"
bas64encoded_creds = base64.b64encode(bytes(f"{user}:{password}", "utf-8")).decode("utf-8")
headers = {
'Authorization': 'Basic ' + bas64encoded_creds,
'Content-Type': 'application/json'
}
self.client.post("/_search?type=logs&use_cache=false", name="/query/histogram", json=data, headers=headers)
# locust -f locustfile.py
# localhost::8089