29-04-2021



There are multiple approaches to install JMeter on Mac. You can either do it manually just like we do it in windows or you can follow a more simplistic method to install JMeter via HomeBrew. I prefer the Homebrew method, as it gets the job done quickly with few simple commands. 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 NONGUI fashion, you can run the following command. 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 NONGUI fashion, you can run the following command.

The Apache JMeter™ application is open source software, a 100% pure Java application designed to load test functional behavior and measure performance. It was originally designed for testing Web Applications but has since expanded to other test functions.

Installation

With mac, to install apache JMeter:

Configuration

Variable

JMeter files can leverage variables in order to update your load test on the fly:

Here I am defining the variable host with a default value of 'localhost'. This variable can be overwritten in the command line using:

So that the host will be 192.168.0.1 during the load test.You can define all of your default variable within a TCP Sampler Config that will apply on all the subsequent Sampler.Also you can configure your Thread Group number of Thread and duration adding variables to it.When using with duration you should use “Infinite Loop”.

Create your Sampler

You can find excellent tutorial on Blazemeter or Dzone with screenshot and detailed examples.There some options available in your Sampler:

  • The timeout parameter:
    • Connect: max time in ms for the Sampler to wait for the connection to be established.
    • Response: max time the sampler will wait for a response from the request.
  • The other connection parameters:
    • Re-use connection: To re use the same connection previously established to send data
    • Close connection: To open and close the connection each time it sends data.
    • Set NoDelay: When set small messages, even those the size of only 1 byte, are sent in a separate packet. Otherwise, if this parameter is cleared, a number of small messages is combined in one packet before sending them.
    • SO_LINGER: This option can be enabled in the socket to cause the script to block the close the connection call for a number of seconds, specified in this field, until all final data is delivered to the destination station.
    • EOL byte value: Tells which is the last byte to expect (So it knows when it got all of the response, otherwise it will timeout with Error: 500)

You can add a TCP Sampler and then add some other things to it like:

  • Response Assertion: To assert on the response data of the request (Because TCP does not return HTTP - 200, you need to add something to say when it’s a success)
  • View Results Tree: To check what has been send and received for the particular sampler
  • BeanShell PreProcessor: To custom the request you are going to send (Uses BeanShell syntax)

If you want the combined results of your Thread Group. You will want to use a Summary Report.Add a filename to it like “performance.csv” so it will be generated at each run.

Brew Jmeter

You can add other Listeners to your Thread Group for assertions or even a graph.To generate a report, see the command line in the next section.

Usage

Run the load test for 100 tps:

The result of the load test will be saved:

  • in output.jtl for the load test values
  • in jmeter.log for the logs of jmeter
  • in performance.csv for the csv with all of the requests (a bit like the output.jtl)

To turn the csv/jtl file into an html in the report folder, use:

This will generate a report that you can open in your browser.

You will get access to all the information you need (timestamp, transaction/s, request average or median time, results, etc …)

As we all know that Most of the Companies are investing in best resources instead of licensed tools and moving towards open source technologies, We as a Performance engineers also has to adopt and utilize open source tools and technologies.

It is quite difficult to store JMeter test results for longer duration and to monitor JMeter test in non-gui mode. One of the solution is Grafana and InfluxDB.

In this article, I will explain step by step, how to install and configure Grafana and InfluxDB with JMeter in MAC and Windows OS.

InfluxDB Setup with JMeter

Windows OS

  1. First we have to download InfluxDB using following URL Download InfluxDB
  2. Unzip the downloaded file. You will see the folder structure like below

3. Open influxdb.conf file and scroll down till graphite section. You will find like below

4. Uncomment few configurations highlighted in below screenshot and change the value of enabled tag to true

Brew meter

5. Execute influxd exe from downloaded folder. This is to start the InfluxDB service.

6. Execute influx exe from downloaded folder to connect to Influx DB and create a database schema

7. Execute below commands to create a new database schema

  • create database jmeter_demo; (jmeter_demo is the database schema name)
  • show databases;

8. Next step is to add a backend listener in JMeter to send test stats to InfluxDB during execution. Do the configuration same as below screenshot. (Here 8086 is default port used by InfluxDB for web access)

  • influxdbURL --> It should be the URL where InfluxDB is hosted followed by database name.
  • application --> Mention any name to identify multiple applications test results.
  • measurement --> Here jmeter is the table name where all the test stats will be written.
  • samplersRegex --> .* will write all the transaction data into InfluxDB.

Make sure you are selecting InfluxDB backend listener client in Dropdown as below:

9. Now JMeter is successfully configured to send data stats to InfluxDB.

  • To validate stats in Influx DB, Run a JMeter test and open influx exe application from downloaded folder

Execute following commands

  • use jmeter_demo (Here Jmeter_demo is the database name which we created in step 7).
  • select * from jmeter; (Here jmeter is a table name)
  • you will be able to see the data in InfluxDB like below

MAC OS

It is quite easy to install InfluxDB and Grafana in MAC if you have Homebrew installed in your system. if not, Download Brew.

Brew
  1. Execute below commands to download InfluxDB
  • brew update
  • brew install influxdb

2. Run below commands after successful installation of InfluxDB

  • ln -sfv /usr/local/opt/influxdb/*.plist ~/Library/LaunchAgents
  • launchctl load ~/Library/LaunchAgents/homebrew.mxcl.influxdb.plist

3. To Verify that InfluxDB is running or not, Execute below commands in terminal

  • Influx
  • SHOW DATABASES
  • Create database jmeter_demo

4. Make few changes in the InfluxDB configuration file. File Path --> /usr/local/etc

  • influxd config
  • Refer step 4 in windows configuration as it is same.

5. Restart Influx DB

  • brew services restart influxdb

6. Refer step 8 and 9 from windows installation to add a backend listener in Jmeter.

-----------------------------------------

Now as the data is reaching to InfluxDB successfully, Next step is to download Grafana and setup dashboard.

Download Grafana

Windows OS:

  1. Download Grafana
  2. Unzip the downloaded file, go to bin folder and run the grafana-server exe. It will start the grafana server and then you can setup InfluxDB in it.

Note: influxd and grafana-server should be running always to push the JMeter data to InfluxDB and to access Grafana portal.

Mac OS:

  1. Execute below commands
  • brew install grafana
  • brew services start grafana

----------------------------------

Setup Grafana and Dashboards

  1. To access Grafana, use http://localhost:3000/ (Grafana by default use 3000 port).
  2. login in Grafana using admin/admin as username and password.
  3. It will ask for password change, You can use the same admin as password.
  4. Next step is to add InfluxDB data source in Grafana.
  5. click on add data source.
  6. select InfluxDB and enter all the details as per below screenshot and click save. Make Sure you are giving 'Jmeter' in Name textBox as below reference dashboard is using datasource called 'Jmeter'.

7. Now InfluxDB is connected to Grafana, Next step is to create a dashboard to view test stats in graphical view.

Brew Install Jmeter 4.0

  • Go to dashboard home.
  • Click on new dashboard. Here you can add multiple panels like graphs, tables etc..
  • Click on graph then click on edit in panel title in the chart heading.
Brew Jmeter

Brew Uninstall Jmeter

  • Now you can write a query to fetch the required data from InfluxDB like below (Here jmeter represents table name and field(avg) represents average transaction response time).

Grafana Dashboard for JMeter test

I have created a dashboard to monitor JMeter test results. You can import it using following steps.

  • Click on Dashboard --> Manage --> Import
  • Download Dashboard JSON from following Git repository and click load.
  • Make sure Datasource name is set to 'Jmeter' and save.

Brew Install Jmeter Specific Version

I hope you will find this article helpful. You can reach out to me if you face any issues while configuring Grafana.