Method, system, device and medium for optimizing database use case execution

By obtaining the resource requirement information and cost calculation rules of database use cases, dynamically selecting the use case with the lowest cost value, and optimizing the database testing process, the problem of lengthy traditional database testing time is solved, and efficient use case execution is achieved.

CN120371712BActive Publication Date: 2025-09-05TIANJIN NANKAI UNIV GENERAL DATA TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510867562.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-06-26
Publication Date
2025-09-05
Estimated Expiration
2045-06-26

AI Technical Summary

Technical Problem

In traditional database testing, when executing multiple test cases, a lot of repetitive preparation work is required before executing each case, resulting in lengthy testing time and low testing efficiency.

Method used

By obtaining the resource requirement information and cost calculation rules of the test cases, the test cases corresponding to the lowest cost value are dynamically selected, and the database case execution process is optimized, including the uninitialized instance pool and the initialized reusable instance pool. The candidate list is screened, the execution cost is calculated, and finally the test cases corresponding to the lowest cost value are executed.

Benefits of technology

The execution time of the use case list is shortened, the test efficiency is improved, and the test case execution time is increased by 2 orders of magnitude without modifying the original use case.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120371712B_ABST
    Figure CN120371712B_ABST
Patent Text Reader

Abstract

The present invention relates to the technical field of automated database testing, and provides a method, system, device, and medium for optimizing database test case execution. The method comprises the following steps: obtaining resource requirement information and corresponding cost calculation rules corresponding to multiple test cases; obtaining the test case corresponding to the lowest cost value based on the resource requirement information and the cost calculation rules; and executing the test case corresponding to the lowest cost value until all test cases have been executed. The present invention performs syntax analysis on test cases written in a DSL (Digital Subtitle Language) and dynamically identifies the test case with the lowest cost during the execution of the test case list, thereby shortening the execution time of the test case list without modifying the original test cases.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of database automated testing, and provides a method, system, device and medium for optimizing the execution of database use cases. Background Art

[0002] In the field of database testing, simple tests can be performed by writing SQL directly on the command line, using the shell to modify configurations and build clusters. However, if complex use cases are encountered, writing shell commands is cumbersome and lengthy, and many functions are difficult to implement. Therefore, database vendors generally develop a scripting language specifically for testing their own database products, which is called DSL (domain-specific language). Test cases are all written in DSL.

[0003] In traditional database testing, executing multiple test cases requires extensive, repetitive preparation before each test case, such as reinitializing the database instance, modifying configuration files, and setting environment variables. Different test cases may frequently start and stop database instances, each requiring a significant amount of time. This increases the overall testing time, leading to longer test case execution times and lower 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. To this end, the present invention provides a method, system, device and medium for optimizing the execution of database use cases, thereby shortening the execution time of the use case list without modifying the original use case.

[0005] The present invention provides a method for optimizing database use case execution, comprising:

[0006] S1: Obtain multiple resource requirement information and corresponding multiple cost calculation rules corresponding to multiple test cases;

[0007] S2: Obtain the test case corresponding to the lowest cost value based on resource demand information and cost calculation rules;

[0008] S3: Execute the test case corresponding to the lowest cost value and return to step S2 until all test cases are executed.

[0009] According to a method for optimizing database use case execution 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, configuration file modification information, environment variable information, and cluster information;

[0010] The cluster information includes the number of nodes, the type of each node, cluster configuration information and cluster environment variable information.

[0011] According to a method for optimizing database use case execution provided by the present invention, step S2 includes:

[0012] S21: Acquire an uninitialized first instance pool and an initialized reusable second instance pool;

[0013] S22: Filtering use cases whose required instance number does not exceed the total number of test instances in the first instance pool and the second instance pool to form a candidate list;

[0014] S23: traversing the test cases in the candidate list according to the resource requirement information and the cost calculation rule, and calculating each execution cost corresponding to each test case in the candidate list;

[0015] S24: If during the traversal process, the execution cost of the first test case is calculated to be 0, the first test case is selected as the test case corresponding to the lowest cost value, and the traversal is terminated; if after traversing the candidate list and the execution cost is not calculated to be 0, the test case with the smallest execution cost is selected as the test case corresponding to the lowest cost value.

[0016] According to a method for optimizing database use case execution 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 rule includes a single instance cost calculation rule and a cluster cost calculation rule.

[0017] According to a method for optimizing database use case execution provided by the present invention, the single instance cost calculation rule includes:

[0018] Obtain a list of single-instance nodes required for the test case according to resource requirement information;

[0019] For each single instance node in the single instance node list, select and obtain the corresponding first instance;

[0020] If the first instance needs to be reinitialized or the configuration file modification information is different from that of the single instance node, the single instance cost is a first value;

[0021] If the first instance differs from the single instance node only in environment variable information, the single instance cost is a second value;

[0022] If the instance configuration completely matches the environment variables, the single instance cost is 0;

[0023] 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 single instance cost is the first value;

[0024] The first instance is the instance in the single instance pool in which the configuration file modification information has the highest matching degree with the single instance node and the environment variable information has the highest matching degree with the single instance node, and the first value is greater than the second value.

[0025] According to a method for optimizing database use case execution provided by the present invention, the cluster cost calculation rule includes:

[0026] Obtain a list of clusters required for the test case according to resource requirement information;

[0027] Traversing the cluster list, for each cluster requirement information in the cluster list, searching the cluster with the highest matching degree between the number of nodes and each node type in the cluster instance pool as the first cluster;

[0028] If the number of nodes or the type of each node of the first cluster does not match the cluster requirement information, the cluster cost is the number of nodes in the cluster multiplied by a third value;

[0029] If the master node configuration information of the first cluster differs from the cluster requirement information, the cluster cost is the fourth value multiplied by the fifth value;

[0030] If the first cluster completely matches the cluster requirement information, the cluster cost is 0;

[0031] 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 in the cluster multiplied by a third value;

[0032] The third value is greater than the fourth value, and the fifth value is the number of nodes in the cluster minus 1.

[0033] According to a method for optimizing database use case execution provided by the present invention, the cost calculation rule further includes:

[0034] If there is a situation where the second test case does not require instance or cluster resources: determining that the execution cost of the second test case is 0;

[0035] If there is a third test case that does not require cluster resources, and 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: splitting the cluster in the cluster instance pool to provide instances for the third test case, and determining that the execution cost of the third test case is a sixth value;

[0036] The sixth value is greater than or equal to the first value.

[0037] The present invention also provides a system for optimizing database use case execution, comprising:

[0038] Cost calculation module: obtains multiple resource requirement information and corresponding cost calculation rules corresponding to multiple test cases;

[0039] Minimum cost query module: obtains the test case corresponding to the minimum cost value according to the resource demand information and cost calculation rules;

[0040] Test case execution module: executes the test case corresponding to the lowest cost value and returns to the lowest cost query module until all test cases are executed.

[0041] The present invention also provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of any one of the above-described methods for optimizing database use case execution are implemented.

[0042] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of any of the above-described methods for optimizing database use case execution.

[0043] The above one or more technical solutions in the embodiments of the present invention have at least one of the following technical effects:

[0044] The present invention provides a method, system, device and medium for optimizing database use case execution. By performing grammatical analysis on test cases written in DSL, the minimum cost use case is dynamically found during the execution of the use case list, thereby shortening the execution time of the use case list and maintaining the original use case without any modification.

[0045] Additional aspects and advantages of the present invention will be set forth in part in the description which follows and, in part, will be obvious from the description which follows, or may be learned by practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0047] Figure 1 This is a flow chart of a method for optimizing database use case execution provided by the present invention.

[0048] Figure 2 This is a structural block diagram of a database use case execution device provided by the present invention.

[0049] Figure 3It is a structural schematic diagram of the electronic device provided by the present invention.

[0050] Reference numerals:

[0051] 101. Cost calculation module; 102. Minimum cost query module; 103. Test case execution module; 810. Processor; 820. Communication interface; 830. Memory; 840. Communication bus. DETAILED DESCRIPTION

[0052] To make the purpose, 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 embodiments described are part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention. The following embodiments are used to illustrate the present invention, but are not used to limit the scope of the present invention.

[0053] In the description of the embodiments of the present invention, it should be noted that the terms “first”, “second” and “third” are used for descriptive purposes only and should not be understood as indicating or implying relative importance.

[0054] In the embodiments of the present invention, unless otherwise expressly specified or limited, a first feature being "above" or "below" a second feature may mean that the first and second features are in direct contact, or that the first and second features are in indirect contact through an intermediate medium. Furthermore, a first feature being "above," "above," or "above" a second feature may mean that the first feature is directly above or diagonally above the second feature, or simply means that the first feature is at a higher level than the second feature. A first feature being "below," "below," or "below" a second feature may mean that the first feature is directly below or diagonally below the second feature, or simply means that the first feature is at a lower level than the second feature.

[0055] In the description of this specification, the reference terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" mean that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the embodiment of the present invention. In this specification, the schematic representations 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 any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art can combine and combine different embodiments or examples described in this specification and features of different embodiments or examples without contradiction.

[0056] Example

[0057] The following combination Figures 1 to 3 The present invention is described.

[0058] like Figure 1 As shown, Figure 1 An embodiment of the present invention provides a method for optimizing database use case execution, comprising:

[0059] S1: Obtain multiple resource requirement information and corresponding multiple cost calculation rules corresponding to multiple test cases;

[0060] S2: Obtain the test case corresponding to the lowest cost value based on resource demand information and cost calculation rules;

[0061] S3: Execute the test case corresponding to the lowest cost value and return to step S2 until all test cases are executed.

[0062] Specifically, in the field of database testing, simple tests can be performed by writing SQL directly on the command line, using the shell to modify configurations, build clusters, etc. However, if complex use cases are encountered, writing in the shell is cumbersome and lengthy, and many functions are difficult to implement. Therefore, database vendors generally develop a scripting language specifically for testing their own database products, which is DSL (domain-specific language), and test cases are all written in DSL.

[0063] Use cases written in a DSL need to be interpreted and executed in the language used by the automation framework. For example, if a line in a use case script says "print "hello world"; 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 syntax analyzer such as javacc or antlr generated based on the syntax file.

[0064] After each test case is analyzed by the syntax analyzer, a List is generated. <dslstatement>DslStatement is an interface with many implementation classes. Each implementation class contains information about executing a statement. For example, the print "hello world" command mentioned earlier has a corresponding DslPrintStatement class that implements the DslStatement interface. It has a member variable, String content, whose value is "hello world". This class also implements the parent class's execute() interface, which contains only one line, System.out.println(content).

[0065] After all use cases are parsed, there is a List <testcase>, the object of the TestCase class contains a List of each test case <dslstatement>.

[0066] If the present invention is not used, the syntax analysis can be performed on the use case to be executed when the use case is about to be executed. Since the present invention needs to know the resource usage of all use cases in advance, all use cases must be analyzed at the beginning.

[0067] 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;

[0068] The cluster information includes the number of nodes, the type of each node, cluster configuration information and cluster environment variable information.

[0069] Specifically, step S2 includes:

[0070] S21: Acquire an uninitialized first instance pool and an initialized reusable second instance pool;

[0071] S22: Filter 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;

[0072] S23: traverse the test cases in the candidate list according to the resource requirement information and the cost calculation rule, and calculate each execution cost corresponding to each test 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;

[0073] S24: During the traversal process, if the execution cost of the first test case is calculated to be 0, the first test case is selected as the test case corresponding to the lowest cost value, and the traversal is terminated;

[0074] S25: When the candidate list is traversed and the calculated execution cost is not 0, the test case with the minimum execution cost is selected as the test case corresponding to the minimum cost value.

[0075] Specifically, the single instance cost calculation rules include:

[0076] Obtain a list of single-instance nodes required for the test case according to resource requirement information;

[0077] For each single instance node in the single instance node list, select and obtain the corresponding first instance;

[0078] If the first instance needs to be reinitialized or the configuration file modification information is different from that of the single instance node, the single instance cost is a first value;

[0079] If the first instance differs from the single instance node only in environment variable information, the single instance cost is a second value;

[0080] If the instance configuration completely matches the environment variables, the single instance cost is 0;

[0081] 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 single instance cost is the first value;

[0082] The first instance is the instance in the single instance pool in which the configuration file modification information has the highest matching degree with the single instance node and the environment variable information has the highest matching degree with the single instance node, and the first value is greater than the second value.

[0083] Specifically, the cluster cost calculation rules include:

[0084] Obtain a list of clusters required for the test case according to resource requirement information;

[0085] Traversing the cluster list, for each cluster requirement information in the cluster list, searching the cluster with the highest matching degree between the number of nodes and each node type in the cluster instance pool as the first cluster;

[0086] If the number of nodes or the type of each node of the first cluster does not match the cluster requirement information, the cluster cost is the number of nodes in the cluster multiplied by a third value;

[0087] If the master node configuration information of the first cluster differs from the cluster requirement information, the cluster cost is the fourth value multiplied by the fifth value;

[0088] If the first cluster completely matches the cluster requirement information, the cluster cost is 0;

[0089] 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 in the cluster multiplied by a third value;

[0090] The third value is greater than the fourth value, and the fifth value is the number of nodes in the cluster minus 1.

[0091] In particular, during the cost calculation process, if there is a situation where the second test case does not require instance or cluster resources: the execution cost of the second test case is determined to be 0;

[0092] If there is a third test case that does not require cluster resources, and 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: splitting the cluster in the cluster instance pool to provide instances for the third test case, and determining that the execution cost of the third test case is a sixth value;

[0093] The sixth value is greater than or equal to the first value.

[0094] Specifically, in this embodiment, after obtaining the resource demand information, the use case with the lowest cost is screened out from all use cases.

[0095] In the test framework, there are actually two instance pools. The first instance pool contains uninitialized instances on each test machine (which means that using these use cases requires the highest cost), corresponding to the instance pool A below. The second instance pool contains instances that have been initialized and returned after running the use case, corresponding to the instance pool B below. Among them, instance pool B can be filtered out according to certain conditions: the second single instance pool listS and the second cluster instance pool listC. ListC contains clusters recovered after running the use case before, and there are 2 or more instances in the cluster.

[0096] Filter use cases whose number of instances required 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 use case in it.

[0097] 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 records the configuration file modifications and environment variable modifications required before instance initialization. ClusterNode is a cluster list, which records the type of each node in the cluster and the configuration file modifications and environment variable modifications of each node. The lengths of the two lists are recorded as sizeIN and sizeCN respectively.

[0098] If both sizeIN and sizeCN are 0, that is, the test case does not need instance or cluster resources, it is considered to have the lowest cost and returns 0 directly. The priority is to calculate the difference between the two lists and the current single instance and cluster (listS, listC), and traverse the List <instancenode>, each loop element is recorded as in, the inner loop traverses listS (deep copy a new one), and each loop element is recorded as ls. The goal is to find the instance with the smallest difference from in from listS.

[0099] If ls has been marked as needing to be reinitialized, for example, this instance needs to be reinitialized due to some operations performed when running the previous use case, such as deliberately deleting a key file, then the maximum cost value of 10000 is directly returned; if a restart is required, the cost value of 2000 is directly returned.

[0100] Then, the differences in the configuration files are calculated. Because some configuration changes require reinitializing the instance to take effect, a list of configuration items is prepared. If the configurations of in and ls are different and are in the configuration item list, the cost value is a maximum of 10,000; otherwise, it is 2,000.

[0101] Then, it calculates whether there are any differences in environment variables, etc. If any of them are different, the instance is considered to need to be restarted and a cost value of 2000 is returned. If there are no differences, a cost value of 0 is returned. After each inner loop, an ls with the lowest cost for in is found and then removed from listS. If the size of listS is already 0 during the outer loop, the instance needs to be taken from instance pool A, that is, a new instance needs to be created, and the cost value is directly assumed to be 10000 (the maximum value).

[0102] The cost of each in calculation is accumulated as the value of this step, denoted as vS.

[0103] There is a special case. If it is determined that the current use case does not need cluster resources, and the current instance pool A and listS have no remaining resources, but listC has remaining resources, then a cluster in listC can be split into multiple instances for the current use case. In this case, the instance must be reinitialized, so the cost is also 10,000.

[0104] Iterating over a List <clusternode>, each loop element is recorded as cn, the inner loop traverses listC (also a deep copy of a new one), each loop element is recorded as lc, the goal is to find the cluster with the smallest difference from cn:

[0105] First, check whether the number and type of cluster nodes in lc and cn are consistent. If not, they cannot be reused and directly return 10000 (the maximum cost of a single instance) * dn;

[0106] Where dn is the number of nodes in cn.

[0107] Then, calculate the difference in cost between the LC and CN master nodes using the same method as for calculating the cost of a single instance. Since the master node plays a decisive role, you can simply assume that if the cost is greater than 0, the cluster cannot be reused. For each database product, you can make a detailed assessment based on your specific situation.

[0108] Then calculate the cost of each non-master node and add them up. If this value is greater than 0, it is considered that all non-master nodes need to be restarted, and the cost value is 2000*(dn-1);

[0109] After each inner loop, a lc with the lowest cost for cn is found and removed from listC. If the size of listC is already 0 during the outer loop, the cost is assumed to be 10000 * the number of cn instances. The cost calculated for each cn is accumulated and used as the value of this step, denoted as vC.

[0110] 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 that a test case with a cost of 0 will be found directly. In this case, the loop can be jumped directly to execute the selected test case.

[0111] In actual tests, the initialization time for a company's GBase8s database product was approximately 1 minute and 20 seconds, and the restart time was approximately 20 seconds. After optimizing the test case using this method, the test case execution time was essentially focused on the test case itself, and the test case list execution speed increased by two orders of magnitude. This also achieved the technical effect of shortening the test case list execution time without requiring any modifications to the original test case.

[0112] like Figure 2 As shown, the present invention also provides a system for optimizing database use case execution, including:

[0113] Cost calculation module 101: obtains multiple resource requirement information and corresponding multiple cost calculation rules corresponding to multiple test cases;

[0114] Minimum cost query module 102: obtains the test case corresponding to the minimum cost value according to the resource demand information and cost calculation rules;

[0115] Test case execution module 103: executes the test case corresponding to the lowest cost value and returns to the lowest cost query module until all test cases are executed.

[0116] Figure 3 An example of a physical structure diagram of an electronic device is shown below. Figure 3 As shown, the electronic device may include: a processor 810, a communication interface 820, a memory 830, and a communication bus 840, wherein the processor 810, the communication interface 820, and the memory 830 communicate with each other via the communication bus 840. The processor 810 may call logic instructions in the memory 830 to execute a method for optimizing database use case execution, the method comprising:

[0117] S1: Obtain multiple resource requirement information and corresponding multiple cost calculation rules corresponding to multiple test cases;

[0118] S2: Obtain the test case corresponding to the lowest cost value based on resource demand information and cost calculation rules;

[0119] S3: Execute the test case corresponding to the lowest cost value and return to step S2 until all test cases are executed.

[0120] Furthermore, the logic instructions in the aforementioned memory 830 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the portion that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product, stored in a storage medium, includes instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, mobile hard drives, read-only memories (ROMs), random access memories (RAMs), magnetic disks, or optical disks.

[0121] In another aspect, the present invention further provides a computer program product, comprising a computer program stored on a non-transitory computer-readable storage medium, wherein the computer program comprises program instructions. When the program instructions are executed by a computer, the computer is capable of performing a method for optimizing database use case execution provided by the above methods, the method comprising:

[0122] S1: Obtain multiple resource requirement information and corresponding multiple cost calculation rules corresponding to multiple test cases;

[0123] S2: Obtain the test case corresponding to the lowest cost value based on resource demand information and cost calculation rules;

[0124] S3: Execute the test case corresponding to the lowest cost value and return to step S2 until all test cases are executed.

[0125] In another aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the computer program is implemented to perform the above-mentioned method for optimizing database use case execution, the method comprising:

[0126] S1: Obtain multiple resource requirement information and corresponding multiple cost calculation rules corresponding to multiple test cases;

[0127] S2: Obtain the test case corresponding to the lowest cost value based on resource demand information and cost calculation rules;

[0128] S3: Execute the test case corresponding to the lowest cost value and return to step S2 until all test cases are executed.

[0129] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, i.e., they may be located in one location or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of the present embodiment. Persons of ordinary skill in the art will be able to understand and implement the present invention without inventive effort.

[0130] Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented using software plus a necessary general-purpose hardware platform, or of course, hardware. Based on this understanding, the essence of the above technical solution, or the portion that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a magnetic disk, or an optical disk, and includes a number of instructions for causing a computer device (such as a personal computer, server, or network device) to execute the methods described in each embodiment or certain portions of the embodiments.

[0131] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention 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. However, 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 various embodiments of the present invention.

[0132] 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 portion can be implemented using dedicated logic; the software portion can be stored in a memory and executed by an appropriate instruction execution system such as a microprocessor or dedicated hardware. Those skilled in the art will understand that the above-mentioned devices and methods can be implemented using computer-executable instructions and / or contained 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.

[0133] In addition, although the operations of the method of the present disclosure are described in a particular order in the accompanying drawings, this does not require or imply that these operations must be performed in this particular order, or that all the operations shown must be performed to achieve the desired result. On the contrary, the steps depicted in the flow chart can change the order of execution. Additionally or alternatively, certain steps can be omitted, multiple steps can be combined into one step, and / or one step can be decomposed into multiple steps. 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 a device described above can be further divided into being embodied by multiple devices.

[0134] 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. A method for optimizing database use case execution, characterized in that: include: S1: Obtain multiple resource requirement information and corresponding multiple cost calculation rules corresponding to multiple test cases; S2: Based on resource requirement information and cost calculation rules, obtain the test case corresponding to the lowest cost value, including: S21: Acquire an uninitialized first instance pool and an initialized reusable second instance pool; S22: Filtering use cases whose required instance number 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: traversing the test cases in the candidate list according to the resource requirement information and the cost calculation rule, and calculating each execution cost corresponding to each test case in the candidate list; S24: If, during the traversal process, the execution cost of the first test case is calculated to be 0, the first test case is selected as the test case corresponding to the lowest cost value, and the traversal is terminated; if, after traversing the candidate list, the execution cost is not calculated to be 0, the test case with the lowest execution cost is selected 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, characterized in that: 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.

3. The method for optimizing database use case execution according to claim 1, characterized in that: 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 rule includes 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 rules include: Obtain a list of single-instance nodes required for the test case according to 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 reinitialized or the configuration file modification information is different from that of the single instance node, the single instance cost is a first value; If the first instance differs from the single instance node only in environment variable information, the single instance cost is a second value; If the instance configuration completely matches the environment variables, 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 single instance cost is the first value; The first instance is the instance in the single instance pool in which the configuration file modification information has the highest matching degree with the single instance node and the environment variable information has the highest matching degree with 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 rules include: Obtain a list of clusters required for the test case according to resource requirement information; Traversing the cluster list, for each cluster requirement information in the cluster list, searching the cluster with the highest matching degree between the number of nodes and each node type in the cluster instance pool as the first cluster; If the number of nodes or the type of each node of the first cluster does not match the cluster requirement information, the cluster cost is the number of nodes in the cluster multiplied by a third value; If the master node configuration information of the first cluster differs from the cluster requirement information, the cluster cost is the fourth value multiplied by the 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 in the cluster multiplied by a third value; The third value is greater than the fourth value, and the fifth value is the number of nodes in the cluster minus 1.

6. The method for optimizing database use case execution according to claim 3, characterized in that: The cost calculation rules also include: If there is a situation where the second test case does not require instance or cluster resources: determining that the execution cost of the second test case is 0; If there is a third test case that does not require cluster resources, and 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: splitting the cluster in the cluster instance pool to provide instances for the third test case, and determining that the execution cost of the third test case is a sixth value; The sixth value is greater than or equal to the first value.

7. A database optimization use case execution system, used to execute the database optimization use case execution method according to any one of claims 1 to 6, characterized in that: include: Cost calculation module: obtains multiple resource requirement information and corresponding cost calculation rules corresponding to multiple test cases; Minimum cost query module: obtains the test case corresponding to the minimum cost value according to the resource demand information and cost calculation rules; Test case execution module: executes the test case corresponding to the lowest cost value and returns 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 in the memory and executable on the processor, wherein: When the processor executes the computer program, the steps of the method for optimizing database use case execution as described in any one of claims 1 to 6 are implemented.

9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method for optimizing database use case execution as described in any one of claims 1 to 6 are implemented.

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