Chaotic SQL statement full-automatic test system and method
Through the chaotic SQL statement fully automated testing system, the test configuration is dynamically adjusted using the front feedback mechanism, which solves the problem of insufficient test coverage of SQL statements in the existing technology, and achieves efficient test coverage and statistical verification.
Patent Information
- Application Number
- CN202411992625.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2025-04-29
AI Technical Summary
The prior art is difficult to test SQL statements comprehensively, complexly and relevantly in database testing, and lacks effective statistical methods.
Provides a chaotic SQL statement fully automated testing system, including a test configuration management module, a test task execution module and a statistical log evaluation module. Dynamically adjust the test configuration through the front feedback mechanism, generate and execute target SQL statements, and optimize test coverage through the statistical log evaluation module.
The maximum test coverage of the target SQL statement is achieved, and the test configuration is dynamically adjusted to ensure sufficient coverage of the test scenario and effective statistical verification.
Smart Images

Figure CN119902985A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of database testing, and in particular to a chaotic SQL statement fully automated testing system and method. Background Art
[0002] At present, as database products become more and more functional and new functions become more and more numerous, higher requirements are placed on database testers. Especially when testing new functions of the database's structured query language SQL syntax, in the design of test cases based on requirements, it is difficult for testers to produce test cases that take into account comprehensiveness, complexity, relevance and other aspects at the same time, and there is also a lack of statistical methods.
[0003] Currently, traditional SQL automatic generation tools focusing on SQL execution testing on the market or in the open source community are divided into two directions: one focuses on the correctness and inclusiveness of the results, and the other focuses more on syntax randomness and complexity. Theoretically, these two SQL tools cannot guarantee sufficient coverage of test scenarios and have not been effectively statistically verified. Summary of the invention
[0004] The present invention provides a chaotic SQL statement fully automated testing system and method, which can dynamically adjust the test configuration through a forward feedback mechanism, thereby optimizing and adjusting the generation of a target SQL statement to ensure the test coverage of the target SQL statement to the maximum extent.
[0005] In a first aspect, an embodiment of the present invention provides a chaotic SQL statement fully automated test system, the chaotic SQL statement fully automated test system comprises a test configuration management module, a test task execution module and a statistical log evaluation module; wherein,
[0006] The test configuration management module is used to obtain a test configuration file and send the test configuration file to the test task execution module;
[0007] The test task execution module is used to generate a target SQL statement according to the test configuration file and execute the target SQL statement; in the process of executing the target SQL statement, generate a statistical log including data features of the target SQL statement, and send the statistical log to the statistical log evaluation module;
[0008] The statistical log evaluation module is used to dynamically evaluate the statistical log and send the evaluation result to the test configuration management module, so that the test configuration management module adjusts the test configuration file according to the evaluation result.
[0009] In a second aspect, an embodiment of the present invention further provides a chaotic SQL statement fully automated testing method, which is applied to a chaotic SQL statement fully automated testing system, and the method comprises:
[0010] Acquire a test configuration file through a test configuration management module, and send the test configuration file to the test task execution module;
[0011] Generate a target SQL statement according to the test configuration file through the test task execution module, and execute the target SQL statement; in the process of executing the target SQL statement, generate a statistical log including the data features of the target SQL statement, and send the statistical log to the statistical log evaluation module;
[0012] The statistical log is dynamically evaluated by the statistical log evaluation module, and the evaluation result is sent to the test configuration management module, so that the test configuration management module adjusts the test configuration file according to the evaluation result.
[0013] The embodiment of the present invention provides a chaotic SQL statement fully automated test system, the system includes a test configuration management module, a test task execution module and a statistical log evaluation module. The test configuration management module is used to obtain a test configuration file and send the test configuration file to the test task execution module; the test task execution module is used to generate a target SQL statement according to the test configuration file and execute the target SQL statement; in the process of executing the target SQL statement, a statistical log including the data features of the target SQL statement is generated and sent to the statistical log evaluation module; the statistical log evaluation module is used to dynamically evaluate the statistical log and send the evaluation result to the test configuration management module, so that the test configuration management module adjusts the test configuration file according to the evaluation result. By dynamically evaluating the statistical log including the data features of the target SQL statement generated and executed by the test task execution module, and adjusting the test configuration file used to generate the target SQL statement according to the evaluation result, the test configuration can be dynamically adjusted through the feedback mechanism, thereby optimizing and adjusting the generation of the target SQL statement to maximize the test coverage of the target SQL statement.
[0014] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present invention, nor are they intended to limit the scope of the present invention. Other features of the present invention will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0016] Figure 1 It is a structural schematic diagram of a chaotic SQL statement fully automated testing system provided by an embodiment of the present invention;
[0017] Figure 2 It is a structural diagram of a test task execution module provided by an embodiment of the present invention;
[0018] Figure 3 It is a structural schematic diagram of another chaotic SQL statement fully automated testing system provided by an embodiment of the present invention;
[0019] Figure 4 The present invention provides a flowchart of a method for fully automated testing of chaotic SQL statements. DETAILED DESCRIPTION
[0020] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0021] 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.
[0022] Figure 1 The structure diagram of a chaotic SQL statement fully automated testing system provided by the embodiment of the present invention. Figure 1As shown, the chaos SQL statement fully automated testing system 100 includes: a test configuration management module 101, a test task execution module 102 and a statistical log evaluation module 103; wherein,
[0023] The test configuration management module 101 is used to obtain a test configuration file and send the test configuration file to the test task execution module 102 .
[0024] The test task execution module 102 is used to generate a target SQL statement according to a test configuration file and execute the target SQL statement; in the process of executing the target SQL statement, a statistical log including data features of the target SQL statement is generated and the statistical log is sent to the statistical log evaluation module 103.
[0025] The statistical log evaluation module 103 is used to dynamically evaluate the statistical log and send the evaluation result to the test configuration management module 101, so that the test configuration management module 101 adjusts the test configuration file according to the evaluation result.
[0026] Among them, the target SQL statement is the structured query language statement to be tested. The test configuration file includes a function configuration file, a probability configuration file, and a syntax configuration file, which are used to generate the target SQL statement. The function configuration file includes the functions to be tested, such as built-in functions, window functions, dialect-compatible functions, custom functions, etc. The probability configuration file includes the generation probability of various statements in the target SQL statement. The syntax configuration file includes the generation syntax of some statements in the target SQL statement. The data features of the target SQL statement include the function name used, the primary key data type, the partition sharding rule, the table index, etc.
[0027] In an embodiment of the present invention, the test configuration management module 101 can obtain a test configuration file including a function configuration file, a probability configuration file, and a grammar configuration file according to the target SQL statement to be tested, and send the test configuration file to the test task execution module 102, so that the test task execution module 102 can generate the target SQL statement according to the test configuration file. After generating the target SQL statement according to the test configuration file, the test task execution module 102 executes the target SQL statement, and in the process of executing the target SQL statement, generates a statistical log including the data features of the target SQL statement, and sends the statistical log to the statistical log evaluation module 103. The statistical log evaluation module 103 can dynamically evaluate the statistical log and send the evaluation result to the test configuration management module 101, so that the test configuration management module 101 adjusts the test configuration file according to the evaluation result. By dynamically evaluating the statistical log including the data features of the target SQL statement generated and executed by the test task execution module, and adjusting the test configuration file used to generate the target SQL statement according to the evaluation result, it is possible to dynamically adjust the test configuration through the forward feedback mechanism, thereby optimizing and adjusting the generation of the target SQL statement to maximize the test coverage of the target SQL statement.
[0028] Optionally, the test configuration management module 101 includes a function configuration unit 110, a probability configuration unit 120 and a syntax configuration unit 130; wherein the function configuration unit 110 is used to determine the function to be tested, and generate a function configuration file according to the input parameter data type and output parameter data type of the function to be tested; the probability configuration unit 120 is used to determine the probability of generating a target SQL statement, and generate a probability configuration file according to the probability; wherein the target SQL statement includes a DDL statement, a DQL statement and a DML statement; the syntax configuration unit 130 is used to generate a syntax configuration file of a DDL statement and a DML statement based on the grouping rules and separation rules of the Backus-Naur form.
[0029] The target SQL statements include DDL statements, DQL statements and DML statements. DDL statements are data definition language statements, DQL statements are data query language statements, and DML statements are data manipulation language statements. The Backus-Naur Form rule, or BNF rule, is a formalized syntax representation method that has the characteristics of simple syntax, clear representation, and easy syntax analysis and compilation.
[0030] In the embodiment of the present invention, the test configuration management module 101 includes a function configuration unit 110, a probability configuration unit 120 and a grammar configuration unit 130, which are respectively used to generate a function configuration file, a probability configuration file and a grammar configuration file in a test configuration file.
[0031] Among them, the function configuration unit 110 can generate a function configuration file according to the input parameter data type and output parameter data type of the function to be tested. Specifically, the function name can be used as the scope first, and then, for normal functions, the function configuration file can be written in the form of "output parameter data type, input parameter data type 1, ..., input parameter data type N, COMMON". For special functions, after the input parameter data type, it is also necessary to add relevant expressions about special parameters, such as dividing special parameters into range INTEGER type (configuration determines the upper and lower ranges), TIMESTAMP type (including characters corresponding to year, month, day, hour, minute, and second), keyword character type, and keywords that need to be separated by spaces, etc. At the same time, when writing special functions, "PH=" is used as the beginning mark at a specific position to indicate that this is a special expression, and ",SPEC" is added at the end to distinguish it from a normal function, so that full coverage of the function to be tested can be achieved. Optionally, a certain SQL dialect and a separator can be added after the function name, and the function generation methods of various SQL dialects can be written, so that when the standard database is verified for the execution result of the target SQL language, a function representation with the same meaning but different writing methods can be directly generated in the standard database.
[0032] Among them, the probability configuration unit 120 can determine the probability of the target SQL statement being generated, and generate a probability configuration file based on the probability of the target SQL statement being generated. Specifically, for the DQL statement in the target SQL statement, the generated probability is determined to be divided into the syntax layer, including SQL standard syntax such as from syntax, where syntax, and SQL dialect-specific syntax. At the same time, it is necessary to control the statement complexity of the DQL statement, such as function nesting depth, subquery nesting depth, join nesting depth, etc. For the DDL statement and DML statement in the target SQL statement, the generated probability is determined to be divided into the statement level, that is, one statement corresponds to one probability. When generating a probability configuration file based on the probability, each probability, that is, the configuration item, corresponds to three parameter items, namely the probability numerator, the probability denominator, and the probability comparison operator, such as >, <, and =. .
[0033] Among them, the grammar configuration unit 130 can generate a grammar configuration file for DDL statements and DML statements based on the grouping rule and separation rule of the Backus-Naur form. Specifically, in the grammar configuration file for the DDL statements and DML statements, the statement name is written as the scope in the first line, and the statement name here is consistent with the corresponding statement name in the probability configuration file. Afterwards, based on the BNF grammar rule, the grammar corresponding to the statement name is written to form a grammar tree corresponding to the DDL statement and the DML statement. Specifically, the options of each grammar part can be determined by [], {}, etc., and written in the key: value format starting from the second line. The second line confirms the main structure of the grammar, which consists of keywords, variables and BNF rule symbols, where the keywords are capitalized, the variables are lowercase, and the variable names can be viewed as tree nodes. In the following lines, the lowercase variable name of the previous line will be used as the key of the next line, and the corresponding value will be written one by one. The specific generation method corresponding to the key, in addition to supporting keywords, variables and BNF rules, also allows recursion, nesting and replication. Optionally, the statement name can correspond to different SQL dialect suffixes to support the simultaneous generation of statements with the same meaning but different writing methods in multiple SQL dialects, so as to facilitate subsequent standard database verification of the target SQL statement.
[0034] Alternatively, see Figure 2 The test task execution module 102 includes a metadata node 210, a statement generation node 220, a statement execution node 230 and a statement statistics node 240; wherein the metadata node 210 is used to determine the library table structure metadata, and read the test configuration file from the test configuration management module 101, and send the library table structure metadata and the test configuration information in the test configuration file to the statement generation node 220; wherein the test configuration information includes probability, function rules and grammar rules; the statement generation node 220 is used to generate a target SQL statement according to the library table structure metadata and the test configuration information, and send the target SQL statement to the statement execution node 230; the statement execution node 230 is used to execute the target SQL statement and obtain the execution result of the target SQL statement; the statement statistics node 240 is used to generate a statistical log including the data features of the target SQL statement during the process of the statement execution node 230 executing the target SQL statement.
[0035] In an embodiment of the present invention, the test task execution module 102 includes a metadata node 210, a statement generation node 220, a statement execution node 230, and a statement statistics node 240, which are respectively used to provide information required for generating a target SQL statement, generate a target SQL statement, execute a target SQL statement, and count the data features of the executed target SQL statement. Among them, the metadata node 210 is connected in communication with the test configuration management module 101 and the statement generation node 220. After determining the library table structure metadata of the test database and obtaining the test configuration file from the test configuration management module 101, the library table structure metadata and the test configuration information in the test configuration file, that is, the probability in the probability configuration file, the function rules in the function configuration file, and the grammar rules in the grammar configuration file, are sent to the statement generation node 220. Among them, the statement generation node 220 is connected in communication with the metadata node 210 and the statement execution node 230. After generating the target SQL statement according to the library table structure metadata and the test configuration information, the target SQL statement is sent to the statement execution node 230. Specifically, when generating a target SQL statement according to the library table structure metadata and the test configuration information, for DDL and DML statements, a function general generation framework matching the output parameter data type and the input parameter data type and a grammar generation framework based on BNF rules can be used to search the syntax tree nodes in order to generate DDL and DML statements. Among them, the statement execution node 230 is connected in communication with the statement generation node 220 and the statement statistics node 240. After receiving the target SQL statement, the target SQL statement is executed to obtain the execution result of the target SQL statement. Among them, the statement statistics node 240 is connected in communication with the statement execution node 230 and the statistical log evaluation module 103. In the process of the statement execution node 230 executing the target SQL statement, a statistical log including the data features of the target SQL statement is generated, and the statistical log is sent to the statistical log evaluation module 103.
[0036] Optionally, the metadata node 210 is also used to: obtain the associated conditions of the successfully executed target SQL statement feedback from the statement execution node 230, and send the associated conditions to the statement generation node 220; the statement generation node 220 is also used to: generate the target SQL statement in a preset order according to the library table structure metadata, test configuration information and associated conditions; wherein the preset order is, in sequence, the target SQL statements corresponding to the add, modify, query and delete operations on the database.
[0037] The associated conditions fed back by the successfully executed DDL statement include the partition and sub-partition rules, primary keys, indexes, sequences, auto-increment columns, function expressions and other standard database syntax of the DDL statement. The associated conditions fed back by the successfully executed DQL statement include the join on of the DQL statement and the conditional parsing results of the where module.
[0038] In an embodiment of the present invention, the metadata node 210 is also communicated with the statement execution node 230 to obtain the associated conditions of the successfully executed target SQL statement feedback, such as the partition and sub-partition rules, function expressions, etc. of the successfully executed DDL statement, update the data in the metadata node 210, and send the associated conditions to the statement generation node 220. The statement generation node 220 can also generate the target SQL statements corresponding to the add, modify, query and delete operations on the database in sequence according to the library table structure metadata, test configuration information and associated conditions in a preset order.
[0039] Optionally, the statement generation node 220 is specifically used to: generate DDL statements based on the library table structure metadata and test configuration information; generate DQL statements based on the library table structure metadata, test configuration information and the associated conditions of the successfully executed DDL statement feedback; generate DML statements based on the library table structure metadata, test configuration information and the associated conditions of the successfully executed DQL statement feedback.
[0040] In an embodiment of the present invention, when the statement generation node 220 generates the target SQL statement according to the library table structure metadata, the test configuration information and the associated conditions in a preset order, first, a DDL statement is generated according to the library table structure metadata and the test configuration file. After that, after the DDL statement is successfully executed, the associated conditions fed back by the DDL statement can be obtained as reference items, and a DQL statement can be generated according to the library table structure metadata, the test configuration information and the reference items. Then, after the DQL statement is successfully executed, the associated conditions fed back by the DQL statement can be obtained as reference items, and a DML statement can be generated according to the library table structure metadata, the test configuration information and the reference items. A series of statements generated by the above process are often more representative of associations, thereby improving the efficiency of hitting the result set. It should be noted that in an embodiment of the present invention, the test task can be executed by multiple processes. Regarding the generation of the target SQL statement, the associated statement generation can be performed in a single manner according to the above order, or the target SQL statement can be randomly generated according to probability without considering the association through a thread pool, so as to take into account both completely random and limited random with association to ensure the extensiveness and finiteness of the target SQL statement.
[0041] Optionally, the statement execution node 230 includes a database client 231, a driver program 232, and an executable file 233 with a memory detection tool; wherein the database client 231 is used to directly execute the target SQL statement to obtain a first execution result of the target SQL statement; the driver program 232 is used to convert the target SQL statement into a string based on a driver code rule corresponding to the driver program 232, and execute the string through the driver program 232 to obtain a second execution result of the target SQL statement; the executable file 233 with the memory detection tool is used to execute the target SQL statement to obtain a third execution result of the target SQL statement, and in the process of executing the target SQL statement, generate a memory log about illegal reading and writing or memory leakage through the memory detection tool.
[0042] In an embodiment of the present invention, the statement execution node 230 may include a database client 231, a driver 232, and an executable file 233 with a memory detection tool to achieve concurrent execution of the target SQL statement. Among them, the database client 231 can directly execute the target SQL statement to obtain the first execution result of the target SQL statement. Among them, the driver 232 needs to convert the target SQL statement into a string based on the driver code rule corresponding to the driver 232, and then execute the string through the interface corresponding to the preapre mode or batch mode of the driver 232 to obtain the second execution result of the target SQL statement. Optionally, the driver 232 may include drivers written in different languages such as Java, C, Python and Go. Among them, the executable file 233 with a memory detection tool can execute the target SQL statement to obtain the third execution result of the target SQL statement, and in the process of executing the target SQL statement, a memory log about illegal reading and writing or memory leakage is generated through the memory detection tool to verify the stability of the system.
[0043] Alternatively, see Figure 3The chaos SQL statement fully automated test system 100 also includes a test process verification module 104. The test process verification module 104 includes a functional verification unit 410, an execution plan verification unit 420, and a stability verification unit 430, wherein the functional verification unit 410 is used to obtain the execution result of the target SQL statement from the statement execution node 230, and perform expected verification, abnormality verification, and standard database verification on the execution result; the execution plan verification unit 420 is used to obtain the execution steps of the target SQL statement through the execution plan parsing syntax, and obtain the target association condition corresponding to the target SQL statement from the metadata node 210 connected to the statement execution node 230, and perform conditional judgment and verification on the execution steps according to the target association condition; the stability verification unit 430 is used to obtain the memory log generated by the memory detection tool from the statement execution node 230, and analyze the abnormal factors that cause the instability of the system 100 according to the memory log.
[0044] Among them, functional verification is mainly aimed at the execution result of the target SQL statement. Among them, the expected verification is used to determine whether the execution result of the target SQL statement meets the expectation, the abnormal verification is used to determine whether the execution result of the pre-constructed abnormal SQL statement contains the corresponding error code, and the standard database verification is used to compare the execution result of the target SQL statement in the current database with the execution result in the standard database.
[0045] In an embodiment of the present invention, the chaos SQL statement fully automated test system 100 further includes a test process verification module 104, which includes a functional verification unit 410, an execution plan verification unit 420, and a stability verification unit 430, which are respectively used to perform functional verification according to the execution result, perform execution plan verification according to the associated conditions, and perform stability verification according to the memory log. Among them, the functional verification unit 410 is connected to the statement execution node 230 in communication, and after obtaining the execution result of the target SQL statement from the statement execution node 230, the execution result is subjected to expected verification, abnormal verification, and standard database verification. Among them, the execution plan verification unit 420 is connected to the metadata node 210 in communication, and after obtaining the execution step of the target SQL statement through the execution plan parsing grammar, the target associated condition corresponding to the target SQL statement is obtained from the metadata node 210, and the execution step of the target SQL statement is conditionally judged and verified according to the target associated condition. Specifically, the execution step of the target SQL statement can be obtained from the statement execution node 230 through the explain grammar, and the execution step is conditionally judged and verified according to the push-down rule defined by the target associated condition. Among them, the stability verification unit 430 is communicated with the statement execution node 230, and after obtaining the memory log generated by the memory detection tool from the statement execution node 230, the memory log is analyzed to determine abnormal factors such as illegal reading and writing or memory leakage that cause system instability.
[0046] Optionally, the statistical log evaluation module 103 is specifically used to: parse the data features of the target SQL statement in the statistical log to determine the parsing result; determine the test coverage of the target SQL statement according to the parsing result, and send the test coverage as the evaluation result to the test configuration management module 101.
[0047] In an embodiment of the present invention, the statistical log evaluation module 103 can parse the data features of the target SQL statement in the statistical log based on the SQL condition, and obtain the parsing results including the function name used, the primary key data type, the partition sharding rule, the table index, etc. Afterwards, the test coverage rate of the target SQL statement can be determined by the open source test coverage analysis tool, and the test coverage rate can be sent to the test configuration management module 101 as the evaluation result, so that the test configuration management module 101 can adjust the test configuration file according to the evaluation result. Specifically, for the target SQL statement that has been covered, its probability in the probability configuration file is reduced, and the name of the corresponding function is annotated in the function configuration file; for the target SQL statement that has not been covered, its probability in the probability configuration file is increased, and the names of multiple corresponding functions are copied in the function configuration file. At the same time, for the construction of test data, the judgment of the value range, the judgment of the string length, the judgment of the time range, etc. can be adopted to dynamically adjust the random value range of the number-making function in the grammar configuration file according to the associated conditions stored in the metadata node 210. After the test configuration file is updated, the test task execution module 102 continues the test process according to the updated test configuration file to ensure the test coverage of the target SQL statement to the maximum extent.
[0048] Optionally, the statistical log evaluation module 103 is further used to determine the total number of target SQL statements based on the statistical log, and trigger a task fuse mechanism when the total number exceeds a preset threshold to terminate the test process.
[0049] In the embodiment of the present invention, the statistical log evaluation module 103 can also determine the total number of target SQL statements according to the statistical log, and trigger the task fuse mechanism when the total number exceeds the preset threshold, terminating the test process. Optionally, the number of a certain type of target SQL statements can also be determined according to the statistical log, and the task fuse mechanism is triggered when the number reaches the preset threshold, terminating the test process.
[0050] Based on the same inventive concept, the embodiment of the present invention also provides a chaotic SQL statement fully automated testing method. Figure 4 A flow chart of a fully automated chaotic SQL statement testing method provided by an embodiment of the present invention is shown in FIG. Figure 4 As shown, the method comprises the following steps:
[0051] S110, obtaining a test configuration file through a test configuration management module, and sending the test configuration file to a test task execution module;
[0052] S120, generating a target SQL statement according to the test configuration file through the test task execution module, and executing the target SQL statement; in the process of executing the target SQL statement, generating a statistical log including data features of the target SQL statement, and sending the statistical log to the statistical log evaluation module;
[0053] S130. Dynamically evaluate the statistical logs through the statistical log evaluation module, and send the evaluation results to the test configuration management module, so that the test configuration management module adjusts the test configuration file according to the evaluation results.
[0054] The chaotic SQL statement fully automated testing method provided by the embodiment of the present invention obtains a test configuration file through a test configuration management module, and sends the test configuration file to a test task execution module; generates a target SQL statement according to the test configuration file through the test task execution module, and executes the target SQL statement; in the process of executing the target SQL statement, generates a statistical log including the data features of the target SQL statement, and sends the statistical log to a statistical log evaluation module; dynamically evaluates the statistical log through the statistical log evaluation module, and sends the evaluation result to the test configuration management module, so that the test configuration management module adjusts the test configuration file according to the evaluation result. By dynamically evaluating the statistical log including the data features of the target SQL statement generated and executed by the test task execution module, and adjusting the test configuration file used to generate the target SQL statement according to the evaluation result, it is possible to dynamically adjust the test configuration through a forward feedback mechanism, thereby optimizing and adjusting the generation of the target SQL statement, so as to maximize the test coverage of the target SQL statement.
[0055] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.
Claims
1. A fully automated chaotic SQL statement testing system, characterized in that: The system includes: a test configuration management module, a test task execution module and a statistical log evaluation module; wherein, The test configuration management module is used to obtain a test configuration file and send the test configuration file to the test task execution module; The test task execution module is used to generate a target SQL statement according to the test configuration file and execute the target SQL statement; in the process of executing the target SQL statement, generate a statistical log including data features of the target SQL statement, and send the statistical log to the statistical log evaluation module; The statistical log evaluation module is used to dynamically evaluate the statistical log and send the evaluation result to the test configuration management module, so that the test configuration management module adjusts the test configuration file according to the evaluation result.
2. The system according to claim 1, characterized in that The test configuration file includes a function configuration file, a probability configuration file and a grammar configuration file; the test configuration management module includes a function configuration unit, a probability configuration unit and a grammar configuration unit, wherein: The function configuration unit is used to determine the function to be tested, and generate the function configuration file according to the input parameter data type and output parameter data type of the function to be tested; The probability configuration unit is used to determine the probability of the target SQL statement being generated, and generate the probability configuration file according to the probability; wherein the target SQL statement includes a DDL statement, a DQL statement, and a DML statement; The grammar configuration unit is used to generate grammar configuration files of the DDL statement and the DML statement based on the grouping rule and separation rule of the Backus-Naur form.
3. The system according to claim 1, characterized in that The test task execution module includes a metadata node, a statement generation node, a statement execution node, and a statement statistics node, wherein: The metadata node is used to determine the library table structure metadata, read the test configuration file from the test configuration management module, and send the library table structure metadata and the test configuration information in the test configuration file to the statement generation node; wherein the test configuration information includes probability, function rules and grammar rules; The statement generation node is used to generate the target SQL statement according to the library table structure metadata and the test configuration information, and send the target SQL statement to the statement execution node; The statement execution node is used to execute the target SQL statement and obtain the execution result of the target SQL statement; The statement statistics node is used to generate a statistics log including data features of the target SQL statement during the process of the statement execution node executing the target SQL statement.
4. The system according to claim 3, characterized in that The metadata node is also used to: Acquire the associated conditions fed back by the successfully executed target SQL statement from the statement execution node, and send the associated conditions to the statement generation node; The statement generates a node and is also used to: The target SQL statement is generated according to the library table structure metadata, the test configuration information and the association conditions in a preset order; wherein the preset order sequentially performs target SQL statements corresponding to the add, modify, query and delete operations on the database.
5. The system according to claim 4, characterized in that The statement generation node is specifically used for: Generate a DDL statement according to the library table structure metadata and the test configuration information; Generate a DQL statement according to the library table structure metadata, the test configuration information and the associated conditions of the successfully executed DDL statement feedback; A DML statement is generated according to the library table structure metadata, the test configuration information and the associated conditions fed back by the successfully executed DQL statement.
6. The system according to claim 3, characterized in that The execution results include a first execution result, a second execution result, and a third execution result, and the statement execution node includes a database client, a driver, and an executable file with a memory detection tool, wherein: The database client is used to directly execute the target SQL statement to obtain a first execution result of the target SQL statement; The driver is used to convert the target SQL statement into a character string based on a driver code rule corresponding to the driver, and execute the character string through the driver to obtain a second execution result of the target SQL statement; The executable file with the memory detection tool is used to execute the target SQL statement, obtain the third execution result of the target SQL statement, and generate a memory log about illegal reading and writing or memory leakage through the memory detection tool during the execution of the target SQL statement.
7. The system according to claim 6, characterized in that The system further includes a test process verification module, which includes a functionality verification unit, an execution plan verification unit, and a stability verification unit, wherein: The functional verification unit is used to obtain the execution result of the target SQL statement from the statement execution node, and perform expectation verification, exception verification and standard database verification on the execution result; The execution plan verification unit is used to obtain the execution steps of the target SQL statement through the execution plan parsing syntax, and obtain the target association condition corresponding to the target SQL statement from the metadata node connected to the statement execution node, and perform conditional judgment and verification on the execution steps according to the target association condition; The stability verification unit is used to obtain the memory log generated by the memory detection tool from the statement execution node, and analyze the abnormal factors that cause system instability based on the memory log.
8. The system according to claim 1, characterized in that The statistical log evaluation module is specifically used for: Analyze the data features of the target SQL statement in the statistical log to determine the analysis result; The test coverage of the target SQL statement is determined according to the parsing result, and the test coverage is sent to the test configuration management module as an evaluation result.
9. The system according to claim 1, characterized in that The statistical log evaluation module is also used for: The total number of the target SQL statements is determined according to the statistical log, and when the total number exceeds a preset threshold, a task fuse mechanism is triggered to terminate the test process.
10. A fully automated testing method for chaotic SQL statements, characterized in that: Applied to a fully automated testing system for chaotic SQL statements, the method comprises: Acquire a test configuration file through a test configuration management module, and send the test configuration file to the test task execution module; Generate a target SQL statement according to the test configuration file through the test task execution module, and execute the target SQL statement; in the process of executing the target SQL statement, generate a statistical log including the data features of the target SQL statement, and send the statistical log to the statistical log evaluation module; The statistical log is dynamically evaluated by the statistical log evaluation module, and the evaluation result is sent to the test configuration management module, so that the test configuration management module adjusts the test configuration file according to the evaluation result.