Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Script log and report processing under jmeter cluster

2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

Jmeter supports distributed testing. In distributed mode, a dispatcher dispatches all executors (cluster nodes). When executing scripts, you can freely choose a single node to execute or distribute the specified or all machines in the cluster to execute. When using the dispatcher client to distribute scripts, no matter in GUI mode or non-GUI mode, there is no problem with the collection of script logs and the generation of reports, but if you use jmeter SDK to call client-side concurrent distribution scripts in the code to be executed by the executor, there will be the problem that logs cannot be obtained in real time (it takes time for super-large logs generated during the execution of super-large jmx scripts to be transferred over the network).

Through the analysis of the source code of jmeter SDK, it is found that log collection is executed asynchronously, but the notification capability of log collection completion is not provided in SDK, which leads to frequent errors in generating reports based on logs (the actual scripts are all executed normally). After analyzing the above problems, the solutions are as follows:

After the script is executed, the current thread sleeps for a certain amount of time

Brute force reflex attempts to obtain the transmission status of the log

Modify the source code of jmeter SDK to add a listening mechanism

The current thread is only responsible for executing the script to the end state, collecting logs regularly and generating reports

In view of the above four schemes, their advantages and disadvantages are analyzed.

Log size cannot be determined, sleep time cannot be determined, and sleep can cause threads to wait, which may result in ThreadInterruptException

Jmeter SDK comments are poorly written (basically no comments). Analyzing the source code requires strong technical ability and a certain amount of time. The current schedule is not allowed.

Similarly, due to the reasons of annotation, it also requires strong technical ability and a certain amount of time, but it is less difficult than the second way, and it is also a solution that can produce the best results.

The lowest technical requirements and easy implementation, but the generation of logs and reports will be delayed (based on timer cycles)

In terms of the current product requirements, logs and reports are not extremely sensitive and real-time data, so finally choose the fourth solution, the code is as follows:

Pull a task that has not been logged for 14400 seconds (task execution timeout, configurable startup parameters) every ten minutes and attempts to get the log.

Because the log is pulled asynchronously, the configuration of jmeter is loaded once before pulling the log.

Considering that each downtime maintenance may take a long time (exceeding the currently set task timeout), you also need to provide an ability to scan tasks when you start the application.

The CommandLineRunner interface identifies the implementation class that executes the interface when the application is started, so you need to use @ Component to add the objects of the class to the IOC container.

After the log is pulled, the report is processed. According to the same principle, every 10 minutes, pull 14400 seconds (task execution timeout, configurable startup parameters) for tasks that have not yet obtained logs and try to generate reports based on the logs.

Also because reports are generated asynchronously, configuration management for jmeter needs to be loaded once when the report is generated. Downtime maintenance should also be considered here, using CommandLineRunner.

At this point, the problems generated by jmeter logs and execution are solved perfectly, and each completed task may have a delay of about 10% to get logs and reports.

The figure above on ▲ shows that logs and reports are being generated when the task is executed and after the task is executed successfully

Author: Chen Jie

How should other technical articles be designed for enterprise application operation and maintenance automation?

Password management for local administrators of computers in the domain

Tencent PaaS platform | what if the hostname is set incorrectly?

Introduction to Redis persistence

4 big steps to save 30% waste, optimizing enterprise cloud cost starts with understanding cloud!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report