Optimized database case execution method, system and device and medium
By obtaining resource requirements information and cost calculation rules for database use cases, dynamically selecting the lowest cost use cases to execute, solving the problem of long-term time in traditional database testing and improving testing efficiency.
Patent Information
- Application Number
- CN202510867562.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-26
- Publication Date
- 2025-07-25
- Estimated Expiration
- 2045-06-26
AI Technical Summary
In traditional database testing, when executing multiple test cases, a lot of repeated preparations are required before each use case is executed, resulting in a long test time and low test efficiency.
By obtaining the resource requirement information and cost calculation rules of the test cases, dynamically select the lowest generation value test cases for execution, and optimize the database use case execution process.
It shortens the execution time of the use case list, improves the testing efficiency without modifying the original use case.
Smart Images

Figure CN120371712A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of database automated testing, and provides an optimized method, system, device and medium for executing database test cases. Background Art
[0002] In the field of database testing, for simple tests, SQL can be directly written in the command line, and the configuration can be modified and the cluster can be set up using shell. However, if complex test cases are encountered, it is cumbersome and lengthy to write in shell, and many functions are difficult to implement. Therefore, generally, database manufacturers will develop a script language dedicated to testing their own database products, that is, DSL (domain-specific language), and all test cases are written in DSL.
[0003] In traditional database testing, when executing multiple test cases, since a large amount of repetitive preparation work may be required before each test case is executed, such as re-initializing the database instance, modifying the configuration file, setting environment variables, etc. Different test cases may frequently start and stop the database instance, and each start and stop takes a certain amount of time, making the overall test time long, resulting in a long total execution time of the test cases and low test efficiency. Summary of the Invention
[0004] The present invention aims to solve at least one of the technical problems existing in the related art. For this purpose, the present invention provides an optimized method, system, device and medium for executing database test cases, which realizes shortening the execution time of the test case list and does not modify the original test cases at all.
[0005] The present invention provides an optimized method for executing database test cases, including: S1: Obtain multiple resource requirement information and corresponding multiple cost calculation rules respectively corresponding to multiple test cases; S2: Obtain the test case corresponding to the lowest cost value according to the resource requirement information and the cost calculation rule; S3: Execute the test case corresponding to the lowest cost value, and return to step S2 until all test cases are executed.
[0006] According to the optimized method for executing database test cases provided by the present invention, the resource requirement information includes: the resource requirement information includes: the number of single instances required by the test case, the configuration file modification information, the environment variable information and the cluster information; Wherein, the cluster information includes the number of nodes, the type of each node, the cluster configuration information and the cluster environment variable information.
[0007] According to the optimized method for executing database test cases provided by the present invention, step S2 includes: S21: Obtain an uninitialized first instance pool and an initialized and reusable second instance pool; S22: Filter out test cases whose required number of instances does not exceed the total number of test instances in the first instance pool and the second instance pool to form a candidate list; S23: According to the resource requirement information and the cost calculation rules, traverse the test cases in the candidate list and calculate the respective execution costs corresponding to each test case in the candidate list; S24: If during the traversal process, when the execution cost of the first test case is calculated to be 0, select the first test case as the test case corresponding to the lowest cost value and terminate the traversal; if after traversing the candidate list and no execution cost of 0 is calculated, select the test case with the minimum execution cost as the test case corresponding to the lowest cost value.
[0008] According to an optimized database test case execution method provided by the present invention, the second instance pool includes a second single-instance pool and a second cluster instance pool, the execution cost includes a single-instance cost and a cluster cost, and the cost calculation rules include a single-instance cost calculation rule and a cluster cost calculation rule.
[0009] According to an optimized database test case execution method provided by the present invention, the single-instance cost calculation rule includes: Obtain the list of single-instance nodes required for the test case according to the resource requirement information; For each single-instance node in the single-instance node list, select and obtain the corresponding first instance; If the first instance needs to be re-initialized or there are differences between the configuration file modification information and the single-instance node, the single-instance cost is a first value; If there are only differences in the environment variable information between the first instance and the single-instance node, the single-instance cost is a second value; If the instance configuration and the environment variables are completely matched, the single-instance cost is 0; In the case where there is no available single-instance in the second instance pool and a new instance needs to be created from the first instance pool, the single-instance cost is a first value; Wherein, the first instance is the instance in the single-instance pool with the highest matching degree of the configuration file modification information and the single-instance node and the highest matching degree of the environment variable information with the single-instance node, and the first value is greater than the second value.
[0010] According to an optimized database test case execution method provided by the present invention, the cluster cost calculation rule includes: Obtain the list of clusters required for the test case according to the resource requirement information; Traverse the cluster list. For each cluster requirement information in the cluster list, find the cluster with the highest matching degree of the number of nodes and each node type in the cluster instance pool as the first cluster; If the number of nodes or each node type of the first cluster does not match the cluster requirement information, the cluster cost is the number of nodes of the cluster multiplied by a third value; If there are differences between the master node configuration information of the first cluster and the cluster requirement information, the cluster cost is the fourth value multiplied by a fifth value; If the first cluster completely matches the cluster requirement information, the cluster cost is 0; If there is no available cluster in the cluster instance pool, create a new cluster from the first instance pool, and the cluster cost is the number of nodes of the cluster multiplied by the third value; Wherein, the third value is greater than the fourth value, and the fifth value is the number of nodes of the cluster minus 1.
[0011] According to an optimized database use case execution method provided by the present invention, the cost calculation rule further includes: If there is a situation where a second test case does not require instance or cluster resources: determine that the execution cost of the second test case is 0; If there is a situation where a third test case does not require cluster resources, there are no available instances in the first instance pool and the single instance pool, but there are available instance resources in the cluster instance pool: split the clusters in the cluster instance pool to provide instances for the third test case, and determine that the execution cost of the third test case is a sixth value; Wherein, the sixth value is greater than or equal to the first value.
[0012] The present invention also provides an optimized database use case execution system, including: Cost calculation module: Obtain multiple resource requirement information and corresponding multiple cost calculation rules respectively corresponding to multiple test cases; Lowest cost query module: According to the resource requirement information and cost calculation rules, obtain the test case corresponding to the lowest cost value; Test case execution module: Execute the test case corresponding to the lowest cost value, and return to the lowest cost query module until all test cases are executed.
[0013] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the program, the steps of an optimized database use case execution method as described in any one of the above are implemented.
[0014] The present invention also provides a non-transitory computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of an optimization database use case execution method as described in any one of the above are implemented.
[0015] One or more of the above technical solutions in the embodiments of the present invention have at least one of the following technical effects: An optimization database use case execution method, system, device and medium provided by the present invention, by performing syntax analysis on test cases written in DSL, dynamically finds the use case with the smallest cost during the execution of the use case list, achieving the effects of shortening the execution time of the use case list and making no modification to the original use case.
[0016] Additional aspects and advantages of the present invention will be given in part in the following description, become apparent in part from the following description, or be understood through the practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0018] Figure 1 is a flowchart of an optimization database use case execution method provided by the present invention.
[0019] Figure 2 is a structural block diagram of an optimization database use case execution device provided by the present invention.
[0020] Figure 3 is a schematic structural diagram of an electronic device provided by the present invention.
[0021] Reference numerals: 101, cost calculation module; 102, lowest cost query module; 103, test case execution module; 810, processor; 820, communication interface; 830, memory; 840, communication bus. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0022] In order to make the objectives, technical solutions and advantages of the present invention clearer, the technical solutions in the present invention will be clearly and completely described below. Obviously, the described embodiments are some, but not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the protection scope of the present invention. The following embodiments are used to illustrate the present invention, but cannot be used to limit the scope of the present invention.
[0023] In the description of the embodiments of the present invention, it should be noted that the terms "first", "second", and "third" are only used for descriptive purposes and cannot be construed as indicating or implying relative importance.
[0024] In the embodiments of the present invention, unless otherwise clearly specified or limited, the first feature being "on" or "under" the second feature may be that the first and second features are in direct contact, or the first and second features are indirectly in contact through an intermediate medium. Moreover, the first feature being "above", "over" and "on top of" the second feature may be that the first feature is directly above or obliquely above the second feature, or merely indicates that the first feature has a higher horizontal height than the second feature. The first feature being "under", "below" and "beneath" the second feature may be that the first feature is directly below or obliquely below the second feature, or merely indicates that the first feature has a lower horizontal height than the second feature.
[0025] In the description of this specification, the description with reference to terms such as "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials, or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the embodiments of the present invention. In this specification, the schematic descriptions of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described can be combined in a suitable manner in any one or more embodiments or examples. In addition, without contradiction, those skilled in the art can combine and combine the different embodiments or examples described in this specification and the features of different embodiments or examples.
[0026] Embodiment The following is combined with Figures 1 to 3 to describe the present invention.
[0027] As Figure 1 shown, Figure 1 A method for optimizing the execution of database use cases provided by an embodiment of the present invention includes: S1: Obtain a plurality of resource requirement information and corresponding plurality of cost calculation rules respectively corresponding to a plurality of test cases; S2: According to the resource requirement information and the cost calculation rules, obtain the test case corresponding to the lowest cost value; S3: Execute the test case corresponding to the lowest cost value, and return to step S2 until all test cases are executed.
[0028] Specifically, in the field of database testing, simple tests can be directly written in SQL on the command line, and the configuration can be modified and the cluster can be set up using shell. However, if complex test cases are encountered, it is cumbersome and time-consuming to write them in shell, and many functions are also difficult to implement. Therefore, generally, database manufacturers will develop a scripting language specifically for testing their own database products, that is, DSL (domain-specific language), and test cases are all written in DSL.
[0029] The test cases written in DSL need to be interpreted into the language used by the automation framework for execution. For example, there is a line "print 'hello world'" in the test case script. Assuming the test framework is written in Java, then when it is actually executed, it will be interpreted as "System.out.println(\"hello world\")"; this syntax analysis or translation work is completed by a parser generated by javacc or antlr according to the grammar file.
[0030] After each test case is analyzed by the parser, a List is generated. <dslstatement>Among them, DslStatement is an interface with many implementation classes. Each implementation class contains information when executing this statement. For example, for the previously mentioned "print \"hello world\"" command, there is a corresponding DslPrintStatement class that implements the DslStatement interface. It has a member variable String content, and the value corresponding to this "print" is "helloworld". This class also implements the execute() method of its parent class, which only contains one line: System.out.println(content); After all test cases are parsed by syntax, there will be a List <testcase>, the object of the TestCase class contains a List of each test case <dslstatement>。
[0031] If the present invention is not used, syntax analysis can be performed on the use case to be executed when the adjacent use case is executed. Since the present invention needs to know the usage of all use case resources in advance, all use cases need to be analyzed at the beginning.
[0032] Among them, the resource requirement information includes: the number of single instances required by the test case, configuration file modification information, environment variable information, and cluster information; The cluster information includes the number of nodes, the type of each node, cluster configuration information, and cluster environment variable information.
[0033] Specifically, step S2 includes: S21: Obtain an uninitialized first instance pool and an initialized and reusable second instance pool; S22: Screen the use cases whose required number of instances does not exceed the total number of test instances in the first instance pool and the second instance pool to form a candidate list; specifically, the second instance pool includes a second single instance pool and a second cluster instance pool; S23: According to the resource requirement information and the cost calculation rule, traverse the test cases in the candidate list, and calculate the execution cost corresponding to each use case in the candidate list; specifically, the execution cost includes a single instance cost and a cluster cost, and the cost calculation rule includes a single instance cost calculation rule and a cluster cost calculation rule; S24: During the traversal process, when the execution cost of the first test case is calculated to be 0, select the first test case as the test case corresponding to the lowest cost value, and terminate the traversal; S25: When the candidate list is traversed and the execution cost of 0 is not calculated, select the test case with the smallest execution cost as the test case corresponding to the lowest cost value.
[0034] Specifically, the single instance cost calculation rule includes: Obtain the list of single instance nodes required by the test case according to the resource requirement information; For each single instance node in the list of single instance nodes, select and obtain the corresponding first instance; If the first instance needs to be re-initialized or the configuration file modification information is different from the single instance node, the single instance cost is the first value; If only the environment variable information of the first instance is different from the single instance node, the single instance cost is the second value; If the instance configuration and the environment variables are completely matched, the single instance cost is 0; When there is no available single instance in the second instance pool and a new instance needs to be created from the first instance pool, the cost of the single instance is the first value; Among them, the first instance is the instance in the single instance pool with the highest matching degree between the configuration file modification information and the single instance node and the highest matching degree between the environment variable information and the single instance node, and the first value is greater than the second value.
[0035] Specifically, the cluster cost calculation rule includes: Obtain the cluster list required for the test case according to the resource requirement information; Traverse the cluster list. For each cluster requirement information in the cluster list, find the cluster with the highest matching degree of the number of nodes and each node type in the cluster instance pool as the first cluster; If the number of nodes or each node type of the first cluster does not match the cluster requirement information, the cluster cost is the number of nodes of the cluster multiplied by the third value; If there are differences between the main node configuration information of the first cluster and the cluster requirement information, the cluster cost is the fourth value multiplied by the fifth value; If the first cluster exactly matches the cluster requirement information, the cluster cost is 0; If there is no available cluster in the cluster instance pool and a new cluster is created from the first instance pool, the cluster cost is the number of nodes of the cluster multiplied by the third value; Among them, the third value is greater than the fourth value, and the fifth value is the number of nodes of the cluster minus 1.
[0036] Especially, if there is a situation where the second test case does not require instance or cluster resources during the cost calculation process: determine that the execution cost of the second test case is 0; If there is a situation where the third test case does not require cluster resources, there are no available instances in the first instance pool and the single instance pool, but there are available instance resources in the cluster instance pool: split the clusters in the cluster instance pool to provide instances for the third test case, and determine that the execution cost of the third test case is the sixth value; Among them, the sixth value is greater than or equal to the first value.
[0037] Specifically, in this embodiment, after obtaining the resource requirement information, the test case with the minimum cost is screened out from all use cases.
[0038] In the test framework, there are actually two instance pools. The first instance pool contains uninitialized instances of each test machine (which means that using these test cases requires the highest cost), corresponding to instance pool A below; the second instance pool contains instances that have been initialized and returned after running the test cases, corresponding to instance pool B below. Among them, instance pool B can be filtered under certain conditions to obtain: the second single-instance pool listS and the second cluster instance pool listC. In listC are the clusters recovered after running the test cases before, and each cluster has two or more instances.
[0039] Filter out the test cases whose required number of instances is less than the total number of instances in instance pool A + instance pool B, and put them into list1; traverse list1 and calculate a cost value for each test case in it.
[0040] After each test case is analyzed by the visitor, there are two lists in TestCase, List <instancenode>, List <clusternode>, InstanceNode is a single-instance node list, which contains configuration file modifications, environment variable modifications, etc. required before instance initialization. ClusterNode is a cluster list, which records the types of each node in the cluster and configuration file modifications, environment variable modifications, etc. for each node. The lengths of the two lists are denoted as sizeIN and sizeCN respectively.
[0041] If both sizeIN and sizeCN are 0, that is, the test case does not require instance or cluster resources, it is considered that the cost is the smallest and 0 is directly returned. First, calculate the differences between the two lists and the existing single instance and cluster (listS, listC) respectively, and traverse the List. <instancenode>, each loop element is denoted as in. The inner loop traverses listS (make a deep copy to get a new one), and each loop element is denoted as ls. The goal is to find the instance in listS with the smallest difference from what in requires.
[0042] If ls has been marked as needing to be re-initialized, for example: this instance needs to be re-initialized because some operations were performed when running previous test cases, such as deliberately deleting key files, then directly return the maximum cost value of 10000; if it needs to be restarted, directly return the cost value of 2000.
[0043] Then calculate the difference in the configuration file. Since some configuration modifications require re-initializing the instance to take effect, a list of configuration items is prepared. If the configuration of in and ls is different and it is in the list of configuration items, the cost value is at most 10000, otherwise it is 2000.
[0044] Then calculate whether there are differences in environment variables, etc. As long as there is any difference, it is considered that the instance needs to be restarted, and return the cost value of 2000. If there are no differences, return the cost value of 0. After each inner loop ends, an ls with the smallest usage cost for in is found, and then it is removed from listS. If the size of listS is already 0 during the outer loop, then the instance needs to be fetched from instance pool A, that is, a new instance needs to be created, so directly consider the cost value to be 10000 (the maximum value).
[0045] The cost values calculated for each in are accumulated as the value for this step, denoted as vS.
[0046] There is a special case. If it is determined that the current test case does not require cluster resources, and there are no remaining instances in current instance pool A and listS, but there are remaining instances in listC, then a certain cluster in listC can be split into multiple instances for the current test case to use. This situation definitely requires re-initializing the instance, so the cost value is also 10000.
[0047] Traverse List <clusternode>, each loop element is denoted as cn. The inner loop traverses listC (which is also a deep copy), and each loop element is denoted as lc. The goal is to find the cluster with the smallest difference from cn: First, determine whether the number and type of cluster nodes of lc and cn are the same. If they are not the same, it cannot be reused, and directly return 10000 (the maximum cost of a single instance) * dn; where dn is the number of nodes of cn.
[0048] Then, calculate the difference cost between the main nodes of lc and cn in the way of calculating the cost of a single instance. Since the main node has a decisive role, it can be simply considered that if the cost is greater than 0, the cluster cannot be reused. For each specific database product, detailed determination can be made according to its own situation; Then, calculate the costs of each non-main node and accumulate them. If this value is greater than 0, it is considered that all non-main nodes need to be restarted, and the cost value is 2000 * (dn - 1); After each inner loop ends, the lc with the smallest usage cost for cn is found, and then it is removed from listC. If the size of listC is already 0 during the outer loop, then it is directly considered that the cost value is 10000 * the number of cn instances. The cost values calculated for each cn are accumulated as the value of this step, denoted as vC.
[0049] The value of vS + vC is the cost of executing this test case. After calculating the costs of all test cases, find the smallest one as the next test case to be executed. During the traversal process, it is very likely to directly find a test case with a cost of 0, then directly jump out of the loop and execute the selected test case.
[0050] The actual measurement shows that the initialization time of the GBase8s database, a database product of a certain company, is about 1 minute and 20 seconds, and the restart time is about 20 seconds. After optimizing with the method of this article, the execution time of test cases is basically focused on the test cases themselves, and the execution speed of the test case list is increased by two orders of magnitude. At the same time, the technical effects of shortening the execution time of the test case list and not requiring any modification to the original test cases are achieved.
[0051] As Figure 2 shown, the present invention also provides an optimized database use case execution system, including: Cost calculation module 101: Obtain multiple resource requirement information and corresponding multiple cost calculation rules respectively corresponding to multiple test cases; Lowest cost query module 102: Obtain the test case corresponding to the lowest cost value according to the resource requirement information and cost calculation rules; Test case execution module 103: Execute the test case corresponding to the lowest cost value, and return to the lowest cost query module until all test cases are executed.
[0052] Figure 3 Illustrates a schematic diagram of the physical structure of an electronic device, as Figure 3 shown. The electronic device may include: a processor 810, a communication interface 820, a memory 830, and a communication bus 840. Among them, the processor 810, the communication interface 820, and the memory 830 communicate with each other through the communication bus 840. The processor 810 may call the logical instructions in the memory 830 to execute an optimized database use case execution method, which includes: S1: Obtain a plurality of resource requirement information and corresponding plurality of cost calculation rules respectively corresponding to a plurality of test cases; S2: According to the resource requirement information and the cost calculation rules, obtain the test case corresponding to the lowest cost value; S3: Execute the test case corresponding to the lowest cost value, and return to step S2 until all test cases are executed.
[0053] In addition, when the logical instructions in the above-mentioned memory 830 are implemented in the form of software functional units and sold or used as an independent product, they may be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of the technical solution, may be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present invention. The foregoing storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), magnetic disks, or optical discs that can store program codes.
[0054] On the other hand, the present invention also provides a computer program product. The computer program product includes a computer program stored on a non-transitory computer-readable storage medium. The computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute an optimized database use case execution method provided by the above-mentioned various methods. The method includes: S1: Obtain a plurality of resource requirement information and corresponding plurality of cost calculation rules respectively corresponding to a plurality of test cases; S2: According to the resource requirement information and the cost calculation rules, obtain the test case corresponding to the lowest cost value; S3: Execute the test case corresponding to the lowest cost value, and return to step S2 until all test cases are executed.
[0055] In another aspect, the present invention also provides a non-transitory computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it is used to execute an optimized database use case execution method provided above, and the method includes: S1: Obtain multiple resource requirement information and corresponding multiple cost calculation rules respectively corresponding to multiple test cases; S2: According to the resource requirement information and the cost calculation rules, obtain the test case corresponding to the lowest cost value; S3: Execute the test case corresponding to the lowest cost value, and return to step S2 until all test cases are executed.
[0056] The device embodiments described above are merely illustrative. 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 may be distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art can understand and implement it without creative labor.
[0057] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on such an understanding, the essence of the above technical solution, or the part that contributes to the prior art, can be embodied in the form of a software product. The computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0058] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements for some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
[0059] It should be noted that the embodiments of the present disclosure can be implemented by hardware, software, or a combination of software and hardware. The hardware part can be implemented using dedicated logic; the software part can be stored in a memory and executed by a suitable instruction execution system such as a microprocessor or dedicated designed hardware. Those skilled in the art can understand that the above devices and methods can be implemented using computer-executable instructions and / or included in processor control code, for example, such code is provided on a programmable memory or a data carrier such as an optical or electronic signal carrier.
[0060] In addition, although the operations of the method of the present disclosure are described in a specific order in the drawings, this does not require or imply that these operations must be performed in that specific order, or that all of the operations shown must be performed to achieve the desired result. On the contrary, the order of execution of the steps depicted in the flowchart can be changed. Additionally or alternatively, certain steps can be omitted, multiple steps can be combined into one step for execution, and / or one step can be decomposed into multiple steps for execution. It should also be noted that the features and functions of two or more devices according to the present disclosure can be embodied in one device. Conversely, the features and functions of one device described above can be further divided and embodied by multiple devices.
[0061] Although the present disclosure has been described with reference to several specific embodiments, it should be understood that the present disclosure is not limited to the specific embodiments disclosed. The present disclosure is intended to cover various modifications and equivalent arrangements included within the spirit and scope of the appended claims.< / clusternode> < / instancenode> < / clusternode> < / instancenode> < / dslstatement> < / testcase> < / dslstatement>
Claims
1. An optimized method for executing database use cases, characterized in that Including: S1: Obtain multiple resource requirement information and corresponding multiple cost calculation rules respectively corresponding to multiple test cases; S2: According to the resource requirement information and the cost calculation rules, obtain the test case corresponding to the lowest cost value, including: S21: Obtain an uninitialized first instance pool and an initialized and reusable second instance pool; S22: Filter out the test cases whose required number of instances does not exceed the total number of test instances in the first instance pool and the second instance pool to form a candidate list; S23: According to the resource requirement information and the cost calculation rules, traverse the test cases in the candidate list, and calculate each execution cost corresponding to each test case in the candidate list; S24: If, during the traversal process, when the execution cost of the first test case is calculated to be 0, select the first test case as the test case corresponding to the lowest cost value and terminate the traversal; if, after traversing the candidate list and no execution cost of 0 is calculated, select the test case with the minimum execution cost as the test case corresponding to the lowest cost value; S3: Execute the test case corresponding to the lowest cost value, and return to step S2 until all test cases are executed.
2. The method for optimizing database use case execution according to claim 1, wherein The resource requirement information includes: the number of single instances required by the test case, configuration file modification information, environment variable information, and cluster information; Among them, the cluster information includes the number of nodes, each node type, cluster configuration information, and cluster environment variable information.
3. The optimized database use case execution method according to claim 1, wherein The second instance pool includes a second single instance pool and a second cluster instance pool, the execution cost includes a single instance cost and a cluster cost, and the cost calculation rules include a single instance cost calculation rule and a cluster cost calculation rule.
4. The method for optimizing database use case execution according to claim 3, characterized in that The single instance cost calculation rule includes: Obtain the list of single instance nodes required by the test case according to the resource requirement information; For each single instance node in the list of single instance nodes, select and obtain the corresponding first instance; If the first instance needs to be re-initialized or the configuration file modification information is different from the single instance node, the single instance cost is a first value; If only the environment variable information of the first instance is different from the single instance node, the single instance cost is a second value; If the instance configuration and the environment variables are completely matched, the single instance cost is 0; In the case that there is no available single instance in the second instance pool and a new instance needs to be created from the first instance pool, the single instance cost is a first value; Among them, the first instance is the instance in the single instance pool with the highest matching degree of the configuration file modification information and the single instance node and the highest matching degree of the environment variable information and the single instance node, and the first value is greater than the second value.
5. The method for optimizing database use case execution according to claim 3, characterized in that The cluster cost calculation rule includes: Obtain the list of clusters required by the test case according to the resource requirement information; Traverse the list of clusters. For each cluster requirement information in the list of clusters, find the cluster with the highest matching degree of the number of nodes and each node type in the cluster instance pool as the first cluster; If the number of nodes or each node type of the first cluster does not match the cluster requirement information, the cluster cost is the number of nodes of the cluster multiplied by a third value; If there are differences between the master node configuration information of the first cluster and the cluster requirement information, the cluster cost is the fourth value multiplied by a fifth value; If the first cluster exactly matches the cluster requirement information, the cluster cost is 0; If there is no available cluster in the cluster instance pool, create a new cluster from the first instance pool, and the cluster cost is the number of nodes of the cluster multiplied by a third value; Wherein, the third value is greater than the fourth value, and the fifth value is the number of nodes of the cluster minus 1.
6. The method for optimizing database use case execution according to claim 3, characterized in that The cost calculation rule further includes: If there is a second test case that does not require instance or cluster resources: determine that the execution cost of the second test case is 0; If there is a third test case that does not require cluster resources, there are no available instances in the first instance pool and the single instance pool, but there are available instance resources in the cluster instance pool: split the clusters in the cluster instance pool to provide instances for the third test case, and determine that the execution cost of the third test case is a sixth value; Wherein, the sixth value is greater than or equal to the first value.
7. An optimized database use case execution system for executing an optimized database use case execution method according to any one of claims 1 to 6, characterized in that, Including: Cost calculation module: Obtain multiple resource requirement information and corresponding multiple cost calculation rules respectively corresponding to multiple test cases; Lowest cost query module: Obtain the test case corresponding to the lowest cost value according to the resource requirement information and the cost calculation rule; Test case execution module: Execute the test case corresponding to the lowest cost value, and return to the lowest cost query module until all test cases are executed.
8. An electronic device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of an optimized database use case execution method according to any one of claims 1 to 6.
9. A non-transitory computer-readable storage medium storing a computer program thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of an optimized database use case execution method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Distributed database cluster test method and device and storage medium
CN110389900A
Method for automatically converting single-instance use case of database into high-availability use case
CN120066979A
Optimizing Execution Order of System Interval Dependent Test Cases
US20170371773A1