Distributed load test using jmeter
This will mainly focus on how to set up jmeter in master and slave system. Multiple jmeter servers will be run using multiple docker from within one machine.
I will assume that you already have a test plan, If not you can use this example plan. https://raw.githubusercontent.com/Sorravit/file-storage/master/proformance-testing/SorravitExampleTestPlan.jmx
Now that we have the test plan, let’s get start with building the docker
First, download the jmeter and put the download file in the same folder as your Dockerfile
Second, Create the “user.properties” file and put it in the same folder as your Dockerfile
We will put this file into the docker that we about to build to use it to config jmeter, this is mine
server_port=24000
server.rmi.ssl.disable=true
“server_port” is the port that you will use to connect to your jmeter server “server.rmi.ssl.disable” is to disable the ssl as the name suggest, which I do in this case.
Third, Create the Dockerfile, Personally I choose to build from “openjdk:17-oracle” for no particular reason so use what ever image you want as long as it have java installed.
But if you want to feel free to use my Dockerfile
FROM openjdk:17-oracle AS temp
COPY /apache-jmeter-5.5.tgz /apache-jmeter-5.5.tgz
RUN tar zxvf apache-jmeter-5.5.tgz && rm apache-jmeter-5.5.tgz
FROM openjdk:17-oracle
COPY --from=temp /apache-jmeter-5.5 /apache-jmeter-5.5
COPY user.properties /apache-jmeter-5.5/bin
ENV PATH=$PATH:/apache-jmeter-5.5/bin
RUN mkdir workspace
WORKDIR /workspace
ENTRYPOINT "jmeter-server"
*Note that you don’t need to copy the user.properties into the docker. You can just simply mount it as volume to the docker when you start it.
Check point:
Now you should have
- Dockerfile
- user.properties
- JmeterTestPlan.jmx
And now we build the docker, big-jmeter is that tag name that I will use
docker build -t big-jmeter .
Now start dockers, in this example I will start 3 docker (either mount the file when you start the docker or copy it in later)
I use this command to run in 3 tab(Because I want to see live logs)
docker run --rm big-jmeter:latest
This is what you will see
Before I sh in the docker I need to know all their ip address first and since I did not assign any special network nor ip for it because as long as it is in the same subnet jmeter will be happy. So this is a command to find out what those ip are.
Then I open another terminal to copy the test plan into the docker
Then, run the jmeter with -R which tell jmeter which remote server we want to run on, this is what it looks like
jmeter -n -t SorravitExampleTestPlan.jmx -l jmeterResult.csv -j jmeter.log -R172.17.0.2:24000,172.17.0.3:24000,172.17.0.4:24000
Even though I actually run my master from one of this docker(I don’t even know which one and I don’t care lol) but since I specify all of their IP to be the remote host all of the server act the same.
Now, the final step, copy the result from docker ( d0a is the hash of my docker so your will be difference
Next, Open Jmeter and in the view result tree and summary report should have the “browse…” button. Click on and and look for your result file.
This is what it looks like
I have 1 intentional fail and since the same test plan execute in 3 server, I got 3 errors as expected.
Ps. Make sure you have the same Java version Jmeter version and stay in the same subnet for this to work happily.