Skip to content

Latest commit

 

History

History
77 lines (53 loc) · 3.13 KB

README.md

File metadata and controls

77 lines (53 loc) · 3.13 KB

Tweet

Locust4j http load

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

Build & Run

App acts as Locust slave that connects to Locust master, hence you need to also run master.

Run slave

  • 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.

Run master (Bash)

You can run master using bash scripts in master-bash directory.

See the scripts for more configuration options.

Run master (Docker)

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

Write your own task objects

See GetExampleTask and PostExampleTask for examples

Http

Http requests are made using HttpRequests, with options to record or not record the request with Locust.