Front-end pressure testing method, device and equipment and storage medium
By conducting two stress tests on the page to be tested, analyzing and processing resource information, the problem of limited front-end stress test range in the existing technology is solved, and a more comprehensive front-end resource coverage and stress testing is achieved.
Patent Information
- Application Number
- CN202411855546.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-16
- Publication Date
- 2025-04-22
AI Technical Summary
In the prior art, the pressure testing range of front-end pressure testing tools is limited and it is difficult to cover all front-end resources, resulting in omissions in front-end pressure testing.
By initiating the first stress test request on the page to be tested, the pressure test request result is obtained, and the resource information is parsed when the result meets the preset state, and then a second stress test is performed on these resource information to generate a front-end stress test report.
The coverage of the second stress test is improved, allowing the stress test to cover more front-end resources and ensure the comprehensiveness of the front-end stress test.
Smart Images

Figure CN119862097A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a front-end stress testing method, device, equipment and storage medium. Background Art
[0002] As the number of users grows, the system needs to have corresponding expansion capabilities. Stress testing can evaluate whether the system can effectively handle more requests after adding resources. Through stress testing, potential problems can be discovered and fixed in advance, reducing the possibility of failures in the production environment and improving the stability and reliability of the system.
[0003] Front-end stress testing is an important step to ensure that a website or application can still run normally under high load. Existing front-end stress testing mainly uses stress testing tools to simulate a large number of users accessing at the same time to find out which parts will cause the system to slow down or crash. However, the stress testing scope of these stress testing tools is limited, and it is difficult to cover all front-end resources, resulting in omissions in front-end stress testing. Summary of the invention
[0004] In view of this, the present application provides a front-end stress testing method and device, the main purpose of which is to solve the problem that the stress testing scope of the stress testing tool in the prior art is limited and it is difficult to cover all front-end resources, resulting in omissions in the front-end stress testing.
[0005] According to a first aspect of the present application, a front-end stress testing method is provided, comprising:
[0006] Initiate the first stress test request for the page to be tested and obtain the stress test request result of the page to be tested;
[0007] When the stress test request result meets the preset request status, the stress test request result meeting the preset request status is parsed to obtain resource information on which the request depends;
[0008] Initiate a second stress test request for the resource information that the request depends on, and obtain the stress test request result of the dependent resource;
[0009] Generate a front-end stress test report based on the stress test request results of the dependent resources and the stress test request results of the dependent resources.
[0010] Furthermore, before initiating a first stress test request for the page to be tested and obtaining a stress test request result for the page to be tested, the method further includes:
[0011] Obtaining parameter configuration information of the stress test, wherein the parameter configuration information of the stress test includes at least a stress test address and a stress test frequency;
[0012] Correspondingly, the first stress test request is initiated for the page to be tested, and the stress test request result of the page to be tested is obtained, including:
[0013] Determine the number of stress test requests according to the stress test frequency, where the number of stress test requests is the number of stress test requests sent within a preset time;
[0014] Send a request to the stress test address according to the stress test request quantity to initiate a first stress test request for the page to be tested, and obtain a stress test request result for the page to be tested.
[0015] Further, sending a request to the stress test address according to the number of stress test requests to initiate a first stress test request for the page to be tested, and obtaining a stress test request result for the page to be tested, includes:
[0016] Splitting the stress test request into request stages controlled by multiple processes, so that each request stage has a set number of stress test requests controlled by the process;
[0017] In each request phase, requests are sent to the stress test address according to the set number to initiate a first stress test request for the page to be tested, and a stress test request result of the page to be tested is obtained.
[0018] Furthermore, the request status corresponding to the stress testing request result includes a request success status and a request failure status;
[0019] Correspondingly, when the stress test request result meets the preset request status, the stress test request result that meets the preset request status is parsed to obtain resource information on which the request depends, including:
[0020] When the stress test request result is in a request success state, resource matching is performed on the stress test request result that meets the preset request state through regular expressions with different resource characteristics to obtain resource information on which the request depends.
[0021] Furthermore, the regular expressions with different resource characteristics include regular expressions with static resource characteristics, and the regular expressions with different resource characteristics are used to perform resource matching on the stress test request results that meet the preset request state to obtain resource information on which the request depends, including:
[0022] The regular expression with static resource characteristics is used to perform resource matching in the stress testing request result that meets the preset request state to obtain static resource information loaded by the request dependency label.
[0023] Furthermore, the regular expressions with different resource characteristics include regular expressions with dynamic resource characteristics, and the regular expressions with different resource characteristics are used to perform resource matching on the stress test request results that meet the preset request state to obtain resource information on which the request depends, including:
[0024] The regular expression with dynamic resource characteristics is used to perform resource matching in the stress testing request results that meet the preset request status to obtain dynamic resource information loaded by the request-dependent script.
[0025] Furthermore, before initiating a first stress test request for the page to be tested and obtaining a stress test request result for the page to be tested, the method further includes:
[0026] Set the filtering resource type corresponding to the stress test request, where the filtering resource type is the resource type that is blocked from matching during the resource matching process;
[0027] Correspondingly, the resource matching of the stress test request results that meet the preset request status is performed through regular expressions with different resource characteristics to obtain resource information that the request depends on, including:
[0028] In the process of matching resources for stress testing request results that meet the preset request status through regular expressions with different resource characteristics, if the resource matches the filtered resource type in the stress testing request result, the resource matching of the filtered resource type is shielded to obtain the resource information that the request depends on.
[0029] Furthermore, after performing resource matching on the stress testing request results that meet the preset request status by using regular expressions with different resource characteristics to obtain resource information on which the request depends, the method further includes:
[0030] The resource information that the request depends on is stored in a resource array, and the resource request address of the filtered resource type is removed from the resource array;
[0031] An address completion operation is performed on the relative path corresponding to the resource request address in the resource array according to the set address completion rule.
[0032] According to a second aspect of the present application, a front-end pressure testing device is provided, comprising:
[0033] The first testing unit is used to initiate a first stress test request to the page to be tested and obtain a stress test request result of the page to be tested;
[0034] A parsing unit, configured to parse the stress testing request result that meets the preset request state to obtain resource information on which the request depends if the stress testing request result meets the preset request state;
[0035] The second testing unit is used to initiate a second stress test request for the resource information on which the request depends, and obtain a stress test request result for the dependent resource;
[0036] A generating unit is used to generate a front-end stress test report according to the stress test request result of the dependent resource and the stress test request result of the dependent resource.
[0037] Furthermore, the device also includes:
[0038] An acquiring unit, configured to acquire parameter configuration information of the stress test before initiating a first stress test request for the page to be tested and obtaining a stress test request result for the page to be tested, wherein the parameter configuration information of the stress test includes at least a stress test address and a stress test frequency;
[0039] Accordingly, the first testing unit is specifically used for:
[0040] Determine the number of stress test requests according to the stress test frequency, where the number of stress test requests is the number of stress test requests sent within a preset time;
[0041] Send a request to the stress test address according to the stress test request quantity to initiate a first stress test request for the page to be tested, and obtain a stress test request result for the page to be tested.
[0042] Furthermore, the first test unit is also used to
[0043] Splitting the stress test request into request stages controlled by multiple processes, so that each request stage has a set number of stress test requests controlled by the process;
[0044] In each request phase, requests are sent to the stress test address according to the set number to initiate a first stress test request for the page to be tested, and a stress test request result of the page to be tested is obtained.
[0045] Furthermore, the request status corresponding to the stress testing request result includes a request success status and a request failure status;
[0046] The parsing unit is specifically used for:
[0047] When the stress test request result is in a request success state, resource matching is performed on the stress test request result that meets the preset request state through regular expressions with different resource characteristics to obtain resource information on which the request depends.
[0048] Further, the regular expressions with different resource characteristics include regular expressions with static resource characteristics, and the parsing unit is further specifically used for:
[0049] The regular expression with static resource characteristics is used to perform resource matching in the stress testing request result that meets the preset request state to obtain static resource information loaded by the request dependency label.
[0050] Further, the regular expressions with different resource characteristics include regular expressions with dynamic resource characteristics, and the parsing unit is further specifically used for:
[0051] The regular expression with dynamic resource characteristics is used to perform resource matching in the stress testing request results that meet the preset request status to obtain dynamic resource information loaded by the request-dependent script.
[0052] Furthermore, the device is also used for:
[0053] A setting unit, configured to set a filtering resource type corresponding to the stress test request before initiating a first stress test request for the page to be tested and obtaining a stress test request result for the page to be tested, wherein the filtering resource type is a resource type that is shielded from matching during a resource matching process;
[0054] Accordingly, the parsing unit is further used for:
[0055] In the process of matching resources for stress testing request results that meet the preset request status through regular expressions with different resource characteristics, if the resource matches the filtered resource type in the stress testing request result, the resource matching of the filtered resource type is shielded to obtain the resource information that the request depends on.
[0056] Furthermore, the device also includes:
[0057] A storage unit, configured to perform resource matching on the stress testing request results that meet the preset request status by using regular expressions with different resource characteristics, obtain resource information on which the request depends, store the resource information on which the request depends in a resource array, and remove the resource request address of the filtered resource type from the resource array;
[0058] The completion unit is used to perform an address completion operation on the relative path corresponding to the resource request address in the resource array according to a set address completion rule.
[0059] According to a third aspect of the present application, a computer device is provided, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the method described in the first aspect when executing the computer program.
[0060] According to a fourth aspect of the present application, a readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method described in the first aspect are implemented.
[0061] By means of the above technical scheme, the front-end stress testing method, device and equipment provided by the present application, compared with the method of implementing front-end stress testing by simulating user access through stress testing tools in the current prior art, the present application initiates a first stress testing request to the page to be tested to obtain the stress testing request result of the page to be tested; when the stress testing request result meets the preset request status, the stress testing request result that meets the preset request status is parsed to obtain the resource information that the request depends on; a second stress testing request is initiated to the resource information that the request depends on to obtain the stress testing request result of the dependent resources; and a front-end stress testing report is generated according to the stress testing request result of the dependent resources. The whole process is based on the first stress testing request corresponding to the stress testing request result meeting the preset request status, and a second stress test is performed on the dependent resource information of the page to be tested, so as to increase the coverage of the second stress test, so that the stress test can cover more front-end resources and ensure the comprehensiveness of the front-end stress test.
[0062] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0063] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0064] Figure 1 is a flow chart of a front-end stress testing method provided by an embodiment of the present application;
[0065] Figure 2 is a flow chart of another front-end stress testing method provided by an embodiment of the present application;
[0066] Figure 3 yes Figure 2 A schematic flow chart of a specific implementation of step 202;
[0067] Figure 4 is a flow chart of another front-end stress testing method provided by an embodiment of the present application;
[0068] Figure 5 is a flow chart of another front-end stress testing method provided by an embodiment of the present application;
[0069] Figure 6 It is a flowchart of the front-end stress test provided by the embodiment of the present application;
[0070] Figure 7 It is a structural schematic diagram of a front-end pressure testing device provided in an embodiment of the present application;
[0071] Figure 8 It is a schematic diagram of the device structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0072] Now the content of the present invention will be discussed with reference to several exemplary embodiments. It should be understood that these embodiments are discussed only to enable those skilled in the art to better understand and thus implement the content of the present invention, rather than implying any limitation on the scope of the present invention.
[0073] As used herein, the term "including" and variations thereof are to be interpreted as open-ended terms meaning "including but not limited to." The term "based on" is to be interpreted as "based, at least in part, on." The terms "one embodiment" and "an embodiment" are to be interpreted as "at least one embodiment." The term "another embodiment" is to be interpreted as "at least one other embodiment."
[0074] In the related technology, front-end stress testing is an important step to ensure that a website or application can still operate normally under high load conditions. Existing front-end stress testing mainly uses stress testing tools to simulate a large number of users accessing at the same time to find out which parts will cause the system to slow down or crash. However, the stress testing scope of these stress testing tools is limited, and it is difficult to cover all front-end resources, resulting in omissions in front-end stress testing.
[0075] In order to solve this problem, this embodiment provides a front-end pressure testing method, such as Figure 1 As shown, the method comprises the following steps:
[0076] 101. Initiate the first stress test request for the page to be tested, and obtain the stress test request result of the page to be tested.
[0077] In this embodiment, the stress test request is to evaluate the performance of the front-end application (such as a web page, a front-end interface of a mobile application, etc.) under various load conditions. Specifically, the performance evaluation can be performed on the page to be tested, including response time measurement, resource loading evaluation, and rendering performance testing.
[0078] For response time evaluation, the front-end application needs to respond quickly to user actions, such as loading a page, feedback after clicking a button, etc., and stress test requests can accurately measure the time from the user initiating the request to the front-end fully presenting the content. For example, when a user clicks a product details button, stress testing can determine the time it takes for the front-end to issue a request to obtain product details data and then display the product image, price, description, etc. For resource loading evaluation, the front-end application usually needs to load multiple resources, including HTML files, CSS style sheets, JavaScript scripts, images, fonts, etc. Stress test requests can simulate a large number of users requesting these resources at the same time to check the performance of resource loading. For example, in high concurrency situations, it can be found whether some resources are loaded too slowly, resulting in blank or partially rendered pages. For rendering performance testing, the rendering performance of the front-end directly affects the user experience. Stress test requests can simulate rendering situations under different devices and screen resolutions. For example, for a complex visualization chart application, stress testing can check whether the rendering of the chart will be stuck or delayed on a high-resolution screen, especially when multiple charts need to be rendered at the same time.
[0079] It is understandable that as the first stress test of the page to be tested, before initiating the first stress test request for the page to be tested, it is necessary to plan the test scenario and request parameters. First, analyze the user behavior of the page to be tested in actual use to determine the user operations to be simulated. For example, for an e-commerce product details page, user behaviors may include loading the page, clicking the purchase button, viewing comments, etc. Based on these behaviors, write a test script using a test tool and simulate in the order of user operations. Then determine the request parameters, which include the number, frequency, and concurrency of requests.
[0080] It should be noted that if the stress test request is just a simple test of page loading, you can set a certain number (such as 100) of page loading requests to be sent within a period of time (such as 1 minute). For concurrent testing, the number of concurrent users must be specified. For example, to simulate 10 users loading a page at the same time, you can set the number of threads in the test tool. At the same time, you must also consider the interval between requests. This interval should be set based on actual user behavior. For example, in the scenario where a user purchases a product after viewing its details, there may be a few seconds between the purchase request and the viewing request.
[0081] Correspondingly, the stress test request results of the page to be tested include performance indicator results, error and exception results, system resource usage, etc. The performance indicator results here include page loading time, resource loading, and concurrent performance indicators, etc. The page loading time includes the first byte time, document loading completion time, page full loading time, etc. The resource loading includes the loading order and time of various resources, resource loading failure, etc. The concurrent performance indicators include the relationship between the number of concurrent users and the response time, the maximum concurrent processing capacity, etc. The error and exception results here include HTTP status code related errors, JavaScript errors, and rendering errors. The system resource usage here includes browser resource usage, network resource usage, etc. The browser resource usage includes memory usage and CPU usage, etc. The network resource usage includes network bandwidth usage.
[0082] 102. When the stress test request result meets the preset request status, the stress test request result meeting the preset request status is parsed to obtain resource information on which the request depends.
[0083] In an implementable scenario, the request status of the stress test request result can be judged by the response status code, which includes success, redirection, client error, and server error. The success status code indicates that the server has successfully processed the request and returned the request content. For example, when a web page is stress tested, if most requests return a success status code and the page content is loaded correctly, then these requests can be judged as successful at the status code level. The redirection status code indicates that the resource has been permanently or temporarily redirected. During the stress test, if a redirection status code is encountered, it is necessary to check whether the redirection is expected. The client error status code indicates that the request sent by the client is syntactically incorrect or the parameters are illegal. During the stress test, if a large number of client error status codes appear, there may be a problem with the front-end request assembly, such as the data format does not meet the back-end interface requirements. The server error status code is a general status code for internal server errors, indicating that the server encountered an unexpected situation when processing the request and could not complete the request. The server error status code status code that appears in the stress test may be caused by a logic error in the back-end code, a database connection problem, or a server configuration error.
[0084] Correspondingly, the request status of the stress test request result includes success status, partial success status and failure status. The success status includes normal response and cache hit status. For the normal response status, when the stress test request is successful, the page can return the complete content as expected, including the correct HTML structure, CSS style rendering and normal execution of JavaScript scripts. For the cache hit status, if the page adopts a cache strategy, the successful stress test result may show that the cache is effectively used. The partial success status includes partial content loading success and partial function availability. For partial content loading success, due to network fluctuations, resource server failures or unreasonable setting of loading priority for certain resources in the front-end code, the main part of the page loads normally, but some secondary elements (such as advertisements, non-critical images) may fail to load or load incompletely. For partial function availability, due to insufficient concurrent processing capabilities of the back-end interface for certain functions, or errors in the interaction logic between the front-end and the back-end, some functions of the page can be used normally, while other functions have problems. The failure status here includes no response status and error response status. For the no response status, due to server downtime, network failure, front-end code dead loop or request blocking, when the stress test request is issued, the page has no response for a long time (exceeding the preset maximum waiting time), it is in the no response state. For the error response status, it may be an error response caused by HTTP error status, JavaScript error and rendering error.
[0085] It is understandable that in order to detect the performance of the system during normal operation, the preset request status usually uses a success status or a partially successful status. On the basis that the stress test results meet the success status or the partially successful status, the stress test request results are parsed to obtain the resource information that the request depends on.
[0086] In this embodiment, the stress test request result that meets the preset request status includes at least information related to the page body content, resource reference related information, network and performance related information, and the page body content related information includes at least HTML document structure, text content, style information, script information, etc., and the resource reference related information includes at least external resource links (CSS, JavaScript, fonts, etc.), pictures and multimedia resource links (such as video, audio, etc.), and the network and performance related information includes at least response status and messages, cache related information, etc. Specifically, the HTML content contained in the stress test request result can be parsed with the help of the stress test request information. Taking a common browser as an example, a resource request record is generated by using the browser tool during the first stress test request. The resource request record includes different resource information in the HTML document, such as CSS files, JavaScript files, pictures, fonts, etc., and then the resource loading order and dependency relationship are analyzed according to the resource request record, and the resource loading order and dependency relationship are used to perform resource parsing on the HTML content to obtain the resource information that the request depends on.
[0087] Specifically, in the process of resource parsing of HTML content, on the one hand, the reference resources that the request depends on can be obtained by searching for resource reference tags, such as CSS reference resources, JavaScript reference resources, image reference resources, multimedia reference resources, etc. On the other hand, the inline resources that the request depends on can be obtained by identifying inline tags, such as CSS inline resources and JavaScript inline resources.
[0088] 103. Initiate a second stress test request for the resource information that the request depends on, and obtain the stress test request result of the dependent resource.
[0089] It is understandable that the first stress test request focuses more on the performance indicators of the stress test request, such as the overall response time and throughput of the page to be tested, while the resource information that the request depends on (such as CSS, JavaScript, pictures, etc.) will also consume system resources and affect performance during loading and processing. By initiating a second stress test request for the resource information that the request depends on, the degree of impact of each resource on system performance under high load can be more accurately determined. Furthermore, different types of resources have their own characteristics in performance. Through the second stress test request, the performance indicators such as loading time, transmission bandwidth usage, and server processing time of each resource can be evaluated separately, which helps to optimize resource usage according to actual conditions.
[0090] In this embodiment, the process of the first stress test request is similar to the process of the second stress test request. The difference is that the objects of the stress test request are different. Accordingly, the stress test request results of the dependent resources are similar to the stress test results of the page to be tested, and also include performance indicator results, errors and exception results, system resource usage, etc., but the stress test request process here is not for page loading, but for loading of dependent resources.
[0091] Correspondingly, the result of the stress test request for the dependent resource can also be judged by the response status code, which includes success, redirection, client error, and server error, etc., as described in step 102, which will not be repeated here.
[0092] 104. Generate a front-end stress test report based on the stress test request results of the dependent resources and the stress test request results of the dependent resources.
[0093] In this embodiment, through the stress test request results of the page to be tested, the status of the page to be tested can be summarized in terms of whether the page request is successful or not, the time taken for the request, and the details of the failed request. Correspondingly, through the stress test request results of the dependent resources, the status of the dependent resources can be summarized in terms of multiple aspects such as the request success status and the resource loading time.
[0094] It can be understood that through the stress testing request results of the page to be tested and the stress testing request results of the dependent resources, the success rate of each stress testing request and dependent resource, the average time consumption of each batch, the total time consumption, the longest time consumption, the shortest time consumption, the median, the percentile, the specific reasons for failed requests, etc. can be summarized, so as to perform a secondary stress test on the page dependent resources based on the stress testing request results of the front-end page, and complete a more comprehensive front-end stress test.
[0095] Compared with the method of implementing front-end stress testing by simulating user access through stress testing tools in the prior art, the front-end stress testing method provided in the embodiment of the present application initiates a first stress testing request to the page to be tested to obtain the stress testing request result of the page to be tested; when the stress testing request result meets the preset request status, the stress testing request result that meets the preset request status is parsed to obtain the resource information that the request depends on; a second stress testing request is initiated to the resource information that the request depends on to obtain the stress testing request result of the dependent resources; and a stress testing report for the front-end is generated based on the stress testing request result of the dependent resources. The whole process is based on the first stress testing request corresponding to the stress testing request result meeting the preset request status, and a second stress test is performed on the dependent resource information of the page to be tested to increase the coverage of the second stress test, so that the stress test can cover more front-end resources and ensure the comprehensiveness of the front-end stress test.
[0096] In the above embodiment, the front-end stress test usually requires accurate positioning of the test page and determining the page dependent resource path according to the test page address. Figure 2 As shown, before the above step 101, the method further includes the following steps:
[0097] 105. Obtain parameter configuration information for stress testing.
[0098] Among them, the parameter configuration information of the stress test at least includes the stress test address and the stress test frequency, through the stress test address.
[0099] The above stress test address is the page address of the stress test, which can be set through the project document. For example, the project document will detail the URL path of each business function module (such as procurement management, sales management, inventory management, etc.). These paths can be used as the page address of the stress test and can also be customized. For example, the user customizes the page address of the stress test through the stress testing platform.
[0100] The above stress test frequency is the request frequency of the stress test, which is usually measured by the number of requests sent per unit time, for example, how many requests are sent per second, or how many requests are sent per minute, etc. It can be set according to actual business needs. If the stress test frequency is set to 10 requests per second, it means that the test tool sends 10 requests to the server of the e-commerce website every second. These requests may be operations such as accessing the product list page and viewing product details.
[0101] Accordingly, the above step 101 includes the following steps:
[0102] 201. Determine the number of stress test requests based on the stress test frequency.
[0103] 202. Send a request to the stress test address according to the number of stress test requests to initiate the first stress test request for the page to be tested, and obtain the stress test request result of the page to be tested.
[0104] In this embodiment, the number of stress test requests is the number of stress test requests sent within a preset time. During the stress test, the test data can be viewed in real time through the listener, such as the success or failure of the request, the response time, etc. Correspondingly, the stress test request results of the page to be tested are viewed through the listener. The stress test results of the page to be tested can display the specific response content of each request, whether it is successful, and other information.
[0105] Specifically, the performance of the page under stress can be analyzed through the stress test results of the page to be tested. The performance can be the success rate of the page to be tested. By calculating the ratio of the number of successful requests to the total number of requests, we can understand whether the page can run stably under stress testing. The higher the success rate, the better the stability. The performance can also be the response time of the page to be tested, including the average response time, the longest response time, the shortest response time, etc. The performance can be the throughput of the page to be tested, that is, the number of requests processed per unit time, which reflects the system's ability to process requests. If the throughput is lower than expected, it may be necessary to further investigate the system bottleneck.
[0106] Specifically, Figure 3 As shown, the above step 202 includes the following steps:
[0107] 301. Split the stress test request into request stages controlled by multiple processes, so that each request stage has a set number of stress test requests controlled by the process.
[0108] 302. In each request phase, a set number of requests are sent to the stress test address to initiate a first stress test request for the page to be tested, and a stress test request result of the page to be tested is obtained.
[0109] In an application scenario, stress test request splitting can be performed based on functional modules. Specifically, stress test requests can be split based on system architecture to obtain stress test requests for different functional modules. Take the e-commerce system as an example, which includes modules such as user registration and login, product display, shopping cart management, and order settlement. During overall stress testing, it is difficult to determine which specific module causes performance problems. By splitting stress test requests, each functional module can be tested separately. For example, if it is found that the loading time of the product details page is too long, while other pages are normal, the code, database query or resource loading related to the product details page can be checked specifically to accurately locate the functional area where the performance bottleneck is located. Stress test requests can also be split based on business importance. Core business functions usually need to be tested in focus, and more stress test requests may need to be allocated. For example, in e-commerce systems, shopping cart settlement and payment functions are key businesses that are directly related to the completion of transactions. More attention should be paid to these functional modules. When splitting requests, relatively more test resources can be allocated to them.
[0110] In another application scenario, stress test request splitting can be performed based on request type. Here, stress test requests can be divided into read requests and write requests. Read requests are mainly for obtaining data, such as querying user information, viewing product lists, etc., while write requests are for modifying, adding or deleting data, such as user registration, product listing, etc. Generally, write requests may involve more system resource consumption, such as database transaction processing, data verification, etc., and write requests may have a greater impact on system performance than read requests.
[0111] In another application scenario, stress test requests can be split according to the number of requests. If there are too many requests, the stress test requests can be evenly split according to the number of stress test requests. In this case, each request stage corresponds to the same number of stress test requests. For example, if the number of stress test requests is 10,000 in 10 seconds and is split into 10 request stages, the number of stress test requests corresponding to each request stage is 1,000 in 1 second. It can also be split according to the weight of the number of stress test requests. In this case, each request stage corresponds to the number of stress test requests with the corresponding weight ratio. For example, if the number of stress test requests is 10,000 in 10 seconds and is split into two request stages, the number of stress test requests corresponding to the first request stage is 3,000 in 5 seconds, and the number of stress test requests corresponding to the second request stage is 7,000 in 5 seconds.
[0112] In actual application scenarios, multiple working processes can be created in a multi-core CPU through the built-in modules in the stress test runtime environment. The main process can send a corresponding number of stress test requests to each working process according to the number of stress test requests. Each process is responsible for processing a corresponding number of stress test requests, thereby improving the concurrency performance of the overall system and reducing the load of a single process. Specifically, the initiation rate of stress test requests can be controlled by the request throttling library that limits the HTTP request rate. For example, the maximum number of stress test requests sent per second can be limited to 1,000.
[0113] In the above embodiment, the request status corresponding to the stress test request result includes a request success status and a request failure status. Accordingly, step 102 specifically includes: when the stress test request result is a request success status, resource matching is performed on the stress test request result that meets the preset request status through regular expressions with different resource characteristics to obtain resource information on which the request depends.
[0114] In this embodiment, the regular expressions with different resource characteristics include regular expressions with static resource characteristics. In the process of performing resource matching on stress testing request results that meet the preset request status by using regular expressions with different resource characteristics, the regular expressions with static resource characteristics can be used to perform resource matching on stress testing request results that meet the preset request status to obtain static resource information loaded by the request dependency label.
[0115] The above-mentioned static resource information at least includes CSS links, JS scripts, images, videos, background images, etc. Correspondingly, the resource matching process includes matching the CSS links, JS scripts, images, videos, background images, etc. in the request results through regular expressions.
[0116] Specifically, in the process of matching resources for CSS links, the regular expression corresponding to the CSS link can be used to match resources with CSS link features in the stress testing request results. Here, the CSS link feature is that the href in the link tag is the resource address and ends with .css.
[0117] Specifically, in the process of matching resources for JS scripts, the regular expression corresponding to the JS script can be used to match resources with image features in the stress testing request results. Here, the JS script feature is that the src in the script tag is the resource address and ends with .js.
[0118] Specifically, in the process of matching resources for images, the regular expression corresponding to the image can be used to match resources with image features in the stress testing request results. Here, the image feature is the src in the image tag, which is the resource address. It should be noted that considering that there are many image formats, the end of the image tag in the image feature is not formatted.
[0119] Specifically, in the process of matching resources for videos, the regular expression corresponding to the video can be used to match resources with video features in the stress test request results. Here, the video feature is the resource address of the src in the video tag. Similarly, considering that there are many video formats, the end of the video tag in the video feature is not limited in format.
[0120] Specifically, in the process of matching resources for the background image, the regular expression corresponding to the background image can be used to match resources with background image features in the stress testing request results. Here, the background image feature is that the link is in the URL and the background image link is background or background-image.
[0121] In this embodiment, the regular expressions with different resource characteristics include regular expressions with dynamic resource characteristics. In the process of performing resource matching on stress testing request results that meet the preset request status by using regular expressions with different resource characteristics, the regular expressions with dynamic resource characteristics can be used to perform resource matching on stress testing request results that meet the preset request status to obtain dynamic resource information loaded by the request-dependent script.
[0122] The above-mentioned dynamic resource information includes at least dynamically loaded script src, dynamic CSS, dynamic images, dynamic videos, dynamic background images, etc. Correspondingly, the resource matching process includes matching the dynamically loaded script src, dynamic CSS, dynamic images, dynamic videos, dynamic background images, etc. in the request results through regular expressions.
[0123] Considering that the dynamic loading process is implemented through code, in the process of resource matching, the resources with label actions can be matched in the stress testing request results through the dynamically loaded regular expression.
[0124] Specifically, in the process of matching resources for dynamically loaded script src, you can first use the dynamically loaded regular expression to match resources with script tag creation actions in the stress testing request results, and then use the regular expression corresponding to the JS script to match resources with JS script features in resources with script tag creation actions. This is similar to the process of matching resources for JS scripts in static resource information. Here, the JS script feature is that src in the script tag is the resource address and ends with .js.
[0125] Specifically, in the process of matching resources for dynamic CSS, you can first use the dynamically loaded regular expression to match resources with link tag creation actions in the stress testing request results, and then use the regular expression corresponding to the CSS link to match resources with CSS link features in resources with link tag creation actions. This is similar to the process of matching resources for CSS links in static resource information. Here, the CSS link feature is that the href in the link tag is the resource address and ends with .css.
[0126] Specifically, in the process of matching resources for dynamic images, you can first match resources with image tag creation actions in the stress test request results through the dynamically loaded regular expression, and then match resources with image features in resources with image tag creation actions through the regular expression corresponding to the image, which is similar to the process of matching resources for images in static resource information. Here, the image feature is the src in the image tag, which is the resource address. It should be noted that considering that there are many image formats, the end of the image tag in the image feature is not formatted.
[0127] Specifically, in the process of matching resources for video images, you can first match resources with video tag creation actions in the stress test request results through the dynamically loaded regular expression, and then match resources with video features in resources with video tag creation actions through the regular expression corresponding to the video, which is similar to the process of matching resources for videos in static resource information. Here, the video feature is the resource address of src in the video tag. Similarly, considering that there are many video formats, the end of the video tag in the video feature is not limited in format.
[0128] Specifically, in the process of matching resources for dynamic background images, you can first use the dynamically loaded regular expression to match the resources with the background image tag setting action in the stress testing request result, and then use the regular expression corresponding to the background image to match the resources with background image features in the resources with the background image tag setting action. This is similar to the process of matching resources for the background image in the static resource information. Here, the background image feature is that the link is in the URL and the background image link is background or background-image.
[0129] Considering that the complex system may contain many types of resources, such as pictures, script files, style files, and various API interfaces in the web page, if no filtering is performed, the stress test will cover all these resources. Figure 4 As shown, before the above step 102, the method further includes the following steps:
[0130] 401. Set the filter resource type corresponding to the stress test request.
[0131] Among them, the filtering resource type is the resource type that is blocked from matching during the resource matching process. By setting the filtering resource type, only focusing on key resources can make the test focus more prominent.
[0132] Correspondingly, in step 102, in the process of performing resource matching on stress testing request results that meet the preset request status through regular expressions with different resource characteristics, if the resource matches the filtered resource type in the stress testing request result, the resource matching of the filtered resource type is shielded to obtain the resource information on which the request depends.
[0133] In one filtering scenario, the resource types that are filtered are those that are not tested for key functions. For example, for an e-commerce system, the main focus is on the performance of the product query interface and the order interface. You can filter out stress test requests for other resources such as website logo images and help documents. This allows you to more accurately test the performance of functions directly related to the core business under stress.
[0134] In another filtering scenario, the resource filtering type is to filter non-critical resource types. For example, the loading speed of some decorative images or animation resources may be affected by network factors, but it has little impact on the core functions of the system. If the requests for these non-critical resources are not filtered, network bandwidth and server resources may be consumed during stress testing, making the stress test results unable to truly reflect the performance of critical resources.
[0135] Furthermore, if Figure 5 As shown, after the above step 102, the method further includes the following steps:
[0136] 501. Store the resource information that the request depends on into a resource array, and remove the resource request address of the filtered resource type from the resource array.
[0137] 502. Perform an address completion operation on the relative path corresponding to the resource request address in the resource array according to the set address completion rule.
[0138] In this embodiment, the resource request addresses of the filtered resource types in the resource array will be filtered accordingly. For the filtered resource array, in order to facilitate the second stress test request, the relative path corresponding to the resource request address in the resource array is an operation that requires address completion. The specific address completion rules are mainly for the following relative paths corresponding to the resource request addresses:
[0139] The first relative path: / css / style.css
[0140] The second relative path: css / style.css
[0141] The third relative path:: / / www.example.com / css / style.css
[0142] The relative path after the corresponding address completion is https: / / www.example.com / css / style.css.
[0143] In actual application scenarios, Figure 6This is a flowchart of the front-end stress test process in this embodiment. The front-end stress test process is the interaction between the stress test client and the front-end stress test system. The stress test address and stress test frequency are set through the stress test client, and the stress test address and stress test frequency are transmitted to the front-end stress test system, so that the front-end stress test system splits the request according to the stress test address and stress test frequency, and controls a set number of stress test requests through process concurrency in each request stage. A stress test request is initiated simultaneously through a static method, and the resource information on which the page to be tested depends is detected and returned. A second stress test request is initiated for the resource information on which the page to be tested depends, and a front-end stress test report is generated according to the stress test request results of the two stress test requests, and the front-end stress test report is fed back to the stress test client for display.
[0144] Further, as Figure 1-Figure 6 The specific implementation of the method, the embodiment of the present application provides a front-end pressure testing device, such as Figure 7 As shown, the device includes: a first testing unit 61, a parsing unit 62, a second testing unit 63, and a generating unit 64.
[0145] The first testing unit 61 is used to initiate a first stress test request to the page to be tested and obtain a stress test request result of the page to be tested;
[0146] The parsing unit 62 is used to parse the stress test request result that meets the preset request state to obtain resource information on which the request depends when the stress test request result meets the preset request state;
[0147] The second testing unit 63 is used to initiate a second stress test request for the resource information on which the request depends, and obtain a stress test request result for the dependent resource;
[0148] The generating unit 64 is used to generate a front-end stress test report according to the stress test request result of the dependent resource and the stress test request result of the dependent resource.
[0149] Compared with the method of implementing front-end stress testing by simulating user access through stress testing tools in the prior art, the front-end stress testing device provided by the embodiment of the present invention initiates a first stress testing request to the page to be tested to obtain the stress testing request result of the page to be tested; when the stress testing request result meets the preset request status, the stress testing request result that meets the preset request status is parsed to obtain the resource information that the request depends on; a second stress testing request is initiated to the resource information that the request depends on to obtain the stress testing request result of the dependent resources; and a front-end stress testing report is generated based on the stress testing request result of the dependent resources. The whole process is based on the first stress testing request corresponding to the stress testing request result meeting the preset request status, and a second stress test is performed on the dependent resource information of the page to be tested, so as to increase the coverage of the second stress test, so that the stress test can cover more front-end resources and ensure the comprehensiveness of the front-end stress test.
[0150] In an actual application scenario, the device further includes:
[0151] An acquiring unit, configured to acquire parameter configuration information of the stress test before initiating a first stress test request for the page to be tested and obtaining a stress test request result for the page to be tested, wherein the parameter configuration information of the stress test includes at least a stress test address and a stress test frequency;
[0152] Accordingly, the first testing unit is specifically used for:
[0153] Determine the number of stress test requests according to the stress test frequency, where the number of stress test requests is the number of stress test requests sent within a preset time;
[0154] Send a request to the stress test address according to the stress test request quantity to initiate a first stress test request for the page to be tested, and obtain a stress test request result for the page to be tested.
[0155] In actual application scenarios, the first test unit is also used to
[0156] Splitting the stress test request into request stages controlled by multiple processes, so that each request stage has a set number of stress test requests controlled by the process;
[0157] In each request phase, requests are sent to the stress test address according to the set number to initiate a first stress test request for the page to be tested, and a stress test request result of the page to be tested is obtained.
[0158] In actual application scenarios, the request status corresponding to the stress testing request result includes a request success status and a request failure status;
[0159] The parsing unit is specifically used for:
[0160] When the stress test request result is in a request success state, resource matching is performed on the stress test request result that meets the preset request state through regular expressions with different resource characteristics to obtain resource information on which the request depends.
[0161] In an actual application scenario, the regular expressions with different resource characteristics include regular expressions with static resource characteristics, and the parsing unit is further used to:
[0162] The regular expression with static resource characteristics is used to perform resource matching in the stress testing request result that meets the preset request state to obtain static resource information loaded by the request dependency label.
[0163] In an actual application scenario, the regular expressions with different resource characteristics include regular expressions with dynamic resource characteristics, and the parsing unit is further used to:
[0164] The regular expression with dynamic resource characteristics is used to perform resource matching in the stress testing request results that meet the preset request status to obtain dynamic resource information loaded by the request-dependent script.
[0165] In practical application scenarios, the device is also used for:
[0166] A setting unit, configured to set a filtering resource type corresponding to the stress test request before initiating a first stress test request for the page to be tested and obtaining a stress test request result for the page to be tested, wherein the filtering resource type is a resource type that is shielded from matching during a resource matching process;
[0167] Accordingly, the parsing unit is further used for:
[0168] In the process of matching resources for stress testing request results that meet the preset request status through regular expressions with different resource characteristics, if the resource matches the filtered resource type in the stress testing request result, the resource matching of the filtered resource type is shielded to obtain the resource information that the request depends on.
[0169] In an actual application scenario, the device further includes:
[0170] A storage unit, configured to perform resource matching on the stress testing request results that meet the preset request status by using regular expressions with different resource characteristics, obtain resource information on which the request depends, store the resource information on which the request depends in a resource array, and remove the resource request address of the filtered resource type from the resource array;
[0171] The completion unit is used to perform an address completion operation on the relative path corresponding to the resource request address in the resource array according to a set address completion rule.
[0172] It should be noted that for other corresponding descriptions of the functional units involved in the front-end pressure testing device provided in this embodiment, reference can be made to Figure 1-Figure 6 The corresponding description in will not be repeated here.
[0173] Based on the above Figure 1-Figure 6 The method shown in the embodiment of the present application accordingly provides a storage medium on which a computer program is stored, and when the program is executed by a processor, the above-mentioned Figure 1-Figure 6 The front-end stress testing method shown.
[0174] Based on this understanding, the technical solution of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.), and includes a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each implementation scenario of the present application.
[0175] Based on the above Figure 1-Figure 6 The method shown, and Figure 7 In order to achieve the above-mentioned purpose, the embodiment of the present application also provides a physical device for front-end stress testing, which can be a computer, a smart phone, a tablet computer, a smart watch, a server, or a network device, etc. The physical device includes a storage medium and a processor; the storage medium is used to store a computer program; the processor is used to execute the computer program to achieve the above-mentioned Figure 1-Figure 6 The front-end stress testing method shown.
[0176] Optionally, the physical device may also include a user interface, a network interface, a camera, a radio frequency (RF) circuit, a sensor, an audio circuit, a WI-FI module, etc. The user interface may include a display, an input unit such as a keyboard, etc., and the optional user interface may also include a USB interface, a card reader interface, etc. The network interface may optionally include a standard wired interface, a wireless interface (such as a WI-FI interface), etc.
[0177] In an exemplary embodiment, see Figure 8 The physical device includes a communication bus, a processor, a memory and a communication interface, and may also include an input / output interface and a display device, wherein each functional unit can communicate with each other through the bus. The memory stores a computer program, and the processor is used to execute the program stored in the memory and execute the front-end stress testing method in the above embodiment.
[0178] Those skilled in the art will appreciate that the physical device structure for a front-end pressure test provided in this embodiment does not constitute a limitation on the physical device, and may include more or fewer components, or a combination of certain components, or different component arrangements.
[0179] The storage medium may also include an operating system and a network communication module. The operating system is a program that manages the hardware and software resources of the physical device processed by the front-end stress test, and supports the operation of the information processing program and other software and / or programs. The network communication module is used to realize the communication between the components inside the storage medium, and the communication with other hardware and software in the information processing physical device.
[0180] Through the description of the above implementation methods, those skilled in the art can clearly understand that the present application can be implemented by means of software plus a necessary general hardware platform, or by hardware. By applying the technical solution of the present application, compared with the current existing methods, the present application performs a second stress test on the dependent resource information of the page to be tested on the basis that the result of the stress test request corresponding to the first stress test request meets the preset request state, so as to improve the coverage of the second stress test, so that the stress test can cover more front-end resources, and ensure the comprehensiveness of the front-end stress test.
[0181] Those skilled in the art will appreciate that the accompanying drawings are only schematic diagrams of a preferred implementation scenario, and the modules or processes in the accompanying drawings are not necessarily necessary for implementing the present application. Those skilled in the art will appreciate that the modules in the devices in the implementation scenario can be distributed in the devices of the implementation scenario according to the description of the implementation scenario, or can be changed accordingly and located in one or more devices different from the present implementation scenario. The modules of the above-mentioned implementation scenario can be combined into one module, or can be further split into multiple submodules.
[0182] The above serial numbers of this application are only for description and do not represent the advantages and disadvantages of the implementation scenarios. The above disclosure is only a few specific implementation scenarios of this application, but this application is not limited to them, and any changes that can be thought of by technicians in this field should fall within the scope of protection of this application.
Claims
1. A front-end stress testing method, characterized in that: include: Initiate the first stress test request for the page to be tested and obtain the stress test request result of the page to be tested; When the stress test request result meets the preset request status, the stress test request result meeting the preset request status is parsed to obtain resource information on which the request depends; Initiate a second stress test request for the resource information that the request depends on, and obtain the stress test request result of the dependent resource; Generate a front-end stress test report based on the stress test request results of the dependent resources and the stress test request results of the dependent resources.
2. The method according to claim 1, characterized in that Before initiating a first stress test request for the page to be tested and obtaining a stress test request result for the page to be tested, the method further includes: Obtaining parameter configuration information of the stress test, wherein the parameter configuration information of the stress test includes at least a stress test address and a stress test frequency; Correspondingly, the first stress test request is initiated for the page to be tested, and the stress test request result of the page to be tested is obtained, including: Determine the number of stress test requests according to the stress test frequency, where the number of stress test requests is the number of stress test requests sent within a preset time; Send a request to the stress test address according to the stress test request quantity to initiate a first stress test request for the page to be tested, and obtain a stress test request result for the page to be tested.
3. The method according to claim 2, characterized in that The sending of a request to the stress test address according to the number of stress test requests to initiate a first stress test request for the page to be tested, and obtaining a stress test request result for the page to be tested, includes: Splitting the stress test request into request stages controlled by multiple processes, so that each request stage has a set number of stress test requests controlled by the process; In each request phase, requests are sent to the stress test address according to the set number to initiate a first stress test request for the page to be tested, and obtain a stress test request result for the page to be tested.
4. The method according to any one of claims 1 to 3, characterized in that The request status corresponding to the stress testing request result includes a request success status and a request failure status; Correspondingly, when the stress test request result meets the preset request status, the stress test request result that meets the preset request status is parsed to obtain resource information on which the request depends, including: When the stress test request result is in a request success state, resource matching is performed on the stress test request result that meets the preset request state through regular expressions with different resource characteristics to obtain resource information on which the request depends.
5. The method according to claim 4, characterized in that The regular expressions with different resource characteristics include regular expressions with static resource characteristics, and the regular expressions with different resource characteristics are used to perform resource matching on the stress test request results that meet the preset request status to obtain resource information on which the request depends, including: The regular expression with static resource characteristics is used to perform resource matching in the stress testing request result that meets the preset request state to obtain static resource information loaded by the request dependency label.
6. The method according to claim 4, characterized in that The regular expressions with different resource characteristics include regular expressions with dynamic resource characteristics. The regular expressions with different resource characteristics are used to perform resource matching on stress testing request results that meet the preset request status to obtain resource information on which the request depends, including: The regular expression with dynamic resource characteristics is used to perform resource matching in the stress testing request results that meet the preset request status to obtain dynamic resource information loaded by the request-dependent script.
7. The method according to claim 4, characterized in that Before initiating a first stress test request for the page to be tested and obtaining a stress test request result for the page to be tested, the method further includes: Set the filtering resource type corresponding to the stress test request, where the filtering resource type is the resource type that is blocked from matching during the resource matching process; Correspondingly, the resource matching of the stress test request results that meet the preset request status is performed through regular expressions with different resource characteristics to obtain resource information that the request depends on, including: In the process of matching resources for stress testing request results that meet the preset request status through regular expressions with different resource characteristics, if the resource matches the filtered resource type in the stress testing request result, the resource matching of the filtered resource type is shielded to obtain the resource information that the request depends on.
8. The method according to claim 7, characterized in that After performing resource matching on the stress testing request results that meet the preset request status by using regular expressions with different resource characteristics to obtain resource information on which the request depends, the method further includes: The resource information that the request depends on is stored in a resource array, and the resource request address of the filtered resource type is removed from the resource array; An address completion operation is performed on the relative path corresponding to the resource request address in the resource array according to the set address completion rule.
9. A front-end pressure testing device, characterized in that: include: The first testing unit is used to initiate a first stress test request to the page to be tested and obtain a stress test request result of the page to be tested; A parsing unit, configured to parse the stress testing request result that meets the preset request state to obtain resource information on which the request depends if the stress testing request result meets the preset request state; The second testing unit is used to initiate a second stress test request for the resource information on which the request depends, and obtain a stress test request result for the dependent resource; A generating unit is used to generate a front-end stress test report according to the stress test request result of the dependent resource and the stress test request result of the dependent resource.
10. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that: When the processor executes the computer program, the steps of the front-end stress testing method described in any one of claims 1 to 8 are implemented.
11. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the front-end stress testing method according to any one of claims 1 to 8 are implemented.