Pressure test method, equipment, storage medium and device
By generating configuration files and command lines upon receiving instructions and automatically executing stress tests, the system solves the problems of complex configuration and high cost of existing stress testing tools and achieves efficient high-concurrency testing.
Patent Information
- Application Number
- CN202410302443.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-15
- Publication Date
- 2025-09-16
AI Technical Summary
Existing stress testing tools lack specialized tools and are complex to configure, resulting in a long time and high cost. In addition, third-party tools are difficult to develop secondary, making it impossible to conduct effective stress testing.
A stress testing method is provided. By determining the test case upon receiving the instruction, generating the configuration file and command line, the stress test is automatically executed, avoiding repeated configuration and compilation installation, and directly converting to high-concurrency testing.
It realizes the conversion of single functional tests into high-concurrency tests without a lot of configuration and compilation installation, shortening test time, reducing costs and providing convenience.
Smart Images

Figure CN120653543A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of pressure testing technology, and in particular to a pressure testing method, equipment, storage medium and device. Background Art
[0002] Currently, during software development, product testing often relies solely on single-function testing tools, rather than dedicated stress testing tools. Developing independent stress testing tools is time-consuming, costly, and requires significant duplication of effort. Furthermore, many third-party tools lack the ability to be redeveloped, making stress testing difficult. Furthermore, while existing stress testing platforms are professional, they are complex to configure and use, requiring significant human, material, and time investment, resulting in high costs. Summary of the Invention
[0003] The main purpose of the present invention is to provide a stress testing method, equipment, storage medium and device, aiming to solve the technical problem that traditional stress testing methods have limitations, resulting in stress testing being time-consuming and costly.
[0004] To achieve the above object, the present invention provides a stress testing method applied to a cloud server, the stress testing method comprising the following steps:
[0005] Upon receiving a stress test instruction, determining a test case for the function to be tested according to the stress test instruction;
[0006] Generate a configuration file according to the test case, and determine the command line required for the test according to the configuration file;
[0007] A stress test is performed based on the configuration file and the command line to obtain a stress test result.
[0008] Optionally, the step of generating a configuration file according to the test case and determining a command line required for the test according to the configuration file includes:
[0009] Determine the number of thread loops, the number of concurrent tests, and test content information based on the preconditions contained in the test case;
[0010] A configuration file is generated according to the number of thread cycles, the test content information, and the number of concurrent tests, and a command line required for the test is determined according to the configuration file.
[0011] Optionally, after the step of determining the command line required for the test according to the configuration file, the method further includes:
[0012] Determine the preprocessing quantity corresponding to the configuration file according to the concurrent test quantity, where the preprocessing quantity is the total quantity of the configuration files;
[0013] The processed amount of the configuration file is counted in real time until the processed amount reaches the pre-processed amount, where the processed amount refers to the amount completed when the configuration file is executed during the test.
[0014] Optionally, the step of performing a stress test based on the configuration file and the command line to obtain a stress test result includes:
[0015] Determine the number of processes to be started based on the number of concurrent tests;
[0016] A stress test is performed based on the thread cycle count, the process quantity, the test content information, and the command line to obtain a stress test result.
[0017] Optionally, after the step of performing a stress test based on the number of thread cycles, the number of processes, the test content information, and the command line and obtaining a stress test result, the step further includes:
[0018] Determine the total number of tests according to the number of thread cycles and the number of processes;
[0019] If the number of stress test results reaches the total number of tests, the test is stopped.
[0020] Optionally, after the step of performing the stress test based on the configuration file and the command line and obtaining the stress test result, the method further includes:
[0021] Real-time statistics of the stress test results to obtain stress test information;
[0022] Generate a test report based on the stress test information.
[0023] Optionally, after the step of collecting statistics of the stress test results in real time and obtaining stress test information, the method further includes:
[0024] Determine a result output period according to the configuration file, and set a timer according to the result output period;
[0025] The pressure test result is counted based on the timer, and pressure test information is output.
[0026] Optionally, the step of performing a stress test based on the configuration file and the command line to obtain a stress test result includes:
[0027] Execute a stress test based on the startup command line in the command line and the configuration file, and obtain a command line return value;
[0028] The stress test result is determined according to the command line return value.
[0029] Optionally, the step of collecting statistics of the stress test results in real time to obtain stress test information includes:
[0030] Determine an average success rate based on the number of successes and failures in the stress test results;
[0031] The stress test statistics are determined based on the average success rate, the number of concurrent tests, the number of started single tests, the number of completed single tests, the failure time, and the test time information.
[0032] Optionally, the step of generating a test report according to the stress test information includes:
[0033] Determine the maximum number of concurrent tests based on the number of concurrent tests and the average success rate in the stress test information;
[0034] Determine the system response time based on the test time information in the stress test information;
[0035] Determining throughput information based on the number of completed single tests and the test duration information;
[0036] A test report is generated according to the maximum number of concurrent connections, the throughput information, and the system response time.
[0037] In addition, to achieve the above-mentioned purpose, the present invention also proposes a stress testing device, which includes a memory, a processor, and a stress testing program stored in the memory and executable on the processor, wherein the stress testing program is configured to implement the stress testing steps described above.
[0038] In addition, to achieve the above-mentioned purpose, the present invention further proposes a storage medium, on which a stress testing program is stored. When the stress testing program is executed by a processor, the steps of the stress testing method described above are implemented.
[0039] In addition, to achieve the above-mentioned purpose, the present invention further provides a pressure testing device, which includes:
[0040] An instruction recognition module is used to determine a test case of the function to be tested according to the stress test instruction when receiving the stress test instruction;
[0041] A preprocessing module, configured to generate a configuration file according to the test case and determine the command line required for the test according to the configuration file;
[0042] The stress test module is used to perform stress testing based on the configuration file and the command line to obtain stress test results.
[0043] Optionally, the preprocessing module is further configured to determine the number of thread cycles, the number of concurrent tests, and test content information according to the preconditions included in the test case;
[0044] The preprocessing module is further configured to generate a configuration file according to the number of thread cycles, the test content information, and the number of concurrent tests, and determine command lines required for the test according to the configuration file.
[0045] Optionally, the pressure testing device further includes a data statistics module;
[0046] The data statistics module is further configured to determine the pre-processing quantity corresponding to the configuration files according to the concurrent test quantity, where the pre-processing quantity is the total quantity of the configuration files;
[0047] The data statistics module is further used to count the processed amount of the configuration file in real time until the processed amount reaches the pre-processed amount, and the processed amount refers to the number of configuration files completed when executing the test.
[0048] Optionally, the stress testing module is further configured to determine the number of processes to be started according to the number of concurrent tests;
[0049] The stress test module is further configured to perform a stress test based on the number of thread cycles, the number of processes, the test content information, and the command line to obtain a stress test result.
[0050] Optionally, the data statistics module is further configured to determine the total number of tests based on the number of thread cycles and the number of processes;
[0051] The data statistics module is further configured to stop the test if the number corresponding to the stress test results reaches the total number of tests.
[0052] Optionally, the data statistics module is further used to collect statistics of the stress test results in real time to obtain stress test information;
[0053] The data statistics module is further used to generate a test report based on the stress test information.
[0054] Optionally, the pressure testing device further includes a timer module;
[0055] The timer module is further configured to determine a result output period according to the configuration file and set a timer according to the result output period;
[0056] The timer module is further configured to collect statistics on the stress test results based on the timer and output stress test information.
[0057] Optionally, the stress testing module is further configured to execute a stress test based on a startup command line in the command line and the configuration file, and obtain a command line return value;
[0058] The stress test module is further configured to determine a stress test result based on a return value of the command line.
[0059] The present invention determines the test case of the function to be tested according to the stress test instruction upon receiving the stress test instruction; generates a configuration file according to the test case, and determines the command line required for the test according to the configuration file; performs the stress test based on the configuration file and the command line to obtain the stress test result. Compared with the traditional stress testing method, which has limitations and causes stress testing to be time-consuming and costly, the present invention realizes automated testing by generating a corresponding configuration file and command line for a single test. The present invention realizes that a single functional test can be converted into a high-concurrency stress testing system without a large amount of configuration or compilation and installation, shortening the test time and providing great convenience for the testing work. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] Figure 1 Schematic diagram of the structure of the stress testing equipment for the hardware operating environment involved in the embodiment of the present invention;
[0061] Figure 2 This is a flow chart of a first embodiment of a pressure testing method according to the present invention;
[0062] Figure 3 A schematic diagram of a pressure testing system according to a first embodiment of the pressure testing method of the present invention;
[0063] Figure 4 This is a schematic diagram of a sub-process flow of a pressure testing system according to a first embodiment of the pressure testing method of the present invention;
[0064] Figure 5 This is a flow chart of starting a test sub-process in the first embodiment of the stress testing method of the present invention;
[0065] Figure 6 This is a flow chart of a second embodiment of the pressure testing method of the present invention;
[0066] Figure 7 This is a flow chart of the statistical sub-process of the second embodiment of the stress testing method of the present invention;
[0067] Figure 8 This is a structural block diagram of the first embodiment of the pressure testing device of the present invention.
[0068] The purpose, features and advantages of the present invention will be further described with reference to the accompanying drawings and in conjunction with the embodiments. DETAILED DESCRIPTION
[0069] It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0070] Reference Figure 1 , Figure 1 This is a schematic diagram of the structure of the stress testing equipment for the hardware operating environment involved in the embodiment of the present invention.
[0071] like Figure 1 As shown, the stress testing device may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), and optionally the user interface 1003 may also include a standard wired interface and a wireless interface. The wired interface of the user interface 1003 may be a USB interface in the present invention. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a wireless fidelity (Wi-Fi) interface). The memory 1005 may be a high-speed random access memory (RAM) or a stable memory (NVM), such as a disk memory. The memory 1005 may optionally be a storage device independent of the aforementioned processor 1001.
[0072] Those skilled in the art will understand that Figure 1 The structure shown in the figure does not constitute a limitation on the pressure testing device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0073] like Figure 1 As shown, the memory 1005 identified as a computer storage medium may include an operating system, a network communication module, a user interface module, and a stress testing program.
[0074] exist Figure 1 In the stress testing device shown, the network interface 1004 is mainly used to connect to the background server and communicate data with the background server; the user interface 1003 is mainly used to connect to the user device; the stress testing device calls the stress testing program stored in the memory 1005 through the processor 1001, and executes the stress testing method provided by the embodiment of the present invention.
[0075] Based on the above hardware structure, an embodiment of the stress testing method of the present invention is proposed.
[0076] Reference Figure 2 , Figure 2 1 is a flow chart of the first embodiment of the pressure testing method of the present invention, which provides the first embodiment of the pressure testing method of the present invention.
[0077] In this embodiment, the stress testing method is applied to a cloud server, and the stress testing method includes the following steps:
[0078] Step S10: upon receiving a stress test instruction, determining a test case of the function to be tested according to the stress test instruction.
[0079] It should be noted that the execution subject in this embodiment can be a device containing a stress testing system, and the device can be a mobile phone, a computer, or a tablet. In this embodiment and the following embodiments, the stress testing method of the present invention is described using a computer as an example. The stress testing system has the functions of process preprocessing, monitoring log files, data statistics, and stress testing. To further illustrate the stress testing system in this solution, please refer to Figure 3 The stress test system diagram shown in the figure includes a statistical sub-process module, a pre-processing process module, a timer sub-process module, a test sub-process group module, and a log file module. When executing the stress test, the startup process of each module can refer to Figure 4 The following diagram shows the sub-process flow of the stress testing system. Upon receiving a stress test command, A) the statistics sub-process module is started. This sub-process module is responsible for monitoring the system's log files, analyzing and compiling the results of "single tests," and generating a test report. This module's operations are passively triggered. B) The pre-processing process module is started: it generates a configuration file and command line for each "single test" and outputs the results to the log file module for processing by the statistics sub-process module. C) The timer sub-process module is started: it is responsible for regularly outputting stress test statistics according to the configured output period. This module runs continuously upon startup and is triggered by a timer. D) The test sub-process group module is started: based on the configured concurrency number m, processes corresponding to the corresponding concurrency number are started. Each process in the test sub-process group represents a complete test flow, and n rounds of "single tests" are completed based on the configured concurrency number n. Stress testing is also known as strength testing or load testing. Stress testing simulates the actual hardware and software environment of an application and the system load during user usage. It runs the test software for a long time or at an extremely high load to test the performance, reliability, and stability of the system under test.
[0080] It is understandable that when a user-triggered stress test instruction is received, a test case for the function to be tested is determined based on the stress test instruction. The function to be tested may be a function corresponding to a certain product, and the stress test in this solution may be a stress test on the server. This solution performs a large number of load tests on each product function one by one to facilitate the determination of product stability. The test case includes the test object, test sequence, test requirements, etc. that the tester initially specifies for the product function. By pre-writing the test case, the stress test can be triggered directly based on the test case without the need for post-compilation.
[0081] In a specific implementation, when a stress test instruction is received, a pre-set test case is called according to the function to be tested corresponding to the object to be tested contained in the stress test instruction, so as to trigger the stress test system according to the test case.
[0082] Step S20: Generate a configuration file according to the test case, and determine the command line required for the test according to the configuration file.
[0083] It should be noted that a test case may include functional modules, use case names, use case numbers, use case levels, preconditions, operating steps, expected results, and other content. Therefore, a test case can be divided into multiple test cases according to different functions. The use case number is used to define the test case number. The use case number is written according to the test case architecture and is unique, which facilitates the search and maintenance of test cases. The precondition may refer to the prerequisite for executing the use case. The precondition sets the corresponding rules. The operating steps may be the steps for executing the test process. The expected results may refer to the expected performance of the test execution. This solution generates a configuration file based on the preconditions set in the test case. The preconditions may be pre-set test content, test concurrency, and thread loop test generated by compiling a bash script. The command line may be a Linux command line, which is applicable to all Linux, Unix, and trusted computing systems.
[0084] It is understandable that the command line may be a test command line to be executed determined according to the test content in the configuration file.
[0085] Furthermore, the step S20 also includes: determining the number of thread loops, the number of test concurrency, and the test content information based on the preconditions contained in the test case; generating a configuration file based on the number of thread loops, the test content information, and the number of test concurrency, and determining the command line required for the test based on the configuration file.
[0086] It should be noted that the number of thread loops can be the number of loops of the pre-set thread group, the number of test concurrency can be the pre-set number of test thread concurrency, the test content information can be different identification information corresponding to the function to be tested, and the identification information can be determined based on different IDs, or represented in the form of characters, numbers and text, so as to generate different configuration files.
[0087] It is understandable that different command lines are determined by configuration files. Therefore, this solution implements stress testing by generating configuration files and command lines for a single test, thereby avoiding the system from being unable to perform stress testing normally due to duplicate processes in the triggered concurrent processes.
[0088] Furthermore, after the step of determining the command line required for the test based on the configuration file, it also includes: determining the preprocessing quantity corresponding to the configuration file based on the concurrent number of the test, and the preprocessing quantity is the total quantity of the configuration files; real-time statistics of the processed amount of the configuration file until the processed amount reaches the preprocessing amount, and the processed amount refers to the amount completed by the configuration file when executing the test.
[0089] It should be noted that in the process of generating configuration files and command lines, this solution will analyze the preprocessing information through the statistical sub-process group module. The preprocessing refers to the generation of configuration files and corresponding command lines for each "single test" during the preprocessing period. The preprocessing information includes: the total number of preprocessings (preprocessed quantity) and the processed quantity (processed quantity).
[0090] It is understandable that by counting the preprocessing results: that is, by counting the preprocessing results in real time, each time a preprocessing is completed, the processed number will be immediately counted and output to the screen and log file module; thereby ensuring that the configuration file and command line meet user needs and avoiding inaccurate test results due to quantity errors.
[0091] In the specific implementation, this solution counts the processed amount of configuration files in real time until the processed amount reaches the pre-processed amount, thereby determining whether the number of generated configuration files meets the user testing requirements.
[0092] Step S30: performing a stress test based on the configuration file and the command line to obtain a stress test result.
[0093] It should be noted that the stress test is performed based on the configuration file and the command line to obtain the stress test result, which includes at least one single test result, which may be a result of success or failure.
[0094] Furthermore, the step S30 further includes: executing a stress test based on the startup command line in the command line and the configuration file, and obtaining a command line return value; and determining a stress test result according to the command line return value.
[0095] It should be noted that in order to ensure the accuracy of the stress test, this solution sets the test content to different content, or marks each configuration file with an ID, so as to avoid the system mistakenly deleting the same configuration file due to the same configuration file. In order to ensure data accuracy, this solution needs to determine the test result based on the command line return value because the test content in each "single test" is different.
[0096] It is understandable that this solution starts a "single test" through the generated configuration file and the startup command line in the command line, and determines the test result according to the command line return value.
[0097] In the specific implementation, to further illustrate the execution process of the test sub-process of this solution, you can refer to Figure 5 Schematic diagram of the process of starting the test sub-process shown in the figure, wherein D1, record the start time: record the current time as the start time of the "single test", and record the start record of the "single test" in the log file module; D2, start the "single test": start the "single test" according to the start command line in the preprocessing result; D3, obtain the "single test" result: the "single test" result varies according to the test content, and is usually based on the command line return value; D4, record the end time: record the time when the "single test" is completed as the end time, and the difference with the start time is used to obtain the time taken for this round of "single test"; D5, record the log file: record the results, time and other information of the "single test" in the log file module.
[0098] This embodiment determines the test case for the function to be tested based on the stress test instruction upon receiving the stress test instruction; generates a configuration file based on the test case, and determines the command line required for the test based on the configuration file; performs the stress test based on the configuration file and the command line to obtain the stress test result. Compared with the limitations of traditional stress testing methods, which result in stress testing being time-consuming and costly, this embodiment achieves automated testing by generating a corresponding configuration file and command line for a single test. This embodiment transforms a single functional test into a highly concurrent stress test system without extensive configuration or compilation and installation, shortening testing time and greatly facilitating testing work.
[0099] Based on the above Figure 2 The first embodiment shown in FIG. 2 is a second embodiment of the pressure testing method of the present invention, referring to FIG. Figure 6 , Figure 6Schematic diagram of the flow of the second embodiment of the pressure testing method of the present invention.
[0100] In this embodiment, the step S30 further includes: determining the number of processes to be started according to the test concurrency number; performing a stress test based on the thread cycle times, the number of processes, the test content information and the command line to obtain a stress test result.
[0101] It should be noted that the number of processes to be started is determined according to the number of concurrent tests. That is, when the number of concurrent tests is set to m, m processes need to be started, and one process refers to a complete test flow from execution to completion according to the function to be tested. For example, sending a text message, from sending a text message to receiving a text message is a complete flow.
[0102] It's understood that the thread loop count refers to the number of times a thread needs to loop after execution. This value can be set to n, meaning that a test process corresponding to the same test needs to loop n times. This solution performs a stress test based on the thread loop count, the number of processes, test content information, and the command line to obtain stress test results.
[0103] In the specific implementation, the total number of tests that need to be executed in this scheme can be determined based on the number of thread loops and the number of processes, and the end of the test in this scheme can be determined based on the total number of tests. The number corresponding to the stress test results is also determined based on the total number of tests. Therefore, when there are m processes and n loops, the total number of tests is m*n times, that is, m*n test results will be generated.
[0104] Furthermore, after step S30, the method further includes: determining a total number of tests according to the number of thread cycles and the number of processes; and stopping the test if the number corresponding to the stress test result reaches the total number of tests.
[0105] It should be noted that the number of tests is counted in real time, and when the number of test results of a "single test" reaches m×n, a test stop message is issued to terminate the entire stress test process.
[0106] In the specific implementation, to further illustrate the execution process of the stress test statistics sub-process in this solution, refer to Figure 7 The flowchart of the statistical sub-process shown includes obtaining test information, analyzing the test information, counting the test information results, outputting stress test statistical information, and stopping the test when the number corresponding to the stress test results reaches the total number of tests.
[0107] In this embodiment, after step S30, the following steps are further included:
[0108] Step S40: Count the stress test results in real time to obtain stress test information.
[0109] It should be noted that this solution can monitor log files in real time by using read, tail, and process replacement techniques. Whenever test information is output to the log file module, the test information is immediately obtained. The test information includes pre-processing information before the test (i.e., the configuration file generated during pre-processing and the corresponding command line) and "single test" information (i.e., stress test information).
[0110] It is understandable that this solution calculates the stress test information by real-time statistics of the "single test" results: real-time statistics of the "single test" results, whenever new "single test" information appears, the data will be immediately included in the stress test statistics.
[0111] Step S50: Generate a test report based on the stress test information.
[0112] It should be noted that by generating a test report based on the stress test information, that is, analyzing the "single test" information: the "single test" information includes the start and end status of the "single test", the test time, the test results (success or failure) and other information, the statistical sub-process module will parse the information in real time, and determine the stress test information (that is, stress test statistical information) and then generate a test report based on the stress test information.
[0113] Furthermore, after step S40, the method further includes: determining a result output cycle according to the configuration file, and setting a timer according to the result output cycle; counting the stress test results based on the timer, and outputting stress test information.
[0114] It should be noted that since it takes time to complete a large number of tests, in order to ensure that users can obtain data from the testing phase, this solution sets a timer to output stress test information at regular intervals so that users can check the stress test progress at any time.
[0115] It should be understood that the output cycle required to complete all tests is determined according to the configuration file, and a timer is set according to the output cycle, thereby regularly outputting stress test statistics.
[0116] This embodiment determines the test case of the function to be tested according to the stress test instruction when receiving the stress test instruction; generates a configuration file according to the test case, and determines the command line required for the test according to the configuration file; performs the stress test based on the configuration file and the command line to obtain the stress test result, and collects the stress test result in real time to obtain stress test information; and generates a test report according to the stress test information. Compared with the traditional stress testing method, which has limitations and causes stress testing to be time-consuming and costly, this embodiment realizes automated testing by generating a corresponding configuration file and command line for a single test. This embodiment realizes that a single functional test can be transformed into a high-concurrency stress testing system without a large amount of configuration or compilation and installation, shortening the test time and providing great convenience for the testing work.
[0117] Based on the above Figure 6 The second embodiment shown provides a third embodiment of the pressure testing method of the present invention.
[0118] In this embodiment, step S40 also includes: determining the average success rate based on the number of successes and failures in the stress test results; determining stress test statistical information based on the average success rate, the number of concurrent tests, the number of single tests started, the number of single tests completed, the failure time, and the test time information.
[0119] It should be noted that the "single test" results are counted in real time. Whenever new "single test" information appears, the data will be immediately included in the stress test statistics; stress test statistics include: the number of stress test concurrency (configured concurrency), the current stress value (the number of single tests started), the number of completed tests (the number of all completed single tests), the number of successes and failures, the average success and failure time, etc.
[0120] It is understandable that the number of successes and the number of failures determine the average success rate, so as to determine the system pressure load capacity according to the average success rate.
[0121] In this embodiment, the step S50 also includes: determining the maximum concurrency number based on the test concurrency number and the average success rate in the stress test information; determining the system response time based on the test time information in the stress test information; determining the throughput information based on the number of completed single tests and the test time information; and generating a test report based on the maximum concurrency number, the throughput information and the system response time.
[0122] It should be noted that the maximum concurrency number is determined based on the test concurrency number and the average success rate in the stress test information; the system response time is determined based on the test time information in the stress test information; the throughput information is determined based on the number of completed single tests and the test time information; and a test report is generated based on the maximum concurrency number, throughput information and system response time.
[0123] This embodiment determines the test case of the function to be tested according to the stress test instruction when receiving the stress test instruction; generates a configuration file according to the test case, and determines the command line required for the test according to the configuration file; performs the stress test based on the configuration file and the command line to obtain the stress test result, and collects the stress test result in real time to obtain stress test information; and generates a test report according to the stress test information. Compared with the traditional stress testing method, which has limitations and causes stress testing to be time-consuming and costly, this embodiment realizes automated testing by generating a corresponding configuration file and command line for a single test. This embodiment realizes that a single functional test can be transformed into a high-concurrency stress testing system without a large amount of configuration or compilation and installation, shortening the test time and providing great convenience for the testing work.
[0124] In addition, to achieve the above-mentioned purpose, the present invention further proposes a storage medium, on which a stress testing program is stored. When the stress testing program is executed by a processor, the steps of the stress testing method described above are implemented.
[0125] Reference Figure 8 , Figure 8 This is a structural block diagram of the first embodiment of the pressure testing device of the present invention.
[0126] like Figure 8 As shown, the pressure testing device proposed in the embodiment of the present invention includes:
[0127] The instruction recognition module 10 is used to determine the test case of the function to be tested according to the stress test instruction when receiving the stress test instruction;
[0128] A preprocessing module 20 is configured to generate a configuration file according to the test case and determine command lines required for the test according to the configuration file;
[0129] The stress test module 30 is configured to perform a stress test based on the configuration file and the command line to obtain a stress test result.
[0130] This embodiment determines the test case for the function to be tested based on the stress test instruction upon receiving the stress test instruction; generates a configuration file based on the test case, and determines the command line required for the test based on the configuration file; performs the stress test based on the configuration file and the command line to obtain the stress test result. Compared with the limitations of traditional stress testing methods, which result in stress testing being time-consuming and costly, this embodiment achieves automated testing by generating a corresponding configuration file and command line for a single test. This embodiment transforms a single functional test into a highly concurrent stress test system without extensive configuration or compilation and installation, shortening testing time and greatly facilitating testing work.
[0131] Furthermore, the pre-processing module 20 is further configured to determine the number of thread loops, the number of concurrent tests, and test content information according to the pre-conditions included in the test case;
[0132] The pre-processing module 20 is further configured to generate a configuration file according to the number of thread cycles, the test content information, and the number of concurrent tests, and determine command lines required for the test according to the configuration file.
[0133] Furthermore, the pressure testing device further includes a data statistics module;
[0134] The data statistics module is further configured to determine the pre-processing quantity corresponding to the configuration files according to the concurrent test quantity, where the pre-processing quantity is the total quantity of the configuration files;
[0135] The data statistics module is further used to count the processed amount of the configuration file in real time until the processed amount reaches the pre-processed amount, and the processed amount refers to the number of configuration files completed when executing the test.
[0136] Furthermore, the stress testing module 30 is further configured to determine the number of processes to be started according to the number of concurrent tests;
[0137] The stress test module 30 is further configured to perform a stress test based on the number of thread cycles, the number of processes, the test content information, and the command line to obtain a stress test result.
[0138] Furthermore, the data statistics module is further configured to determine the total number of tests based on the number of thread cycles and the number of processes;
[0139] The data statistics module is further configured to stop the test if the number corresponding to the stress test results reaches the total number of tests.
[0140] Furthermore, the data statistics module is also used to collect statistics of the stress test results in real time to obtain stress test information;
[0141] The data statistics module is further used to generate a test report based on the stress test information.
[0142] Furthermore, the pressure testing device further includes a timer module;
[0143] The timer module is further configured to determine a result output period according to the configuration file and set a timer according to the result output period;
[0144] The timer module is further configured to collect statistics on the stress test results based on the timer and output stress test information.
[0145] Furthermore, the stress test module 30 is further configured to execute a stress test based on the startup command line in the command line and the configuration file, and obtain a command line return value;
[0146] The pressure test module 30 is further configured to determine a pressure test result according to a return value of the command line.
[0147] Furthermore, the data statistics module is further configured to determine an average success rate based on the number of successes and failures in the stress test results;
[0148] The data statistics module is also used to determine stress test statistical information based on the average success rate, the number of concurrent tests, the number of started single tests, the number of completed single tests, the failure time and the test time information.
[0149] Furthermore, the data statistics module is further configured to determine the maximum concurrency number based on the concurrent test number and the average success rate in the stress test information;
[0150] The data statistics module is further configured to determine the system response time based on the test time information in the stress test information;
[0151] The data statistics module is further configured to determine throughput information based on the number of completed single tests and the test time information;
[0152] The data statistics module is further configured to generate a test report based on the maximum concurrent number, the throughput information, and the system response time.
[0153] The present invention further provides A1, a pressure testing method, characterized in that the pressure testing method comprises the following steps:
[0154] Upon receiving a stress test instruction, determining a test case for the function to be tested according to the stress test instruction;
[0155] Generate a configuration file according to the test case, and determine the command line required for the test according to the configuration file;
[0156] A stress test is performed based on the configuration file and the command line to obtain a stress test result.
[0157] A2. The stress testing method according to A1, wherein the step of generating a configuration file according to the test case and determining the command line required for the test according to the configuration file comprises:
[0158] Determine the number of thread loops, the number of concurrent tests, and test content information based on the preconditions contained in the test case;
[0159] A configuration file is generated according to the number of thread cycles, the test content information, and the number of concurrent tests, and a command line required for the test is determined according to the configuration file.
[0160] A3. The stress testing method according to A2, further comprising, after the step of determining the command line required for the test according to the configuration file:
[0161] Determine the preprocessing quantity corresponding to the configuration file according to the concurrent test quantity, where the preprocessing quantity is the total quantity of the configuration files;
[0162] The processed amount of the configuration file is counted in real time until the processed amount reaches the pre-processed amount, where the processed amount refers to the amount completed when the configuration file is executed during the test.
[0163] A4. The stress testing method according to A2, wherein the step of performing the stress test based on the configuration file and the command line to obtain the stress test result comprises:
[0164] Determine the number of processes to be started based on the number of concurrent tests;
[0165] A stress test is performed based on the thread cycle count, the process quantity, the test content information, and the command line to obtain a stress test result.
[0166] A5. The stress testing method according to A4, further comprising: performing a stress test based on the number of thread cycles, the number of processes, the test content information, and the command line, and obtaining a stress test result;
[0167] Determine the total number of tests according to the number of thread cycles and the number of processes;
[0168] If the number of stress test results reaches the total number of tests, the test is stopped.
[0169] A6. The stress testing method according to A1, further comprising, after the step of performing the stress test based on the configuration file and the command line and obtaining the stress test result, the following steps:
[0170] Real-time statistics of the stress test results to obtain stress test information;
[0171] Generate a test report based on the stress test information.
[0172] A7. The stress testing method according to A6, after the step of collecting real-time statistics of the stress testing results and obtaining stress testing information, further comprising:
[0173] Determine a result output period according to the configuration file, and set a timer according to the result output period;
[0174] The pressure test result is counted based on the timer, and pressure test information is output.
[0175] A8. In the stress testing method described in A1, the step of performing the stress test based on the configuration file and the command line to obtain the stress test result comprises:
[0176] Execute a stress test based on the startup command line in the command line and the configuration file, and obtain a command line return value;
[0177] The stress test result is determined according to the command line return value.
[0178] A9. In the stress testing method described in A6, the step of collecting real-time statistics of the stress testing results to obtain stress testing information comprises:
[0179] Determine an average success rate based on the number of successes and failures in the stress test results;
[0180] The stress test statistics are determined based on the average success rate, the number of concurrent tests, the number of started single tests, the number of completed single tests, the failure time, and the test time information.
[0181] A10. The stress testing method according to A9, wherein the step of generating a test report based on the stress testing information comprises:
[0182] Determine the maximum number of concurrent tests based on the number of concurrent tests and the average success rate in the stress test information;
[0183] Determine the system response time based on the test time information in the stress test information;
[0184] Determining throughput information based on the number of completed single tests and the test duration information;
[0185] A test report is generated according to the maximum number of concurrent connections, the throughput information, and the system response time.
[0186] It should be understood that the above is only an example and does not constitute any limitation to the technical solution of the present invention. In specific applications, those skilled in the art can make settings as needed, and the present invention does not impose any limitation on this.
[0187] It should be noted that the workflow described above is merely illustrative and does not limit the scope of protection of the present invention. In practical applications, technicians in this field can select part or all of it according to actual needs to achieve the purpose of the embodiment scheme, and no limitation is made here.
[0188] In addition, for technical details not fully described in this embodiment, reference can be made to the pressure testing method provided in any embodiment of the present invention, and will not be repeated here.
[0189] It should be noted that, in this document, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or system comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or system. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or system comprising the element.
[0190] The serial numbers of the embodiments of the present invention are for descriptive purposes only and do not represent superiority or inferiority of the embodiments. In a unit claim that enumerates several means, several of these means may be embodied by the same item of hardware. The use of the terms first, second, and third, etc., does not denote any order; these terms should be interpreted as designations.
[0191] Through the description of the above embodiments, those skilled in the art can clearly understand that the above embodiment methods can be implemented by means of software plus the necessary general hardware platform, or of course by hardware, but in many cases the former is a better embodiment. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as a read-only memory image (ROM) / random access memory (RAM), a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0192] The above are only preferred embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention description and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A stress testing method, characterized in that: The pressure testing method comprises the following steps: Upon receiving a stress test instruction, determining a test case for the function to be tested according to the stress test instruction; Generate a configuration file according to the test case, and determine the command line required for the test according to the configuration file; A stress test is performed based on the configuration file and the command line to obtain a stress test result.
2. The pressure testing method according to claim 1, wherein: The step of generating a configuration file according to the test case and determining a command line required for the test according to the configuration file includes: Determine the number of thread loops, the number of concurrent tests, and test content information based on the preconditions contained in the test case; A configuration file is generated according to the number of thread cycles, the test content information, and the number of concurrent tests, and a command line required for the test is determined according to the configuration file.
3. The pressure testing method according to claim 2, wherein: After the step of determining the command line required for the test according to the configuration file, the method further includes: Determine the preprocessing quantity corresponding to the configuration file according to the concurrent test quantity, where the preprocessing quantity is the total quantity of the configuration files; The processed amount of the configuration file is counted in real time until the processed amount reaches the pre-processed amount, where the processed amount refers to the amount completed when the configuration file is executed during the test.
4. The pressure testing method according to claim 2, wherein: The step of performing the stress test based on the configuration file and the command line to obtain the stress test result includes: Determine the number of processes to be started based on the number of concurrent tests; A stress test is performed based on the thread cycle count, the process quantity, the test content information, and the command line to obtain a stress test result.
5. The pressure testing method according to claim 4, wherein: After the step of performing the stress test based on the number of thread cycles, the number of processes, the test content information, and the command line to obtain the stress test result, the method further includes: Determine the total number of tests according to the number of thread cycles and the number of processes; If the number of stress test results reaches the total number of tests, the test is stopped.
6. The pressure testing method according to claim 1, wherein: After the step of performing the stress test based on the configuration file and the command line and obtaining the stress test result, the method further includes: Real-time statistics of the stress test results to obtain stress test information; Generate a test report based on the stress test information.
7. The pressure testing method according to claim 6, wherein: After the step of collecting the stress test results in real time and obtaining stress test information, the method further includes: Determine a result output period according to the configuration file, and set a timer according to the result output period; The pressure test result is counted based on the timer, and pressure test information is output.
8. A pressure testing device, characterized in that: The stress testing device includes: a memory, a processor, and a stress testing program stored in the memory and executable on the processor. When the stress testing program is executed by the processor, the stress testing method according to any one of claims 1 to 7 is implemented.
9. A storage medium, characterized in that: The storage medium stores a stress test program, which, when executed by a processor, implements the stress test method according to any one of claims 1 to 7.
10. A pressure testing device, characterized in that: The pressure testing device comprises: An instruction recognition module is used to determine a test case of the function to be tested according to the stress test instruction when receiving the stress test instruction; A preprocessing module, configured to generate a configuration file according to the test case and determine the command line required for the test according to the configuration file; The stress test module is used to perform stress testing based on the configuration file and the command line to obtain stress test results.