Setting up the JMeter distributed test infrastructure for the performance testing is not very easy! We already have seen that Docker can help us here in setting up the infrastructure. If you have not read the articles of TestAutomationGuru, I would suggest you to check these.
When we do the actual performance testing, we might use our own servers or cloud like AWS-EC2. Even though Docker helped us in creating the containers with JMeter + Java etc, multi-host networking was not very easy!!
Lets see how it can be done using RancherOS + Rancher Server
RancherOS is the smallest, easiest way to run containers at scale in production, and includes only the services needed to run Docker. By removing unneeded libraries, and running the latest version of Docker by default, RancherOS reduces the hassle with updating, patching, and maintaining your container host operating system. Containers on RancherOS boot in seconds, making it easy for teams to move and scale quickly.
RancherOS is a lightweight OS + Rancher is a docker-containers management platform which runs on RancherOS or any other OS where docker is installed.
sudo docker run -d –restart=unless-stopped -p 8080:8080 rancher/server
As part of this post, I am going to use AWS-EC2. You can also use any VMs/cloud/Physical machines.
Rancher communicates with rancher agents using some ports. Please ensure that below ports are open.
The last 3 ports (1099,50000 & 60000) have been added for JMeter master-slave communication.
I am creating a separate environment in the Rancher UI – call it as jmeter-distributed-test environment. Rancher uses different templates for managing multi-container application. Cattle is Rancher’s own container orchestration template which is default.
Once an environment template is chosen, then the next step is to create hosts. I chose Amazon EC2.
Once all the hosts are ready, edit 1 of the hosts which is going to be a JMeter-Master. Add a label “io.rancher.host.name=master“. You will know why in the next section.
Stack is simply a set of services to run our application. To run our JMeter-distributed test, we need 2 services.
Access Rancher’s containers section to see the list of all the containers It had created so far and it details like names & ip address etc. As you see each and every container runs on a separate hosts which is the right set up for the actual performance test.
./jmeter -n -t jmeter-docker-compose.jmx -Rjmeter-server-1,jmeter-server-2,jmeter-server-3,jmeter-server-4
Creating a Stack with master and slave services might look like a little bit work for you for the first time! Actually It is simple. Rancher also provides an option to export this configuration – so that you can import next time / share with others.
Next time you can either copy & paste the config / import the files. You can use below config which I had exported.
Here before – Setting up this test environment was not very easy. We need to ensure that same version of JMeter + Java + jmeter-plugins + any other dependencies are present in all the machines. On top of that we also need to ensure that appropriate ports are open. Sometimes – you will still face an issue – due to Java RMI.
Rancher + Docker + EC2 make our life easier. As soon as you upload the config – everything is set up & all the containers are ready within a minute to run the test.
Rancher also exposes a set of API & comes with CLI to do everything programmatically!!
Happy Testing & Subscribe 🙂