Skip to content

Instantly share code, notes, and snippets.

@lauriku
Last active March 8, 2016 19:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lauriku/6282a67bc4430ed09e78 to your computer and use it in GitHub Desktop.
Save lauriku/6282a67bc4430ed09e78 to your computer and use it in GitHub Desktop.
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"}
@task(1)
def get_latest_data(self):
self.client.get("/query", params=self.query1,
name="Select 6h of data from temperature for 5 devices")
@task(1)
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
min_wait=1000
max_wait=3000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment