Test task allocation method, computer-readable storage medium, and processor
By adding tags to the scripts to be tested and defining allocation rules, dynamic allocation of automated testing tasks is achieved, which solves the resource waste problem caused by manual allocation in the existing technology, improves the resource utilization efficiency of the computer cluster and minimizes the execution time.
Patent Information
- Application Number
- CN202210229002.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-08
- Publication Date
- 2025-09-05
- Estimated Expiration
- 2042-03-08
AI Technical Summary
In existing automated testing, the need for manual allocation of test tasks results in an inability to fully and reasonably utilize computer cluster resources and an inability to guarantee the shortest execution time.
By adding tags to the scripts to be tested and defining specific allocation rules, the scripts with tags are automatically assigned to the predetermined servers. If there are idle servers, the scripts without tags are assigned to idle servers, thus achieving dynamic and automated allocation of test tasks.
It reduces the manpower and time costs of manual allocation, improves the utilization efficiency of computer cluster resources, and shortens the waiting time for automated execution of test tasks.
Smart Images

Figure CN114816731B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of automated testing, and in particular to a method, device, computer-readable storage medium, and processor for allocating test tasks. Background Art
[0002] When conducting automated testing, if there are a large number of scripts to be tested, it will take a long time to complete a round of regression testing. In order to complete a round of regression testing in the shortest time, a distributed operation method is usually adopted to disperse the scripts to be tested to multiple machines for parallel execution. The distributed operation method can shorten the script running time. However, the current mainstream method of distributed operation of automated testing uses a static method to allocate test tasks (the static method means that before each task is executed, the test task needs to be manually allocated to the designated machine before the test is performed). This method requires manual intervention and cannot ensure that the computer cluster resources are fully and reasonably used. Summary of the Invention
[0003] The main purpose of this application is to provide a test task allocation method, device, computer-readable storage medium and processor to solve the problem in the prior art that due to the need for manual allocation of test tasks, computer cluster resources cannot be fully and reasonably used.
[0004] According to one aspect of an embodiment of the present invention, a method for allocating test tasks is provided, comprising: obtaining a plurality of scripts to be tested; generating a test task using at least one of the scripts to be tested, wherein the test task includes at least one of the scripts to be tested with a label, the label being used to characterize the category of the script to be tested and a script allocation rule, the script allocation rule being a rule for allocating the scripts to be tested to corresponding servers; allocating the scripts to be tested with the label in the test task to a predetermined server; and in the case where there is an idle server, allocating the scripts to be tested without the label in the test task to the idle server.
[0005] Optionally, the label includes a first label, a second label and a third label, the first label is used to characterize that the category of the script to be tested is the first category, and the script to be tested of the first category runs on a uniquely designated server, the second label is used to characterize that the category of the script to be tested is the second category, and the script to be tested of the second category runs on the same server as at least one of the multiple scripts to be tested except the second category, and the third label is used to characterize that the category of the script to be tested is the third category, and the script to be tested of the third category runs in parallel with any one of the multiple scripts to be tested except the third category on different servers, and allocating the script to be tested with the label to a predetermined server includes: allocating the script to be tested of the first category to the uniquely designated server; allocating multiple scripts to be tested of the second category running on the same server to the same server; and allocating multiple scripts to be tested of the third category to the different servers.
[0006] Optionally, before allocating the first category of scripts to be tested to the uniquely designated server, the method further includes: constructing a first set, the first set including multiple first category scripts to be tested; constructing a server list, the number of servers in the server list is the same as the number of the first category of scripts to be tested in the first set, and the first category of scripts to be tested in the first set corresponds one-to-one to the servers in the server list.
[0007] Optionally, multiple scripts to be tested in the second category running on the same server are assigned to the same server, including: constructing a second set, the second set including multiple scripts to be tested in the second category running on the same server; obtaining the total running time of each of the multiple servers to which the scripts to be tested have been assigned, the total running time being the time taken to run all the scripts to be tested in one server; and assigning multiple scripts to be tested in the second category in the second set to the server with the shortest total running time.
[0008] Optionally, allocating multiple scripts to be tested in the third category to the different servers includes: constructing a third set, the third set including multiple scripts to be tested in the third category running in parallel on different servers; obtaining the sum of the running time of each of the multiple servers to which the scripts to be tested have been allocated, the sum of the running time being the time taken to run all the scripts to be tested in one server; sorting the sum of the running time of the multiple servers in order from short to long, and selecting a predetermined number of the servers in order from short to long of the sum of the running time, the predetermined number being the same as the number of scripts to be tested in the third category in the third set; obtaining the running time of each script to be tested in the third category in the third set; and allocating the scripts to be tested in the third category with the current longest running time to the server with the current shortest sum of the running time in order from short to long or from long to short of the running time of the scripts to be tested in the third category.
[0009] Optionally, when there are idle servers, the scripts to be tested that do not have the label in the test task are allocated to the idle servers, including: when there is one script to be tested that does not have the label and there is also one idle server, allocating the script to be tested to the idle server; when there are multiple scripts to be tested that do not have the label and the number of the scripts to be tested is greater than the number of idle servers, obtaining the running time of multiple scripts to be tested that do not have the label; allocating the scripts to be tested that do not have the label in order of the running time of the scripts to be tested from long to short until the allocation of multiple idle servers is completed; when there are multiple scripts to be tested that do not have the label and the number of the scripts to be tested is equal to the number of idle servers, allocating the scripts to be tested that do not have the label in sequence in order of the running time of the scripts to be tested from long to short.
[0010] Optionally, the method further includes: in the absence of the idle server, constructing a fourth set, the fourth set including multiple scripts to be tested that do not have the label; obtaining the running time of each script to be tested that does not have the label; obtaining the sum of the running time of each of the multiple servers to which the scripts to be tested have been assigned, the sum of the running time being the time taken to run all the scripts to be tested in one server; sorting the sum of the running time of the multiple servers in order from short to long, and assigning the scripts to be tested that do not have the label and have the longest current running time to the server with the shortest current sum of the running time in order from short to long or from long to short.
[0011] According to another aspect of an embodiment of the present invention, a test task allocation device is also provided, including: a first acquisition unit, used to acquire multiple scripts to be tested; a generation unit, used to generate a test task using at least one of the scripts to be tested, wherein the test task includes at least one script to be tested with a label, and the label is used to characterize the category of the script to be tested and the script allocation rule, and the script allocation rule is a rule for allocating the script to be tested to the corresponding server; a first allocation unit, used to allocate the script to be tested with the label in the test task to a predetermined server; and a second allocation unit, used to allocate the script to be tested without the label in the test task to the idle server when there is an idle server.
[0012] According to yet another aspect of the embodiments of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium includes a stored program, wherein the program executes any one of the methods described above.
[0013] According to yet another aspect of the embodiments of the present invention, a processor is provided, wherein the processor is configured to run a program, wherein the program executes any one of the methods when running.
[0014] In an embodiment of the present invention, a plurality of scripts to be tested are first obtained, and then a test task is generated using at least one of the scripts to be tested, wherein the test task includes at least one script to be tested with a label, and then the scripts to be tested with the label in the test task are allocated to a predetermined server, and finally, if there is an idle server, the scripts to be tested without the label in the test task are allocated to the idle server. In this solution, by defining the allocation rules of specific scripts by adding labels to the scripts to be tested, the scripts to be tested with labels can be automatically allocated, reducing the labor cost and time cost of manual allocation. In addition, if there is an idle server, the tasks to be tested without labels can be allocated to the idle server, thereby realizing dynamic and automatic allocation of test tasks, reducing the waiting time for the automated execution of test tasks, and ensuring that the computer cluster resources can be fully and reasonably used. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] The drawings that constitute part of this application are used to provide a further understanding of this application. The illustrative embodiments of this application and their descriptions are used to explain this application and do not constitute an improper limitation on this application. In the drawings:
[0016] Figure 1 A schematic diagram showing a flow chart of a method for allocating test tasks according to an embodiment of the present application is shown;
[0017] Figure 2 A flow chart showing another method for allocating and executing test tasks is shown;
[0018] Figure 3 A schematic diagram of the process of dynamic allocation of automated test tasks is shown;
[0019] Figure 4 A schematic diagram showing a framework for the allocation and execution of test tasks;
[0020] Figure 5 A structural schematic diagram of a test task allocation device according to an embodiment of the present application is shown. DETAILED DESCRIPTION
[0021] It should be noted that, in the absence of conflict, the embodiments and features of the embodiments in this application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0022] To help those skilled in the art better understand the present invention, the following will provide a clear and complete description of the technical solutions in the embodiments of the present invention, in conjunction with the accompanying drawings. It should be understood that the embodiments described are only part of the embodiments of the present invention, not all of them. All other embodiments derived by persons of ordinary skill in the art based on the embodiments of the present invention without inventive effort should fall within the scope of protection of the present invention.
[0023] It should be noted that the terms "first," "second," etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential sequence. It should be understood that the numbers used in this way can be interchanged where appropriate so that the embodiments of the present application described herein. In addition, the terms "including" and "having," as well as any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products, or devices.
[0024] It should be understood that when an element (such as a layer, film, region, or substrate) is described as being "on" another element, the element may be directly on the other element or intervening elements may be present. Moreover, in the specification and claims, when it is described that an element is "connected to" another element, the element may be "directly connected to" the other element or "connected to" the other element through a third element.
[0025] For ease of description, some nouns or terms involved in the embodiments of the present application are explained below:
[0026] Automated testing: Automated testing is the process of converting human-driven testing behaviors into machine-executed ones. Typically, after a test case is designed and reviewed, testers execute the test step by step according to the procedures described in the test case, comparing the actual results with the expected results. Automated testing can save manpower, time, or hardware resources, and improve testing efficiency.
[0027] Computer cluster: A group of loosely or tightly connected computers that work together. These computers work together, and in many ways, multiple computers can be treated as a single system. Unlike grid computers, computer clusters set each node to perform the same task, controlled and scheduled by software.
[0028] Distributed computing: Divide a problem that requires enormous computing power into many small parts, then distribute these parts to many computers for processing, and finally combine these calculation results to get the final result.
[0029] Existing automated test scripts use static allocation or item-by-item dispatching for distributed execution. These two methods require manual intervention from testers, fail to properly utilize cluster resources, and fail to minimize execution time for the following reasons:
[0030] 1. When distributing test tasks one by one, the execution time can be relatively balanced, but it cannot meet the specific execution requirements of some test scripts, such as running on a single designated server, running multiple test scripts on the same server, or running multiple test scripts in parallel on different servers.
[0031] 2. The static allocation method pre-allocates test scripts to designated servers based on the number of test scripts and the number of idle servers. This method also requires human intervention, and simply considering the quantity factor cannot achieve the shortest execution time and the reasonable allocation of computer cluster resources.
[0032] As mentioned in the background technology, the existing technology cannot ensure that computer cluster resources are fully and reasonably used due to the need to manually allocate test tasks. In order to solve the above problem, in one embodiment of the present application, a test task allocation method, device, computer-readable storage medium and processor are provided.
[0033] According to an embodiment of the present application, a method for allocating test tasks is provided.
[0034] Figure 1 FIG. 1 is a flow chart of a method for allocating test tasks according to an embodiment of the present application. Figure 1 As shown, the method includes the following steps:
[0035] Step S101, obtaining multiple scripts to be tested;
[0036] Step S102: Generate a test task using at least one of the scripts to be tested, wherein the test task includes at least one of the scripts to be tested with a label, wherein the label is used to characterize the category of the script to be tested and a script allocation rule, wherein the script allocation rule is a rule for allocating the script to be tested to a corresponding server;
[0037] Step S103, allocating the script to be tested with the tag in the test task to a predetermined server;
[0038] Step S104: in the case where there is an idle server, the to-be-tested script in the test task that does not have the label is allocated to the idle server.
[0039] In the above method, a plurality of scripts to be tested are first obtained, and then a test task is generated using at least one of the scripts to be tested, wherein the test task includes at least one script to be tested with a label, and then the scripts to be tested with the label in the test task are allocated to a predetermined server, and finally, if there is an idle server, the scripts to be tested without the label in the test task are allocated to the idle server. In this solution, by defining the allocation rules of specific scripts by adding labels to the scripts to be tested, the scripts to be tested with labels can be automatically allocated, reducing the manpower and time costs of manual allocation. In addition, if there is an idle server, the tasks to be tested without labels can be allocated to the idle server, thus realizing dynamic and automatic allocation of test tasks, reducing the waiting time for the automated execution of test tasks, and thus ensuring that the computer cluster resources can be fully and reasonably used.
[0040] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0041] In one embodiment, a code repository (such as a Git repository) may be used to store the scripts to be tested, and operations of adding, deleting, modifying, and checking the scripts to be tested may be performed before the scripts to be tested are distributed.
[0042] In a specific embodiment, a table of allocation of scripts to be tested and servers can also be constructed, and the specific allocation principle is as follows: ij ,i=1,2,...,M,j=1,2,...,N,S ij Indicates that the i-th script to be tested is assigned to the j-th idle server, M is the number of scripts to be tested, N is the number of idle servers, and initially S ij If it is 0, the allocation table indicates whether the i-th script to be tested is allocated to the j-th idle server. 0 means unallocated and 1 means allocated.
[0043] In one embodiment of the present application, the above-mentioned label includes a first label, a second label and a third label, the above-mentioned first label is used to characterize that the category of the above-mentioned script to be tested is the first category, and the script to be tested of the above-mentioned first category runs on a uniquely designated server, the above-mentioned second label is used to characterize that the category of the above-mentioned script to be tested is the second category, and the script to be tested of the above-mentioned second category and at least one of the multiple scripts to be tested except the script to be tested of the above-mentioned second category run on the same server, the above-mentioned third label is used to characterize that the category of the above-mentioned script to be tested is the third category, and the script to be tested of the above-mentioned third category and any one of the multiple scripts to be tested except the script to be tested of the above-mentioned third category run in parallel on different servers, and the above-mentioned script to be tested with the above-mentioned label is assigned to a predetermined server, including: assigning the script to be tested of the above-mentioned first category to the above-mentioned uniquely designated server; assigning multiple scripts to be tested of the above-mentioned second category running on the same server to the above-mentioned same server; and assigning multiple scripts to be tested of the above-mentioned third category to the above-mentioned different servers. In this embodiment, by adding different tags to the script to be tested, the allocation rules of specific scripts can be further defined. When the script to be tested is of the first category, the script to be tested of the first category is allocated to a uniquely designated server. When the script to be tested is of the second category, multiple scripts to be tested of the second category running on the same server are allocated to the same server. When the script to be tested is of the third category, multiple scripts to be tested of the third category are allocated to different servers. The scripts to be tested with tags are further automatically allocated, thereby ensuring that the test tasks can be dynamically and automatically allocated more efficiently, thereby further ensuring that the computer cluster resources can be fully and reasonably used.
[0044] In another embodiment of the present application, before allocating the scripts to be tested of the first category to the uniquely designated server, the method further includes: constructing a first set, wherein the first set includes a plurality of scripts to be tested of the first category; and constructing a server list, wherein the number of the servers in the server list is the same as the number of the scripts to be tested of the first category in the first set, and the scripts to be tested of the first category in the first set correspond one-to-one to the servers in the server list. In this embodiment, the first set and the server list are constructed, and subsequently, based on the relationship between the scripts to be tested of the first category in the first set and the servers in the server list, the scripts to be tested of the first category can be more efficiently allocated to the uniquely designated server.
[0045] In a specific embodiment, the first set is C, and the server list of the first category of scripts to be tested in C corresponds to A. i,i∈C, after assigning the first category of test scripts to the only designated server, the assignment table is updated to S ij =1,i∈C,i=A i .
[0046] In another embodiment of the present application, multiple scripts to be tested of the second category running on the same server are assigned to the same server, including: constructing a second set, the second set including multiple scripts to be tested of the second category running on the same server; obtaining the sum of the running time of each of the multiple servers to which the scripts to be tested have been assigned, the sum of the running time being the time taken to run all the scripts to be tested in one server; and assigning the multiple scripts to be tested of the second category in the second set to the server with the shortest sum of the running time. In this embodiment, a second set is constructed, and the multiple scripts to be tested of the second category in the second set are assigned to the server with the shortest sum of the running time, so that the running end time of the scripts to be tested of the second category in the second set can be ensured earlier. This embodiment can more efficiently realize the dynamic and automatic allocation of test tasks, thereby further ensuring that the computer cluster resources can be fully and reasonably used.
[0047] In a specific embodiment, the second set is U k , k represents the category number of multiple second-category test scripts running on the same server. Multiple second-category test scripts running on the same server are divided into a group and need to be run on the same server. After the k-category second-category test scripts are assigned to the server with the shortest total running time, the allocation table is updated to S ij =S mj =1,i∈U k ,m∈U k .
[0048] In another embodiment of the present application, multiple scripts to be tested in the third category are assigned to the different servers, including: constructing a third set, the third set including multiple scripts to be tested in the third category running in parallel on different servers; obtaining the sum of the running time of each of the multiple servers to which the scripts to be tested have been assigned, the sum of the running time being the time taken to run all the scripts to be tested in one server; sorting the sum of the running time of the multiple servers in order from short to long, and selecting a predetermined number of servers in order from short to long of the sum of the running time, the predetermined number being the same as the number of scripts to be tested in the third category in the third set; obtaining the running time of each script to be tested in the third set; and sequentially assigning the scripts to be tested in the third category with the longest running time to the server with the shortest total running time in order from short to long or from long to short of the running time of the scripts to be tested in the third category. In this embodiment, a third set is constructed, and the running times of the third category of scripts to be tested in the third set are to be allocated to the servers with the current shortest running times in turn according to the order from short to long or from long to short. This can further ensure that the sum of the running times of the allocated scripts to be tested and the running times of the scripts to be tested to be allocated on multiple servers is relatively equal. This embodiment can more efficiently realize the dynamic and automatic allocation of test tasks, thereby further ensuring that the computer cluster resources can be fully and reasonably used.
[0049] In one embodiment, there are 4 scripts to be tested in the third category, namely script A to be tested, script B to be tested, script C to be tested and script D to be tested. The running time of script A to be tested is 5 minutes, the running time of script B to be tested is 4 minutes, the running time of script C to be tested is 3 minutes, and the running time of script D to be tested is 2 minutes. There are 4 servers, namely server E, server F, server G and server H. The total running time of server E is 10 minutes, the total running time of server F is 20 minutes, the total running time of server G is 30 minutes, and the total running time of server H is 40 minutes. Script A to be tested is first assigned to server E, then script B to be tested is assigned to server F, then script C to be tested is assigned to server G, and then script D to be tested is assigned to server H.
[0050] In a specific embodiment, the third set is P1, 1 represents the category number of the third category of scripts to be tested running on different servers, and after the third category of scripts to be tested are allocated, the allocation table is updated to Sij =1,S nt =1,i∈P1,n∈P1,j≠t.
[0051] In a specific embodiment of the present application, when there are idle servers, the above-mentioned scripts to be tested that do not have the above-mentioned labels in the above-mentioned test tasks are allocated to the above-mentioned idle servers, including: when there is one above-mentioned script to be tested that does not have the above-mentioned label and there is also one above-mentioned idle server, the above-mentioned script to be tested is allocated to the above-mentioned idle server; when there are multiple above-mentioned scripts to be tested that do not have the above-mentioned label and the number of the above-mentioned scripts to be tested is greater than the number of the above-mentioned idle servers, the running time of the multiple above-mentioned scripts to be tested that do not have the above-mentioned label is obtained; the above-mentioned scripts to be tested that do not have the above-mentioned labels are allocated in order of the running time of the above-mentioned scripts to be tested from long to short until the allocation of the multiple above-mentioned idle servers is completed; when there are multiple above-mentioned scripts to be tested that do not have the above-mentioned label and the number of the above-mentioned scripts to be tested is equal to the number of the above-mentioned idle servers, the above-mentioned scripts to be tested that do not have the above-mentioned labels are allocated in sequence in order of the above-mentioned running time of the above-mentioned scripts to be tested from long to short. In this embodiment, when there are idle servers, the scripts to be tested that do not have labels can be allocated to the idle servers. During the allocation process, the allocation is made according to time. This can further ensure that the sum of the running time of the allocated scripts to be tested of multiple idle servers plus the running time of the scripts to be tested to be allocated is relatively equal. This embodiment can more efficiently realize the dynamic and automatic allocation of test tasks, thereby further ensuring that the computer cluster resources can be fully and reasonably used.
[0052] In one embodiment of the present application, the method further includes: in the absence of the idle server, constructing a fourth set, the fourth set including multiple scripts to be tested that do not have the label; obtaining the running time of each script to be tested that does not have the label; obtaining the sum of the running time of each of the multiple servers to which the script to be tested has been assigned, the sum of the running time being the time taken to run all the scripts to be tested in one server; sorting the sum of the running time of the multiple servers in order from short to long, and assigning the script to be tested that does not have the label and has the longest running time to the server with the shortest total running time in order from short to long or from long to short. In this embodiment, a fourth set is constructed, and the unlabeled scripts to be tested in the fourth set are allocated to the server with the shortest total running time in order from short to long or from long to short. This can further ensure that the sum of the running time of the allocated scripts to be tested and the running time of the scripts to be tested to be allocated on multiple servers is relatively equal. This embodiment can more efficiently realize the dynamic and automatic allocation of test tasks, thereby further ensuring that the computer cluster resources can be fully and reasonably used.
[0053] In a specific embodiment, the set of running times of all scripts to be tested without labels is {T1, T2, ..., T M}, calculate the sum of the running time of all the scripts to be tested without labels, the number of idle servers is N, and the average running time of each idle server is The fourth set is D. Traversing the fourth set, the running time of the i-th script to be tested without a label is greater than or equal to the average running time (T i ≥Ave), assign the i-th unlabeled script to be tested to the server with the shortest total running time, and remove the i-th unlabeled script to be tested from the fourth set, and then traverse the servers that have not completed the assignment, and sort the unlabeled scripts to be tested in the fourth set in descending order of running time. For the j-th idle server, traverse the unlabeled scripts to be tested in the fourth set in turn. First, assume that S ij =1, and the following situations occur: After each server is assigned, the fourth set is updated and the next server is assigned. After all servers are traversed, if there are still unassigned unlabeled scripts to be tested, these unlabeled scripts to be tested are assigned one by one to the server with the shortest total running time.
[0054] In the process of allocating scripts to be tested, it is also possible to determine whether there are new idle servers at regular intervals. If there are no new idle servers, the currently allocated test task plan is maintained. If there are new idle servers, the unrunning scripts to be tested in the fourth set and the latest hollow server category are traversed, and the unrunning scripts to be tested are reallocated to realize the dynamic division of test tasks during the operation process.
[0055] In another embodiment, the specific flow chart of the test task allocation and execution method is as follows: Figure 2 As shown:
[0056] S1: Automated management of test scripts, specifically:
[0057] S1-1: Get multiple scripts to be tested. The scripts to be tested can be stored in a Git repository. Before assigning the scripts to be tested, operations such as adding, deleting, modifying, and checking the scripts to be tested can be performed.
[0058] S1-2: Generate a test task using at least one script to be tested, the test task including at least one script to be tested with a label, the label including a first label, a second label and a third label, the first label being used to characterize that the category of the script to be tested is the first category, and the script to be tested of the first category runs on a uniquely designated server, the second label being used to characterize that the category of the script to be tested is the second category, and the script to be tested of the second category and at least one script to be tested among multiple scripts to be tested except the script to be tested of the second category run on the same server, the third label being used to characterize that the category of the script to be tested is the third category, and the script to be tested of the third category runs in parallel with any one script to be tested among multiple scripts to be tested except the script to be tested of the third category on a different server;
[0059] S2: Assign the scripts to be tested with labels in the test task to the predetermined servers, specifically:
[0060] S2-1: Process the test task generated in S1-2, obtain the set of scripts to be tested in the test task, determine whether the set of scripts to be tested is empty, and if so, parse the tags of the scripts to be tested and convert them into rules that the scripts to be tested must satisfy. If the set of scripts to be tested is empty, end this test task.
[0061] S2-2: Obtain a list of idle servers in the computer cluster and determine whether the list is empty. If the list is not empty, dynamically allocate automated test tasks. If the list is empty, block the test task and wait for an idle server.
[0062] S2-3: Dynamic allocation of automated testing tasks;
[0063] S3: Control server operation, specifically:
[0064] S3-1: The control server receives the automated test task assigned by S2-3, obtains the assigned script to be tested, and updates the server's running status to running;
[0065] S3-2: Based on the type of test task, the control server uses the corresponding method or tool to run the script to be tested;
[0066] S4: Monitors the server's operating status, which can be either running or idle. Specifically:
[0067] S4-1: Monitor the existence of the process of the script to be tested running on the server every 10 minutes through process monitoring. If the process exists, the server is in the running state; if not, the server is in the idle state. During the monitoring process, if a new idle server appears, notify S2-3 to dynamically allocate the remaining unrunning scripts to be tested again;
[0068] S5: Automated test report generation and post-test data processing, specifically:
[0069] S5-1: After all servers have completed the test, the test results of the servers running the test task are summarized and combined to generate an automated test report for the test task;
[0070] S5-2: Record the running time of all the scripts to be tested that have passed the test and store them in the database. If there is no historical data of the script to be tested in the database, add a new record of the script to be tested. If there is historical data of the script to be tested in the database, update the record of the script to be tested.
[0071] The flowchart for the dynamic allocation of automated test tasks for S2-3 is as follows Figure 3 As shown: First, determine whether the script to be tested has a label. If the script to be tested has a label, run S2-3-1;
[0072] S2-3-1: Sort out the tags of the scripts to be tested, obtain the current list of idle servers, and check whether the current idle servers meet the script allocation rules. If the servers corresponding to the scripts to be tested in the first category are running, or the number of scripts to be tested in the third category is greater than the number of idle servers, it is determined that the current server status does not meet the running requirements of the scripts to be tested. Run S2-3-7 to notify the tester. Otherwise, run S2-3-2;
[0073] S2-3-2: Determine whether the script to be tested includes the first tag, and if the script to be tested includes the first tag, assign the script to be tested of the first category to a uniquely designated server;
[0074] S2-3-3: Determine whether the script to be tested includes a second tag, and if the script to be tested includes the second tag, assign multiple scripts to be tested of the second category running on the same server to the same server;
[0075] S2-3-4: Determine whether the script to be tested includes a third tag, and if the script to be tested includes the third tag, allocate multiple scripts to be tested of the third category to different servers;
[0076] S2-3-5: For the unlabeled scripts to be tested, assign them in descending order of their running time;
[0077] S2-3-6: During the execution of the script to be tested, it is continuously determined whether there are newly added idle servers. If there are no newly added idle servers, the allocation and operation plan of the currently assigned test tasks are maintained. If there are newly added idle servers, the list of unlabeled scripts to be tested and the latest idle servers is sorted out, and the unlabeled scripts to be tested are reallocated according to the steps of S2-3-5, thereby realizing dynamic division of test tasks during the execution process.
[0078] S2-3-7: If some exceptions during the operation cause the automated test tasks to be unable to be dynamically allocated, notify the tester, who will decide how to run the script.
[0079] For the above scheme, the framework diagram is as follows Figure 4 As shown in the figure, the method of dynamic allocation and operation of automated test tasks is mainly divided into four steps:
[0080] Step 1: Manage test scripts: Test scripts can be stored in Git repositories. Testers can add, delete, modify, and query test scripts before assigning them to trigger test tasks.
[0081] Step 2: Dynamically allocate test tasks: allocate test tasks according to script allocation rules. There can be multiple script allocation rules.
[0082] Step 3. Server monitoring: monitor the running status of the server. There can be multiple running servers.
[0083] Step 4: Result processing: Summarize the test results in the servers running the test tasks, merge them to generate an automated test report for the test tasks, and record the running time of all the scripts to be tested that have passed the test.
[0084] The present application also provides a test task allocation device. It should be noted that the test task allocation device of the present application can be used to execute the test task allocation method provided in the present application. The following describes the test task allocation device provided in the present application.
[0085] Figure 5 Schematic diagram of a device for allocating test tasks according to an embodiment of the present application. Figure 5 As shown, the device includes:
[0086] A first acquisition unit 10 is used to acquire multiple scripts to be tested;
[0087] A generating unit 20 is configured to generate a test task using at least one of the scripts to be tested, wherein the test task includes at least one of the scripts to be tested having a label, wherein the label is used to characterize the category of the script to be tested and a script allocation rule, wherein the script allocation rule is a rule for allocating the script to be tested to a corresponding server;
[0088] A first allocating unit 30 is configured to allocate the to-be-tested script with the label in the test task to a predetermined server;
[0089] The second allocating unit 40 is configured to allocate the to-be-tested scripts that do not have the label in the test task to the idle server if there is an idle server.
[0090] In the above-mentioned device, the first acquisition unit acquires multiple scripts to be tested, the generation unit uses at least one of the above-mentioned scripts to be tested to generate a test task, the above-mentioned test task includes at least one of the above-mentioned scripts to be tested with a label, the first allocation unit allocates the above-mentioned scripts to be tested with the above-mentioned label in the above-mentioned test task to a predetermined server, and the second allocation unit allocates the above-mentioned scripts to be tested without the above-mentioned label in the above-mentioned test task to the above-mentioned idle server when there is an idle server. In this solution, by defining the allocation rules of specific scripts by adding labels to the scripts to be tested, the scripts to be tested with labels can be automatically allocated, reducing the manpower cost and time cost of manual allocation. In addition, when there are idle servers, the tasks to be tested without labels can be allocated to idle servers, thereby realizing dynamic and automatic allocation of test tasks, reducing the waiting time for the automated execution of test tasks, and ensuring that the resources of the computer cluster can be fully and reasonably used.
[0091] In one embodiment, a code repository (such as a Git repository) may be used to store the scripts to be tested, and operations of adding, deleting, modifying, and checking the scripts to be tested may be performed before the scripts to be tested are distributed.
[0092] In a specific embodiment, a table of allocation of scripts to be tested and servers can also be constructed, and the specific allocation principle is as follows: ij ,i=1,2,...,M,j=1,2,...,N,S ij Indicates that the i-th script to be tested is assigned to the j-th idle server, M is the number of scripts to be tested, N is the number of idle servers, and initially S ij If it is 0, the allocation table indicates whether the i-th script to be tested is allocated to the j-th idle server. 0 means unallocated and 1 means allocated.
[0093] In one embodiment of the present application, the above-mentioned label includes a first label, a second label and a third label, the above-mentioned first label is used to characterize that the category of the above-mentioned script to be tested is the first category, and the script to be tested of the above-mentioned first category runs on a uniquely designated server, the above-mentioned second label is used to characterize that the category of the above-mentioned script to be tested is the second category, and the script to be tested of the above-mentioned second category and at least one of the multiple scripts to be tested except the script to be tested of the above-mentioned second category run on the same server, the above-mentioned third label is used to characterize that the category of the above-mentioned script to be tested is the third category, and the script to be tested of the above-mentioned third category and any one of the multiple scripts to be tested except the script to be tested of the above-mentioned third category run in parallel on different servers, and the first allocation unit includes a first allocation module, a second allocation module and a third allocation module, the first allocation module is used to allocate the script to be tested of the above-mentioned first category to the above-mentioned uniquely designated server; the second allocation module is used to allocate multiple scripts to be tested of the above-mentioned second category running on the same server to the above-mentioned same server; the third allocation module is used to allocate multiple scripts to be tested of the above-mentioned third category to the above-mentioned different servers. In this embodiment, by adding different tags to the script to be tested, the allocation rules of specific scripts can be further defined. When the script to be tested is of the first category, the script to be tested of the first category is allocated to a uniquely designated server. When the script to be tested is of the second category, multiple scripts to be tested of the second category running on the same server are allocated to the same server. When the script to be tested is of the third category, multiple scripts to be tested of the third category are allocated to different servers. The scripts to be tested with tags are further automatically allocated, thereby ensuring that the test tasks can be dynamically and automatically allocated more efficiently, thereby further ensuring that the computer cluster resources can be fully and reasonably used.
[0094] In another embodiment of the present application, the apparatus further includes a first construction unit and a second construction unit, the first construction unit being used to construct a first set before allocating the first category of scripts to be tested to the uniquely designated server, wherein the first set includes a plurality of the first category of scripts to be tested; and the second construction unit being used to construct a server list, wherein the number of servers in the server list is the same as the number of the first category of scripts to be tested in the first set, and the first category of scripts to be tested in the first set corresponds one-to-one to the servers in the server list. In this embodiment, the first set and the server list are constructed, and subsequently, based on the relationship between the first category of scripts to be tested in the first set and the servers in the server list, the first category of scripts to be tested can be more efficiently allocated to the uniquely designated server.
[0095] In a specific embodiment, the first set is C, and the server list of the first category of scripts to be tested in C corresponds to A. i ,i∈C, after assigning the first category of test scripts to the only designated server, the assignment table is updated to S ij =1,i∈C,i=A i .
[0096] In another embodiment of the present application, the second allocation module includes a first construction submodule, a first acquisition submodule, and a first allocation submodule. The first construction submodule is used to construct a second set, wherein the second set includes multiple scripts to be tested of the second category running on the same server; the first acquisition submodule is used to obtain the sum of the running time of each of the multiple servers to which the scripts to be tested are assigned, wherein the sum of the running time is the time taken to complete the execution of all the scripts to be tested on one server; and the first allocation submodule is used to allocate the multiple scripts to be tested of the second category in the second set to the server with the shortest sum of the running time. In this embodiment, the second set is constructed, and the multiple scripts to be tested of the second category in the second set are allocated to the server with the shortest sum of the running time. This ensures that the running of the scripts to be tested of the second category in the second set ends earlier. This embodiment can more efficiently realize the dynamic and automated allocation of test tasks, thereby further ensuring that computer cluster resources can be fully and reasonably used.
[0097] In a specific embodiment, the second set is U k , k represents the category number of multiple second-category test scripts running on the same server. Multiple second-category test scripts running on the same server are divided into a group and need to be run on the same server. After the k-category second-category test scripts are assigned to the server with the shortest total running time, the allocation table is updated to S ij =S mj =1,i∈U k ,m∈U k .
[0098] In another embodiment of the present application, the third allocation module includes a second construction submodule, a second acquisition submodule, a processing submodule, a third acquisition submodule and a second allocation submodule, wherein the second construction submodule is used to construct a third set, wherein the third set includes multiple scripts to be tested of the third category running in parallel on different servers; the second acquisition submodule is used to obtain the total running time of each of the multiple servers to which the scripts to be tested have been assigned. The above-mentioned total running time is the time taken to run all the above-mentioned scripts to be tested in one of the above-mentioned servers; the processing submodule is used to sort the above-mentioned total running time of multiple servers in order from short to long, and select a predetermined number of the above-mentioned servers in order from short to long according to the above-mentioned total running time, and the above-mentioned predetermined number is the same as the number of the above-mentioned third category of scripts to be tested in the above-mentioned third set; the third acquisition submodule is used to obtain the running time of each above-mentioned third category of scripts to be tested in the above-mentioned third set; the second allocation submodule is used to allocate the above-mentioned third category of scripts to be tested with the current longest running time to the above-mentioned server with the current shortest total running time in order from short to long or from long to short according to the above-mentioned running time of the above-mentioned third category of scripts to be tested. In this embodiment, a third set is constructed, and the running times of the third category of scripts to be tested in the third set are to be allocated to the servers with the current shortest running times in turn according to the order from short to long or from long to short. This can further ensure that the sum of the running times of the allocated scripts to be tested and the running times of the scripts to be tested to be allocated on multiple servers is relatively equal. This embodiment can more efficiently realize the dynamic and automatic allocation of test tasks, thereby further ensuring that the computer cluster resources can be fully and reasonably used.
[0099] In one embodiment, there are 4 scripts to be tested in the third category, namely script A to be tested, script B to be tested, script C to be tested and script D to be tested. The running time of script A to be tested is 5 minutes, the running time of script B to be tested is 4 minutes, the running time of script C to be tested is 3 minutes, and the running time of script D to be tested is 2 minutes. There are 4 servers, namely server E, server F, server G and server H. The total running time of server E is 10 minutes, the total running time of server F is 20 minutes, the total running time of server G is 30 minutes, and the total running time of server H is 40 minutes. Script A to be tested is first assigned to server E, then script B to be tested is assigned to server F, then script C to be tested is assigned to server G, and then script D to be tested is assigned to server H.
[0100] In a specific embodiment, the third set is P1, 1 represents the category number of the third category of scripts to be tested running on different servers, and after the third category of scripts to be tested are allocated, the allocation table is updated to S ij =1,S nt =1,i∈P1,n∈P1,j≠t.
[0101] In a specific embodiment of the present application, the second allocation unit includes a fourth allocation module, an acquisition module, a fifth allocation module and a sixth allocation module. The fourth allocation module is used to allocate the above-mentioned script to be tested to the above-mentioned idle server when there is one above-mentioned script to be tested that does not have the above-mentioned label and there is also one above-mentioned idle server; the acquisition module is used to obtain the running time of the above-mentioned scripts to be tested that do not have the above-mentioned label when there are multiple above-mentioned scripts to be tested that do not have the above-mentioned label and the number of the above-mentioned scripts to be tested is greater than the number of the above-mentioned idle servers; the fifth allocation module is used to allocate the above-mentioned scripts to be tested that do not have the above-mentioned label in order of the running time of the above-mentioned scripts to be tested from long to short until the allocation of the multiple above-mentioned idle servers is completed; the sixth allocation module is used to allocate the above-mentioned scripts to be tested that do not have the above-mentioned label in sequence in order of the running time of the above-mentioned scripts to be tested from long to short when there are multiple above-mentioned scripts to be tested that do not have the above-mentioned label and the number of the above-mentioned scripts to be tested is equal to the number of the above-mentioned idle servers. In this embodiment, when there are idle servers, the scripts to be tested that do not have labels can be allocated to the idle servers. During the allocation process, the allocation is made according to time. This can further ensure that the sum of the running time of the allocated scripts to be tested of multiple idle servers plus the running time of the scripts to be tested to be allocated is relatively equal. This embodiment can more efficiently realize the dynamic and automatic allocation of test tasks, thereby further ensuring that the computer cluster resources can be fully and reasonably used.
[0102] In one embodiment of the present application, the above-mentioned device also includes a third construction unit, a second acquisition unit, a third acquisition unit and a third allocation unit. The third construction unit is used to construct a fourth set in the absence of the above-mentioned idle server, and the above-mentioned fourth set includes multiple above-mentioned scripts to be tested that do not have the above-mentioned label; the second acquisition unit is used to obtain the running time of each of the above-mentioned scripts to be tested that do not have the above-mentioned label; the third acquisition unit is used to obtain the sum of the running time of each of the multiple above-mentioned servers to which the above-mentioned scripts to be tested have been allocated, and the above-mentioned sum of running time is the time taken to run all the above-mentioned scripts to be tested in one of the above-mentioned servers; the third allocation unit is used to sort the above-mentioned sum of running time of the multiple above-mentioned servers in order from short to long, and in order from short to long or from long to short of the above-mentioned running time of the above-mentioned scripts to be tested that do not have the above-mentioned label, the above-mentioned scripts to be tested that have the longest current running time are allocated to the above-mentioned server with the shortest current sum of running time. In this embodiment, a fourth set is constructed, and the unlabeled scripts to be tested in the fourth set are allocated to the server with the shortest total running time in order from short to long or from long to short. This can further ensure that the sum of the running time of the allocated scripts to be tested and the running time of the scripts to be tested to be allocated on multiple servers is relatively equal. This embodiment can more efficiently realize the dynamic and automatic allocation of test tasks, thereby further ensuring that the computer cluster resources can be fully and reasonably used.
[0103] In a specific embodiment, the set of running times of all scripts to be tested without labels is {T1, T2, ..., T M}, calculate the sum of the running time of all the scripts to be tested without labels, the number of idle servers is N, and the average running time of each idle server is The fourth set is D. Traversing the fourth set, the running time of the i-th script to be tested without a label is greater than or equal to the average running time (T i ≥Ave), assign the i-th unlabeled script to be tested to the server with the shortest total running time, and remove the i-th unlabeled script to be tested from the fourth set, and then traverse the servers that have not completed the assignment, and sort the unlabeled scripts to be tested in the fourth set in descending order of running time. For the j-th idle server, traverse the unlabeled scripts to be tested in the fourth set in turn. First, assume that S ij =1, and the following situations occur: After each server is assigned, the fourth set is updated and the next server is assigned. After all servers are traversed, if there are still unassigned unlabeled scripts to be tested, these unlabeled scripts to be tested are assigned one by one to the server with the shortest total running time.
[0104] In the process of allocating scripts to be tested, it is also possible to determine whether there are new idle servers at regular intervals. If there are no new idle servers, the currently allocated test task plan is maintained. If there are new idle servers, the unrunning scripts to be tested in the fourth set and the latest hollow server category are traversed, and the unrunning scripts to be tested are reallocated to realize the dynamic division of test tasks during the operation process.
[0105] The above-mentioned test task allocation device includes a processor and a memory. The above-mentioned first acquisition unit, generation unit, first allocation unit and second allocation unit are all stored in the memory as program units, and the processor executes the above-mentioned program units stored in the memory to realize corresponding functions.
[0106] The processor contains a kernel, which retrieves the corresponding program unit from the memory. One or more kernels can be configured, and testing tasks can be automatically allocated by adjusting kernel parameters to ensure that the computer cluster resources are fully and rationally utilized.
[0107] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0108] An embodiment of the present invention provides a computer-readable storage medium storing a program, which implements the above-mentioned test task allocation method when executed by a processor.
[0109] An embodiment of the present invention provides a processor, which is used to run a program, wherein the method for allocating the test tasks is executed when the program is running.
[0110] An embodiment of the present invention provides a device, comprising a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, at least the following steps are performed:
[0111] Step S101, obtaining multiple scripts to be tested;
[0112] Step S102: Generate a test task using at least one of the scripts to be tested, wherein the test task includes at least one of the scripts to be tested with a label, wherein the label is used to characterize the category of the script to be tested and a script allocation rule, wherein the script allocation rule is a rule for allocating the script to be tested to a corresponding server;
[0113] Step S103, allocating the script to be tested with the tag in the test task to a predetermined server;
[0114] Step S104: in the case where there is an idle server, the to-be-tested script in the test task that does not have the label is allocated to the idle server.
[0115] The devices in this article can be servers, PCs, PADs, mobile phones, etc.
[0116] The present application also provides a computer program product, which, when executed on a data processing device, is adapted to execute a program for initializing at least the following method steps:
[0117] Step S101, obtaining multiple scripts to be tested;
[0118] Step S102: Generate a test task using at least one of the scripts to be tested, wherein the test task includes at least one of the scripts to be tested with a label, wherein the label is used to characterize the category of the script to be tested and a script allocation rule, wherein the script allocation rule is a rule for allocating the script to be tested to a corresponding server;
[0119] Step S103, allocating the script to be tested with the tag in the test task to a predetermined server;
[0120] Step S104: in the case where there is an idle server, the to-be-tested script in the test task that does not have the label is allocated to the idle server.
[0121] In the above embodiments of the present invention, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0122] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only exemplary. For example, the division of the above-mentioned units can be a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0123] The units described above as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0124] In addition, the functional units in the various embodiments of the present invention may be integrated into a single processing unit, each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0125] If the above-mentioned integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, server or network device, etc.) to execute all or part of the steps of the above-mentioned methods of each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.
[0126] From the above description, it can be seen that the above embodiments of the present application achieve the following technical effects:
[0127] 1) The test task allocation method of the present application first obtains multiple scripts to be tested, and then uses at least one of the above scripts to be tested to generate a test task, wherein the above test task includes at least one script to be tested with a label, and then the above scripts to be tested with the above label in the above test task are allocated to a predetermined server, and finally, if there is an idle server, the above scripts to be tested without the above label in the above test task are allocated to the above idle server. In this scheme, by defining the allocation rules of specific scripts by adding labels to the scripts to be tested, the scripts to be tested with labels can be automatically allocated, reducing the manpower cost and time cost of manual allocation. In addition, if there is an idle server, the tasks to be tested without labels can be allocated to the idle server, thereby realizing dynamic and automatic allocation of test tasks, reducing the waiting time for the automated execution of test tasks, and ensuring that the computer cluster resources can be fully and reasonably used.
[0128] 2) The test task allocation device of the present application comprises a first acquisition unit that acquires a plurality of scripts to be tested, a generation unit that uses at least one of the scripts to be tested to generate a test task, the test task including at least one script to be tested with a label, the first allocation unit allocates the scripts to be tested with the label in the test task to a predetermined server, and the second allocation unit allocates the scripts to be tested without the label in the test task to the idle server when there is an idle server. In this solution, by defining allocation rules for specific scripts by adding labels to the scripts to be tested, the scripts to be tested with labels can be automatically allocated, reducing the manpower and time costs of manual allocation. In addition, when there is an idle server, the tasks to be tested without labels can be allocated to the idle server, thus realizing dynamic and automatic allocation of test tasks and reducing the waiting time for the automated execution of test tasks, thereby ensuring that computer cluster resources can be fully and reasonably used.
[0129] The above description is merely a preferred embodiment of the present application and is not intended to limit the present application. Persons skilled in the art will readily appreciate that various modifications and variations are possible. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present application shall be included within the scope of protection of the present application.
Claims
1. A method for allocating test tasks, characterized in that: include: Get multiple scripts to be tested; Generating a test task using at least one of the scripts to be tested, wherein the test task includes at least one of the scripts to be tested having a label, wherein the label is used to characterize a category of the script to be tested and a script allocation rule, wherein the script allocation rule is a rule for allocating the script to be tested to a corresponding server; Allocating the to-be-tested script with the label in the test task to a predetermined server; In the case where there is an idle server, allocating the to-be-tested script without the label in the test task to the idle server; The tag includes a first tag, a second tag, and a third tag, wherein the first tag is used to characterize that the category of the script to be tested is the first category, and the script to be tested of the first category runs on a uniquely designated server, the second tag is used to characterize that the category of the script to be tested is the second category, and the third tag is used to characterize that the category of the script to be tested is the third category. Allocating the script to be tested with the tag to a predetermined server includes: allocating the script to be tested of the first category to the uniquely designated server; allocating multiple scripts to be tested of the second category running on the same server to the same server; and allocating multiple scripts to be tested of the third category to different servers; In the absence of the idle server, a fourth set is constructed, wherein the fourth set includes multiple scripts to be tested that do not have the label; the running time of each script to be tested that does not have the label is obtained; the sum of the running time of each of the multiple servers to which the scripts to be tested have been assigned is obtained, and the sum of the running time is the time taken to run all the scripts to be tested in one server; the sum of the running time of the multiple servers is sorted in order from short to long, and the scripts to be tested that do not have the label and have the longest current running time are assigned to the server with the shortest current sum of the running time in order from short to long or from long to short.
2. The method according to claim 1, characterized in that Before allocating the first category of to-be-tested scripts to the uniquely designated server, the method further includes: Constructing a first set, wherein the first set includes a plurality of scripts to be tested of the first category; A server list is constructed, wherein the number of the servers in the server list is the same as the number of the scripts to be tested of the first category in the first set, and the scripts to be tested of the first category in the first set correspond one-to-one to the servers in the server list.
3. The method according to claim 1, characterized in that Allocating multiple scripts to be tested of the second category running on the same server to the same server includes: Constructing a second set, wherein the second set includes a plurality of scripts to be tested of the second category running on the same server; Obtaining a total running time of each of the plurality of servers to which the scripts to be tested are assigned, the total running time being the time taken to complete running all the scripts to be tested in one server; Allocate the plurality of to-be-tested scripts of the second category in the second set to the server with the shortest total running time.
4. The method according to claim 1, wherein Allocating a plurality of the third category of scripts to be tested to the different servers comprises: Constructing a third set, wherein the third set includes a plurality of scripts to be tested of the third category running in parallel on different servers; Obtaining a total running time of each of the plurality of servers to which the scripts to be tested are assigned, the total running time being the time taken to complete running all the scripts to be tested in one server; sorting the sum of the running times of the plurality of servers in ascending order, and selecting a predetermined number of the servers in ascending order of the sum of the running times, the predetermined number being the same as the number of the scripts to be tested of the third category in the third set; Obtaining the running time of each script to be tested of the third category in the third set; According to the order of the running time of the scripts to be tested in the third category from short to long or from long to short, the scripts to be tested in the third category with the longest running time are sequentially allocated to the server with the shortest total running time.
5. The method according to claim 1, wherein In the case where there is an idle server, allocating the to-be-tested script that does not have the label in the test task to the idle server includes: In a case where there is one script to be tested that does not have the label and there is one idle server, allocating the script to be tested to the idle server; When there are multiple scripts to be tested that do not have the label, and the number of the scripts to be tested is greater than the number of the idle servers, obtaining the running time of the multiple scripts to be tested that do not have the label; Allocating the scripts to be tested that do not have the tags in descending order of the running time of the scripts to be tested until the allocation of the plurality of idle servers is completed; When there are multiple scripts to be tested that do not have the label, and the number of the scripts to be tested is equal to the number of the idle servers, the scripts to be tested that do not have the label are allocated in sequence according to the running time of the scripts to be tested from long to short.
6. A device for allocating test tasks, characterized in that: include: A first acquisition unit is used to acquire multiple scripts to be tested; a generating unit, configured to generate a test task using at least one of the scripts to be tested, wherein the test task includes at least one of the scripts to be tested having a label, wherein the label is used to characterize a category of the script to be tested and a script allocation rule, wherein the script allocation rule is a rule for allocating the script to be tested to a corresponding server; A first allocating unit, configured to allocate the to-be-tested script with the label in the test task to a predetermined server; A second allocating unit is configured to allocate the to-be-tested script without the label in the test task to an idle server when an idle server exists; The tag includes a first tag, a second tag, and a third tag, the first tag is used to indicate that the category of the script to be tested is the first category, and the script to be tested of the first category is run on a uniquely designated server, the second tag is used to indicate that the category of the script to be tested is the second category, and the third tag is used to indicate that the category of the script to be tested is the third category, the first allocation unit includes a first allocation module, a second allocation module, and a third allocation module, the first allocation module is used to allocate the script to be tested of the first category to the uniquely designated server; The second allocation module is used to allocate multiple scripts to be tested of the second category running on the same server to the same server; The third allocation module is used to allocate multiple scripts to be tested in the third category to different servers; A third constructing unit is configured to construct a fourth set in the absence of the idle server, wherein the fourth set includes a plurality of the scripts to be tested that do not have the label; A second obtaining unit is configured to obtain the running time of each of the scripts to be tested that does not have the label; a third acquiring unit, configured to acquire a total running time of each of the plurality of servers to which the scripts to be tested are allocated, wherein the total running time is the time taken to complete running all the scripts to be tested in one server; The third allocation unit is used to sort the total running time of the multiple servers in order from short to long, and to allocate the scripts to be tested without the label with the longest current running time to the server with the shortest current total running time in order from short to long or from long to short.
7. A computer-readable storage medium, characterized in that The computer-readable storage medium includes a stored program, wherein the program executes the method according to any one of claims 1 to 5.
8. A processor, characterized in that: The processor is configured to run a program, wherein the program executes the method according to any one of claims 1 to 5 when running.
Citation Information
Patent Citations
Automatic testing method and device
CN111159006A
Firewall testing method and device, nonvolatile storage medium and electronic device
CN112769810A