This testing framework provides a scalable test harness that you can use for load testing applications using Apache JMeter test scripts. The framework uses Azure Kubernetes Service (AKS) in a distributed architecture that can carry out an intensive load test, simulating hundreds and thousands of simultaneous users. The results of the load testing are sent to InfluxDB using the built-in backend listener available in JMeter. Grafana is used to render this data in an easily consumable dashboard.
The testing framework utilizes a master JMeter node, and one or more slave nodes are used to run the tests. This implementation deploys a single JMeter slave pod, but you can scale it as needed to support the required number of client threads.
To use this framework, you must have a JMeter test plan in the form of a .jmx file configured with a backend listener.
JMeter architecture on Azure
The framework uses a Kubernetes-based deployment of Apache JMeter, InfluxDB, and Grafana. AKS is a managed platform that makes it easy to set up a distributed architecture on Azure. The framework builds on Apache JMeter's distributed load testing model whereby tests are initiated from one JMeter master node, which then distributes the test script to the slaves (JMeter instances). The slaves are pods that carry out the load testing.
Note: The test plan is replicated to all slaves, so you must consider the overall client load. For example, a test plan with 100 client threads distributed to five JMeter slaves results in 500 active clients.
To get started, set up the environment and prerequisites as follows:
Make sure you have Azure CLI version 2.0.80 or above (assumes use of a Linux client, not PowerShell).
install Deploys to the target environment using the resource group and location defined. It creates the resource group, a service principal, and a repository in Azure Container Registry. Then it builds and uploads containers for the JMeter master, JMeter slave and reporting. A reporting node pool is created, followed by the creation an AKS cluster, and then all the elements required to run a test are deployed and configured.
After the deployment has completed successfully, you can go to the Grafana dashboard via the public IP address of the provisioned load balancer. The easiest way to obtain this address is to run:
kubectl get svc
Using the public IP address of the load balancer, you can then access the Grafana logon window. To log on, use the default credentials—admin for username and admin for password.
Set up the JMeter dashboard
When you start Grafana, a default data source is used to display an initial dashboard, which is loaded as part of the installation. To open the default dashboard that supports testing, select JMeter Dashboard.
If no dashboard is available, follow the steps below to load a JMeter dashboard to display testing data:
Select Dashboards, then select Manage as shown:
In the Dashboards window, select Import.
In the Import window, enter 4026 to identify the dashboard from Grafana labs and then press Tab.
In the settings options that appear, type jmeterdb for DB name, then click Import to load the dashboard with the default settings.
Use the Grafana dashboard
When the Grafana dashboard for JMeter is loaded, note the following items:
Name (marked 1 in the following figure) is the application name and is linked to your JMeter test plan configuration.
Start/Stop marker (2) indicates when a JMeter test starts and stops.
Last 30 minutes (3) shows the time period for the data currently displayed on the dashboard.
Run your first JMeter test
To validate the deployment, a simple test script has been provided. To run this test, navigate to the deploy directory, then use the starttest.sh file as follows:
Make the file starttest.sh executable:
chmod +x starttest.sh
Execute a test run:
For example, to execute the simple test script that’s provided:
The example output shows that the test plan is distributed to a single node (as this default implementation uses only one slave node).
If you navigate to the Grafana dashboard, you can see output data like the following, which shows a different time range and application name:
Write your own JMeter test plan
To set up your own JMeter test plan, refer to the Apache JMeter documentation. The key element to include in your test plan is a backend listener. To get real-time metrics, you must configure the JMeter backend listener to send data to InfluxDB.
To configure the backend listener in JMeter:
On the Backend Listener screen, set the Backend Listener Implementation to the influxdb listener.
Set the influxDb URL parameter to http://jmeter-influxdb:8086/write?db=jmeter.
Set the application parameter to the name you want to use to filter results in the Grafana dashboard, such as test.
Set the measurement parameter to jmeter.
You can also send your result data to log analytics using the Azure backend listener as described here
Run your own test plan
After creating your test plan using a local JMeter GUI instance, save a copy of the test plan to the deploy directory.
Run the test plan with:
Scale the test framework
This test framework is deployed with a single JMeter slave node, but you can scale out the deployment. To run a larger test with more slaves, use the following: