Skip to main content
New to Testkube? Unleash the power of cloud native testing in Kubernetes with Testkube. Get Started >

Distributed JMeter Example

info

This Workflows functionality is not available when running the Testkube Agent in Standalone Mode - Read More

Testkube has built-in support for parallelising any testing tool - check out the Parallelization documentation for details and examples.

The below example shows how to distribute a JMeter test across a configurable number of nodes

  • Read JMX configuration from Git repository (spec.content.git)
  • Start 5 remote workers (spec.services.slave.count)
    • Distribute them evenly across nodes (spec.services.slave.use[0] - distribute/evenly template is setting common pod.topologySpreadConstraints)
    • Reserve 1/8 CPU and 128MB memory for each instance (spec.services.slave.container.resources)
    • Wait until they will accept connection at port 1099 (spec.services.slave.readinessProbe)
  • Run JMeter controller against all the remote workers (spec.services.steps[0].run)
    • It uses {{ services.slave.*.ip }} as an argument - services.slave.*.ip will return list of IPs, and they will be joined by comma (,) to convert to text
Distributed JMeter Workflow
kind: TestWorkflow
apiVersion: testworkflows.testkube.io/v1
metadata:
name: distributed-jmeter-example-config-artifacts
namespace: testkube
labels:
docs: example
spec:
config:
slavecount:
type: integer
default: 3
content:
git:
uri: https://github.com/kubeshop/testkube
revision: main
paths:
- test/jmeter/executor-tests/jmeter-executor-smoke.jmx
container:
workingDir: /data/repo/test/jmeter/executor-tests
services:
slave:
use:
- name: distribute/evenly
count: config.slavecount
logs: always
timeout: 30s
image: anasoid/jmeter:5.6-plugins-21-jre
command:
- jmeter-server
- -Dserver.rmi.localport=60000
- -Dserver_port=1099
- -Jserver.rmi.ssl.disable=true
readinessProbe:
tcpSocket:
port: 1099
periodSeconds: 1
steps:
- name: Run tests
run:
image: anasoid/jmeter:5.6-plugins-21-jre
shell: |
jmeter -n \
-X -Jserver.rmi.ssl.disable=true -Jclient.rmi.localport=7000 \
-R {{ services.slave.*.ip }} \
-t jmeter-executor-smoke.jmx \
-j /data/artifacts/jmeter.log \
-o /data/artifacts/report \
-l /data/artifacts/jtl-report.jtl -e
artifacts:
paths:
- /data/artifacts/**/*
status: {}

After execution, you can see the output from the test executions under the executions panel tabs:

The log output from the JMeter execution:

JMeter Framework Log Output