Scheduling and distributing method and device for database test cases, equipment and medium
By dividing database test cases into test case groups that require exclusive execution nodes and test case groups that do not require exclusive execution nodes, and adopting different execution strategies according to their characteristics, the problems of lack of flexibility in test case scheduling and insufficient resource utilization in the existing technology are solved, and efficient use of test resources and improved testing efficiency is achieved.
Patent Information
- Application Number
- CN202510243920.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-03
- Publication Date
- 2025-05-23
AI Technical Summary
The existing database test case scheduling methods lack flexibility and cannot adapt to complex dependencies and execution order requirements, resulting in inefficient testing; at the same time, insufficient resource utilization leads to waste of resources and prolonged testing time.
By detecting whether there are test cases in each test case group that require exclusive execution nodes to be divided into the first feature set and the second feature set. For the test case group in the first feature set, it can be executed concurrently; for the test case group in the second feature set, it needs to be executed serially in sequence.
The scheduling and distribution strategy of test cases is optimized, the execution strategy of test cases on the execution node is dynamically adjusted, the testing resources are fully utilized, the test cycle is shortened, and the testing efficiency is improved.
Smart Images

Figure CN120029923A_ABST
Abstract
Description
Technical Field
[0001] The present application is applicable to the testing field, and in particular relates to a method, device, equipment and medium for scheduling and distributing database test cases. Background Art
[0002] With the rapid development of database technology, especially the increasing application of distributed databases, non-relational databases and big data platforms, database performance testing and functional verification have become more and more complex. In the development and maintenance of database systems, the scheduling and distribution of test cases plays a vital role. Effective test scheduling can reduce test time, improve test efficiency and coverage, and ensure the stability and reliability of the database under various conditions. However, the current database test case scheduling still has certain limitations: First, it lacks flexibility: some scheduling methods schedule through rough code segmentation, which is prone to errors and cannot adapt to the complex dependencies and execution order requirements between test cases, affecting test efficiency. Second, resource utilization is insufficient: in a continuous integration environment, some scheduling methods distribute test cases according to simple rules. This distribution method will cause fierce resource competition when the concurrency is high. Instead of shortening the execution time, it will cause the time to prolong, thereby reducing the test efficiency. When the test resources are relatively scarce and the concurrency is too low, the resources cannot be fully and effectively utilized, which not only causes a waste of resources, but also affects the test efficiency. Therefore, how to improve the test efficiency while making full use of test resources has become an urgent problem to be solved. Summary of the invention
[0003] In view of this, the embodiments of the present application provide a method, apparatus, device and medium for scheduling and distributing database test cases to solve the problem of how to improve test efficiency while making full use of test resources.
[0004] In a first aspect, an embodiment of the present application provides a method for scheduling and distributing a database test case, the method comprising: Obtain N test case groups to be distributed, and detect whether there is a test case that needs to exclusively occupy an execution node in each test case group, wherein each test case group includes at least one test case, and N is an integer greater than zero; The test case group corresponding to the test case that does not need to be exclusively executed nodes forms a first feature set, and the test case group corresponding to the test case that needs to be exclusively executed nodes forms a second feature set; In a preset execution node, calling any thread to execute any test case group in the first feature set; In the preset execution node, each test case group in the second feature set is executed in turn.
[0005] In a second aspect, an embodiment of the present application provides a scheduling and distribution device for a database test case, the scheduling and distribution device comprising: A first acquisition module is used to acquire N test case groups to be distributed, and detect whether there is a test case that needs to exclusively occupy an execution node in each test case group, wherein each test case group includes at least one test case, and N is an integer greater than zero; A classification module, used to form a first feature set with a test case group corresponding to a test case that does not have a node that needs to be exclusively executed, and form a second feature set with a test case group corresponding to a test case that has a node that needs to be exclusively executed; A first execution module, used to call any thread in a preset execution node to execute any test case group in the first feature set; The second execution module is used to execute each test case group in the second feature set in sequence in the preset execution node.
[0006] In a third aspect, an embodiment of the present application provides a computer device, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor implements the scheduling and distribution method as described in the first aspect when executing the computer program.
[0007] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the scheduling and distribution method as described in the first aspect is implemented.
[0008] The beneficial effect of the embodiments of the present application compared with the prior art is as follows: the present application detects whether there are test cases that require exclusive execution nodes in each test case group, forms a first feature set for the test case group corresponding to the test cases that do not require exclusive execution nodes, and forms a second feature set for the test case group that requires exclusive execution nodes; in a preset execution node, calls any thread to execute any test case group in the first feature set; and in the preset execution node, executes each test case group in the second feature set in turn.
[0009] Among them, by dividing the test case group into a first feature set and a second feature set, different execution strategies are adopted in the preset execution nodes. Since there are no test cases that require exclusive execution nodes in the test case group of the first feature set, any thread can be called to execute any test case group in the first feature set on the preset execution node, and multiple test case groups can be executed concurrently. Since there are test cases that require exclusive execution nodes in the test case group of the second feature set, each test case group in the second feature set needs to be executed sequentially on the preset execution node, and multiple test case groups are executed serially. The scheduling and distribution strategy of test cases is optimized. According to whether there are test cases that require exclusive execution nodes in the test case group, the execution strategy of test cases on the execution node is dynamically adjusted, which not only makes full use of the test resources of the execution node but also improves the test efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] To more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0011] Figure 1 It is a schematic diagram of an application environment of a scheduling and distribution method provided in Embodiment 1 of the present application; Figure 2 It is a schematic flowchart of a scheduling and distribution method provided in Embodiment 2 of the present application; Figure 3 It is a schematic flowchart of a scheduling and distribution method provided in Embodiment 3 of the present application; Figure 4 It is a schematic flowchart of a scheduling and distribution method provided in Embodiment 4 of the present application; Figure 5 It is a schematic flowchart of a scheduling and distribution method provided in Embodiment 5 of the present application; Figure 6 It is a schematic flowchart of a scheduling and distribution method provided in Embodiment 6 of the present application; Figure 7 It is a schematic structural diagram of a scheduling and distribution device provided in Embodiment 7 of the present application; Figure 8 It is a schematic structural diagram of a computer device provided in Embodiment 8 of the present application. DETAILED DESCRIPTION
[0012] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0013] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.
[0014] It should also be understood that the term “and / or” used in the specification and appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.
[0015] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.
[0016] In addition, in the description of the present application specification and the appended claims, the terms "first", "second", "third", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance.
[0017] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0018] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Among them, artificial intelligence is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0019] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0020] It should be understood that the size of the serial numbers of the steps in the following embodiments does not 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 embodiments of the present application.
[0021] In order to illustrate the technical solution of the present application, a specific embodiment is provided below for illustration.
[0022] See also Figure 1 , is a schematic diagram of an application environment of a scheduling and distribution method provided in Embodiment 1 of the present application. The overall process of the scheduling and distribution method can be: 1) Obtain M test cases to be distributed, form a test case group with the same functional scenario, and obtain N test case groups to be distributed. Form the test case groups corresponding to the test cases that do not need to be exclusively executed nodes into a first feature set, and form the test case groups corresponding to the test cases that need to be exclusively executed nodes into a second feature set; for any test case group in the first feature set, if there is a test case in the test case group whose historical independent average time consumption exceeds the fourth threshold, move the test case group to the second feature set; 2) The main server first schedules and distributes the first feature set. If there are 8 idle threads in execution node 1, execution node 2 and execution node 3, the test case groups in the first feature set are divided into 8 test case groups as a batch, and a batch of test case groups are distributed to each execution node respectively; on any execution node, a batch of test case groups distributed to the execution node are executed concurrently. For any test case group, the test cases in the test case group are executed serially in turn. During the execution process, the execution node writes the execution results to the database in real time; the main server periodically polls to check whether the test case groups running on each execution node are less than 8. If less than 8, a new test case group is distributed to the corresponding execution node, and 8 test case groups are always kept running on each execution node; 3) After the execution of the first feature set is completed, the main server schedules and distributes the second feature set, and distributes the test case groups in the second feature set to each execution node in batches of one test case group; on any execution node, if the historical overall average time consumption of the test case group distributed to the execution node is greater than the first threshold, and the test case execution order is not specified, then the independent execution cases in the test case group with a historical independent average time consumption greater than the second threshold and that require exclusive use of the execution node are independently executed, and the parallel execution cases in the test case group with a historical independent average time consumption not greater than the second threshold are executed concurrently using a corresponding number of threads. In the process of concurrent execution using a corresponding number of threads, the parallel execution cases with a historical independent average time consumption greater than the third threshold and not greater than the second threshold are formed into a first parallel execution group, and the historical independent average time consumption is greater than the third threshold and not greater than the second threshold. Parallel execution cases whose historical independent average time consumption is less than the third threshold value form a second parallel execution group; a preset first number of threads are called to concurrently execute the parallel execution cases in the first parallel execution group, and a preset second number of threads are called to concurrently execute the parallel execution cases in the second parallel execution group; if the historical overall average time consumption of the test case group distributed to the execution node is not greater than the first threshold value, or the test case execution order is specified, the test cases in the test case group are executed serially in sequence, and during the execution process, the execution node writes the execution results to the database in real time; the main server periodically polls to check whether the test case group on each execution node has been completed. If completed, it continues to distribute new test case groups to the corresponding execution nodes, and always keeps one test case group running on each execution node.
[0023] In the embodiment of the present application, the test case group is divided into a first feature set and a second feature set according to whether there are test cases that require exclusive execution nodes and the historical independent average time consumption, and different scheduling and distribution strategies are adopted to distribute them to the corresponding execution nodes. When the corresponding execution nodes execute the test case groups in the first feature set and the second feature set, different execution strategies are adopted according to the different characteristics of the test case group and the test cases in the test case group (execution time, execution order, and whether exclusive execution nodes are required, etc.), thereby optimizing the scheduling and execution strategies of the test cases, making full use of test resources, shortening the test cycle, and improving test efficiency. The main server periodically monitors the execution status of the execution nodes and distributes and supplements the test case groups in a timely manner, so that the execution nodes are always kept in a state of efficient utilization during the test process, avoiding the idle execution nodes or the low execution efficiency due to unreasonable concurrent numbers, achieving full utilization of test resources, and improving test efficiency.
[0024] See also Figure 2 , is a flow chart of a method for scheduling and distributing database test cases provided in Example 2 of the present application, such as Figure 2 As shown, the scheduling distribution method may include the following steps: Step S201, obtaining N test case groups to be distributed, and detecting whether there is a test case that needs to exclusively occupy an execution node in each test case group.
[0025] Step S202, forming a first feature set with a test case group corresponding to a test case that does not have a node that needs to be exclusively executed, and forming a second feature set with a test case group corresponding to a test case that has a node that needs to be exclusively executed.
[0026] In this embodiment, a test case may refer to a document or automated script designed for a specific test objective (such as verifying whether a certain function of the software works as expected), a test case group may refer to a set consisting of at least one test case, an execution node may refer to a computer resource or environment used to execute a test case, a test case that requires an exclusive execution node may refer to a test case that, when executed, needs to occupy an independent execution node and does not allow other test cases to be executed on the execution node at the same time. For example, the test case that requires an exclusive execution node may be a test case that requires restarting the test environment; the first feature set may refer to a set formed by a test case group corresponding to a test case that does not require an exclusive execution node, and the second feature set may refer to a set formed by a test case group corresponding to a test case that requires an exclusive execution node.
[0027] Specifically, for the N test case groups to be distributed, all test case groups corresponding to test cases that do not require exclusive execution nodes are formed into a first feature set, and test case groups corresponding to test cases that require exclusive execution nodes are formed into a second feature set.
[0028] Step S203: In a preset execution node, call any thread to execute any test case group in the first feature set.
[0029] In this embodiment, the preset execution node may refer to a computer resource or environment that is preset for executing a test case.
[0030] Specifically, in a preset execution node, the test case groups in the first feature set are respectively distributed to the idle threads in the preset execution node. If there are at least two idle threads on the preset execution node, each test case group distributed thereto can be executed concurrently on the preset execution node, and for any idle thread, the test cases in the test case group distributed to the idle thread can be executed serially; Step S204: In a preset execution node, each test case group in the second feature set is executed in sequence.
[0031] Specifically, on a preset execution node, a test case group in the second feature set is distributed to the preset execution node in turn, and on the preset execution node, the distributed test case groups are executed serially in turn. During the execution of any test case group, a corresponding execution strategy is adopted to execute the test cases in the test case group based on the historical time consumption of the test case group and the execution sequence requirements of the test cases in the test case group.
[0032] In the embodiment of the present application, by dividing the test case group into a first feature set and a second feature set, different execution strategies are respectively adopted in the preset execution nodes. Since there are no test cases that need to exclusively occupy the execution node in the test case group of the first feature set, any thread can be called on the preset execution node to execute any test case group in the first feature set, and multiple test case groups can be executed concurrently; since there are test cases that need to exclusively occupy the execution node in the test case group of the second feature set, each test case group in the second feature set needs to be executed in turn on the preset execution node, and multiple test case groups are executed serially. The scheduling and distribution strategy of the test case is optimized, and the execution strategy of the test case on the execution node is dynamically adjusted according to whether there are test cases that need to exclusively occupy the execution node in the test case group, which makes full use of the test resources of the execution node while also improving the test efficiency.
[0033] See also Figure 3 , is a flow chart of a scheduling distribution method provided in Example 3 of the present application. Figure 3 As shown, in the above step S203, in a preset execution node, calling any thread to execute any test case group in the first feature set may include the following steps: Step S301: In a preset execution node, the test case groups in the first feature set are respectively distributed to the idle threads in the preset execution node.
[0034] Step S302: for any idle thread, serially execute the test cases in the test case group distributed to the idle thread.
[0035] Specifically, in a preset execution node, the test case groups in the first feature set are respectively distributed to the idle threads in the preset execution node. If there are at least two idle threads on the preset execution node, the test case groups distributed to the execution node can be concurrently executed on the preset execution node. During the concurrent execution, for any idle thread, the test cases in the test case group distributed to the idle thread are sequentially executed in sequence. The execution of the test cases in the test case group follows the following rule: first execute the pre-test case -> execute the common test case -> execute the post-test case. .
[0036] For example, if there are 8 central processing units (CPUs) on the preset execution node, the test case groups in the first feature set can be allocated to a preset execution node in batches of 8 test case groups (if there are more than 8, there may be resource competition, and if there are less than 8, it may lead to insufficient resource utilization). Each preset execution node starts 8 idle threads to execute simultaneously, and the test cases in each test case group are executed serially in sequence.
[0037] In an embodiment of the present application, by distributing the test case groups in the first feature set to the idle threads in the preset execution node respectively, if there are at least two idle threads on the preset execution node, the test case groups distributed to the execution node can be concurrently executed on the preset execution node, and for any idle thread, the test cases in the test case group distributed to the idle thread are serially executed, which ensures high concurrent execution while ensuring that the test cases under the test case group are executed in the order of dependency, thereby making full use of test resources, shortening the test cycle, and improving test efficiency.
[0038] See also Figure 4 , is a flow chart of a scheduling distribution method provided in Example 4 of the present application. Figure 4 As shown, in the above step S204, in the preset execution node, each test case group in the second feature set is executed in turn, which may include the following steps: Step S401, obtain the historical overall average time consumption of each test case group in the second feature set, determine that the test case group whose historical overall average time consumption is greater than the first threshold and for which the test case execution order is not specified is a parallel group, and determine that the test case groups other than the parallel group in the second feature set are non-parallel groups.
[0039] Step S402, for any parallel group, when executing the parallel group in a preset execution node, obtain the historical independent average time consumption of each test case in the parallel group, determine the test cases whose historical independent average time consumption is greater than the second threshold and the test cases that need to exclusively occupy the execution node as independent execution cases, and determine the test cases whose historical independent average time consumption is not greater than the second threshold as parallel execution cases.
[0040] Step S403: independently executing the independent execution use case in the preset execution node, and concurrently executing the parallel execution use case using a corresponding number of threads in the preset execution node.
[0041] Step S404: for any non-parallel group, the test cases in the non-parallel group are executed in sequence in a preset execution node.
[0042] In this embodiment, the historical overall average time consumption may refer to the average value of the historical execution time consumption of the test case group, and the historical independent average time consumption may refer to the average value of the historical execution time consumption of the test case; the parallel group may refer to the test case group in the second characteristic set, whose historical overall average time consumption is greater than the first threshold value and the test case execution order is not specified, and the non-parallel group may refer to the test case group in the second characteristic set, whose historical overall average time consumption is not greater than the first threshold value, or the test case execution order is specified; Independent execution use cases may refer to test cases whose historical independent average time consumption is greater than the second threshold and test cases that require exclusive execution nodes. The reason why independent execution use cases are executed independently is that time-consuming use cases often consume high machine resources. At this time, it is best to let the use cases exclusively execute resources. If there is too much concurrency, it will lead to fierce resource competition and delay the execution time. Parallel execution use cases may refer to test cases whose historical independent average time consumption is not greater than the second threshold.
[0043] Specifically, all test case groups in the second feature set may be sorted from the highest to the lowest historical overall average time consumption according to the historical overall average time consumption of each test case group in the second feature set to obtain a sorted second feature set, and according to the sorted second feature set, a test case group in the second feature set may be distributed to each preset execution node in turn, and for any preset execution node, the test case groups in the second feature set distributed thereto may be executed in turn on the preset execution node in the order of the historical overall average time consumption from the highest to the lowest; During the execution of any test case group in the second feature set distributed to it on the preset execution node, if the historical overall average time consumption of the test case group is greater than the first threshold value and the execution order of the test cases is not specified, the test case group is determined to be a parallel group. When the parallel group is executed on the preset execution node, the test cases in the parallel group whose historical independent average time consumption is greater than the second threshold value and the test cases that need to exclusively occupy the execution node are determined to be independent execution cases, and the test cases in the parallel group whose historical independent average time consumption is not greater than the second threshold value are determined to be parallel execution cases. In the preset execution node, a single process independently executes the independent execution case, and a corresponding number of threads are used on the preset execution node to concurrently execute the parallel execution case. The execution of the parallel group follows the following rules: first execute the preceding test case -> execute the independent execution case -> concurrently execute the parallel execution case with multiple threads -> execute the post-test case.
[0044] Optionally, in the process of concurrently executing parallel execution use cases using a corresponding number of threads on the preset execution node, parallel execution use cases whose historical independent average time consumption is greater than a third threshold and not greater than a second threshold are formed into a first parallel execution group, and parallel execution use cases whose historical independent average time consumption is less than the third threshold are formed into a second parallel execution group; a preset first number of threads are called to concurrently execute the parallel execution use cases in the first parallel execution group, and a preset second number of threads are called to concurrently execute the parallel execution use cases in the second parallel execution group.
[0045] Among them, the second threshold is greater than the third threshold, and the preset first number is less than the preset second number, because test cases that take a long time correspond to high resource consumption and fewer concurrent threads, while test cases that take a shorter time correspond to low resource consumption and more concurrent threads.
[0046] For example, if the third threshold is 5 minutes and the second threshold is 10 minutes, the parallel execution cases with a historical independent average duration of 5 minutes and a historical independent average duration of 10 minutes are formed into a first parallel execution group, and 4 threads are started for concurrent execution. The parallel execution cases with a historical independent average duration of less than 5 minutes are formed into a second parallel execution group, and 8 threads are started for concurrent execution. If the historical overall average time consumption of the test case group is not greater than the first threshold, or the test case execution order is specified, the test case group is determined to be a non-parallel group. For any non-parallel group, a single process in the preset execution node executes the test cases in the non-parallel group in sequence, and the execution of the non-parallel group follows the following rules: execute the preceding test case first -> execute the ordinary test case -> execute the post-test case.
[0047] In an embodiment of the present application, the test case groups in the second feature set are sorted based on the historical overall average time consumption, and on any preset execution node, the test case group with the longest historical overall average time consumption is executed first, thereby avoiding the situation where the last test case group to be run takes too long, while other execution nodes can only wait idle, thus prolonging the time consumption of the entire test; when executing any test case group, the test case group is divided into a parallel group and a non-parallel group based on the historical overall average time consumption and whether the test case execution order is specified, and in the parallel group, based on the historical independent average time consumption, an independent or concurrent execution strategy is assigned to the execution of the test case, and in the non-parallel group, an independent execution strategy is assigned to the execution of the test case, thereby optimizing the scheduling execution strategy of the test case, making full use of test resources, shortening the test cycle, and improving test efficiency.
[0048] See also Figure 5 , is a flowchart of a scheduling distribution method provided in Embodiment 5 of the present application, such as Figure 5 As shown, the scheduling distribution method may also include the following steps: Step S501, for any test case group, obtain a preset number of historical execution times of the test case group.
[0049] Step S502, calculating the average historical execution time of the test case group in a preset number of times, and obtaining the overall historical average execution time of the test case group.
[0050] Step S503: For any test case in the test case group, obtain the historical execution time of the test case for a preset number of times.
[0051] Step S504, calculating the average historical execution time of the test case in a preset number of times to obtain the historical independent average time of the test case.
[0052] In this embodiment, the historical execution time of the test case group may refer to the execution time of the test case group monitored during the historical execution process, the historical overall average time may refer to the average value of the historical execution time of the test case group for a preset number of times, the historical execution time of the test case may refer to the execution time of the test case monitored during the historical execution process, and the historical independent average time may refer to the average value of the historical execution time of the test case for a preset number of times.
[0053] During each build, the result data of the test cases and test case groups can be written into the database. When calculating the historical overall average time or the historical independent average time, the historical execution time of the test cases or test case groups can be directly obtained from the database.
[0054] For example, the historical execution time of each test case group in the historical 10 builds and the historical execution time of each test case in the test case group can be queried from the database. For any test case group, the average historical execution time of the test case group in the historical 10 builds is calculated to obtain the historical overall average time of the test case group. For any test case in the test case group, the average historical execution time of the test case in the historical 10 builds is calculated to obtain the historical independent average time of the test case.
[0055] Optionally, in the above step S202, after forming the first feature set with the test case group corresponding to the test case that does not need to be exclusively executed as a node, and forming the second feature set with the test case group corresponding to the test case that needs to be exclusively executed as a node, it is also possible to: For any test case group in the first feature set, obtain the historical independent average time consumption of each test case in the test case group. If there are test cases in the test case group whose historical independent average time consumption exceeds the fourth threshold, move the test case group to the second feature set.
[0056] For any test case group in the first feature set, if there are test cases in the test case group whose historical independent average time consumption exceeds the fourth threshold, it means that the test cases in the test case group may be more resource-consuming and suitable for single-process execution, and the test case group is moved to the second feature set.
[0057] The embodiments of the present application provide an execution time reference for the scheduling of test cases and test case groups based on historical execution time. In the process of dividing the feature sets of the test case groups, the first feature set and the second feature set obtained by division can be adjusted based on the evaluated historical independent average time, so that the first feature set is a set of test cases with low resource consumption and short time consumption, and the second feature set is a set of test cases with high resource consumption, long time consumption or exclusive execution node execution requirements. In this way, resources can be more reasonably allocated to the execution of the first feature set and the second feature set, thereby improving the test efficiency. In the process of scheduling and distributing the test cases, more reasonable scheduling execution strategies can be allocated to the test cases and test case groups based on the evaluated historical overall average time consumption and historical independent average time consumption, thereby improving the test efficiency.
[0058] See also Figure 6 , is a flowchart of a scheduling distribution method provided in Example 6 of the present application, such as Figure 6 As shown, before obtaining the N test case groups to be distributed in the above step S201, the following steps may also be included: Step S601, obtain M test cases to be distributed, and determine the functional scenario to which each test case belongs.
[0059] Step S602: Test cases with the same functional scenario are grouped into a test case group.
[0060] In this embodiment, a functional scenario may refer to a specific functional area or business process in the software or system. Each test case is designed to verify the correctness, performance, etc. of these functional scenarios. A test case group may refer to a set of at least one test case belonging to the same functional scenario, wherein each test case belongs to only one test case group. The test cases in each test case group may be independent of each other, or may have execution order requirements, or may have the same pre- and post-dependencies.
[0061] Specifically, a test case attribute table pre-built in the database can be obtained, which records the basic attributes of each test case, such as serial, parallel, functional scenario, execution order, predecessor and successor dependencies, and priority. According to the obtained test case attribute table, the functional scenario to which each test case belongs is determined, and the test cases belonging to the same functional scenario are formed into a test case group. For any test case, the test case group to which the test case belongs is written into the test case attribute table.
[0062] In the embodiment of the present application, test cases are grouped based on the functional scenarios to which the test cases belong to obtain test case groups. During the scheduling and distribution of test cases, more efficient scheduling and distribution can be performed based on the test case groups, thereby improving testing efficiency.
[0063] Corresponding to the scheduling and distribution method of the database test case in the above embodiment, Figure 7 A structural block diagram of a scheduling and distribution device for database test cases provided in Example 7 of the present application is shown. For ease of explanation, only the parts related to the embodiment of the present application are shown.
[0064] See also Figure 7 , the scheduling and distribution device comprises: A first acquisition module 71 is used to acquire N test case groups to be distributed, and detect whether there is a test case that needs to exclusively occupy an execution node in each test case group, wherein each test case group includes at least one test case, and N is an integer greater than zero; A classification module 72, configured to form a first characteristic set of test case groups corresponding to test cases that do not have nodes that need to be executed exclusively, and form a second characteristic set of test case groups corresponding to test cases that have nodes that need to be executed exclusively; A first execution module 73, configured to call any thread in a preset execution node to execute any test case group in the first feature set; The second execution module 74 is used to execute each test case group in the second feature set in sequence in the preset execution node.
[0065] Optionally, the first execution module 73 includes: A distribution unit, configured to distribute the test case groups in the first feature set to the idle threads in the preset execution nodes respectively in the preset execution nodes; The first serial unit is used to serially execute the test cases in the test case group distributed to any idle thread.
[0066] Optionally, the second execution module 74 includes: A first determination unit is used to obtain the historical overall average time consumption of each test case group in the second feature set, determine the test case group whose historical overall average time consumption is greater than a first threshold and for which the test case execution order is not specified as a parallel group, and determine the test case group in the second feature set other than the parallel group as a non-parallel group; A second determination unit is used for obtaining, for any parallel group, a historical independent average time consumption of each test case in the parallel group when executing the parallel group in the preset execution node, determining test cases whose historical independent average time consumption is greater than a second threshold and test cases that need to exclusively occupy the execution node as independent execution cases, and determining test cases whose historical independent average time consumption is not greater than the second threshold as parallel execution cases; A first concurrent unit, configured to independently execute the independent execution use case in the preset execution node, and concurrently execute the parallel execution use case using a corresponding number of threads in the preset execution node; The second serial unit is used to execute the test cases in any non-parallel group in sequence in the preset execution node.
[0067] Optionally, the first concurrent unit includes: A third determining subunit is used to form a first parallel execution group with parallel execution cases whose historical independent average time consumption is greater than a third threshold and not greater than the second threshold, and to form a second parallel execution group with parallel execution cases whose historical independent average time consumption is less than the third threshold; The second concurrent sub-unit is used to call a preset first number of threads to concurrently execute the parallel execution cases in the first parallel execution group, and call a preset second number of threads to concurrently execute the parallel execution cases in the second parallel execution group.
[0068] Optionally, the scheduling and distribution device further includes: A second acquisition module is used to acquire, for any test case group, a preset number of historical execution times of the test case group; A first calculation module is used to calculate the average value of the historical execution time of the test case group in the preset number of times to obtain the overall historical average time of the test case group; A third acquisition module is used to acquire, for any test case in the test case group, the historical execution time of the test case for the preset number of times; The second calculation module is used to calculate the average value of the historical execution time of the test case in the preset number of times to obtain the historical independent average time of the test case.
[0069] Optionally, the scheduling and distribution device further includes: An adjustment module is used to obtain, for any test case group in the first feature set, the historical independent average time consumption of each test case in the test case group; if there are test cases in the test case group whose historical independent average time consumption exceeds a fourth threshold, the test case group is moved to the second feature set.
[0070] Optionally, the scheduling and distribution device further includes: A fourth acquisition module is used to acquire M test cases to be distributed and determine the functional scenario to which each test case belongs, where M is an integer greater than zero; The grouping module is used to group test cases with the same functional scenarios into a test case group.
[0071] It should be noted that the information interaction, execution process and other contents between the above-mentioned modules are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
[0072] Figure 8 This is a schematic diagram of the structure of a computer device provided in Example 8 of the present application. Figure 8 As shown, the computer device of this embodiment includes: at least one processor ( Figure 8 Only one is shown in the figure), a memory, and a computer program stored in the memory and executable on at least one processor, wherein when the processor executes the computer program, the steps in any of the above-mentioned scheduling and distribution method embodiments are implemented.
[0073] The computer device may include, but is not limited to, a processor and a memory. Those skilled in the art will appreciate that Figure 8 This is merely an example of a computer device and does not constitute a limitation on the computer device. The computer device may include more or fewer components than those shown in the figure, or a combination of certain components, or different components. For example, it may also include a network interface, a display screen, and an input device.
[0074] The processor may be a CPU, or other general-purpose processors, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0075] The memory includes a readable storage medium, an internal memory, etc., wherein the internal memory may be the memory of a computer device, and the internal memory provides an environment for the operation of the operating system and computer-readable instructions in the readable storage medium. The readable storage medium may be a hard disk of a computer device, and in other embodiments, it may also be an external storage device of the computer device, for example, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. equipped on the computer device. Further, the memory may also include both an internal storage unit of the computer device and an external storage device. The memory is used to store an operating system, an application program, a boot loader (BootLoader), data, and other programs, such as the program code of a computer program, etc. The memory may also be used to temporarily store data that has been output or is to be output.
[0076] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device is divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated into a processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned device can refer to the corresponding process in the above-mentioned method embodiment, which will not be repeated here. If the 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 present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of the above-mentioned method embodiment can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device capable of carrying computer program code, recording medium, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.
[0077] The present application implements all or part of the processes in the above-mentioned embodiment method, and may also be completed through a computer program product. When the computer program product runs on a computer device, the computer device can implement the steps in the above-mentioned method embodiment when executing the computer program product.
[0078] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0079] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0080] In the embodiments provided in the present application, it should be understood that the disclosed devices / computer equipment and methods can be implemented in other ways. For example, the device / computer equipment embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, 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 devices or units, which can be electrical, mechanical or other forms.
[0081] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0082] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A method for scheduling and distributing database test cases, characterized in that: The scheduling distribution method comprises: Obtain N test case groups to be distributed, and detect whether there is a test case that needs to exclusively occupy an execution node in each test case group, wherein each test case group includes at least one test case, and N is an integer greater than zero; The test case group corresponding to the test case that does not need to be exclusively executed nodes forms a first feature set, and the test case group corresponding to the test case that needs to be exclusively executed nodes forms a second feature set; In a preset execution node, calling any thread to execute any test case group in the first feature set; In the preset execution node, each test case group in the second feature set is executed in turn.
2. The scheduling distribution method according to claim 1, characterized in that: The step of calling any thread in a preset execution node to execute any test case group in the first feature set includes: In the preset execution node, the test case groups in the first feature set are respectively distributed to the idle threads in the preset execution node; For any idle thread, the test cases in the test case group distributed to the idle thread are executed serially.
3. The scheduling distribution method according to claim 1, characterized in that: The step of sequentially executing each test case group in the second feature set in the preset execution node includes: Obtain the historical overall average time consumption of each test case group in the second feature set, determine that the test case group whose historical overall average time consumption is greater than the first threshold and for which the test case execution order is not specified is a parallelizable group, and determine that the test case groups in the second feature set other than the parallelizable group are non-parallelizable groups; For any parallel group, when executing the parallel group in the preset execution node, obtain the historical independent average time consumption of each test case in the parallel group, determine the test cases whose historical independent average time consumption is greater than a second threshold and the test cases that need to exclusively occupy the execution node as independent execution cases, and determine the test cases whose historical independent average time consumption is not greater than the second threshold as parallel execution cases; Independently executing the independent execution use case in the preset execution node, and concurrently executing the parallel execution use case using a corresponding number of threads in the preset execution node; For any non-parallel group, the test cases in the non-parallel group are executed in sequence in the preset execution nodes.
4. The scheduling distribution method according to claim 3, characterized in that: The using a corresponding number of threads in the preset execution node to concurrently execute the parallel execution use case includes: The parallel execution cases whose historical independent average time consumption is greater than the third threshold and not greater than the second threshold are formed into a first parallel execution group, and the parallel execution cases whose historical independent average time consumption is less than the third threshold are formed into a second parallel execution group; A preset first number of threads are called to concurrently execute the parallel execution use cases in the first parallel execution group, and a preset second number of threads are called to concurrently execute the parallel execution use cases in the second parallel execution group.
5. The scheduling distribution method according to claim 3, characterized in that: Before obtaining the historical overall average consumption of each test case group in the second feature set, the method further includes: For any test case group, obtaining the historical execution time of the test case group for a preset number of times; Calculate the average of the historical execution time of the test case group in the preset number of times to obtain the overall historical average time of the test case group; For any test case in the test case group, obtaining the historical execution time of the test case for the preset number of times; The average of the historical execution time of the test case in the preset number of times is calculated to obtain the historical independent average time of the test case.
6. The scheduling distribution method according to claim 3, characterized in that: After forming the first characteristic set with the test case group corresponding to the test case that does not need to be exclusively executed, and forming the second characteristic set with the test case group corresponding to the test case that needs to be exclusively executed, the method further includes: For any test case group in the first feature set, obtain the historical independent average time consumption of each test case in the test case group; if there are test cases in the test case group whose historical independent average time consumption exceeds a fourth threshold, move the test case group to the second feature set.
7. The scheduling distribution method according to claim 1, characterized in that: Before obtaining the N test case groups to be distributed, the method further includes: Obtain M test cases to be distributed, and determine the functional scenario to which each test case belongs, where M is an integer greater than zero; Test cases with the same functional scenarios are grouped into a test case group.
8. A scheduling and distribution device for database test cases, characterized in that: The scheduling and distribution device comprises: A first acquisition module is used to acquire N test case groups to be distributed, and detect whether there is a test case that needs to exclusively occupy an execution node in each test case group, wherein each test case group includes at least one test case, and N is an integer greater than zero; A classification module, used to form a first feature set with a test case group corresponding to a test case that does not have a node that needs to be exclusively executed, and form a second feature set with a test case group corresponding to a test case that has a node that needs to be exclusively executed; A first execution module, used to call any thread in a preset execution node to execute any test case group in the first feature set; The second execution module is used to execute each test case group in the second feature set in sequence in the preset execution node.
9. A computer device, characterized in that: The computer device includes a processor, a memory, and a computer program stored in the memory and executable on the processor, and the processor implements the scheduling distribution method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the scheduling distribution method according to any one of claims 1 to 7 is implemented.
Citation Information
Cited By
Performance accelerated analysis method and system of test case and storage medium
CN120743792A