Multi-server interface test method and electronic equipment
By dynamically allocating and monitoring server resources, the problems of low automation testing of a single server interface and poor resource utilization are solved, and efficient execution of distributed testing of multiple servers and rational resource utilization are achieved.
Patent Information
- Application Number
- CN202411630054.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-14
- Publication Date
- 2025-02-28
AI Technical Summary
Existing interface automation testing methods usually rely on a single server to execute all scripts, resulting in high resource usage and low efficiency, and prone to server downtime or insufficient processor usage, resulting in interruption of script execution and blocked process.
By obtaining the processor usage and idle rates of multiple servers, dynamically allocate scripts in the execution test plan to different servers, and execute the assigned scripts on each server, while monitoring the server status. If the processor usage reaches the threshold or goes down, the unfinished scripts will be automatically transferred to the server with the highest idle rate execution.
It realizes automated server resource allocation and script distribution, improves test execution efficiency, rationally utilizes processor resources, and reduces the time and cost of manual intervention and data integration.
Smart Images

Figure CN119537116A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field related to automated testing, and in particular to a multi-server interface testing method, electronic equipment, storage medium and computer program product. Background Art
[0002] Existing interface automation testing generally specifies a server to execute all interface automation scripts. For example, by specifying a specific branch through Jenkins, a server is specified to execute the interface automation script.
[0003] However, if only one server is used, the server resources will be larger, and the execution efficiency of the script will be lower. In addition, sometimes the server will crash and the processor utilization rate will be insufficient. In addition, when the interface automation script is executed in batches, it will cause the process to be blocked. If this server crashes, the execution of all scripts will be interrupted.
[0004] If multiple modules or products of a project are divided into multiple branches and multiple servers are specified for execution, large batches of interface automation scripts need to be manually split and the servers for script execution need to be manually specified. At the same time, the final results of execution on multiple servers cannot be aggregated for statistical analysis. There will also be resource utilization issues when each branch is executed on a specified server. Summary of the invention
[0005] Based on this, it is necessary to provide a multi-server interface testing method, electronic device, storage medium and computer program product to address the technical problems existing in the prior art when executing interface automation scripts.
[0006] The present invention provides a multi-server interface testing method, comprising:
[0007] Obtain one or more test plans, wherein the test plans include scripts of functional modules of one or more products;
[0008] Obtaining processor usage rates and / or processor idle rates of multiple servers, allocating servers to execute the scripts in the test plan according to the multiple processor usage rates and / or processor idle rates, and executing the allocated scripts on each of the servers;
[0009] The test report obtained by executing the script on the server is obtained, and all the test reports are statistically summarized based on products and functional modules.
[0010] Further, allocating the server to execute the script in the test plan according to the plurality of processor usage rates and / or processor idle rates includes:
[0011] Calculate the allocation ratio of each server according to the processor usage rate and / or processor idle rate of each server;
[0012] Allocate the scripts of the test plan to the servers according to the allocation ratio.
[0013] Furthermore, allocating the scripts of the test plan to the servers according to the allocation ratios includes:
[0014] Calculate the number of scripts accommodated by each server according to the allocation ratio of the server and the total number of scripts;
[0015] Select one of the test plans in turn as the current test plan, and perform the following operations on each of the current test plans:
[0016] If the script data of the current test plan is less than or equal to the number of scripts accommodated by one of the servers, allocating all scripts of the current test plan to the server, and subtracting the number of scripts of the current test plan from the number of scripts accommodated by the server;
[0017] If the number of scripts in the current test plan is greater than the number of scripts that can be accommodated by any of the servers, the scripts in the current test plan are divided into one or more script groups according to concurrency, each of the script groups includes one or more scripts to be executed continuously, and the scripts between different script groups are executed concurrently. One of the script groups is selected in turn as the current script group. For each current script group, if the script data of the current script group is less than or equal to the number of scripts that can be accommodated by one of the servers, all the scripts of the current script group are allocated to the server, and the number of scripts that can be accommodated by the server is subtracted from the number of scripts that can be accommodated by the current script group. If the number of scripts in the current script group is greater than the number of scripts that can be accommodated by any of the servers, all the scripts of the current script group are allocated to the server with the lowest processor utilization, and the number of scripts that can be accommodated by the server with the lowest processor utilization is set to zero.
[0018] Further, executing the assigned script on each of the servers includes:
[0019] monitoring the servers while each of the servers executes the assigned script;
[0020] If the processor usage of the server reaches a preset threshold or crashes, the scripts that have not been fully executed in the server are transferred to the server with the highest processor idle rate for execution.
[0021] Further, the obtaining of the test report obtained by the server executing the script and the statistical aggregation of all the test reports based on products and functional modules include:
[0022] Obtaining a test report obtained by executing the script on the server, parsing the test report, and obtaining a test pass rate and / or error data of each script;
[0023] Counting the test pass rates of the scripts of the same product to obtain the test pass rate of each product; and / or
[0024] Counting the test pass rates of the scripts of the same functional module to obtain the test pass rate of each functional module; and / or
[0025] The error data of the same type in all scripts are counted to obtain the error rate of each error type.
[0026] Further, the obtaining of the test report obtained by the server executing the script and the statistical aggregation of all the test reports based on products and functional modules include:
[0027] Obtaining a test report obtained by executing the script on the server, parsing the test report, and obtaining a test pass rate and / or error data of each script;
[0028] Get the specified time dimension and specified time period;
[0029] Count the test pass rates of the scripts of the same product, obtain the average test pass rate of each product in the specified time dimension, and display the change trend of the average test pass rate of each product in the specified time period; and / or
[0030] Count the test pass rates of the scripts of the same functional module to obtain the average test pass rate of each functional module in the specified time dimension, and display the change trend of the average test pass rate of each functional module in the specified time period; and / or
[0031] The error data of the same type in all scripts are counted to obtain the average error rate of each error data in the specified time dimension, and the change trend of the average error rate of each error type in the specified time period is displayed.
[0032] Furthermore, the obtaining of the test report obtained by the server executing the script and the statistical aggregation of all the test reports based on products and functional modules also include:
[0033] Calculate the fluctuation range of the average test pass rate of each of the products in the specified time dimension; and / or
[0034] Calculate the fluctuation range of the average test pass rate of each functional module in the specified time dimension; and / or
[0035] Calculate the fluctuation range of the error rate average value of each error data in the specified time dimension.
[0036] The present invention provides an electronic device, comprising:
[0037] at least one processor; and,
[0038] a memory communicatively connected to at least one of the processors; wherein,
[0039] The memory stores instructions that can be executed by at least one of the processors. The instructions are executed by at least one of the processors to enable the at least one of the processors to execute the multi-server interface testing method as described above.
[0040] The present invention provides a storage medium, wherein the storage medium stores computer instructions, and when a computer executes the computer instructions, it is used to execute all steps of the multi-server interface testing method as described above.
[0041] The present invention provides a computer program product, comprising a computer program / instruction, which implements the multi-server interface testing method as described above when executed by a processor.
[0042] The present invention allocates servers for executing the scripts in the test plan according to the utilization rate and / or idle rate of the processors, and executes the allocated scripts on each server, so that different interface automation scripts can be automatically distributed to different machines for execution according to the resource occupancy of the server. The technical problems that the prior art needs to manually split the scripts and manually specify the servers for script execution when using multiple servers to run large quantities of interface automation scripts are solved, thereby improving the overall efficiency of test execution and achieving the rational use of processor utilization. At the same time, the present invention improves the overall execution efficiency by executing large quantities of interface automation scripts in a distributed manner on different servers. By obtaining the test reports obtained by the server executing the scripts, all the test reports are statistically summarized based on the products and functional modules, and the overall analysis and statistical data can be obtained more intuitively, which greatly reduces the time and labor cost of integrating data analysis test results by manpower. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1A flowchart of a multi-server interface testing method according to an embodiment of the present invention;
[0044] Figure 2 A flowchart of a multi-server interface testing method according to another embodiment of the present invention;
[0045] Figure 3 A flowchart of a multi-server interface testing method implemented by a device tool in a preferred embodiment of the present invention;
[0046] Figure 4 The figure is a schematic diagram of the hardware structure of an electronic device of the present invention. DETAILED DESCRIPTION
[0047] The specific embodiments of the present invention are further described below in conjunction with the accompanying drawings. The same components are represented by the same reference numerals. It should be noted that the words "front", "rear", "left", "right", "upper" and "lower" used in the following description refer to directions in the accompanying drawings, and the words "inner" and "outer" refer to directions toward or away from the geometric center of a specific component, respectively.
[0048] In this demand context, it is necessary to implement a method that can execute a large number of interface automation scripts in a distributed manner, and then dynamically allocate the resources of multiple servers in the form of multiple servers, and then execute the test scripts and generate the corresponding test results, and automatically analyze and count the test results. In this way, the efficiency of the overall interface test can be improved, the execution time can be reduced, and the server resources can be automatically allocated, and the test server can be more reasonably specified to utilize the processor usage rate. And the test results can be further integrated and analyzed on the basis of fully utilizing resources and improving execution efficiency.
[0049] like Figure 1 The figure shows a workflow diagram of a multi-server interface testing method according to an embodiment of the present invention, including:
[0050] Step S101, obtaining one or more test plans, wherein the test plans include scripts of functional modules of one or more products;
[0051] Step S102, obtaining processor usage rates and / or processor idle rates of multiple servers, allocating servers to execute the scripts in the test plan according to the multiple processor usage rates and / or processor idle rates, and executing the allocated scripts on each of the servers;
[0052] Step S103, obtaining a test report obtained by executing the script on the server, and summarizing all the test reports based on products and functional modules.
[0053] Specifically, the present invention can be applied to electronic devices with processing capabilities, such as computers.
[0054] The present invention realizes a method capable of executing a large number of interface automation scripts in a distributed manner, and then dynamically allocating the resources of the multiple servers in the form of multiple servers, executing the scripts through the multiple servers and generating corresponding test results, and automatically performing combined result analysis and statistics of the test results, thereby improving the efficiency of the overall interface test, reducing the execution time, and being able to automatically allocate server resources, being able to more reasonably specify test servers, achieving full utilization of processor usage, and further performing integrated analysis of test results on the basis of improving execution efficiency.
[0055] Specifically, a device tool in the form of software is used to implement a multi-server interface testing method. The device tool can implement an interface for executing interface automation testing based on PyQt, and include the overall task progress, task log, and statistical management of execution results for multi-server execution scripts. Among them, Qt is a cross-platform C++ development framework for creating desktop applications and mobile applications. It provides a wealth of GUI components, tool libraries, and platform-related functions; and PyQt is a cross-platform library of Python for creating desktop applications and mobile applications. It is based on the Qt framework and provides a wealth of GUI components and tool libraries.
[0056] The overall implementation logic is as follows
[0057] First, step S101 is executed to obtain one or more test plans, where the test plans include scripts of functional modules of one or more products.
[0058] Specifically, take a product system as an example. Put all the interface automation scripts of the functional modules of a system into a code branch, and then create a test plan in the code to specify which modules' scripts to execute. Each script is distinguished by a label, and then fill in the specific scripts you want to execute in the test plan, that is, fill in the corresponding label name. If you want to execute the entire specified module directly, you can directly fill in the entire folder path of the module in the code in the test plan.
[0059] After the test plan is determined, the test plan is input into the device tool used for testing, and the tool automatically parses the specified scripts in the filled-in test plan and automatically finds all the scripts under the specified folder.
[0060] Among them, the script is the interface of a functional module in the product. By running the script, the corresponding functions of the corresponding functional module will be executed.
[0061] Preferably, the script is an interface automation script.
[0062] Then execute step S102 to obtain the processor usage rates and / or processor idle rates of multiple servers, and allocate servers to execute the scripts in the test plan based on the multiple processor usage rates and / or processor idle rates, and execute the allocated scripts on each server.
[0063] Specifically, the device tool first selects the machines whose server status is normal, then obtains the processor usage or processor idle rate of the monitored multiple servers, and allocates scripts according to the processor usage or processor idle rate of different machines, that is, determines which server each script is executed on, and executes the allocated script on each server.
[0064] Finally, step S103 is executed to obtain a test report obtained by the server executing the script, and all the test reports are statistically summarized based on products and functional modules.
[0065] Specifically, after all scripts are executed on different servers, a test report of each functional module of the product is obtained from each server, and then all test reports are statistically summarized based on the product and functional module.
[0066] The present invention allocates servers for executing the scripts in the test plan according to the utilization rate and / or idle rate of the processors, and executes the allocated scripts on each server, so that different interface automation scripts can be automatically distributed to different machines for execution according to the resource occupancy of the server. The technical problems that the prior art needs to manually split the scripts and manually specify the servers for script execution when using multiple servers to run large quantities of interface automation scripts are solved, thereby improving the overall efficiency of test execution and achieving the rational use of processor utilization. At the same time, the present invention improves the overall execution efficiency by executing large quantities of interface automation scripts in a distributed manner on different servers. By obtaining the test reports obtained by the server executing the scripts, all the test reports are statistically summarized based on the products and functional modules, and the overall analysis and statistical data can be obtained more intuitively, which greatly reduces the time and labor cost of integrating data analysis test results by manpower.
[0067] like Figure 2 The flowchart of a multi-server interface testing method in another embodiment of the present invention includes:
[0068] Step S201, obtaining one or more test plans, wherein the test plans include scripts of functional modules of one or more products.
[0069] Step S202: Obtain processor usage rates and / or processor idle rates of multiple servers.
[0070] Step S203: Calculate the allocation ratio of each server according to the processor usage rate and / or processor idle rate of each server.
[0071] Step S204, allocating the scripts of the test plan to the servers according to the allocation ratios.
[0072] In one embodiment, allocating the scripts of the test plan to the servers according to the allocation ratios includes:
[0073] Calculate the number of scripts accommodated by each server according to the allocation ratio of the server and the total number of scripts;
[0074] Select one of the test plans in turn as the current test plan, and perform the following operations on each of the current test plans:
[0075] If the script data of the current test plan is less than or equal to the number of scripts accommodated by one of the servers, allocating all scripts of the current test plan to the server, and subtracting the number of scripts of the current test plan from the number of scripts accommodated by the server;
[0076] If the number of scripts in the current test plan is greater than the number of scripts that can be accommodated by any of the servers, the scripts in the current test plan are divided into one or more script groups according to concurrency, each of the script groups includes one or more scripts to be executed continuously, and the scripts between different script groups are executed concurrently. One of the script groups is selected in turn as the current script group. For each current script group, if the script data of the current script group is less than or equal to the number of scripts that can be accommodated by one of the servers, all the scripts of the current script group are allocated to the server, and the number of scripts that can be accommodated by the server is subtracted from the number of scripts that can be accommodated by the current script group. If the number of scripts in the current script group is greater than the number of scripts that can be accommodated by any of the servers, all the scripts of the current script group are allocated to the server with the lowest processor utilization, and the number of scripts that can be accommodated by the server with the lowest processor utilization is set to zero.
[0077] Step S205, monitoring the server while each server executes the assigned script;
[0078] If the processor usage of the server reaches a preset threshold or crashes, the scripts that have not been fully executed in the server are transferred to the server with the highest processor idle rate for execution.
[0079] Step S206, obtaining a test report obtained by executing the script on the server, and summarizing all the test reports based on products and functional modules.
[0080] Specifically, firstly, step S201 is executed to obtain one or more test plans, wherein the test plans include scripts of functional modules of one or more products.
[0081] Specifically, take a product system as an example. Put all the interface automation scripts of the functional modules of a system into a code branch, and then create a test plan in the code to specify which modules' scripts to execute. Each script is distinguished by a label, and then fill in the specific scripts you want to execute in the test plan, that is, fill in the corresponding label name. If you want to execute the entire specified module directly, you can directly fill in the entire folder path of the module in the code in the test plan.
[0082] After the test plan is determined, the test plan is input into the device tool used for testing, and the tool automatically parses the specified scripts in the filled-in test plan and automatically finds all the scripts under the specified folder.
[0083] As an example, the current production code result is
[0084] Product 1
[0085] Module 1
[0086] Script1@product1_module1_tag1
[0087] Script 2@product1_module1_tag2
[0088] Module 2
[0089] Script1@product1_module2_tag1
[0090] Script 2@product1_module2_tag2
[0091] Product 2
[0092] Module 1
[0093] Script1@product2_module1_tag1
[0094] Script 2@Product 2_Module 1_tag2
[0095] Among them, @product1_module1_tag1, @product1_module1_tag2, @product1_module2_tag1, @product1_module2_tag2, @product2_module1_tag1, @product2_module1_tag2 are different tags.
[0096] Create a test plan
[0097] Test Plan 1:
[0098] product1 / module1 / @product1_module1_tag1
[0099] product1 / module1 / @product1_module1_tag2
[0100] product2 / module1 / @product1_module2_tag1
[0101] Test plan 2: product 1 / module 2 / @product 1_module 2_tag1
[0102] product1 / module2 / @product1_module2_tag2
[0103] Among them, product1 / module1 / , product1 / module2 / , and product2 / module1 / are the directories where the scripts are located.
[0104] By using the script label and script directory, you can determine the location of the script and determine which script to execute. At the same time, you can also count the number of scripts in the test plan.
[0105] Then, step S202 is executed to obtain processor usage rates and / or processor idle rates of multiple servers.
[0106] Specifically, the device tool accesses the IP addresses of multiple servers, monitors the status of the servers, and determines whether they are normal or abnormal. It then monitors the resource usage of the servers in real time, mainly monitoring the CPU usage, which mainly affects the speed and efficiency of program execution.
[0107] The device tool first selects machines whose server status is normal, and then obtains the processor utilization rate or processor idle rate of the monitored multiple servers.
[0108] Then, step S203 is executed to calculate the allocation ratio of each server according to the processor usage rate and / or processor idle rate of each server.
[0109] Specifically, the total number of servers used is first determined, and then the servers used are determined, and the weight ratios of the scripts to be executed are calculated as the allocation ratios according to the processor usage rates or processor idle rates of the multiple servers used.
[0110] The processor idle rate and the processor utilization rate can be calculated from each other, that is, if the processor utilization rate is obtained, the processor idle rate can be calculated as 1-processor utilization rate. Similarly, if the processor idle rate is obtained, the processor utilization rate can be calculated as 1-processor idle rate.
[0111] The allocation ratio is generally calculated using the processor idle rate, that is, the ratio of the processor idle rates among multiple servers is calculated as the allocation ratio.
[0112] Then, step S204 is executed to distribute the scripts of the test plan to the servers according to the distribution ratio.
[0113] Specifically, the total number of servers that execute the distribution can be configured by the system or user. For example, the total number of servers for specific distribution execution can be specified according to the actual number of scripts. For example, if three servers are customized for execution, the device tool first selects three servers with normal status and the lowest processor utilization. Then determine that the processor utilization rates of these three servers are 20%, 40%, and 60%, respectively. There are 1,000 interface automation scripts. The device tool first calculates the processor idle rate of each machine, which corresponds to 80%, 60%, and 40%, respectively. Then calculate the distribution ratio between them as 4:3:2. Then, for a total of 1,000 scripts, calculate the number of scripts initially allocated to each server according to the distribution ratio, and allocate scripts according to the concurrency between scripts, put the scripts that need to be executed sequentially in the same test plan into the same server, and the scripts that are executed concurrently can be placed in different servers as needed.
[0114] In one embodiment, allocating the scripts of the test plan to the servers according to the allocation ratios includes:
[0115] Calculate the number of scripts accommodated by each server according to the allocation ratio of the server and the total number of scripts;
[0116] Select one of the test plans in turn as the current test plan, and perform the following operations on each of the current test plans:
[0117] If the script data of the current test plan is less than or equal to the number of scripts accommodated by one of the servers, allocating all scripts of the current test plan to the server, and subtracting the number of scripts of the current test plan from the number of scripts accommodated by the server;
[0118] If the number of scripts in the current test plan is greater than the number of scripts that can be accommodated by any of the servers, the scripts in the current test plan are divided into one or more script groups according to concurrency, each of the script groups includes one or more scripts to be executed continuously, and the scripts between different script groups are executed concurrently. One of the script groups is selected in turn as the current script group. For each current script group, if the script data of the current script group is less than or equal to the number of scripts that can be accommodated by one of the servers, all the scripts of the current script group are allocated to the server, and the number of scripts that can be accommodated by the server is subtracted from the number of scripts that can be accommodated by the current script group. If the number of scripts in the current script group is greater than the number of scripts that can be accommodated by any of the servers, all the scripts of the current script group are allocated to the server with the lowest processor utilization, and the number of scripts that can be accommodated by the server with the lowest processor utilization is set to zero.
[0119] Specifically, firstly, the number of scripts accommodated by each server is calculated according to the allocation ratio of the server and the total number of the scripts.
[0120] Then, select one of the test plans as the current test plan and perform the following assignment operations:
[0121] If the script data of the current test plan is less than or equal to the number of scripts that can be accommodated by one of the servers, all scripts of the current test plan can be allocated to the server, and the number of scripts that can be accommodated by the server is subtracted from the number of scripts in the current test plan. In this way, all scripts of the same test plan can be run on the same server.
[0122] If the number of scripts in the current test plan is greater than the number of scripts that can be accommodated by any server, all scripts in the current test plan cannot be executed by one server and need to be split. When splitting, the principle is to put the scripts that need to be executed continuously, that is, the scripts with a time sequence, into the same server for execution as much as possible. Therefore, the scripts in the current test plan are divided into one or more script groups according to concurrency, each script group includes one or more scripts to be executed continuously, and the scripts in different script groups are executed concurrently.
[0123] Then, select one script group as the current script group in turn. For each current script group, if the script data of the current script group is less than or equal to the number of scripts accommodated by one of the servers, all scripts of the current script group are allocated to the server, and the number of scripts accommodated by the server is subtracted from the number of scripts accommodated by the current script group. If the number of scripts in the current script group is greater than the number of scripts accommodated by any server, all scripts of the current script group are allocated to the server with the lowest processor utilization, and the number of scripts accommodated by the server with the lowest processor utilization is set to zero.
[0124] After all scripts of the current test plan are assigned, select another test plan as the current test plan and continue to perform the aforementioned assignment operation until all scripts of all test plans are assigned.
[0125] This embodiment distributes scripts based on the test plan, and tries to ensure that all scripts of the same test plan are executed on the same server to ensure the integrity of the test plan. At the same time, when the number of scripts in the test plan is too large, they are split based on concurrency to ensure the time order of consecutive scripts in the test plan and the accuracy of script execution.
[0126] Then, step S205 is performed to monitor the server while each server executes the assigned script;
[0127] If the processor usage of the server reaches a preset threshold or crashes, the scripts that have not been fully executed in the server are transferred to the server with the highest processor idle rate for execution.
[0128] Specifically, the changes in the processor resources of the server are monitored at all times during execution. If the processor utilization rate of any server reaches a preset threshold or crashes, the server with the highest remaining idle rate (i.e., the lowest processor utilization rate) is automatically found among the remaining servers in normal status as a transfer server, and the remaining scripts in the server whose resources reach the preset threshold or crashes are transferred to the transfer server for continued execution.
[0129] Preferably, the preset threshold is 85%.
[0130] According to the processor idle rate of the available servers and the number of scripts in the test plan, the number of scripts that each server should accommodate is calculated as the number of scripts that the server can accommodate. Since different test plans are executed at the same time, there is no correlation between the test plans and the scripts between the test plans.
[0131] As an example, there are three test plans, each with 10, 20, and 30 scripts, and two servers are used. The processor idle rate of each server is 50%. Then, according to the number of scripts, the test plans with 10 and 20 scripts are put on the first server for execution, and the test plan with 30 scripts is put on the second server for execution. The servers are monitored during execution. For example, if the processor usage of the first server suddenly reaches 85% or crashes, the unfinished scripts in the test plan executed on the first server will be transferred to the second server for re-execution.
[0132] Finally, step S206 is executed to obtain a test report obtained by executing the script on the server, and all the test reports are statistically summarized based on products and functional modules.
[0133] Specifically, after all scripts are executed on different servers, test reports on different functional modules of different products can be obtained from different servers, and then all test reports are integrated.
[0134] In one embodiment, the obtaining of the test report obtained by the server executing the script and the statistical aggregation of all the test reports based on products and functional modules include:
[0135] Obtaining a test report obtained by executing the script on the server, parsing the test report, and obtaining a test pass rate and / or error data of each script;
[0136] Counting the test pass rates of the scripts of the same product to obtain the test pass rate of each product; and / or
[0137] Counting the test pass rates of the scripts of the same functional module to obtain the test pass rate of each functional module; and / or
[0138] The error data of the same type in all scripts are counted to obtain the error rate of each error type.
[0139] Specifically, the logic of test report integration is as follows:
[0140] First obtain multiple test results, then parse the test report content, and then group and reorganize them according to different products, different functional modules and different error data.
[0141] By obtaining the detailed results of script execution of different products and modules, the overall test pass rate of different product systems and the test execution pass rate of different functional modules can be automatically analyzed. And the analysis and summary are performed according to the types of different error data. Error data includes but is not limited to: interface response code error, interface assertion error, interface parameter error. The error data of different functional modules of different products can be counted, and then the error rate of different error types can be calculated. In addition, the test report results of the overall request and response of a specific interface can also be viewed.
[0142] In one embodiment, the obtaining of the test report obtained by the server executing the script and the statistical aggregation of all the test reports based on products and functional modules include:
[0143] Obtaining a test report obtained by executing the script on the server, parsing the test report, and obtaining a test pass rate and / or error data of each script;
[0144] Get the specified time dimension and specified time period;
[0145] Count the test pass rates of the scripts of the same product, obtain the average test pass rate of each product in the specified time dimension, and display the change trend of the average test pass rate of each product in the specified time period; and / or
[0146] Count the test pass rates of the scripts of the same functional module to obtain the average test pass rate of each functional module in the specified time dimension, and display the change trend of the average test pass rate of each functional module in the specified time period; and / or
[0147] The error data of the same type in all scripts are counted to obtain the average error rate of each error data in the specified time dimension, and the change trend of the average error rate of each error type in the specified time period is displayed.
[0148] Specifically, the results of each interface automation test are stored and recorded, and then managed through a visual interface. The results of different time periods can be further aggregated and the time can be split according to the dimensions of day, week, and month.
[0149] Specifically, the time dimension specified by the user can be obtained from the interface as the specified time dimension, and the time period specified by the user can be obtained as the specified time period, or the system can set a default time dimension as the specified time dimension, and set a default time period as the specified time period.
[0150] Then, the average test pass rates of different products, the average test pass rates of different functional modules, and the average error rate of each error type are calculated under the specified time dimension. Then, the change trend of each average value over time in the specified time period specified by the user is generated. Specifically, a trend chart of each average value in the specified time period specified by the user can be generated.
[0151] In one embodiment, the obtaining of the test report obtained by executing the script by the server, and summarizing all the test reports based on products and functional modules, further includes:
[0152] Calculate the fluctuation range of the average test pass rate of each of the products in the specified time dimension; and / or
[0153] Calculate the fluctuation range of the average test pass rate of each functional module in the specified time dimension; and / or
[0154] Calculate the fluctuation range of the error rate average value of each error data in the specified time dimension.
[0155] Specifically, it is possible to calculate whether the fluctuation range of each average value is within a defined threshold, thereby further analyzing the stability of the system function. The fluctuation range may be a variance.
[0156] In some embodiments:
[0157] The fluctuation range of the average value of the test pass rate of each of the products in the specified time dimension is the variance of the average value of the test pass rate of each of the products in the specified time dimension;
[0158] The fluctuation range of the average value of the test pass rate of each functional module in the specified time dimension is the variance of the average value of the test pass rate of each functional module in the specified time dimension;
[0159] The fluctuation range of the average error rate of each error data in the specified time dimension is the variance of the average error rate of each error data in the specified time dimension.
[0160] In addition, the error rates of error types between different modules can be analyzed to determine which specific modules in the product system need to focus on corresponding issues.
[0161] This embodiment allocates servers that execute the scripts in the test plan according to the utilization rate and / or processor idle rate of multiple processors, and executes the allocated scripts on each server, so that different interface automation scripts can be automatically distributed to different machines for execution according to the resource occupation of the server. On the one hand, this embodiment solves the problem of script interruption and processor utilization rate utilization caused by machine downtime or insufficient resources when all large-scale scripts in the market are executed by only one server. On the other hand, it solves the technical problem that when the prior art uses multiple servers to run large-scale interface automation scripts, it needs to manually split the scripts and manually specify the servers for script execution, thereby improving the overall test execution efficiency and realizing the reasonable utilization of processor utilization. At the same time, this embodiment improves the overall execution efficiency by executing large-scale interface automation scripts in a distributed manner through different servers. By obtaining the test report obtained by the server executing the script, all the test reports are statistically summarized based on the product and function module, and the data results of the test results on different servers can be integrated. By integrating the interface test reports between multiple modules or products, and statistically analyzing the pass rate or error rate of different products, function modules, and error data, the change trend and fluctuation range can also be displayed. Therefore, this embodiment can obtain the overall analysis statistical data more intuitively, greatly reducing the time and labor cost of integrating data analysis test results through manpower.
[0162] like Figure 3 The flowchart of the best embodiment of the present invention using a device tool to implement a multi-server interface testing method includes:
[0163] Step S301, opening the device tool;
[0164] Step S302, access multiple servers and automatically monitor server status and CPU usage;
[0165] Step S303, the interface automation script is placed in a branch, and several servers are specified to execute the interface automation script;
[0166] Step S304, automatically screening several servers with normal status and lowest CPU idle rate among the access servers, allocating the number of concurrently executed scripts according to the CPU idle rate ratio, and dynamically adjusting the execution server according to the CPU idle rate resources;
[0167] Step S305, after all scripts to be executed are automatically executed, multiple test reports are generated on different execution servers, and the test reports are automatically integrated according to the tool to automatically analyze the results;
[0168] Step S306, automatically analyzing the overall test pass rate of the system and the test execution pass rate of different modules, calculating the error rates of different types of problems, and calculating the average values by day, week, and month through time aggregation, automatically performing fluctuation trend analysis, analyzing the stability of the system, and the error rates of problems between modules;
[0169] Step S307, the test ends.
[0170] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.
[0171] like Figure 4 The figure shows a hardware structure diagram of an electronic device of the present invention, including:
[0172] at least one processor 401; and,
[0173] A memory 402 is communicatively connected to at least one of the processors 401; wherein,
[0174] The memory 402 stores instructions that can be executed by at least one of the processors. The instructions are executed by at least one of the processors to enable the at least one of the processors to execute the multi-server interface testing method as described above.
[0175] Figure 4A processor 401 is taken as an example.
[0176] The electronic device may further include: an input device 403 and a display device 404 .
[0177] The processor 401, the memory 402, the input device 403 and the display device 404 may be connected via a bus or other means, and the figure takes the connection via a bus as an example.
[0178] The memory 402 is a non-volatile computer-readable storage medium that can be used to store non-volatile software programs, non-volatile computer executable programs and modules, such as program instructions / modules corresponding to the multi-server interface testing method in the embodiment of the present application, for example, Figure 1 , Figure 2 The processor 401 executes various functional applications and data processing by running the non-volatile software programs, instructions and modules stored in the memory 402, that is, the multi-server interface testing method in the above embodiment is implemented.
[0179] The memory 402 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and an application required by at least one function; the data storage area may store data created according to the use of the multi-server interface testing method, etc. In addition, the memory 402 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory 402 may optionally include a memory remotely arranged relative to the processor 401, and these remote memories may be connected to the device for executing the multi-server interface testing method via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0180] The input device 403 can receive input user clicks and generate signal inputs related to user settings and function control of the multi-server interface testing method. The display device 404 can include display devices such as a display screen.
[0181] The one or more modules are stored in the memory 402 and when executed by the one or more processors 401 , the multi-server interface testing method in any of the above method embodiments is executed.
[0182] The present invention allocates servers for executing the scripts in the test plan according to the utilization rate and / or idle rate of the processors, and executes the allocated scripts on each server, so that different interface automation scripts can be automatically distributed to different machines for execution according to the resource occupancy of the server. The technical problems that the prior art needs to manually split the scripts and manually specify the servers for script execution when using multiple servers to run large quantities of interface automation scripts are solved, thereby improving the overall efficiency of test execution and achieving the rational use of processor utilization. At the same time, the present invention improves the overall execution efficiency by executing large quantities of interface automation scripts in a distributed manner on different servers. By obtaining the test reports obtained by the server executing the scripts, all the test reports are statistically summarized based on the products and functional modules, and the overall analysis and statistical data can be obtained more intuitively, which greatly reduces the time and labor cost of integrating data analysis test results by manpower.
[0183] An embodiment of the present invention provides a storage medium, wherein the storage medium stores computer instructions. When a computer executes the computer instructions, the storage medium is used to execute all steps of the multi-server interface testing method as described above.
[0184] In the context of the present disclosure, a storage medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or apparatus. The storage medium may be a machine-readable signal medium or a machine-readable storage medium. Alternatively, the storage medium may be a non-temporary computer-readable storage medium, for example, a non-temporary computer-readable storage medium may be a ROM, a random access memory (Random Access Memory, RAM), a compact disc read-only memory (Compact Disc ROM, CD-ROM), a magnetic tape, a floppy disk, and an optical data storage device, etc.
[0185] An embodiment of the present invention provides a computer program product, including a computer program / instruction, which implements the multi-server interface testing method as described above when executed by a processor.
[0186] The above-mentioned embodiments only express several implementation methods of the present invention, and the description thereof is relatively specific and detailed, but it cannot be understood as limiting the scope of the patent of the present invention. It should be pointed out that, for ordinary technicians in this field, several variations and improvements can be made without departing from the concept of the present invention, which all belong to the protection scope of the present invention. Therefore, the protection scope of the patent of the present invention shall be subject to the attached claims.
Claims
1. A multi-server interface testing method, characterized in that: include: Obtain one or more test plans, wherein the test plans include scripts of functional modules of one or more products; Obtaining processor usage rates and / or processor idle rates of multiple servers, allocating servers to execute the scripts in the test plan according to the multiple processor usage rates and / or processor idle rates, and executing the allocated scripts on each of the servers; The test report obtained by executing the script on the server is obtained, and all the test reports are statistically summarized based on products and functional modules.
2. The multi-server interface testing method according to claim 1, characterized in that: The step of allocating servers for executing the scripts in the test plan according to the plurality of processor usage rates and / or processor idle rates comprises: Calculate the allocation ratio of each server according to the processor usage rate and / or processor idle rate of each server; Allocate the scripts of the test plan to the servers according to the allocation ratio.
3. The multi-server interface testing method according to claim 2, characterized in that: The step of distributing the scripts of the test plan to the servers according to the distribution ratios includes: Calculate the number of scripts accommodated by each server according to the allocation ratio of the server and the total number of scripts; Select one of the test plans in turn as the current test plan, and perform the following operations on each of the current test plans: If the script data of the current test plan is less than or equal to the number of scripts accommodated by one of the servers, all scripts of the current test plan are allocated to the server, and the number of scripts accommodated by the server is subtracted from the number of scripts of the current test plan; If the number of scripts in the current test plan is greater than the number of scripts that can be accommodated by any of the servers, the scripts in the current test plan are divided into one or more script groups according to concurrency, each of the script groups includes one or more scripts to be executed continuously, and the scripts between different script groups are executed concurrently. One of the script groups is selected in turn as the current script group. For each current script group, if the script data of the current script group is less than or equal to the number of scripts that can be accommodated by one of the servers, all the scripts of the current script group are allocated to the server, and the number of scripts that can be accommodated by the server is subtracted from the number of scripts that can be accommodated by the current script group. If the number of scripts in the current script group is greater than the number of scripts that can be accommodated by any of the servers, all the scripts of the current script group are allocated to the server with the lowest processor utilization, and the number of scripts that can be accommodated by the server with the lowest processor utilization is set to zero.
4. The multi-server interface testing method according to claim 1, characterized in that: Executing the assigned script on each of the servers includes: monitoring the servers while each of the servers executes the assigned script; If the processor usage of the server reaches a preset threshold or crashes, the scripts that have not been fully executed in the server are transferred to the server with the highest processor idle rate for execution.
5. The multi-server interface testing method according to claim 1, characterized in that: The obtaining of the test report obtained by executing the script by the server, and statistically summarizing all the test reports based on products and functional modules, includes: Obtaining a test report obtained by executing the script on the server, parsing the test report, and obtaining a test pass rate and / or error data of each script; Counting the test pass rates of the scripts of the same product to obtain the test pass rate of each product; and / or Counting the test pass rates of the scripts of the same functional module to obtain the test pass rate of each functional module; and / or The error data of the same type in all scripts are counted to obtain the error rate of each error type.
6. The multi-server interface testing method according to claim 1, characterized in that: The obtaining of the test report obtained by executing the script by the server, and statistically summarizing all the test reports based on products and functional modules, includes: Obtaining a test report obtained by executing the script on the server, parsing the test report, and obtaining a test pass rate and / or error data of each script; Get the specified time dimension and specified time period; Count the test pass rates of the scripts of the same product, obtain the average test pass rate of each product in the specified time dimension, and display the change trend of the average test pass rate of each product in the specified time period; and / or Count the test pass rates of the scripts of the same functional module to obtain the average test pass rate of each functional module in the specified time dimension, and display the change trend of the average test pass rate of each functional module in the specified time period; and / or The error data of the same type in all scripts are counted to obtain the average error rate of each error data in the specified time dimension, and the change trend of the average error rate of each error type in the specified time period is displayed.
7. The multi-server interface testing method according to claim 6, characterized in that: The obtaining of the test report obtained by executing the script by the server, and summarizing all the test reports based on products and functional modules, further includes: Calculate the fluctuation range of the average test pass rate of each of the products in the specified time dimension; and / or Calculate the fluctuation range of the average test pass rate of each functional module in the specified time dimension; and / or Calculate the fluctuation range of the error rate average value of each error data in the specified time dimension.
8. An electronic device, characterized in that: include: at least one processor; as well as, a memory communicatively connected to at least one of the processors; wherein, The memory stores instructions that can be executed by at least one of the processors, and the instructions are executed by at least one of the processors to enable at least one of the processors to execute the multi-server interface testing method according to any one of claims 1 to 7.
9. A storage medium, characterized in that: The storage medium stores computer instructions, and when a computer executes the computer instructions, it is used to execute all steps of the multi-server interface testing method according to any one of claims 1 to 7.
10. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instruction is executed by a processor, the multi-server interface testing method as described in any one of claims 1 to 7 is implemented.