Subscribe to our RSS here.
JMeter is a Java application that allows you to build up test plans that can stress test your application. You can set everything from the amount of simultaneous users of the service, to the amount of requests they make a second. ForEach Controller in Jmeter iterates through an array of variables. In this JMeter tutorial, we’ll use the ForEach Controller to loop through a JSON Array. There are times when we need to parse a response and extract certain information from it. For example, when testing an API, we could get a JSON response which could contain JSON Arrays. Jmeter: 18: Installs on Request (30 days) jmeter: 18: Build Errors (30 days) jmeter: 0: Installs (90 days) jmeter: 55: Installs on Request (90 days) jmeter: 55: Installs (365 days) jmeter: 349: Installs on Request (365 days) jmeter: 349.
Where are we?
Installing Jenkins using Docker
Jenkins is installed locally in many ways depending on your OS.
On Mac, you can use brew:
On Debian, you can use apt:
You can find the instructions to other systems here.
In the end, you can simply run bash jenkins
and the service will be up and running.
The command will give the initial administrator password. The next screens will guide you through Jenkins configuration. For our purposes you can simply use the default options.
Afterwards Jenkins will be ready to go!
Running JMeter from the command line
To configure Jenkins, we will need to learn how to run our Jenkins plans from the command line.
The first step is to identify the location of your JMeter.On Linux and Windows, it will probably the folder that you extracted JMeter. On Mac, if you installed JMeter using brew, you can use where jmeter
to find out (it will probably be /usr/local/bin/jmeter
).
Then, to run JMeter in a NON_GUI fashion, you can run the following command:
The only new part is the cryptic .jtl file. This is a XML or CSV format used by JMeter to save its results. After you run the command, you shall see a new or updated file in the indicated folder.
Creating a Jenkins job to execute the JMeter plan
For this example, we will be using a JMeter plan that makes call to the Open Maps API.
For starters, we will add the Performance plugin, in order to have nice reports on JMeter screen.
To add it, go to Manage Jenkins and Manage Plugins.
Then Select Performance form the Available tab.
No restart is necessary.
Back on Jenkins initial screen, you can click on create new jobs and then create a Freestyle project.
Clicking on Configure allows us to add the building steps.
Firstly we will add a Build step execute the exact command we use before to run JMeter in NON-GUI mode.
Brew Jmeter
Secondly, we will add a Post-build step. The type will be Publishing Performance test result report, which is coupled to the Performance plugin.
Here we just need to add the path to our .jtl file in the Source data files field.
Information overview
After a couple of executions, you can see that the Performance plugin shows a trend chart on the job home page.
New mac desktop 2016. Additionally, you can see more detailed data into each execution.
Possible improvements
Of course, this is just the first step.
You can configure many triggers for the Jenkins job, such as a new commit on GitHub, a deployment on certain environment.
Also you can configure the JMeter plan itself, for instance, by passing arguments on the non-GUI command.
Conclusion
Brew Jmeter Install
This ends the 5-part series to introduce JMeter, from the basics concepts to continous execution. You can check out the whole series here.