In my previous post you can find some information about Locust and Jenkins. Jenkins operates the CI environment and Locust is a tool for performance testing. To run the Locust on Jenkins you need command line arguments which control the number of clients, hatch rate, running locust without web interface and there should be some parameters to stop the Locust automatically.
Parameters:
--clients : number of users / concurrent user
--hatch-rate : number of users will join the system (users per second)
--num-reques : number of request in total
--no-web : tell that test will perform on command line
--only-summary : only show the result
For the full list of the parameters, see this For stopping the test, you can also use stop_timeout variable in your Locust class. For the examples beow, it will stop after 20 seconds. This should be set because CI means feedback shorter and quickier if there is anything wrong in the system. If you have problem with sending request, waiting the --num-reques may take to much time.
class User(HttpLocust): task_set = UserBehaviour stop_timeout = 20
Full script for testing Myhabit's my account page:
With the following command, all-links-4.py will be run with 20 clients, every second 1 client is hatched and it continues until the total request number is 100.
/usr/local/bin/locust -f all-links-4.py --clients=20 --hatch-rate=1 --num-request=100 --no-web
Same as in the web part of Locust, you can see the result from Jenkins console output as success and failure respectively: