Skip to content

Instantly share code, notes, and snippets.

Last active March 8, 2016 19:49
What would you like to do?
from locust import HttpLocust, TaskSet, task
class UserBehavior(TaskSet):
def on_start(self):
self.query1 = {"q": "select * from temperature where (device_id = '10001' or
device_id = '10002' or device_id = '10003' or device_id = '10004' or
device_id = '10005') and time > now() - 6h",
"db": "load_testing"}
self.query2 = {"q": "select last(value) from /.*/ where time > NOW() - 1m group by *",
"db": "load_testing"}
def get_latest_data(self):
self.client.get("/query", params=self.query1,
name="Select 6h of data from temperature for 5 devices")
def get_latest_data_for_all_devices(self):
self.client.get("/query", params=self.query2,
name= "Select last value from all measurements for all devices")
class WebsiteUser(HttpLocust):
task_set = UserBehavior
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment