An example project for http load testing using locust4j, written in Java and Kotlin.
This is not a library of any sort, just an example on how to use Locust and Locust4j to write load tests for more complex scenarios (dependent subsequent requests, ...)
Inspired by/based on locust4j-http
App acts as Locust slave that connects to Locust master, hence you need to also run master.
- Build and package with Maven:
$ git clone https://github.com/nejckorasa/locust4j-http-load
$ cd locust4j-http-load
$ mvn package
- Run jar:
$ java -jar locust4j-load-http-1.0-SNAPSHOT-fat.jar
Jar accepts arguments to configure Locust, see ConfigurationContext.
You can run master using bash scripts in master-bash directory.
- start-locust-web.sh runs Locust master with web interface
- start-locust.sh runs Locust master without in no-web mode
See the scripts for more configuration options.
Run Locust master in Docker, see master-docker directory.
Build image:
$ docker build -t master-locust .
Run with web:
$ docker run --rm --name master-locust -p 8089:8089 -p 5557:5557 -p 5558:5558 master-locust \
--master \
--master-bind-port=5557
Run with no-web (for 180s):
$ docker run --rm --name master-locust -p 8089:8089 -p 5557:5557 -p 5558:5558 -v $PWD:/locust master-locust \
--master \
--master-bind-port=5557 \
--run-time=180s \
--clients=10 \
--hatch-rate=1 \
--no-web \
--print-stats \
--expect-slaves=1 \
--csv-base-name=example
See GetExampleTask and PostExampleTask for examples
Http requests are made using HttpRequests, with options to record or not record the request with Locust.