DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Because the DevOps movement has redefined engineering responsibilities, SREs now have to become stewards of observability strategy.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Related

  • Vibe Coding With GitHub Copilot: Optimizing API Performance in Fintech Microservices
  • Multi-Tenancy and Its Improved Support in Hibernate 6.3.0
  • Showing Long Animation Frames in Your DevTools
  • How to Enhance the Performance of .NET Core Applications for Large Responses

Trending

  • How Kubernetes Cluster Sizing Affects Performance and Cost Efficiency in Cloud Deployments
  • How to Build Real-Time BI Systems: Architecture, Code, and Best Practices
  • Data Lake vs. Warehouse vs. Lakehouse vs. Mart: Choosing the Right Architecture for Your Business
  • AI-Driven Root Cause Analysis in SRE: Enhancing Incident Resolution
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Testing, Tools, and Frameworks
  4. How To Use Smart-Doc To Generate JMeter Scripts

How To Use Smart-Doc To Generate JMeter Scripts

Explore smart-doc, used to automatically scan code to generate JMeter performance test scripts, improving the efficiency of performance stress testing.

By 
sun yu user avatar
sun yu
·
May. 16, 24 · Tutorial
Likes (5)
Comment
Save
Tweet
Share
1.8K Views

Join the DZone community and get the full member experience.

Join For Free

smart-doc is a tool for automatically generating Java API documentation. It creates documentation by analyzing interfaces and comments in the source code and supports a variety of document output formats, including Markdown, HTML5,  OpenAPI 3.0, and more. The design goal of smart-doc is to simplify the document writing process, improve development efficiency, and ensure the accuracy and timeliness of the documentation.

In the software development lifecycle, the automatic generation of API documentation and the performance testing of interfaces are key steps in improving development efficiency and ensuring product quality. With the addition of the ability to generate JMeter performance testing scripts in smart-doc version 3.0.1, developers can more conveniently accomplish these two tasks. This article will introduce how to use smart-doc and JMeter for effective performance testing.

smart-doc overview

Generate JMeter Scripts

Using smart-doc to generate JMeter performance test scripts can significantly reduce the time taken to write performance test scripts, thereby improving testing efficiency. The JMeter scripts that are automatically generated by smart-doc can be directly run in JMeter without the need for complex configuration and debugging, making performance testing much simpler and faster.

First, ensure that the smart-doc-maven-plugin has been added to your project. Then, configure the relevant parameters of the smart-doc plugin in the pom.xml file of the project, for example:

Configure the relevant parameters of the smart-doc plugin in the pom.xml file of the project

Run the command mvn -Dfile.encoding=UTF-8 smart-doc:jmeter. Smart-doc will scan the project source code, extract annotation information, and automatically generate the corresponding JMeter performance test scripts.

Those who are not familiar with how to use it can refer to the official smart-doc documentation.

Import Into JMeter

Open JMeter, click "File" -> "Open", select the JMeter script file generated in the first step, and click the "Start" button. JMeter will then begin performing performance tests according to the script.JMeter beginning performing performance tests according to the script

Configure Prometheus

Prometheus is an open-source monitoring and alerting tool for handling time-series data. We can use it to perform real-time monitoring during the JMeter stress testing process, thereby enhancing the observability of performance testing.

Step 1: Install the JMeter Prometheus Plugin

First, you need to install the Prometheus plugin in the lib/ext directory of JMeter. You can download the plugin from the JMeter Plugins Manager or the official website. It can also be downloaded from GitHub. For this instance, download the latest version 0.7.1 from GitHub.

Downloading the latest version 0.7.1 from GitHub

  • Note: JMeter's default listening IP address is 127.0.0.1, which by default will prevent Prometheus from connecting to the JMeter Prometheus listening port. Therefore, it is necessary to add prometheus.ip=0.0.0.0 in jmeter.properties.

Step 2: Add Prometheus Listener

Open JMeter and add the Prometheus Listener to your test plan. This can be done by right-clicking on Test Plan-> Add -> Listener -> Prometheus Listener.

Open JMeter and add the Prometheus Listener to your test plan

The configuration of the listener can refer to the official settings, with reference as follows (smart-doc 3.0.4 supports configuring and adding Prometheus Listener generation):

Adding Prometheus Listener generation

Step 3: Configure Prometheus Scrape

In the configuration file of Prometheus (prometheus.yml), add a new scrape_config to fetch data from the JMeter Prometheus plugin. For example:

YAML
 
scrape_configs:
  - job_name: 'jmeter'
    scrape_interval: 15s
    static_configs:
        - targets: ['<Your JMeter machine IP>:9270']


Here, <Your JMeter machine IP> is the IP address of the machine running the JMeter test, and 9270 is the default listening port for the JMeter Prometheus plugin.

Step 4: Run the Test Plan

For the purpose of easy verification in this article, the thread group is set to "infinite loop" during stress testing, which can be adjusted according to actual needs.Thread group is set to "infinite loop"

After starting successfully, JMeter Prometheus will, by default, create a service on the local port 9270. 

Access the URL http://localhost:9270/metrics and if you see the following content, it means it has been successful.

Output showing success

Step 5: Start Prometheus

After starting Prometheus, it will begin to fetch data from the JMeter Prometheus plugin. As shown in the following configuration, once successfully started, you can see the set targets in Prometheus.

Setting the targets in Prometheus
Step 6: Configure Grafana

On the Grafana official website, find the prometheus-jmeter monitoring panel provided by the official site. Here, we select the template with ID 14927 to import into Grafana.

Select the template with ID 14927 to import into Grafana

After clicking Load, select the Prometheus data source.Select the Prometheus data source

  • Note: During testing, it was found that the original template 14927 had some errors. These were fixed during the writing process of this article. Import the corrected template downloaded from GitHub.

After the template is successfully imported, we will be able to see the entire performance testing monitoring data in Grafana.

Performance testing monitoring data in Grafana (1)

Performance testing monitoring data in Grafana (2)

To facilitate a rapid experience of the entire performance testing process, the smart-doc community has curated and provided a template that can be launched with a single command using docker-compose. For those who wish to experience it through Kubernetes deployment, AI tools can be utilized to directly convert the docker-compose template into a Kubernetes deployment template.

smart-doc demo

The project for the experience also includes usage instructions.

JMeter Performance Test instructionsThe example code for this article can be found here.

The Assistance of Smart-Doc in JMeter Performance Testing

The combination of smart-doc and JMeter for performance stress testing offers several advantages:

  • Automation: smart-doc can automatically extract API information from the source code and generate JMeter performance test scripts without the need for manual writing, greatly improving efficiency.
  • Precision: The JMeter performance test scripts generated by smart-doc are completely consistent with the API definitions in the source code, avoiding errors that may occur when manually writing scripts.
  • Flexibility: smart-doc supports a variety of configuration options, allowing the generated JMeter scripts to be customized according to testing requirements.

smart-doc will also continue to improve and optimize support for JMeter. Please stay tuned for the ongoing development of the smart-doc open-source project.

Summary

By combining smart-doc and JMeter, we can not only automate the generation of API documentation but also swiftly create performance test scripts and conduct stress testing. This automation tool significantly enhances development and testing efficiency while helping teams more easily maintain and optimize the performance of software systems. We hope this article has provided practical references for you to apply these tools more efficiently in your daily work.

We also welcome everyone to continue to follow and support the smart-doc open-source community. In the future, we are exploring support for additional languages to assist more developers.

API Stress testing Performance Apache JMeter Test script

Opinions expressed by DZone contributors are their own.

Related

  • Vibe Coding With GitHub Copilot: Optimizing API Performance in Fintech Microservices
  • Multi-Tenancy and Its Improved Support in Hibernate 6.3.0
  • Showing Long Animation Frames in Your DevTools
  • How to Enhance the Performance of .NET Core Applications for Large Responses

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!