Rbillon59 / jmeter-docker-compose-starterkit

37 stars 23 forks source link

JMeter dockerized template repository

JMeter version

The JMeter image used is the https://hub.docker.com/r/rbillon59/jmeter-k8s-base Each tag of that Docker image is a JMeter version

To use a specific version, just change the JMETER_VERSION env var in the docker-compose.yaml file

  jmeter-master:
    build: &common-build
      context: .
      args:
        - JMETER_VERSION=5.4.1

These images are based on openjdk 16 and are compatible for x86_64 and arm64 architectures

How to use it

Be sure to have Docker up and ready on your host and docker-compose installed

Create a repository from this template then clone it with :

git clone <REPO> 

Prerequisites

File structure

dataand modules are in the scenario folder and not below inside the <project> folder because, in some cases, you can have multiple JMeter projects that are sharing the JMeter modules (that's the goal of using modules after all).

Below a visual representation of the file structure

+-- .env
+-- scenario
|   +-- data
|   +-- modules
|   +-- my-scenario
|       +-- my-scenario.jmx
|       +-- .env

In JMeter

In JMeter just put the filename in the path of your CSV Data Set Config : Be sure your filename have a .csv suffix (in lowercase)

Do the same for the Include Controller, just use the filename without any path (with the extension)

Runtime

To launch your test in a one liner fashion :

source scenario/my-scenario/.env && sudo docker-compose -p jmeter up --scale jmeter-slave=${nbInjector} -d

:warning: Use the -p jmeter option for every docker-compose command

You can visualize your performance test on host:30000 with the grafana attached. (login: admin password: admin)

At the end of the test, JMeter will create a report in the report/your-scenario directory

When you are done you can do

docker-compose -p jmeter down

to shutdown influxdb, grafana as well

Tips :

Options

Options can be set in the .env file of your project

XMX optional : Set the java heap (default 1g)
XMS optional : Set the java heap (default 1g)
host optional : Set the default request hostname on which perform the test (default jsonplaceholder.typicode.com)
port optional : Set the default request port on which perform the test (default 443)
protocol optional : Set the default request protocol (default https)
threads optional : Set the number of virtual users to create (default 10)
duration optional : Set the duration of the test in seconds (default 600)
rampup optional : Set the time needed to create the total threads number (dafault 60)
nbInjector optional : Set the number of injectors needed to run the test (default 1)