Relational database system-oriented test case automatic reduction method, system and equipment and storage medium

By automatically reducing test cases of relational database systems in multi-dimensional manner, the problem of low positioning efficiency of complex test cases in the existing technology is solved, and the effect of rapid analysis and defect positioning is achieved.

CN119166507APending Publication Date: 2024-12-20ZHONGKE NANJING SOFTWARE TECH RES INST
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411189767.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-28
Publication Date
2024-12-20

AI Technical Summary

Technical Problem

The existing technology is difficult to quickly analyze and locate test case defects in relational database systems, resulting in huge labor costs and efficiency problems for developers when dealing with complex test cases.

Method used

Automatic multi-dimensional deduction of test cases of relational database systems, including initialization statement sequence, test prophetic statement WHERE predicate, defect-triggered irrelevant data columns and data constraints, using minimized incremental debugging algorithms and abstract syntax tree technology , ensure that the reduced test cases can effectively trigger defects.

Benefits of technology

It realizes automated reduction of test cases, simplifies the developer's analysis and defect location process, reduces labor costs, and improves the comprehensibility and efficiency of test cases.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119166507A_ABST
    Figure CN119166507A_ABST
Patent Text Reader

Abstract

The invention discloses a relational database system-oriented test case automatic subtraction method, system and device and a storage medium, and belongs to the technical field of test case subtraction, and the method comprises the following steps: obtaining an original test case of which potential logic defects are detected; sequentially carrying out initial statement sequence reduction, test oracle statement WHERE predicate reduction, defect triggering irrelevant data column reduction and defect triggering irrelevant data constraint reduction on the original test case; the test oracle statement WHERE predicate subtraction is based on the test case after the initialization statement sequence subtraction, the defect triggering irrelevant data column subtraction is based on the test case after the test oracle statement WHERE predicate subtraction, and the defect triggering irrelevant data constraint subtraction is based on the test case after the defect triggering irrelevant data column subtraction; according to the method, the test cases can be automatically reduced in multiple dimensions, so that developers can conveniently and quickly analyze the test cases and position defect root causes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of test case reduction, and in particular relates to a test case automatic reduction method, system, device and storage medium for a relational database system. Background Art

[0002] Database systems are the foundation of data-intensive applications, providing the ability to store and query massive amounts of data for fields such as aviation, finance, and logistics. Relational database systems, such as MySQL, MariaDB, and TiDB, are the most popular relational database systems. Relational database systems are built on the relational data model and use Structured Query Language (SQL) as the standard interactive language. Due to design or implementation problems in relational database systems, there are often a variety of implementation defects, such as returning incorrect query results or generating incorrect database states. These defects seriously affect the quality of relational database systems.

[0003] At present, there are many research works devoted to the automatic detection of defects in relational database systems, such as RAGS (Donald R. Slutz, Massive Stochastic Testing of SQL, VLDB 1998.), SQLancer (Rigger M, Su Z. SQLancer.), SQLsmith (Seltenreich A. SQLsmith.) and Go-randgen (go-randgen.). These research works usually generate test cases based on generation or templates, and automatically detect defects in relational database systems by designing new test predictions; in order to more comprehensively cover the execution path of the database system and discover more potential defects, the test cases generated by automated testing tools are usually very complex. These test cases usually contain a large number of random initialization statements, generate data tables containing multiple data columns and multiple constraints, and the test prediction statements also contain many constant and function combined operations. It is difficult for developers to understand such complex test cases containing a large number of redundant elements in a short time, which brings huge manpower costs to the test case analysis and defect root cause location of the database system. Summary of the invention

[0004] The purpose of the present invention is to provide a method, system, device and storage medium for automatically reducing test cases for a relational database system, which can automatically reduce test cases in multiple dimensions, thereby facilitating developers to quickly analyze test cases and locate root causes of defects.

[0005] The present invention provides the following technical solutions:

[0006] In a first aspect, a method for automatically reducing test cases for a relational database system is provided, comprising:

[0007] Step 1: obtaining an original test case for detecting potential logical defects in a relational database system; the original test case includes an initialization statement sequence and a test prediction statement sequence; in the original test case, executing the initialization statement sequence to generate a data table to be tested;

[0008] Step 2: For the original test case, perform initialization statement sequence reduction, test prediction statement WHERE predicate reduction, defect trigger irrelevant data column reduction, and defect trigger irrelevant data constraint reduction in turn;

[0009] Wherein, step 2.1: the initialization statement sequence reduction is: based on the original test case, the initialization statement sequence is reduced using a minimized incremental debugging algorithm;

[0010] Step 2.2: The test prediction statement WHERE predicate reduction is as follows: based on the test case after the initialization statement sequence reduction, for the test prediction statement sequence, each WHERE predicate is regarded as an abstract syntax tree, and the operation nodes of the abstract syntax tree are reduced;

[0011] Step 2.3: the defect triggering irrelevant data column elimination is: based on the test case after the WHERE predicate of the test prediction statement is eliminated, the data column irrelevant to the defect trigger in the initialization statement sequence is eliminated;

[0012] Step 2.4: The defect trigger irrelevant data constraint reduction is: based on the test case after the defect trigger irrelevant data column reduction, the data constraints irrelevant to the defect trigger in the data table to be tested are reduced.

[0013] Optionally, the step 2.1 includes:

[0014] Step 2.1.1: Divide the initialization statement sequence into two subsets;

[0015] Step 2.1.2: For each subset and each subset's complement, execute all the initialization statements it contains and test whether it can trigger the original defect. If so, keep the subset or complement that triggers the defect. If not, test other untested subsets or corresponding complements.

[0016] Step 2.1.3: Further partition each retained subset or complement, and return to step 2.1.2 for the further partitioned subset or complement, until each partitioned subset includes only one initialization statement, and the initialization statement has been individually tested to see whether it can trigger the original defect, then the initialization statement sequence reduction is completed.

[0017] Optionally, the step 2.2 includes:

[0018] Step 2.2.1: For each WHERE predicate, treat it as an abstract syntax tree AST;

[0019] Step 2.2.2: Record the root node and all child nodes of AST; the child nodes are operators or operands;

[0020] Step 2.2.3: Assume that the SQL string translated from the AST starting from the root node is &;

[0021] Step 2.2.4: Use the SELECT& provided by the relational database to obtain the constant value of the root node to replace the root node, and use the replaced root node to test whether it can trigger the original defect. If so, delete the root node and all child nodes of the current WHERE predicate, and the reduction of the current WHERE predicate is completed. If not, replace and reduce the AST child nodes to delete all child nodes that are not related to the defect triggering, and complete the reduction of the current WHERE predicate.

[0022] Optionally, in step 2.2.4, replacing and eliminating AST child nodes includes:

[0023] Use each child node to replace the parent node separately. If there is a child node that can trigger the same defect as the parent node, use this child node to replace the parent node, and recursively try to eliminate this child node. If all individual child nodes cannot trigger the same defect as the parent node, then try to eliminate each child node in turn; the sign that a node can no longer be eliminated is that all child nodes of the node have been subjected to all elimination strategies.

[0024] Optionally, the step 2.3 includes:

[0025] Step 2.3.1: Based on the test case after the WHERE predicate of the test prediction statement is eliminated, traverse all the test prediction statements of the current test case to obtain the data columns used by the test prediction statement;

[0026] Step 2.3.2: Query the relational database system to obtain all data columns generated by the current test case;

[0027] Step 2.3.3: Compare the differences between all generated data columns and the used data columns to obtain the data columns to be eliminated that may not be related to the defect trigger;

[0028] Step 2.3.4: For each data column to be eliminated in the initialization statement sequence, attempt to delete it; after attempting to delete each data column to be eliminated, update the test case, and use the updated test case to perform a defect trigger operation. If the triggered defect is the same as the original defect, determine to delete the current data column to be eliminated; otherwise, the attempt to delete fails and the current data column to be eliminated is retained.

[0029] Optionally, in step 2.3.4, when attempting to delete the data column to be deleted, the constraint information and dependency relationship of the data column to be deleted are also deleted.

[0030] Optionally, the step 2.4 includes,

[0031] Step 2.4.1: Obtain all data constraints in the data table to be tested through the database schema of the relational database;

[0032] Step 2.4.2: For each data constraint, use the data definition language statement to try to delete it. After each deletion attempt, a defect triggering operation is performed. If the triggered defect is the same as the original defect, the current data constraint is deleted. Otherwise, the deletion attempt fails and the current data constraint is retained.

[0033] In a second aspect, a test case automatic reduction system for a relational database system is provided, comprising:

[0034] An acquisition module is used to acquire an original test case for detecting potential logical defects in a relational database system; the original test case includes an initialization statement sequence and a test prediction statement sequence; in the original test case, the initialization statement sequence is executed to generate a data table to be tested;

[0035] The reduction module is used to reduce the initialization statement sequence, test prediction statement WHERE predicate, defect trigger irrelevant data column and defect trigger irrelevant data constraint for the original test case in sequence;

[0036] The abatement module includes a first abatement unit, a second abatement unit, a third abatement unit and a fourth abatement unit;

[0037] A first reduction unit is used to reduce the initialization statement sequence based on the original test case using a minimized incremental debugging algorithm;

[0038] A second reduction unit is used to treat each WHERE predicate of the test prediction statement sequence as an abstract syntax tree based on the test case after the initialization statement sequence is reduced, and reduce the operation nodes of the abstract syntax tree;

[0039] A third elimination unit is used to eliminate data columns irrelevant to the defect trigger in the initialization statement sequence based on the test case after the WHERE predicate of the test prediction statement is eliminated;

[0040] The fourth elimination unit is used to eliminate data constraints irrelevant to the defect trigger in the data table to be tested based on the test case after the defect trigger irrelevant data column is eliminated.

[0041] According to a third aspect, a computer device is provided, comprising a processor and a memory; wherein, when the processor executes a computer program stored in the memory, the steps of the method for automatically reducing test cases for a relational database system as described in any one of the first aspects are implemented.

[0042] In a fourth aspect, a computer-readable storage medium is provided for storing a computer program; when the computer program is executed by a processor, the steps of the method for automatically reducing test cases for a relational database system described in any one of the first aspects are implemented.

[0043] Compared with the prior art, the present invention has the following beneficial effects:

[0044] The present invention provides a method for automatically reducing test cases for a relational database system. The method gradually deletes elements in the test case that do not affect the defect triggering effect from four dimensions: the initialization statement sequence of the test case, the WHERE predicate of the test prediction statement, the data column of the data table to be tested, and the data constraint of the data table to be tested, thereby achieving the purpose of automatically reducing the test case. The method is applicable to all relational database system test cases that use data definition language and data manipulation language to initialize the database state and use test prediction and original test statements to detect WHERE predicate logic defects. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] Figure 1 It is a schematic diagram of the overall process of the automatic test case reduction method for a relational database system of the present invention;

[0046] Figure 2 It is a structural block diagram of the test case automatic reduction system for relational database system of the present invention. DETAILED DESCRIPTION

[0047] The present invention will be further described below in conjunction with the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solution of the present invention, and cannot be used to limit the protection scope of the present invention.

[0048] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0049] like Figure 1 As shown, a method for automatically reducing test cases for a relational database system is provided, comprising the following steps:

[0050] Step 1: Obtain an original test case that detects potential logical defects in a relational database system; the original test case includes an initialization statement sequence and a test prediction statement sequence; in the original test case, execute the initialization statement sequence to generate a data table to be tested.

[0051] Specifically, whether a potential logic defect is found is determined based on the test prediction statement and the original query statement execution results of the test case. The test prediction statement and the original query statement execution results include: the test prediction statement and the original query statement execution results in the target database system, and the abnormal information returned during the execution process.

[0052] The initialization statement sequence of the original test case is composed of data definition language and data manipulation language, and the test prediction statement sequence is composed of test prediction statements and original query statements; the initialization statement sequence is mainly used to initialize the state of the data table to be tested; the test prediction statement sequence determines the defect triggering effect through the execution results of the test prediction statements and original query statements.

[0053] Step 2: For the original test case, perform initialization statement sequence reduction, test prediction statement WHERE predicate reduction, defect trigger irrelevant data column reduction, and defect trigger irrelevant data constraint reduction in turn.

[0054] After the reduction in the above four dimensions, the original test cases only retain the initialization statements, operators and operands, data columns and data constraints necessary to trigger defects, thereby achieving the purpose of automatically reducing test cases; this method is applicable to test cases of all relational database systems that use data definition language and data manipulation language to initialize database status and use test prophecies and original test statements to detect WHERE predicate logic defects.

[0055] Among them, step 2.1: the initialization statement sequence reduction is: based on the original test case, the initialization statement sequence is reduced using a minimized incremental debugging algorithm.

[0056] Specifically, the initialization statement sequence is reduced using a minimized incremental debugging algorithm. The reduction of the initialization statement sequence includes taking each individual SQL statement in the initialization statement sequence as a basic unit, dividing the initialization statement sequence into two subsets through the minimized incremental debugging method, and testing each subset and its complement to see whether they can trigger the same defect effect of the original test case. The subset or complement that can trigger the defect is retained, and the new set is recursively minimized incremental debugging until the number of divided sets is equal to the number of SQL statements, and the reduction is completed. This strategy ensures that each SQL statement in the initialization statement sequence of the test case after the reduction strategy is executed can no longer be deleted, and ensures that the defect can still be triggered.

[0057] More specifically, step 2.1 includes:

[0058] Step 2.1.1: Divide the initialization statement sequence into two subsets;

[0059] Step 2.1.2: For each subset and each subset's complement, execute all the initialization statements contained therein, and test whether the original defect can be triggered. If so, retain the subset or complement that triggers the defect. If not, test other untested subsets or corresponding complements. The original defect is the same logical defect as the original test case.

[0060] Step 2.1.3: Further partition each retained subset or complement, and return to step 2.1.2 for the further partitioned subset or complement, until each partitioned subset includes only one initialization statement, and the initialization statement has been individually tested to see whether it can trigger the original defect, then the initialization statement sequence reduction is completed.

[0061] Step 2.2: The test prediction statement WHERE predicate reduction is as follows: based on the test case after the initialization statement sequence reduction, for each test prediction statement in the test prediction statement sequence, each WHERE predicate is regarded as an abstract syntax tree (Abstract Syntax Tree, AST), and the operation nodes of the abstract syntax tree are reduced from top to bottom, and the operators and operands in the WHERE predicate that are not related to the defect triggering are gradually deleted.

[0062] Specifically, the step 2.2 includes:

[0063] Step 2.2.1: For each WHERE predicate of the test prediction statement, treat it as an abstract syntax tree AST;

[0064] Step 2.2.2: Record the root node and all child nodes of AST; the AST is an abstract syntax tree, and the child nodes are operators or operands;

[0065] Step 2.2.3: Assume that the SQL string translated from the AST starting from the root node is &;

[0066] Step 2.2.4: Use the SELECT& provided by the relational database to obtain the constant value of the root node to replace the root node, and use the replaced root node to test whether it can trigger the original defect. If so, it means that all operators and operands corresponding to the root node do not affect the triggering of the defect. Then delete the root node and all child nodes of the current WHERE predicate, and the reduction of the current WHERE predicate is completed. If not, it means that some child nodes contained in the root node play an important role in triggering the defect. Then, for each AST child node, replace and reduce it to delete all child nodes that are not related to the defect triggering, and complete the reduction of the current WHERE predicate.

[0067] In step 2.2.4, the AST child nodes are replaced and reduced, including: using each child node to replace the parent node separately; if there is a child node that can trigger the same defect as the parent node, use this child node to replace the parent node, and recursively try to reduce this child node; if all individual child nodes cannot trigger the same defect as the parent node, then try to reduce each child node in turn; the sign that a node can no longer be reduced is that all child nodes of this node have been subjected to all reduction strategies.

[0068] More specifically, traverse each child node and try to replace the current parent node with this child node; test whether it can still trigger the same defect effect as the original parent node if only this child node is used.

[0069] If a child node can trigger the same defect effect as the parent node alone, then this child node can replace the parent node, indicating that the triggering of the defect by other parts of the parent node is redundant. If the parent node is successfully replaced by the child node, the child node itself should be further reduced. This process is recursive, that is, the child node is now regarded as the new parent node, and then the above replacement and reduction process is repeated; by gradually simplifying, retaining the smallest necessary part, and continuing to find and delete redundant operators and operands.

[0070] If all child nodes cannot trigger the same defect effect as the parent node alone, it means that each child node in the parent node may contain some necessary parts, and deleting any of the child nodes alone will cause the defect to fail to trigger; in this case, it is necessary to perform more fine-grained reduction attempts on each child node in turn. Specifically, it is to further subdivide the child nodes and find out the redundant parts.

[0071] The condition for a node to no longer be reduced is that all child nodes of a node have undergone all possible reduction attempts and cannot be further simplified, which means that the node has been simplified to the smallest necessary form.

[0072] Step 2.3: The defect triggering irrelevant data column elimination is as follows: based on the test case after the WHERE predicate of the test prediction statement is eliminated, the data column irrelevant to the defect triggering in the initialization statement sequence is eliminated.

[0073] Specifically, the step 2.3 includes:

[0074] Step 2.3.1: Based on the test case after the WHERE predicate of the test prediction statement is eliminated, traverse all the test prediction statements of the current test case to obtain the data columns used by the test prediction statement;

[0075] Step 2.3.2: Query the relational database system to obtain all data columns generated by the current test case;

[0076] Step 2.3.3: Compare the differences between all generated data columns and the used data columns to obtain the data columns to be eliminated that may not be related to the defect trigger;

[0077] Step 2.3.4: For each data column to be eliminated in the initialization statement sequence, attempt to delete it; after attempting to delete each data column to be eliminated, update the test case, and use the updated test case to perform the defect triggering operation. If the triggered defect is the same as the original defect, determine to delete the current data column to be eliminated; otherwise, the deletion attempt fails and the current data column to be eliminated is retained. That is, after all data columns to be eliminated are attempted to be deleted, the test case after deleting all defect-triggered irrelevant data columns is obtained, and the defect-triggered irrelevant data column reduction is completed.

[0078] Furthermore, when attempting to delete the data column to be deleted, the constraint information and dependency relationship of the data column to be deleted are also deleted.

[0079] The constraint information is deleted because the data column is usually defined together with constraints such as indexes. When the data column is deleted, the corresponding column constraint information is also deleted.

[0080] The reason for deleting dependencies is that there are data column dependencies between statements in the initialization statement sequence, such as the INSERT statement depends on the column information generated by the CREATE TABLE statement. Therefore, it is necessary to eliminate all statements containing the data column information, that is, if a data column is deleted, it must be deleted in all statements.

[0081] Due to the randomness of the initialization statements constructed by the relational database system testing tool, the data table to be tested generated by executing the initialization statement sequence usually contains multiple data columns, some of which may be irrelevant to the defect triggering. Therefore, the data columns irrelevant to the defect triggering are eliminated from the initialization statement sequence. Specifically, by comparing the differences between the generated data table to be tested and the data table column names in the test prediction statements, all data columns that may be irrelevant to the defect triggering in each data table are obtained, and the data columns that may be irrelevant to the defect are deleted one by one using the ALETR TABLE statement, and the defect triggering effect is detected until all data columns that are potentially irrelevant to the defect triggering are deleted.

[0082] Step 2.4: The defect trigger irrelevant data constraint reduction is: based on the test case after the defect trigger irrelevant data column reduction, the data constraints irrelevant to the defect trigger in the data table to be tested are reduced.

[0083] Specifically, the step 2.4 includes:

[0084] Step 2.4.1: Obtain all data constraints in the data table to be tested through the database schema of the relational database;

[0085] Step 2.4.2: For each data constraint, use the data definition language statement to try to delete it. After each deletion attempt, a defect trigger operation is performed. If the triggered defect is the same as the original defect, the current data constraint is deleted. Otherwise, the deletion attempt fails and the current data constraint is retained.

[0086] All data constraints have been attempted to be reduced, and the necessary data constraints are retained to obtain the final initialization statement sequence, thereby completing the reduction of defect-triggered irrelevant data constraints.

[0087] When the present invention performs test prediction statement WHERE predicate reduction, the initialization statement sequence reduction of the original test case has been completed; when the defect triggering irrelevant data column reduction is performed, the initialization statement reduction and the test prediction statement WHERE predicate reduction of the original test case have been completed in sequence; when the defect triggering irrelevant data constraint reduction is performed, the initialization statement reduction, the test prediction statement WHERE predicate reduction and the defect triggering irrelevant data column reduction of the original test case have been completed in sequence. The present invention automatically reduces test cases from four dimensions, which is more comprehensive and thorough, so that developers can quickly analyze test cases and locate the root causes of defects; at the same time, the present invention uses a defect re-triggering mechanism to ensure that the new test cases generated by the reduction can trigger the same defect effect as the original test cases, avoiding the situation in which the prior art does not consider the dependency between the deleted expression and other parts of the query, which may cause invalid queries to be generated by the reduction.

[0088] In another embodiment, test cases of multiple databases are given and the reduced data is reduced using the automatic reduction method of the present invention.

[0089] Table 1 The reduction results of multiple test cases using the method of the present invention

[0090]

[0091]

[0092]

[0093] It is worth noting that in the data of columns 5-9 of Table 1, the left side of each column is the original test case data, the middle is the automatically reduced data, and the right side is the minimum test case data (manually reduced). It can be seen from Table 1 that the size of the test cases, the number of initialization statements, the number of test prediction WHERE predicate operators, the number of data table constraints, and the number of data tables and data columns after the automatic reduction method of the present invention are reduced to a great extent, indicating that the reduction effect of the automatic reduction method of the present invention is significant.

[0094] In another embodiment, if Figure 2 As shown, a test case automatic reduction system for a relational database system is provided, comprising:

[0095] An acquisition module is used to acquire an original test case for detecting potential logical defects in a relational database system; the original test case includes an initialization statement sequence and a test prediction statement sequence; in the original test case, the initialization statement sequence is executed to generate a data table to be tested;

[0096] The reduction module is used to reduce the initialization statement sequence, test prediction statement WHERE predicate, defect trigger irrelevant data column and defect trigger irrelevant data constraint for the original test case in sequence;

[0097] The abatement module includes a first abatement unit, a second abatement unit, a third abatement unit and a fourth abatement unit;

[0098] A first reduction unit is used to reduce the initialization statement sequence based on the original test case using a minimized incremental debugging algorithm;

[0099] A second reduction unit is used to treat each WHERE predicate of each test prediction statement in the test prediction statement sequence as an abstract syntax tree based on the test case after the initialization statement sequence is reduced, and reduce the operation nodes of the abstract syntax tree;

[0100] A third elimination unit is used to eliminate data columns irrelevant to the defect trigger in the initialization statement sequence based on the test case after the WHERE predicate of the test prediction statement is eliminated;

[0101] The fourth elimination unit is used to eliminate data constraints irrelevant to the defect trigger in the data table to be tested based on the test case after the defect trigger irrelevant data column is eliminated.

[0102] For more specific processes of the above method, please refer to the corresponding contents disclosed in the aforementioned embodiments, which will not be repeated here.

[0103] In another embodiment, the present invention provides a computer device, including a processor and a memory; wherein the processor implements the steps of the above-mentioned test case automatic reduction method for a relational database system when executing a computer program stored in the memory.

[0104] For more specific processes of the above method, please refer to the corresponding contents disclosed in the aforementioned embodiments, which will not be repeated here.

[0105] In another embodiment, the present invention provides a computer-readable storage medium for storing a computer program; when the computer program is executed by a processor, the steps of the above-mentioned test case automatic reduction method for a relational database system are implemented.

[0106] For more specific processes of the above method, please refer to the corresponding contents disclosed in the aforementioned embodiments, which will not be repeated here.

[0107] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the system, device, and storage medium disclosed in the embodiment, since they correspond to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.

[0108] Those skilled in the art can clearly understand that the technology in the embodiments of the present invention can be implemented by means of software plus a necessary general hardware platform. Based on this understanding, the technical solution in the embodiments of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which can be stored in a storage medium such as ROM / RAM, a disk, an optical disk, etc., and includes a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present invention or some parts of the embodiments.

[0109] The above are only preferred embodiments of the present invention, and the protection scope of the present invention is not limited to the above embodiments. All technical solutions under the concept of the present invention belong to the protection scope of the present invention. It should be pointed out that for ordinary technicians in this technical field, some improvements and modifications without departing from the principle of the present invention should be regarded as the protection scope of the present invention.

Claims

1. A method for automatically reducing test cases for a relational database system, characterized in that: include: Step 1: Obtain the original test cases that detect potential logical defects in the relational database system; The original test case includes an initialization statement sequence and a test prediction statement sequence; In the original test case, the initialization statement sequence is executed to generate the data table to be tested; Step 2: For the original test case, perform initialization statement sequence reduction, test prediction statement WHERE predicate reduction, defect trigger irrelevant data column reduction, and defect trigger irrelevant data constraint reduction in turn; Wherein, step 2.1: the initialization statement sequence reduction is: based on the original test case, the initialization statement sequence is reduced using a minimized incremental debugging algorithm; Step 2.2: The test prediction statement WHERE predicate reduction is as follows: based on the test case after the initialization statement sequence reduction, for each test prediction statement in the test prediction statement sequence, each WHERE predicate is regarded as an abstract syntax tree, and the operation nodes of the abstract syntax tree are reduced; Step 2.3: the defect triggering irrelevant data column elimination is: based on the test case after the WHERE predicate of the test prediction statement is eliminated, the data column irrelevant to the defect trigger in the initialization statement sequence is eliminated; Step 2.4: The defect trigger irrelevant data constraint reduction is: based on the test case after the defect trigger irrelevant data column reduction, the data constraints irrelevant to the defect trigger in the data table to be tested are reduced.

2. The method for automatically reducing test cases for a relational database system according to claim 1, characterized in that: The step 2.1 comprises: Step 2.1.1: Divide the initialization statement sequence into two subsets; Step 2.1.2: For each subset and each subset's complement, execute all the initialization statements it contains and test whether it can trigger the original defect. If so, keep the subset or complement that triggers the defect. If not, test other untested subsets or corresponding complements. Step 2.1.3: Further partition each retained subset or complement, and return to step 2.1.2 for the further partitioned subset or complement, until each partitioned subset includes only one initialization statement, and the initialization statement has been individually tested to see whether it can trigger the original defect, then the initialization statement sequence reduction is completed.

3. The method for automatically reducing test cases for a relational database system according to claim 1, characterized in that: The step 2.2 comprises: Step 2.2.1: For each WHERE predicate of the test prediction statement, treat it as an abstract syntax tree AST; Step 2.2.2: Record the root node and all child nodes of AST; the child nodes are operators or operands; Step 2.2.3: Assume that the SQL string translated from the AST starting from the root node is &; Step 2.2.4: Use the SELECT& provided by the relational database to obtain the constant value of the root node to replace the root node, and use the replaced root node to test whether it can trigger the original defect. If so, delete the root node and all child nodes of the current WHERE predicate, and the reduction of the current WHERE predicate is completed. If not, replace and reduce each AST child node to delete all child nodes that are not related to the defect triggering, and complete the reduction of the current WHERE predicate.

4. The method for automatically reducing test cases for a relational database system according to claim 3, characterized in that: In step 2.2.4, the AST subnodes are replaced and eliminated, including: Use each child node to replace the parent node separately. If there is a child node that can trigger the same defect as the parent node, use this child node to replace the parent node, and recursively try to eliminate this child node. If all individual child nodes cannot trigger the same defect as the parent node, then try to eliminate each child node in turn; the sign that a node can no longer be eliminated is that all child nodes of the node have been subjected to all elimination strategies.

5. The method for automatically reducing test cases for a relational database system according to claim 1, characterized in that: The step 2.3 comprises: Step 2.3.1: Based on the test case after the WHERE predicate of the test prediction statement is eliminated, traverse all the test prediction statements of the current test case to obtain the data columns used by the test prediction statement; Step 2.3.2: Query the relational database system to obtain all data columns generated by the current test case; Step 2.3.3: Compare the differences between all generated data columns and the used data columns to obtain the data columns to be eliminated that may not be related to the defect trigger; Step 2.3.4: For each data column to be eliminated in the initialization statement sequence, attempt to delete it; after attempting to delete each data column to be eliminated, update the test case, and use the updated test case to perform a defect trigger operation. If the triggered defect is the same as the original defect, determine to delete the current data column to be eliminated; otherwise, the attempt to delete fails and the current data column to be eliminated is retained.

6. The method for automatically reducing test cases for a relational database system according to claim 5, characterized in that: In the step 2.3.4, when attempting to delete the data column to be deleted, the constraint information and dependency relationship of the data column to be deleted are also deleted.

7. The method for automatically reducing test cases for a relational database system according to claim 1, characterized in that: The step 2.4 includes, Step 2.4.1: Obtain all data constraints in the data table to be tested through the database schema of the relational database; Step 2.4.2: For each data constraint, use the data definition language statement to try to delete it. After each deletion attempt, a defect trigger operation is performed. If the triggered defect is the same as the original defect, the current data constraint is deleted. Otherwise, the deletion attempt fails and the current data constraint is retained.

8. The automatic test case reduction system for relational database system is characterized by: include: An acquisition module, used to acquire original test cases for detecting potential logical defects in a relational database system; The original test case includes an initialization statement sequence and a test prediction statement sequence; In the original test case, the initialization statement sequence is executed to generate the data table to be tested; The reduction module is used to reduce the initialization statement sequence, test prediction statement WHERE predicate, defect trigger irrelevant data column and defect trigger irrelevant data constraint for the original test case in sequence; The abatement module includes a first abatement unit, a second abatement unit, a third abatement unit and a fourth abatement unit; A first reduction unit is used to reduce the initialization statement sequence based on the original test case using a minimized incremental debugging algorithm; A second reduction unit is used to treat each WHERE predicate of each test prediction statement in the test prediction statement sequence as an abstract syntax tree based on the test case after the initialization statement sequence is reduced, and reduce the operation nodes of the abstract syntax tree; A third elimination unit is used to eliminate data columns irrelevant to the defect trigger in the initialization statement sequence based on the test case after the WHERE predicate of the test prediction statement is eliminated; The fourth elimination unit is used to eliminate data constraints irrelevant to the defect trigger in the data table to be tested based on the test case after the defect trigger irrelevant data column is eliminated.

9. A computer device, characterized in that: It comprises a processor and a memory; wherein, when the processor executes the computer program stored in the memory, the steps of the test case automatic reduction method for a relational database system described in any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium, characterized in that: Used to store computer programs; when the computer programs are executed by a processor, the steps of the method for automatically reducing test cases for a relational database system described in any one of claims 1 to 7 are implemented.