-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlocustfile.py
37 lines (35 loc) · 1006 Bytes
/
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
import random
from locust import HttpUser, task, between
from datetime import datetime
class QuickStartUser(HttpUser):
wait_time = between(5, 10)
@task
def load_page(self):
#self.client.get("/")
now = datetime.now()
currtime = now.strftime("%Y-%m-%dT%H:%M:%S.%f")
data = {
"device_id": "loadtest002",
"timestamp": "",
"altitude": 400.56,
"latitude": 11.976750,
"longitude": 78.575279,
"battery_level": 75.1,
"aq1": {
"pm10": 51.1,
"pm75": 71.3,
"pm25": 121.3
},
"aq2": {
"pm10": 41.4,
"pm75": 81.3,
"pm25": 201.7
},
"aq3": {
"pm10": 51.6,
"pm75": 61.6,
"pm25": 291.9
}
}
data['timestamp'] = currtime
self.client.post("/add_sensor_data", json=data)