Custom plugin creation and integration with JMeter and Azure Load Testing
Published Mar 28 2023 05:28 AM 6,247 Views
Microsoft

JMeter has a lot to offer, though sometimes, you may run into use cases that are unique to your workflows or user scenarios, and not directly implementable using standard JMeter elements. For example, you might want to enable a custom authentication process, create a sampler of your own, or design a testing element that is not yet released in the open source JMeter community. 

Custom plugins extend the core functionality of JMeter and may allow you to implement that custom scenario into your performance tests to fine tune your test scripts and reporting capabilities. Learn how to get more from your performance testing, using custom plugins and Azure Load Testing.  

 

In our blog we will talk about how one can broadly classify planning and execution for performance testing in 3 stages.

  1. Pre-Requisite (Mandatory) – Test Data, environment setup check, property file, 3rd party connectivity, firewall rules etc.
  2. Execution - Run your test scripts with Azure Load Testing 
  3. Post execution (Optional) – Report Generation, Basic Validation etc.

Take advantage of Azure Load Testings support for custom plugins to optimize your test planning (pre-requisites) and reporting, allow user to use the plugins from https://jmeter-plugins.org or, upload a Java archive (JAR) file with your own plugin code.  

 

Consider a case for Custom Plugin “If there is a need of 1Million of JSON files to be created and inserted in database as pre-requisite before execution, once execution is completed, we need to validate if the records are transformed correctly and pushed to some other database  
This can be handled easily using a custom plugin “Which will have a Java function which can create a Million JSON file and do a DB (databases) insert and once execution is done via JMeter script in Azure load test, can provide a quick validation and generate report as well.”
 

 

Custom Plugin(jar) is created using Java SDK (software development kits). Classes and Function can be called JMeter BeanShell Sampler or JSR223 Sampler. These are the steps for generating simple custom plugins, integrating them with JMeter Suite. 
 
Pre-Requisite - 
1. Java SDK (latest version recommended) 
2. Maven (latest version recommended) 
3. IDE (integrated development environments) (Visual Studio Code or any other IDEs) 

 
Steps for Creating Custom Plugin

1. Download the Sample Java Maven project - 
azureloadtest_custompluginsample.zip

Shivam_Maralay_1-1676646213509.png


2. Using Maven create a JAR using the command 
mvn clean compile assembly:single
Note
: Execute this command on the location having .pom file present.


3. Link the new JAR in the JMeter Suite - Click on browse and import jar.
Note Use the name of the JAR file instead of using the complete path of the JAR file 

for example. in our case we have name as sampleexample-1.0-jar-with-dependencies.jar

 

Shivam_Maralay_4-1676647788401.png

 

4. Create a BeanShell or JSR223 Sampler in your JMeter Suite and import the package after this create an object of class and call the functions.

Shivam_Maralay_1-1676652537702.png

5. Upload the .jmx file and .jar file in Azure Load Testing and perform the execution

Read more about JMeter plugins in the Azure Load Testing docs: https://learn.microsoft.com/azure/load-testing/how-to-use-jmeter-plugins?tabs=portal 

 

Additional resources:  

If you have any feedback on Azure Load Testing, let us know in our feedback forum.  

 

 

Co-Authors
Version history
Last update:
‎Mar 28 2023 07:11 AM
Updated by: