Skip to content

Instantly share code, notes, and snippets.

@alexdean
Created May 16, 2018 20:17
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 alexdean/cda93ad1f8a51ae1584d022dc4295616 to your computer and use it in GitHub Desktop.
Save alexdean/cda93ad1f8a51ae1584d022dc4295616 to your computer and use it in GitHub Desktop.
from locust import HttpLocust, TaskSet, task
class UserBehavior(TaskSet):
def on_start(self):
""" on_start is called when a Locust start before any task is scheduled """
self.login()
def on_stop(self):
""" on_stop is called when the TaskSet is stopping """
self.logout()
def login(self):
self.client.post("/login", {"username":"ellen_key", "password":"education"})
def logout(self):
self.client.post("/logout", {"username":"ellen_key", "password":"education"})
@task(2)
def index(self):
self.client.get("/")
@task(1)
def profile(self):
self.client.get("/profile")
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