Traffic Generators: Difference between revisions

Line 39:
= Locust =
 
Installation:
sudo apt-get update
sudo apt-get -y install python-pip python-dev libxml2-dev libxslt-dev
sudo pip install locustio
 
Install pyzmq for tests across multiple servers to increase the testing capacity:
sudo pip install pyzmq
 
Set file limit to unlimited to ensure there is no OS problems with files at concurrency:
ulimit -n 9999
 
 
 
<syntaxhighlight lang="python">
from locust import HttpLocust, TaskSet
 
def login(l):
l.client.post("/login/process", {"email":"me@someemail.com", "pass":"password"})
 
def index(l):
l.client.get("/")
 
def group(l):
l.client.get("/group/1/")
 
class UserBehavior(TaskSet):
tasks = {index:1, group:3}
 
def on_start(self):
login(self)
 
class WebsiteUser(HttpLocust):
task_set = UserBehavior
min_wait=5000
max_wait=9000
</syntaxhighlight>
 
 
 
Upload the locust test file (Click here to see how to make a locust testfile)
Exec this command (this only starts the interface to control the tests it doesnt actually start a test):
 
locust -f ./test.py --host=http://somedomain.io --master
 
You will get this:
SHOW LOCUST PICS HERE
Go to the web interface to control the test variables and to start and stop it.
 
 
Running on multiple hosts:
 
You will have a master slave setup where only one master exists.
 
Run the "running a test" steps on each node you want to have as part of the testing cluster but on each slave you should exec this instead:
 
locust -f ./test.py --host=http://somedomain.io --slave --master-host=x.x.x.x
 
Where x.x.x.x is the ip of the master you would have set up in the "running a test" section.
 
You will only need to use the one admin interface provided my the master. It should report whether the slaves are correctly setup and activey serving traffic.
 
= Slowhttptest =