Docker and Jmeter
With more and more test environments moving to the cloud it makes sense to embrace the cloud and consider how we can take advantage of it.
Virtualisation of applications using containers allows you to migrate your application and also to scale it. Using containers we can look to wrap this technology around Apache Jmeter.
You can build your own docker image for Jmeter but with Docker hub you can often find a pre-made image. For Apache Jmeter a great image has been created called egaillardon/jmeter. To download this docker image log on to a machine where docker engine is installed and execute the following command:-
docker pull egaillardon/jmeter
Once installed Jmeter can be executed in standalone mode (interactive/detached), server mode or distributed testing mode. In the section below, we provide several examples, to show you how you can use the docker container. Full documentation can be found on the docker hub page.
Examples commands
Running standalone clients (interactive)
docker run --interactive --tty --rm --volume `pwd`:/jmeter egaillardon/jmeter --nongui --testfile test.jmx --logfile result.jtl
Running standalone clients (detached)
docker run --detach --rm --volume `pwd`:/jmeter egaillardon/jmeter --nongui --testfile test.jmx --logfile result.jtl
Running server (with default RMI port and SSL for RMI disabled)
docker run --detach --publish 1099:1099 --rm egaillardon/jmeter -Jserver.rmi.ssl.disable=true -Djava.rmi.server.hostname=192.168.1.1 -Jserver.rmi.localport=1099 --server
Running client in distributed testing mode
docker run --detach --rm --volume `pwd`:/jmeter egaillardon/jmeter -Jserver.rmi.ssl.disable=true --nongui --testfile test.jmx --remotestart 192.168.1.1 --logfile result.jtl
By visualising jmeter we can start to consider the possibilities of its rapid deployment, even scaling out jmeter slaves as we design test plans that require greater number of threads. It’s an area that will continue to grow so it makes sense to consider using it when performance testing.