Skip to content

Instantly share code, notes, and snippets.

@jacopen
Created February 4, 2020 06:06
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 jacopen/9d42b445a2c9d59e999f5c4d8d8c64a8 to your computer and use it in GitHub Desktop.
Save jacopen/9d42b445a2c9d59e999f5c4d8d8c64a8 to your computer and use it in GitHub Desktop.
Locust memo
version: '3'
services:
master:
image: greenbirdit/locust:0.9.0
environment:
- "LOCUST_MODE=master"
- "TARGET_HOST=http://site.example.com"
- "LOCUST_SCRIPT=/locust-tasks/tasks.py"
volumes:
- ./app/locust-tasks/tasks.py:/locust-tasks/tasks.py
networks:
locust-nw:
ports:
- "8089:8089"
worker:
image: greenbirdit/locust:0.9.0
environment:
- "LOCUST_MODE=worker"
- "LOCUST_MASTER=master"
- "LOCUST_MASTER_WEB=8089"
- "TARGET_HOST=http://site.example.com"
- "LOCUST_SCRIPT=/locust-tasks/tasks.py"
volumes:
- ./app/locust-tasks/tasks.py:/locust-tasks/tasks.py
networks:
locust-nw:
networks:
locust-nw
from locust import HttpLocust, TaskSet, between
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("/info")
class UserBehavior(TaskSet):
tasks = {index: 2, profile: 1}
def on_start(self):
print("hoge")
def on_stop(self):
print("hoge")
class WebsiteUser(HttpLocust):
task_set = UserBehavior
wait_time = between(5.0, 9.0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment