Skip to content

Instantly share code, notes, and snippets.

@wilxsv
Created March 28, 2018 12:36
Show Gist options
  • Save wilxsv/9cbd5de8ca03325d27f472796fd28022 to your computer and use it in GitHub Desktop.
Save wilxsv/9cbd5de8ca03325d27f472796fd28022 to your computer and use it in GitHub Desktop.
from locust import HttpLocust, TaskSet
def login(l):
l.client.post("/login", {"username":"ellen_key", "password":"education"})
def logout(l):
l.client.post("/logout", {"username":"ellen_key", "password":"education"})
def index(l):
l.client.get("/")
def profile(l):
l.client.get("/profile")
class UserBehavior(TaskSet):
tasks = {index: 2, profile: 1}
def on_start(self):
login(self)
def on_stop(self):
logout(self)
class WebsiteUser(HttpLocust):
task_set = UserBehavior
min_wait = 5000
max_wait = 9000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment