Pressure measurement method, device and equipment and storage medium
By obtaining the target protocol and calling the performance pressure measurement tool to build a protocol request, the problem of complex and low efficiency of server pressure measurement settings in the existing technology is solved, and efficient and concise custom pressure measurement is achieved.
Patent Information
- Application Number
- CN202411971944.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-03-25
AI Technical Summary
The existing method of pressure measurement on the server side is complicated to set up, the entire pressure measurement process is cumbersome and inefficient.
By obtaining the target protocol, calling the performance pressure measurement tool to build a protocol request, responding to the user-initiated pressure measurement request instruction, extracting the pressure measurement parameters, and performing pressure measurement based on the parameter call server to determine the number of pressure measurement requests per second.
Custom pressure measurement is realized, the setting process is simplified, the pressure measurement efficiency is improved, and the pressure measurement capability is provided with high degree of freedom.
Smart Images

Figure CN119690849A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of stress testing technology, and in particular to a stress testing method, device, equipment and storage medium. Background Art
[0002] With the rapid development of information technology, various software systems and network services play a vital role in all aspects of today's society. In this context, the performance, stability and reliability of software systems and network services have become the focus of great attention of development teams, operation and maintenance teams and corporate management.
[0003] However, the existing method of stress testing the server has a complicated setting process, and the entire stress testing process is cumbersome and inefficient. Summary of the invention
[0004] In view of this, the present application provides a stress testing method, apparatus, device and storage medium for solving the problems in the existing method of stress testing on the server that the setting process is relatively complicated, the entire stress testing process is relatively cumbersome and the efficiency is relatively low.
[0005] To achieve the above objectives, the proposed solution is as follows: In a first aspect, a stress testing method includes: Get the target protocol; Call the performance stress testing tool and construct a protocol request according to the target protocol; In response to a request instruction for performing a stress test initiated by a user, extracting a plurality of stress test parameters from the request instruction; According to each of the stress testing parameters, the server is called using the protocol request; Determine the number of stress test requests per second of the user; Perform stress test on the called server according to the number of stress test requests per second.
[0006] Preferably, the calling of the performance stress testing tool and constructing a protocol request according to the target protocol includes: Calling a performance stress testing tool and creating an initial project in the performance stress testing tool; Obtain library data of the performance stress testing tool, and add the library data to the initial project; Create a test result record object; Determine a request format corresponding to the target protocol, and select a corresponding request class according to the request format; In the initial project, a protocol request corresponding to the target protocol is created using the request class.
[0007] Preferably, calling the server using the protocol request according to each of the stress testing parameters includes: Using the stress testing parameters, create a client instance; Determining a parameter format corresponding to the target protocol; Formatting each of the stress testing parameters according to the parameter format to obtain each target parameter; Obtain the URL address of the server; The server is called using the target parameters, URL address and protocol request.
[0008] Preferably, the calling of the server using each of the target parameters, URL address and protocol request includes: Configuring the URL address in the protocol request; Add each of the target parameters to the protocol request configured with the URL address to obtain a new request; The new request is sent to the server, so that the server processes the new request to obtain a processing result, and returns the processing result.
[0009] Preferably, performing stress testing on the called server according to the number of stress testing requests per second includes: Packaging the protocol requests and placing the packaged protocol requests in a preset folder of the performance stress testing tool; Establish an initial task in the performance stress testing tool; Set the number of threads, and calculate the number of loops and duration based on the number of threads and the number of stress test requests per second; The initial task is configured using the number of threads, the number of cycles and the duration to obtain a test task; The server is called to execute the test task to implement stress testing.
[0010] Preferably, the stress testing parameters include host name, port number, timeout period, interface service name, method name, and interface input parameters.
[0011] In a second aspect, a stress testing device includes: A target protocol acquisition module, used to acquire the target protocol; A protocol request construction module is used to call the performance stress testing tool and construct a protocol request according to the target protocol; A stress testing parameter acquisition module, configured to extract a plurality of stress testing parameters from a stress testing request instruction initiated by a user; A server calling module, used to call the server using the protocol request according to each of the stress testing parameters; The module for determining the number of stress test requests per second is used to determine the number of stress test requests per second of the user; The stress testing module is used to perform stress testing on the called server according to the number of stress testing requests per second.
[0012] Preferably, the protocol request building module includes: An initial project creation module, used to call a performance stress testing tool and create an initial project in the performance stress testing tool; A library data adding module, used to obtain the library data of the performance stress testing tool and add the library data to the initial project; Create a module to create a test result record object; A request class selection module, used to determine a request format corresponding to the target protocol and select a corresponding request class according to the request format; A protocol request creation module is used to create a protocol request corresponding to the target protocol in the initial project using the request class.
[0013] In a third aspect, a stress testing device includes a memory and a processor; The memory is used to store programs; The processor is used to execute the program to implement each step of the stress testing method as described in any one of the first aspects.
[0014] In a fourth aspect, a storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the stress testing method as described in any one of the first aspects are implemented.
[0015] It can be seen from the above technical scheme that the present application obtains the target protocol; calls the performance stress testing tool, and constructs a protocol request according to the target protocol; extracts multiple stress testing parameters from the request instruction in response to the request instruction for stress testing initiated by the user; calls the server using the protocol request according to each of the stress testing parameters; determines the number of stress testing requests per second of the user; and performs stress testing on the called server according to the number of stress testing requests per second. The present application first obtains the target protocol, then calls the performance stress testing tool, and constructs a protocol request according to the target protocol to achieve custom stress testing. When responding to the request instruction for stress testing initiated by the user, it only needs to extract multiple stress testing parameters from the request instruction, and call the server according to the stress testing parameters and the protocol request, and at the same time determine the number of stress testing requests per second. The number of stress testing requests per second can be specified by the user or formulated according to preset requirements to achieve high-degree-of-freedom stress testing, and the whole process is efficient and concise. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0017] Figure 1 An optional flow chart of a stress testing method provided in an embodiment of the present application; Figure 2 A schematic diagram of the structure of a pressure measurement device provided in an embodiment of the present application; Figure 3 A schematic diagram of the structure of a stress testing device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0018] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0019] With the rapid development of information technology, various software systems and network services play a vital role in all aspects of today's society. In this context, the performance, stability and reliability of software systems and network services have become the focus of great attention of development teams, operation and maintenance teams and corporate management.
[0020] However, the existing method of stress testing the server has a complicated setting process, and the entire stress testing process is cumbersome and inefficient.
[0021] To solve the above-mentioned defects of the prior art, an embodiment of the present invention provides a stress testing method that can be used in many general or special computing device environments or configurations, such as personal computers, server computers, handheld devices or portable devices, tablet devices, multi-processor devices, and distributed computing environments including any of the above devices or equipment.
[0022] The method can also be applied to various computer terminals or intelligent terminals, and its execution subject can be a processor or server of the computer terminal or intelligent terminal. The method flow chart of the method is as follows: Figure 1 As shown, specifically including: S1: Get the target protocol.
[0023] The target protocol in this application refers to the standard or convention used to specify the communication rules and data format between the test tool and the system being tested (i.e., the server) during the stress testing process. It is the language of communication between the test tool and the system being tested, ensuring that both parties can accurately understand and process requests and responses in high-load, high-intensity stress testing scenarios. Therefore, in the stress testing method provided in this application, it is first necessary to obtain the target protocol.
[0024] The target protocol can be the protocol used by the server on which you want to perform stress testing, such as the communication protocol within the server, etc. As the target protocol, the target protocol corresponds to the server.
[0025] S2: Call the performance stress testing tool and construct a protocol request according to the target protocol.
[0026] After obtaining the target protocol, call the performance stress testing tool and build a protocol request based on the target protocol. This can achieve a customized effect. The protocol request built by customizing the target protocol can closely fit specific business scenarios and functional requirements.
[0027] Custom target protocols can build protocol requests for specific functional modules of the system, making it easier to conduct in-depth testing on these key modules.
[0028] In an example, take a content management system as an example, which includes multiple functional modules such as article publishing, review, and category management. Now, if you want to stress test the performance of the article publishing module, you can customize the corresponding target protocol and build a protocol request specifically for the target protocol, so as to accurately test the performance problems that may exist in the article publishing module under high load and other pressures.
[0029] Performance stress testing tools can be selected from JMeter, LoadRunner, Gatling, etc. This application does not impose any restrictions on this. Different tools have different characteristics. JMeter is rich in functions, easy to use, and supports multiple protocols. LoadRunner is suitable for large-scale stress testing of complex enterprise-level applications. Gatling has the characteristics of high performance and light weight. For example, if JMeter is selected, the JAVA request of its sampler can be written based on JMeter's software development kit (SDK).
[0030] S3: In response to a stress test request instruction initiated by a user, extract multiple stress test parameters from the request instruction.
[0031] When a user initiates a request command for stress testing, the stress testing parameters must first be obtained from the request command. The stress testing parameters include multiple types, such as host name (Host), port number (Post), timeout (Timeout), interface service name (serviceClass), method name (method), and interface input parameters (params); they can also include the caller name (callerId), whether to enable debug mode (debugMode), minimum QPS (initRate), maximum QPS (maxRate), growth percentage (growthPercentage), and QPS growth interval (growthInterval).
[0032] These stress testing parameters are very important for completing the stress testing process. Therefore, when responding to the request instructions initiated by the user, it is necessary to obtain these stress testing parameters first to ensure the smooth completion of the stress testing process.
[0033] S4: According to each of the stress testing parameters, the server is called using the protocol request.
[0034] In this step, you can use a suitable network programming library or tool to send the constructed protocol request to the corresponding address and port of the server, and the stress test parameters define the stress test indicators, so that you can accurately call the server to implement stress testing.
[0035] S5: Determine the number of stress test requests per second for the user.
[0036] In the traditional stress testing process, if you want to use a performance stress testing tool, you need to set the number of stress testing requests per second (QPS). The specific process includes: Clarify the target QPS value of the stress test. If the target QPS value is the response time when the load reaches 20QPS, then the load of sending requests to the server homepage needs to be controlled to 20QPS.
[0037] The number of stress test requests per second in this application can be set by the user independently, or it can be set according to the user's needs or corresponding circumstances.
[0038] S6: Perform stress testing on the called server according to the number of stress testing requests per second.
[0039] In this step, you can identify the specific functional modules of the server to be tested and the information you expect to obtain through stress testing, which can help with subsequent targeted analysis results. According to the number of stress test requests per second, start the stress test tool and perform real-time monitoring, and you can perform response time analysis, throughput analysis, error rate analysis, etc.
[0040] It can be seen from the above technical scheme that the present application obtains the target protocol; calls the performance stress testing tool, and constructs a protocol request according to the target protocol; extracts multiple stress testing parameters from the request instruction in response to the request instruction for stress testing initiated by the user; calls the server using the protocol request according to each of the stress testing parameters; determines the number of stress testing requests per second of the user; and performs stress testing on the called server according to the number of stress testing requests per second. The present application first obtains the target protocol, then calls the performance stress testing tool, and constructs a protocol request according to the target protocol to achieve custom stress testing. When responding to the request instruction for stress testing initiated by the user, it only needs to extract multiple stress testing parameters from the request instruction, and call the server according to the stress testing parameters and the protocol request, and at the same time determine the number of stress testing requests per second. The number of stress testing requests per second can be specified by the user or formulated according to preset requirements to achieve high-degree-of-freedom stress testing, and the whole process is efficient and concise.
[0041] In the method provided in the embodiment of the present invention, a performance stress testing tool is called to construct a process of protocol request according to the target protocol, which is specifically described as follows: Calling a performance stress testing tool and creating an initial project in the performance stress testing tool; Obtain library data of the performance stress testing tool, and add the library data to the initial project; Create a test result record object; Determine a request format corresponding to the target protocol, and select a corresponding request class according to the request format; In the initial project, a protocol request corresponding to the target protocol is created using the request class.
[0042] Specifically, in the above process, the performance stress testing tool is first called, and an initial project is built in it, that is, the initial project is used to implement the server-side stress testing. After creation, the library data of the performance stress testing tool is obtained, and the library data is added to the initial project. This allows the project to call the information in the library data, which helps to efficiently execute the stress testing process. A test result recording object can also be created, so that the results of the stress testing can be recorded in real time, and problems encountered during the stress testing process can also be recorded, or stress testing logs can be recorded, so that traceability analysis can be performed after the stress testing is completed.
[0043] In this process, it is also necessary to obtain the request format corresponding to the target protocol. Since different target protocols correspond to different protocol formats, this request format can be regarded as a protocol format, or as a request format corresponding to a protocol request, and select the corresponding request class (request implementation class). This request implementation class is a class structure used to execute the operation of sending a request to an external service. It encapsulates various operations and logic related to the request, such as the target protocol, request format, etc., to construct a protocol request.
[0044] The following embodiments describe in detail the process of invoking the server using the protocol request according to each of the stress testing parameters in the present application.
[0045] Using the stress testing parameters, create a client instance; Determining a parameter format corresponding to the target protocol; Formatting each of the stress testing parameters according to the parameter format to obtain each target parameter; Obtain the URL address of the server; The server is called using the target parameters, URL address and protocol request.
[0046] Specifically, using various stress testing parameters to create a client instance can also be regarded as creating a new thread group. Considering that the stress testing parameters need to correspond to the target protocol, the parameter format corresponding to the target protocol is determined, and the stress testing parameters are formatted according to the parameter format to obtain the target parameters corresponding to the stress testing parameters. This ensures that the format remains consistent and avoids failures caused by different formats.
[0047] In addition, calling the server requires the server's address to be clear, so obtain the server's URL address, and then use the target parameters, URL address and protocol request to call the server.
[0048] The step of using each of the target parameters, URL address and protocol request to call the server specifically includes: Configuring the URL address in the protocol request; Add each of the target parameters to the protocol request configured with the URL address to obtain a new request; The new request is sent to the server, so that the server processes the new request to obtain a processing result, and returns the processing result.
[0049] Specifically, the URL address is configured in the protocol request, which can ensure the accuracy and efficiency of calling the server. Then the target parameters need to be added to the protocol request configured with the URL address to obtain a new request, and the new request is sent to the server for the server to process the new request and return the processing result.
[0050] The above embodiment illustrates the process of calling the server using the protocol request according to each of the stress testing parameters in this application. The following is a detailed explanation of the process of performing stress testing on the called server according to the number of stress testing requests per second in this application.
[0051] Packaging the protocol requests and placing the packaged protocol requests in a preset folder of the performance stress testing tool; Establish an initial task in the performance stress testing tool; Set the number of threads, and calculate the number of loops and duration based on the number of threads and the number of stress test requests per second; The initial task is configured using the number of threads, the number of cycles and the duration to obtain a test task; The server is called to execute the test task to implement stress testing.
[0052] Specifically, the protocol request is packaged to form a jar package, so that it can be used in the subsequent stress testing process without code foundation, which greatly improves the efficiency of stress testing. The preset folder can be the Jmeter file\lib\ext folder, which is used to store the packaged protocol request, so that the protocol request can be used in stress testing. The number of threads refers to the number of simulated users, which is a component used to simulate users' concurrent access to the server. This application needs to implement stress testing according to the number of stress tests requested per second, so first you need to consider how many users to simulate. For example, if it is set to generate 100 requests per second, and each user initiates 1 request per second, then the number of threads is 100.
[0053] In order to keep the test going and obtain stable data on the number of requests per second, it is necessary to set the number of loops and duration so that the stress test process can be carried out as required. Finally, the server is called to execute the test task and ultimately achieve the purpose of the stress test.
[0054] In the prior art, in the process of adjusting the number of threads and timers, the QPS is controlled by gradually adjusting the number of thread calculations in the test plan and adding timers to the sampler. However, this method is time-consuming and labor-intensive, and it takes multiple attempts to reach the target QPS. Another method is to use a Constant Throughput Timer, which can conveniently control the throughput of requests sent by a given sampler. Specifically, the Constant Throughput Timer can be configured, and the name is a name set for the timer. Target throughput (in samples per minute): Set the target throughput. Note that this is the number of requests sent per minute. Therefore, corresponding to the 20 QPS required by the test requirements in the above embodiment, the value here should be 1200 (because there are 60 seconds per minute, so 20 QPS * 60 seconds / minute = 1200 samples / minute), Calculate Throughput based on: There are 5 options, select the appropriate option to control the distribution of throughput. For example, you can select This thread only to control the throughput of each thread, or select All active threads to set the target Throughput to be allocated to each active thread. However, this method is also cumbersome and complicated, and is not as efficient and convenient as this application.
[0055] The code flow corresponding to the stress testing method provided in this application is as follows: Define the class PlaybackFlow to inherit AbstractJavaSamplerClient Define the static variable rateLimiter Define constant RATE_LIMIT Define variables initRate, maxRate, growthPercentage, growthInterval, host,port, currentQPS Define variables time, timeout Define Map methodParamsName, serviceClassMap, methodMap Define function getDefaultParameters to return Arguments Create parameters params Add various parameter values to the parameter params Return params Define the function setupTest with the input parameter context of type JavaSamplerContext Get the current time and save it to time Get parameters from context and set variable values double rate = Double.parseDouble(context.getParameter(initRate)); currentQPS = rate; / / Create a RateLimiter instance and set the rate at which requests are sent rateLimiter = RateLimiter.create(rate); Create a RateLimiter instance and set the rate Load the jar package in the JMeter lib directory Define function runTest Input parameter arg0, type JavaSamplerContext Return SampleResult / / Get the current time Long runTime = System.currentTimeMillis(); / / If the current time and the last time the QPS was adjusted exceed the set time interval if (currentQPS<Double.valueOf(arg0.getParameter("maxRate"))&&(runTime- time)> Integer.valueOf(arg0.getParameter("growthInterval")) * 1000L) { / / Increase QPS according to a certain ratio currentQPS += (currentQPS * Integer.valueOf(arg0.getParameter("growthPercentage"))) / 100; / / Ensure that QPS does not exceed the maximum value currentQPS = Math.min(currentQPS, Double.valueOf(arg0.getParameter("maxRate"))); / / Update rate limiter rate rateLimiter.setRate(currentQPS); / / Update time time = runTime; } / / Get permission from RateLimiter rateLimiter.acquire(); Creating a SampleResult Get method and its parameters Calling a method and receiving the result Return the response result to SampleResult Returns SampleResult and Figure 1 Corresponding to the method described above, the embodiment of the present invention further provides a stress testing device for Figure 1 In the specific implementation of the method, the stress measurement device provided by the embodiment of the present invention can be used in a computer terminal or various mobile devices, combined with Figure 2 , introduce the pressure measurement device, such as Figure 2 As shown, the device may include: A target protocol acquisition module 10 is used to acquire a target protocol; The protocol request construction module 20 is used to call the performance stress testing tool and construct a protocol request according to the target protocol; A stress testing parameter acquisition module 30 is used to extract multiple stress testing parameters from a stress testing request instruction initiated by a user; A server calling module 40 is used to call the server using the protocol request according to each of the stress testing parameters; A stress test request number determination module 50 is used to determine the stress test request number per second of a user; The stress testing module 60 is used to perform stress testing on the called server according to the number of stress testing requests per second.
[0056] It can be seen from the above technical scheme that the present application obtains the target protocol; calls the performance stress testing tool, and constructs a protocol request according to the target protocol; extracts multiple stress testing parameters from the request instruction in response to the request instruction for stress testing initiated by the user; calls the server using the protocol request according to each of the stress testing parameters; determines the number of stress testing requests per second of the user; and performs stress testing on the called server according to the number of stress testing requests per second. The present application first obtains the target protocol, then calls the performance stress testing tool, and constructs a protocol request according to the target protocol to achieve custom stress testing. When responding to the request instruction for stress testing initiated by the user, it only needs to extract multiple stress testing parameters from the request instruction, and call the server according to the stress testing parameters and the protocol request, and at the same time determine the number of stress testing requests per second. The number of stress testing requests per second can be specified by the user or formulated according to preset requirements to achieve high-degree-of-freedom stress testing, and the whole process is efficient and concise.
[0057] In one example, the protocol request building module 20 may include: An initial project creation module, used to call a performance stress testing tool and create an initial project in the performance stress testing tool; A library data adding module, used to obtain the library data of the performance stress testing tool and add the library data to the initial project; Create a module to create a test result record object; A request class selection module, used to determine a request format corresponding to the target protocol and select a corresponding request class according to the request format; A protocol request creation module is used to create a protocol request corresponding to the target protocol in the initial project using the request class.
[0058] Furthermore, the embodiment of the present application provides a stress testing device. Optionally, Figure 3 The hardware structure diagram of the stress test equipment is shown in Figure 3 The hardware structure of the stress testing device may include: at least one processor 01 , at least one communication interface 02 , at least one memory 03 and at least one communication bus 04 .
[0059] In the embodiment of the present application, the number of the processor 01 , the communication interface 02 , the memory 03 , and the communication bus 04 is at least one, and the processor 01 , the communication interface 02 , and the memory 03 communicate with each other through the communication bus 04 .
[0060] The processor 01 may be a central processing unit (CPU), or an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present invention.
[0061] The memory 03 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), etc., such as at least one disk memory.
[0062] The memory stores a program, and the processor can call the program stored in the memory. The program is used to execute the following stress testing method, including: Get the target protocol; Call the performance stress testing tool and construct a protocol request according to the target protocol; In response to a request instruction for performing a stress test initiated by a user, extracting a plurality of stress test parameters from the request instruction; According to each of the stress testing parameters, the server is called using the protocol request; Determine the number of stress test requests per second of the user; Perform stress test on the called server according to the number of stress test requests per second.
[0063] Optionally, the detailed functions and extended functions of the program may refer to the description of the stress testing method in the method embodiment.
[0064] The embodiment of the present application further provides a storage medium, which may store a program suitable for execution by a processor, and when the program is running, controls the device where the storage medium is located to execute the following stress testing method, including: Get the target protocol; Call the performance stress testing tool and construct a protocol request according to the target protocol; In response to a request instruction for performing a stress test initiated by a user, extracting a plurality of stress test parameters from the request instruction; According to each of the stress testing parameters, the server is called using the protocol request; Determine the number of stress test requests per second of the user; Perform stress test on the called server according to the number of stress test requests per second.
[0065] Specifically, the storage medium may be a computer-readable storage medium, and the computer-readable storage medium may be an electronic memory such as a flash memory, an EEPROM (Electrically Erasable Programmable Read-Only Memory), an EPROM, a hard disk or a ROM.
[0066] Optionally, the detailed functions and extended functions of the program may refer to the description of the stress testing method in the method embodiment.
[0067] In addition, the functional modules in the various embodiments of the present disclosure can be integrated together to form an independent part, or each module can exist separately, or two or more modules can be integrated to form an independent part. If the function is implemented in the form of a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present disclosure is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes a number of instructions for a computer device (which can be a personal computer, a live broadcast device, or a network device, etc.) to perform all or part of the steps of the methods of the various embodiments of the present disclosure.
[0068] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0069] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0070] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A stress testing method, characterized in that: include: Get the target protocol; Call the performance stress testing tool and construct a protocol request according to the target protocol; In response to a request instruction for performing a stress test initiated by a user, extracting a plurality of stress test parameters from the request instruction; According to each of the stress testing parameters, the server is called using the protocol request; Determine the number of stress test requests per second of the user; Perform stress test on the called server according to the number of stress test requests per second.
2. The method according to claim 1, characterized in that The calling of the performance stress testing tool and constructing a protocol request according to the target protocol include: Calling a performance stress testing tool and creating an initial project in the performance stress testing tool; Obtain library data of the performance stress testing tool, and add the library data to the initial project; Create a test result record object; Determine a request format corresponding to the target protocol, and select a corresponding request class according to the request format; In the initial project, a protocol request corresponding to the target protocol is created using the request class.
3. The method according to claim 1, characterized in that The calling of the server by using the protocol request according to each of the stress testing parameters includes: Using the stress testing parameters, create a client instance; Determining a parameter format corresponding to the target protocol; Formatting each of the stress testing parameters according to the parameter format to obtain each target parameter; Obtain the URL address of the server; The server is called using the target parameters, URL address and protocol request.
4. The method according to claim 3, characterized in that: The method of calling the server by using the target parameters, URL address and protocol request includes: Configuring the URL address in the protocol request; Add each of the target parameters to the protocol request configured with the URL address to obtain a new request; The new request is sent to the server, so that the server processes the new request to obtain a processing result, and returns the processing result.
5. The method according to any one of claims 1 to 4, characterized in that: The stress test on the called server according to the number of stress test requests per second includes: Packaging the protocol requests and placing the packaged protocol requests in a preset folder of the performance stress testing tool; Establish an initial task in the performance stress testing tool; Set the number of threads, and calculate the number of loops and duration based on the number of threads and the number of stress test requests per second; The initial task is configured using the number of threads, the number of cycles and the duration to obtain a test task; The server is called to execute the test task to implement stress testing.
6. The method according to claim 1, characterized in that The stress testing parameters include host name, port number, timeout period, interface service name, method name, and interface input parameters.
7. A pressure measurement device, characterized in that: include: A target protocol acquisition module, used to acquire the target protocol; A protocol request construction module is used to call the performance stress testing tool and construct a protocol request according to the target protocol; A stress testing parameter acquisition module, configured to extract a plurality of stress testing parameters from a stress testing request instruction initiated by a user; A server calling module, used to call the server using the protocol request according to each of the stress testing parameters; The module for determining the number of stress test requests per second is used to determine the number of stress test requests per second of the user; The stress testing module is used to perform stress testing on the called server according to the number of stress testing requests per second.
8. The device according to claim 7, characterized in that The protocol request building module includes: An initial project creation module, used to call a performance stress testing tool and create an initial project in the performance stress testing tool; A library data adding module, used to obtain the library data of the performance stress testing tool and add the library data to the initial project; Create a module to create a test result record object; A request class selection module, used to determine a request format corresponding to the target protocol and select a corresponding request class according to the request format; A protocol request creation module is used to create a protocol request corresponding to the target protocol in the initial project using the request class.
9. A stress testing device, characterized in that: including memory and processor; The memory is used to store programs; The processor is used to execute the program to implement each step of the stress testing method according to any one of claims 1 to 6.
10. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, each step of the stress testing method according to any one of claims 1 to 6 is implemented.