Software performance testing method, system and readable storage medium
By selecting the device with the lowest load in JMeter distributed test to start the container and sending the result data to the Kafka cluster, the problems of large single point pressure and poor reusability in distributed tests are solved, and efficient cross-network distributed tests and Resource utilization.
Patent Information
- Application Number
- CN202011251917.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-11
- Publication Date
- 2024-11-22
- Estimated Expiration
- 2040-11-22
AI Technical Summary
The existing JMeters have problems such as high single point pressure, poor node reusability, complex environmental management and high network requirements in distributed performance testing, which affect the testing efficiency and effectiveness.
By receiving software performance test scripts, selecting the device with the lowest load to start the JMeter container, sending the result data to the Kafka cluster in real time, separating the control plane and data plane, and realizing distributed testing across networks.
It improves the efficiency and resource utilization of software performance testing, reduces the processing burden of the master device, realizes distributed testing across networks, and avoids bottlenecks and complex environment management of the master device.
Smart Images

Figure CN112346979B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of software testing, and in particular to a software performance testing method, system and readable storage medium. Background Art
[0002] Apache JMeter is a Java-based stress testing tool developed by the Apache organization. It is used to stress test software. It can be used to test static and dynamic resources, such as static files, Java servlets, CGI (Common Gateway Interface) scripts, Java objects, databases, FTP (File Transfer Protocol) servers, and so on. JMeter can be used to simulate huge loads on servers, networks, or objects, test their strength under different stress categories, or analyze overall performance. In addition, JMeter can perform functional / regression testing on applications by creating scripts with assertions to verify that the program returns the expected results. For maximum flexibility, JMeter allows the use of regular expressions to create assertions.
[0003] Currently, JMeter is used to perform distributed performance testing, mainly using JMeter's Master-Slave mechanism. Figure 1 The following is a schematic diagram of the existing system architecture for distributed performance testing using JMeter. Figure 1 As shown in the figure, in this solution, a MasterJMeter service and several Slave JMeters need to be started. The Master node issues test tasks and control commands, and the Slave node executes the actual test script and returns the results to the Master node for unified processing. This solution has the following shortcomings:
[0004] 1. High pressure at a single point
[0005] Since the execution results of all Slave nodes will be sent back to the Master node for processing, and the Master node cannot be horizontally expanded, the configuration of the Master node will become the bottleneck of the entire test model when the concurrency is large, affecting the test effect.
[0006] 2. Poor node reusability
[0007] Due to the limitations of JMeter's own mechanism, the same Slave node can only accept test tasks from one Master node at the same time. When the load of a single test task is not high, the Slave node cannot execute multiple test tasks at the same time, resulting in the node being unable to be reused by multiple tests and low resource utilization.
[0008] 3. Complex environmental management
[0009] The Master and Slave nodes need to be manually configured and managed separately. For example, the information of all Slave nodes needs to be configured on the Master node, and the information of the Master node needs to be configured on each Slave node. The configuration work is cumbersome and inefficient.
[0010] 4. High network requirements
[0011] JMeter's Master-Slave mechanism uses the RMI (Remote Method Invoke) protocol to communicate between nodes. This mechanism requires that the Master and Slave nodes must be in the same Layer 2 network, which has high requirements for the network environment and cannot implement distributed testing across networks. Summary of the invention
[0012] The embodiments of the present invention provide a software performance method, a system and a readable storage medium to improve the efficiency of software performance testing.
[0013] The technical solution of the embodiment of the present invention is achieved as follows:
[0014] A software performance testing method, the method comprising:
[0015] The second device receives one or more software performance test task creation requests carrying software performance test scripts from the first device, wherein each software performance test script includes a Kafka backend listener module;
[0016] The second device creates a software performance test task for each software performance test script, starts a JMeter container for each software performance test task, and sends the software performance test script corresponding to each software performance test task to a JMeter container; and, the JMeter container receives and executes the software performance test script, and according to the Kafka backend listener module in the script, sends the result data generated during the task execution to the predefined message topic queue of the Kafka cluster in real time, wherein the result data contains the corresponding software performance test task ID.
[0017] After sending the result data generated during the task execution process to the predefined message topic queue of the Kafka cluster in real time, it further includes:
[0018] The third device consumes result data from the queue of the message topic of the Kafka cluster according to the predefined message topic, and stores the result data in a preset database; the first device reads the result data from the database, and displays the result data on a Web page.
[0019] Before the second device receives one or more software performance test task creation requests carrying software performance test scripts from the first device, the method further includes:
[0020] The first device receives one or more software performance test scripts input by the user, and for each software performance test script, selects the second device with the smallest load according to the real-time load of each second device maintained in real time, and sends the current software performance test script to the selected second device in a software performance test task creation request.
[0021] The first device receives one or more software performance test scripts input by the user, including:
[0022] The first device receives one or more software performance test scripts and an optional second device list input by a user;
[0023] The selecting of the second device with the smallest load comprises:
[0024] The second device with the smallest load is selected from the selectable second device list input by the user.
[0025] Before the first device receives one or more software performance test scripts input by a user, the method further includes:
[0026] The first device stores the IP addresses of the second devices;
[0027] The sending the current software performance test script to the selected second device in the software performance test task creation request includes:
[0028] According to the IP address of the selected second device, the current software performance test script is carried in the software performance test task creation request and sent to the selected second device.
[0029] The second device communicates with the first device via HTTP.
[0030] The second device receiving one or more software performance test task creation requests carrying software performance test scripts from the first device includes:
[0031] The second device receives one or more software performance test task creation requests carrying software performance test scripts sent by one or more first devices, wherein each first device sends one or more software performance test task creation requests carrying software performance test scripts.
[0032] A software performance testing system, comprising:
[0033] The first device receives one or more software performance test scripts input by a user, selects a second device for each software performance test script, and sends the software performance test script to the selected second device in a software performance test task creation request;
[0034] The second device receives one or more software performance test task creation requests carrying software performance test scripts from the first device, wherein each software performance test script contains a Kafka backend listener module; creates a software performance test task for each software performance test script, starts a JMeter container for each software performance test task, and sends the software performance test script corresponding to each software performance test task to a JMeter container; and the JMeter container receives and executes the software performance test script, and according to the Kafka backend listener module in the script, sends the result data generated during the task execution process to the predefined message topic queue of the Kafka cluster in real time, wherein the result data contains the corresponding software performance test task ID;
[0035] Kafka cluster equipment, maintains the Kafka cluster.
[0036] The system further comprises:
[0037] The third device consumes the result data from the queue of the message topic of the Kafka cluster according to the predefined message topic, and stores the result data in a preset database;
[0038] Furthermore, the first device reads result data generated during the execution of the software performance test script from a preset database, and displays the result data on a Web page.
[0039] A non-transitory computer-readable storage medium stores instructions, which, when executed by a processor, cause the processor to perform the steps of any of the methods described above.
[0040] In an embodiment of the present invention, after the second device receives multiple software performance test scripts, it can create a software performance test task for each software performance test script, and start a JMeter container for each software performance test task, so that the second device can execute multiple software performance test scripts at the same time, thereby improving the efficiency of software performance testing; at the same time, the result data during the execution of the software test script does not need to be sent to the first device, but is stored in the Kafka queue, separating the control plane and the data plane, thereby reducing the processing burden of the first device and further improving the efficiency of software performance testing. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 This is a schematic diagram of the existing system architecture for distributed performance testing using JMeter;
[0042] Figure 2 A flowchart of a software performance testing method provided by an embodiment of the present invention;
[0043] Figure 3 A flowchart of a software performance testing method provided by another embodiment of the present invention;
[0044] Figure 4 A schematic diagram of the structure of a software performance testing system provided by an embodiment of the present invention;
[0045] Figure 5 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0046] The present invention will be further described in detail below in conjunction with the accompanying drawings and specific embodiments.
[0047] Figure 2 The flowchart of the software performance testing method provided by one embodiment of the present invention has the following specific steps:
[0048] Step 201: The second device receives one or more software performance test task creation requests carrying software performance test scripts from the first device, wherein each software performance test script includes a Kafka backend listener module.
[0049] Step 202: The second device creates a software performance test task for each software performance test script, starts a JMeter container for each software performance test task, and sends the software performance test script corresponding to each software performance test task to a JMeter container.
[0050] Step 203: The JMeter container receives and executes the software performance test script, and sends the result data generated during the task execution process to the predefined message topic queue of the Kafka cluster in real time according to the Kafka backend listener module in the script, wherein the result data includes the corresponding software performance test task ID.
[0051] In the above embodiment, after the second device receives multiple software performance test scripts, it can create a software performance test task for each software performance test script, and start a JMeter container for each software performance test task, so that the second device can execute multiple software performance test scripts at the same time, thereby improving the efficiency of software performance testing; at the same time, the result data during the execution of the software test script does not need to be sent to the first device, but is stored in the Kafka queue, separating the control plane and the data plane, thereby reducing the processing burden of the first device and further improving the efficiency of software performance testing.
[0052] In an optional embodiment, in step 203, after the JMeter container sends the result data generated during the task execution process to the predefined message topic queue of the Kafka cluster in real time, the method further includes:
[0053] The third device consumes result data from the queue of the message topic of the Kafka cluster according to the predefined message topic, and stores the result data in a preset database; the first device reads the result data from the database, and displays the result data on a Web page.
[0054] In the above embodiment, by reading the result data from the Kafka queue to the preset database, the result data is persistently saved, and the first device can read the result data from the database and display it on the Web page, thereby displaying the result data to the user.
[0055] In an optional embodiment, in step 201, before the second device receives one or more software performance test task creation requests carrying software performance test scripts from the first device, the method further includes:
[0056] The first device receives one or more software performance test scripts input by the user, and for each software performance test script, selects the second device with the smallest load according to the real-time load of each second device maintained in real time, and sends the current software performance test script to the selected second device in a software performance test task creation request.
[0057] In the above embodiment, the software performance test script can be allocated according to the load of each second device, thereby avoiding delayed execution of the software performance test script and improving the efficiency of the software performance test.
[0058] In an optional embodiment, the first device receiving one or more software performance test scripts input by a user includes: the first device receiving one or more software performance test scripts input by a user and an optional second device list;
[0059] And, selecting the second device with the smallest load includes: selecting the second device with the smallest load from a list of optional second devices input by a user.
[0060] Taking into account that multiple users may perform software performance testing at the same time, in order to ensure that all second devices can be used evenly, all second devices can be pre-allocated to various users, that is, a part of second devices can be allocated to each user. In this way, each user has a list of optional second devices, thereby improving the load balancing of all second devices and improving the efficiency of software performance testing.
[0061] In an optional embodiment, before the first device receives one or more software performance test scripts input by the user, the method further includes: the first device saves the IP address of each second device;
[0062] Carrying the current software performance test script in the software performance test task creation request and sending it to the selected second device includes: carrying the current software performance test script in the software performance test task creation request and sending it to the selected second device according to the IP address of the selected second device.
[0063] It can be seen from the above embodiments that in the embodiments of the present invention, it is only necessary to configure the IP address of the second device on the first device, and the configuration is simple.
[0064] In an optional embodiment, the second device communicates with the first device via HTTP (HyperText Transfer Protocol).
[0065] Since the second device and the first device communicate via HTTP, the second device and the first device do not need to be in the same layer-2 network, and distributed testing across networks can be implemented.
[0066] In an optional embodiment, in step 201, the second device receives one or more software performance test task creation requests carrying software performance test scripts from the first device, including:
[0067] The second device receives one or more software performance test task creation requests carrying software performance test scripts sent by one or more first devices, wherein each first device sends one or more software performance test task creation requests carrying software performance test scripts.
[0068] It can be seen from the above embodiments that the second device can simultaneously accept and execute software performance test scripts sent from multiple first devices, thereby improving resource utilization of the second device. At the same time, the first device can be horizontally expanded to avoid the first device reaching a processing bottleneck, thereby further improving software performance testing efficiency.
[0069] Figure 3 A flowchart of a software performance testing method provided by another embodiment of the present invention, wherein the specific steps are as follows:
[0070] Step 301: pre-set one or more first devices as control devices, preset multiple second devices configured with Node-Controller components as execution devices, set one or more third devices configured with Data-Streaming components as result processing devices, and configure the IP addresses of all second devices on each first device.
[0071] Step 302: Any first device receives one or more software performance test scripts in JMX format and an optional second device list input by a user.
[0072] In actual applications, for the sake of convenience, when the content of the current software performance test script is basically the same as the content of the previously compiled software performance test script, with only some differences in stress parameters, the user can directly send the previous software performance test script and a stress parameter update table to the first device, wherein the stress parameter update table includes the name of the changed stress parameter and the new value.
[0073] Step 303: The first device receives the one or more software performance test scripts and adds a predefined KafkaBackendListener (Kafka backend listener) module to a preset position of each script.
[0074] The function of the KafkaBackendListener module is to write the result data generated during the script execution process to the preset message topic of the Kafka cluster in real time.
[0075] If a software performance test script has a corresponding pressure parameter update table, the first device also needs to modify the value of the corresponding pressure parameter in the script according to the pressure parameter update table.
[0076] Step 304: the first device creates a software performance test task for each script, selects a second device from the optional second device list for each task, and sends the task to the selected second device.
[0077] In actual applications, when there are front-end processing steps, a front-end device is usually specially set up to process the front-end steps, that is, the first device can be split into two devices: a front-end device and a back-end device. The front-end device executes step 302 and then sends the received software performance test scripts to the back-end device. The back-end device executes steps 303 and 304.
[0078] The front-end device and the back-end device communicate via HTTP.
[0079] Step 305: The second device receives the task through the interface of the Node-Controller component. The Node-Controller component starts a JMeter container through the Docker interface and sends the software performance test script corresponding to the task to the JMeter container.
[0080] Step 306: The JMeter container executes the script and sends the result data of the execution process to the preset message topic of the Kafka cluster in real time according to the KafkaBackendListener module in the script, wherein the result data includes the corresponding software performance test task ID.
[0081] The JMeter container is automatically destroyed after executing the software performance test script.
[0082] Step 307: The Data-Streaming component of the third device consumes result data from the queue of the preset message topic of the Kafka cluster according to the pre-subscribed consumption message topic, and stores the consumed result data in the preset database.
[0083] Step 308: The first device reads result data from the database and displays the result data on a Web page.
[0084] If the first device is divided into a front-end device and a back-end device, the back-end device reads the result data from the database, sends the result data to the front-end device, and the front-end device displays the result data on a Web page.
[0085] The first device and the second device communicate with each other via HTTP.
[0086] Figure 4 The architecture diagram of the software performance testing system provided by the embodiment of the present invention is as follows: Figure 4 As shown, the system includes: at least one first device, multiple second devices, a Kafka cluster device and at least one third device, wherein:
[0087] The first device receives one or more software performance test scripts input by the user, selects a second device for each software performance test script, carries the software performance test script in a software performance test task creation request and sends it to the selected second device; reads result data generated during the execution of the software performance test script from a database, and displays the result data on a Web page.
[0088] The second device receives one or more software performance test task creation requests carrying software performance test scripts from the first device, wherein each software performance test script includes a Kafka backend listener module; creates a software performance test task for each software performance test script, starts a JMeter container for each software performance test task, and sends the software performance test script corresponding to each software performance test task to a JMeter container; and the JMeter container receives and executes the software performance test script, and according to the Kafka backend listener module in the script, sends the result data generated during the task execution to the predefined message topic queue of the Kafka cluster in real time, wherein the result data includes the corresponding software performance test task ID.
[0089] Kafka cluster equipment, maintains the Kafka cluster.
[0090] The third device consumes result data from the queue of the message topic of the Kafka cluster according to the predefined message topic, and stores the result data in a preset database.
[0091] An embodiment of the present invention further provides a non-transitory computer-readable storage medium, which stores instructions, and when the instructions are executed by a processor, the processor executes steps 201-203.
[0092] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. The electronic device includes the non-transitory computer-readable storage medium 51 as described above, and a processor 52 capable of accessing the non-transitory computer-readable storage medium 51.
[0093] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A software performance testing method, characterized in that: The method includes: The second device receives one or more software performance test task creation requests carrying software performance test scripts from the first device, wherein each software performance test script includes a Kafka backend listener module; The second device creates a software performance test task for each software performance test script, and starts a JMeter container for each software performance test task, so that: the second device executes multiple software performance test scripts simultaneously, and sends the software performance test script corresponding to each software performance test task to a JMeter container respectively; and the JMeter container receives and executes the software performance test script, and sends the result data generated during the task execution process to the predefined message topic queue of the Kafka cluster in real time according to the Kafka backend listener module in the script, wherein the result data contains the corresponding software performance test task ID; Before the second device receives one or more software performance test task creation requests carrying software performance test scripts from the first device, the method further includes: The first device receives one or more software performance test scripts input by the user, and for each software performance test script, selects the second device with the smallest load according to the real-time load of each second device maintained in real time, and sends the current software performance test script to the selected second device in a software performance test task creation request.
2. The method according to claim 1, characterized in that After sending the result data generated during the task execution process to the predefined message topic queue of the Kafka cluster in real time, it further includes: The third device consumes result data from the queue of the message topic of the Kafka cluster according to the predefined message topic, and stores the result data in a preset database; the first device reads the result data from the database, and displays the result data on a Web page.
3. The method according to claim 1, characterized in that The first device receives one or more software performance test scripts input by the user, including: The first device receives one or more software performance test scripts and an optional second device list input by a user; The selecting of the second device with the smallest load comprises: Select a second device with the smallest load from the selectable second device list input by the user.
4. The method according to claim 1, characterized in that: Before the first device receives one or more software performance test scripts input by a user, the method further includes: The first device stores the IP addresses of the second devices; The sending the current software performance test script to the selected second device in the software performance test task creation request includes: According to the IP address of the selected second device, the current software performance test script is carried in the software performance test task creation request and sent to the selected second device.
5. The method according to claim 1, characterized in that The second device communicates with the first device via HTTP.
6. The method according to claim 1, characterized in that The second device receiving one or more software performance test task creation requests carrying software performance test scripts from the first device includes: The second device receives one or more software performance test task creation requests carrying software performance test scripts sent by one or more first devices, wherein each first device sends one or more software performance test task creation requests carrying software performance test scripts.
7. A software performance testing system, characterized in that: include: The first device receives one or more software performance test scripts input by a user, selects a second device for each software performance test script, and sends the software performance test script to the selected second device in a software performance test task creation request; The second device receives one or more software performance test task creation requests carrying software performance test scripts from the first device, wherein each software performance test script contains a Kafka backend listener module; creates a software performance test task for each software performance test script, and starts a JMeter container for each software performance test task, so that: the second device executes multiple software performance test scripts simultaneously, and sends the software performance test script corresponding to each software performance test task to a JMeter container respectively; and the JMeter container receives and executes the software performance test script, and according to the Kafka backend listener module in the script, sends the result data generated during the task execution process to the predefined message topic queue of the Kafka cluster in real time, wherein the result data contains the corresponding software performance test task ID; Kafka cluster equipment, maintaining the Kafka cluster; The first device selects a second device for each software performance test script, including: For each software performance test script, the second device with the smallest load is selected according to the real-time loads of the second devices maintained in real time.
8. The system according to claim 7, characterized in that The system further comprises: The third device consumes the result data from the queue of the message topic of the Kafka cluster according to the predefined message topic, and stores the result data in a preset database; Furthermore, the first device reads result data generated during the execution of the software performance test script from a preset database, and displays the result data on a Web page.
9. A non-transitory computer-readable storage medium storing instructions, characterized in that: When the instructions are executed by a processor, the processor is caused to perform the steps of the method according to any one of claims 1 to 6.
