Database change capture tool automatic test method, system, equipment and medium
By expanding the PQS automated testing method, an automated testing method for database change capture tools is provided, which solves the problem of lack of a general automation testing framework in the existing technology, and realizes efficient performance verification and potential vulnerability detection of CDC tools.
Patent Information
- Application Number
- CN202510339884.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-21
- Publication Date
- 2025-04-18
AI Technical Summary
The prior art lacks a general and effective automated testing framework to verify the functionality and performance of database change capture (CDC) tools, especially in scenarios with multiple database types and complex data organization.
By expanding the automated testing method based on key row query synthesis (PQS), an automated testing method for database change capture tools is provided, including randomly initializing the library table structure in the source database, building the library table structure in the target database, randomly selecting feature row pairs, and combining test predictions to generate expressions that conform to semantic specifications to verify the correctness of database change capture tools.
It significantly improves the performance reliability of database change capture tools in high concurrency scenarios, and enhances the detection of potential vulnerabilities of modern database and data integration platforms.
Smart Images

Figure CN119848880A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer software technology, and in particular to an automated testing method, system, device and medium for a database change capture tool. Background Art
[0002] In recent years, technologies such as the Internet, the Internet of Things, and artificial intelligence have further accelerated the generation and accumulation of data. New data-based applications have put forward higher requirements for data organization and management, driving database services from traditional stand-alone models to cloud deployment, emerging data lakes, and data warehouses. This evolution has brought new challenges to the adaptability of database services and the development of automated testing tools, especially in dealing with multiple database types, complex data organization forms, and frequent data flows.
[0003] Automated testing technology originates from software engineering practice and continuous integration, and has formed a set of efficient testing methods. Compared with manual testing, which relies on manual operation, is inefficient and error-prone, automated testing modularizes the process and achieves high reuse and automation. It supports multiple programming languages (such as C, Java, Python), and can run on multiple platforms through frameworks (such as JUnit and Selenium). JUnit is an automated testing framework for the Java language, and Selenium is an open source tool set for testing Web applications (applications running on browsers) that supports multiple languages.
[0004] The "USENIX Operating System Design and Implementation Conference" published in 2020 and the "ACM International Conference on Data Management" published in 2023 both mentioned that in the database field, stand-alone database automation testing tools such as SQLSmith (SQL fuzzy query generator) and SQLancer (SQL semantic query generator) can effectively detect logical defects, boundary problems and performance bottlenecks of the database by automatically generating SQL (Structured Query Language) statements and logical verification. For example, SQLancer is based on PQS, TLP, and NoREC technical solutions, which can locate logical vulnerabilities in query results and crash failures that cause system downtime. These automated tools significantly improve testing efficiency and provide strong support for database security verification and performance optimization.
[0005] Database change capture (CDC) technology plays a key role in modern data architecture. Traditional full synchronization and batch processing modes (such as ETL tools) usually require periodic replication of part or all of the database to the target system, but in scenarios with huge data volumes and frequent changes, this method is prone to high latency and impact on external services. CDC tools achieve real-time or near-real-time data synchronization by capturing incremental changes in the database (such as insert, update, and delete operations), and perform well in improving data transmission efficiency and reducing system resource usage. However, there is currently a lack of a general and effective automated testing framework to verify the functions and performance of CDC tools. In particular, due to the diversity of stand-alone database system designs and the differences in incremental capture methods, data formats, and communication protocols among different databases, open source CDC tools such as Debezium (a distributed CDC tool), Flink CDC (a real-time data integration framework based on database log CDC technology), and TiCDC (TiDB incremental data synchronization tool, TiDB is a distributed relational database) are usually used as independent pipelines or bridges to connect different systems, rather than plug-ins for specific databases. This limitation makes it impossible for traditional automated testing frameworks for single databases to be directly applied to test database systems that integrate CDC tools. Therefore, designing automated tests for CDC tools has become one of the key challenges in the current database integration field.
[0006] In view of this, the present invention is proposed. Summary of the invention
[0007] The purpose of the present invention is to provide a method, system, device and medium for automated testing of a database change capture tool, aiming to expand the Pivoted Query Synthesis (PQS)-based automated testing method that has been proven effective on a single-machine database to detect potential vulnerabilities in modern database systems.
[0008] The objective of the present invention is achieved through the following technical solutions: An automated testing method for a database change capture tool, wherein the database change capture tool realizes synchronization from a source database to a target database, the method comprising: According to the given configuration information, determine the source database and target database versions associated with the database change capture tool to be tested, obtain the corresponding source database and target database, and start the database change capture tool; Randomly initialize the library and table structure in the source database, and build the library and table structure in the target database based on the data flow detected by the database change capture tool; Randomly select a row of data from the source database table, and find the corresponding row of data in the target database table, and use these two rows of data as a feature row pair; combined with the set test prediction, randomly construct an expression that can query the selected feature row pair and conform to the semantic specifications of the query language of the source database and the target database; Execute the corresponding expressions in the source database and the target database respectively, obtain the actual corresponding execution results, and determine the test results based on the execution results.
[0009] A database change capture tool automated testing system, used to implement the aforementioned method, comprising: A change capture tool monitoring module is used to determine the database change capture tool to be tested, start the database change capture tool and monitor the data flow detected by the database change capture tool, and monitor the activity of the database change capture tool itself; The database initialization module is used to determine the source database and target database versions according to the given configuration information, and obtain the corresponding source database and target database; and randomly initialize the library table structure in the source database, and build the library table structure in the target database according to the data flow detected by the database change capture tool; The test language management module is used to manage the types of test oracles and set test oracles in combination with configuration information; The automatic test case generation module is used to randomly select a row of data from the library table of the source database, find the corresponding row of data in the library table of the target database, and use these two rows of data as a feature row pair; combined with the set test prediction, randomly construct an expression that can query the selected feature row pair and conform to the semantic specifications of the query language of the source database and the target database; The result verification module is used to execute the corresponding expressions in the source database and the target database respectively, obtain the corresponding execution results, and determine the test results in combination with the execution results.
[0010] A processing device, comprising: one or more processors; a memory for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the aforementioned method.
[0011] A readable storage medium stores a computer program, which implements the above method when the computer program is executed by a processor.
[0012] It can be seen from the technical solution provided by the present invention that the initialization mechanism is based on the consistency of the state of the source database and the target database, the compatibility is guaranteed by using standardized statements, and the correctness of the database change capture tool is verified based on randomly constructed expressions for queries. The present invention significantly improves the performance reliability of the database change capture tool in high-concurrency scenarios, while enhancing the ability to detect potential vulnerabilities in modern databases and data integration platforms. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative work.
[0014] Figure 1 A flowchart of an automated testing method for a database change capture tool provided by an embodiment of the present invention; Figure 2 A schematic diagram of the relationship between a change event flow and data records provided by an embodiment of the present invention; Figure 3 A schematic diagram of an abstract syntax tree structure provided by an embodiment of the present invention; Figure 4 A schematic diagram of an automated testing system for a database change capture tool provided by an embodiment of the present invention; Figure 5 A schematic diagram of a processing device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0015] The following is a clear and complete description of the technical solutions in the embodiments of the present invention 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 are within the protection scope of the present invention.
[0016] First, the terms that may be used in this article are explained as follows: The terms "include", "comprises", "contains", "has" or other descriptions with similar semantics should be interpreted as non-exclusive inclusion. For example, including certain technical feature elements (such as raw materials, components, ingredients, carriers, dosage forms, materials, dimensions, parts, components, mechanisms, devices, steps, procedures, methods, reaction conditions, processing conditions, parameters, algorithms, signals, data, products or products, etc.) should be interpreted as including not only certain technical feature elements explicitly listed, but also other technical feature elements known in the art that are not explicitly listed.
[0017] The term "consisting of..." means excluding any technical feature elements not explicitly listed. If this term is used in a claim, it will make the claim closed, so that it does not contain technical feature elements other than the technical feature elements explicitly listed, except for the conventional impurities related to them. If this term only appears in a clause of a claim, it only limits the elements explicitly listed in the clause, and the elements recorded in other clauses are not excluded from the overall claim.
[0018] The following is a detailed description of an automated test method, system, device and medium for a database change capture tool provided by the present invention. The contents not described in detail in the embodiments of the present invention belong to the prior art known to professional and technical personnel in the field. If no specific conditions are specified in the embodiments of the present invention, the conventional conditions in the field or the conditions recommended by the manufacturer are followed. If the manufacturer of the instruments used in the embodiments of the present invention is not specified, they are all conventional products that can be purchased commercially.
[0019] Embodiment 1 An embodiment of the present invention provides an automated testing method for a database change capture tool, wherein the database change capture tool realizes synchronization from a source database to a target database, such as Figure 1 As shown, it mainly includes the following steps: Step 1: According to the given configuration information, determine the source database and target database versions associated with the database change capture tool to be tested, obtain the corresponding source database and target database, and start the database change capture tool.
[0020] Step 2: Randomly initialize the library table structure in the source database, and build the library table structure in the target database according to the data flow detected by the database change capture tool, so that the library table structure of the source database is semantically consistent with the library table structure of the target database.
[0021] Step 3: Randomly select a row of data from the database table of the source database, and find the corresponding row of data in the database table of the target database, and use these two rows of data as a feature row pair for verification; combined with the set test oracle, randomly construct an expression that can query the selected feature row pair and conform to the semantic specifications of the query language of the source database and the target database.
[0022] Step 4: Execute the corresponding expressions in the source database and the target database respectively, obtain the actual corresponding execution results, and determine the test results based on the execution results.
[0023] Preferably, randomly initializing the library table structure in the source database, and constructing the library table structure in the target database according to the data flow detected by the database change capture tool includes: 1) randomly generating the library table structure in the source database to obtain the corresponding library table; 2) capturing the state data changes initialized by the source database through the database change capture tool, and synchronizing them to the target database, and constructing the library table structure corresponding to the target database through the data flow of the database change capture tool.
[0024] Preferably, the randomly constructed expression that can query the selected feature row pairs and conform to the semantic specifications of the query language of the source database and the target database includes: utilizing the feature row pairs to randomly construct two semantically equivalent abstract syntax trees, each corresponding to an expression supported by the syntax of the source database and the target database, wherein the expressions are constructed in combination with logical operators and comparison operators, covering a variety of logical conditions and query scenarios; wherein, the abstract syntax tree corresponding to the source database is first constructed, and then the dialect mapping is implemented through the syntax conversion rules to obtain the abstract syntax tree corresponding to the target database.
[0025] Preferably, after randomly constructing the semantically compliant expression corresponding to the feature row pair, it also includes: correcting the expression so that after the source database and the target database execute the corresponding corrected expression, the final returned value is TRUE, and the TRUE indicates that the calculation result is a true value, which formally guarantees that the output result set should contain the specified rows randomly selected in advance.
[0026] Preferably, the combining the execution results to determine the test results comprises: recording the characteristic row pairs as<r0,r1> , where r0 is a row of data randomly selected from the source database, and r1 is the corresponding row of data in the target database. The data in the feature row pair is uniquely corresponding; the execution result of the source database is the result set rs0, and the execution result of the target database is the result set rs1; if r0 ∈ rs0 and r1 ∈ rs1, the test passes; otherwise, the test fails, indicating that a vulnerability is detected in the source database, the database change capture tool, the target database, or the link between the three.
[0027] Preferably, the method further includes: recording expressions generated during the test process, as well as test results, and generating log records; when the test results indicate the existence of a vulnerability, performing an exception analysis in combination with the log records to locate the cause of the vulnerability.
[0028] In order to more clearly demonstrate the technical solution and technical effects provided by the present invention, the method provided by the embodiment of the present invention is described in detail below using a common open source change capture tool Debezium to synchronize a MySQL source database (a relational database management system) to a PostgreSQL target database (an object-relational database management system) for automated testing as a specific example.
[0029] 1. Database initialization and change data capture tool monitoring.
[0030] Before the test begins, a configuration file is given, and the source database and target database specified in the configuration file are pulled for connection testing; afterwards, the two distributed middleware Kafka and Zookeeper services that Debezium depends on can be built and started according to the database change capture tool (hereinafter referred to as CDC tool) and version specified in the configuration. The module will automatically check the service status, configure and start the Debezium connector, and specify the source database and capture rules. At the same time, the import connector for injecting pipeline data into the target database is synchronously built. After the status of the relevant components of the CDC tool is ready, the initialization work can begin.
[0031] In the embodiment of the present invention, the source database and the target database with the same random initialization state can use a unified DDL (Database Definition Language) subset to define the library table structure of the source database and the target database, and create corresponding library tables T0 and T1.
[0032] Specifically: In order to ensure the consistency of the mode of the initial state of the source database and the target database, it is first necessary to use standardized DDL statements to define the library table structure to ensure that the library table structure can be correctly parsed and applied in both databases to avoid false positives caused by undefined behavior or unsupported functions. The DDL syntax must be the intersection of the syntax supported by the source database, the target database and the CDC tool. The present invention defines a set of unified DDL subsets and corresponding syntax conversion rules as the trust basis for test operations. After the table structure definition is completed, the state of the source database table can be initialized by serial random data insertion operations to obtain the library table T0. The CDC tool captures the data changes initialized by the source database and synchronizes it to the target database, thereby constructing the corresponding library table T1. Since this process only includes simple insertion operations, it can be approximately regarded as a basic full synchronization operation. In this process, the CDC tool ensures the consistency of the source database and the target database in table structure and data status.
[0033] Preferably, the process of capturing the data changes initialized by the source database and synchronizing them to the target database by the CDC tool can be implemented in the following way: automatically registering the CDC task, initiating a configuration request through the Representational State Transfer (REST) interface, specifying the connection to be used, the data to be captured, and the library table T0, so as to achieve the change capture of the source database and the real-time synchronization of the target database. At this time, the mapping corresponding mechanism and the injection data connector are ready to read the subsequent captured change logs and perform corresponding operations.
[0034] 2. Automatic test case generation.
[0035] (1) Randomly select pairs of rows to establish the test basis.
[0036] In order to further ensure the data consistency of the initial state of the source database and the target database, and lay the foundation for generating expressions for subsequent tests, the present invention designs a row mapping correspondence mechanism (Pair Row Insurance). This mechanism ensures that each row of data in the source table and the target table can be uniquely corresponded by parsing the synchronization log or event stream of the CDC tool. The existence of the mapping relationship not only ensures the consistency of the source database and the target database after full synchronization, but also verifies the correctness of the simple full synchronization performed by the CDC tool in the first step. After the row mapping relationship is established, a specific row pair (pivot row pair) will be randomly selected from the source database and the target database as the basis for the test. For example, row r0 is extracted from the source table T0, and the corresponding row r1 is extracted from the target table T1.<r0,r1> As a verification line pair, this line pair serves as the basis for the subsequent generation of test expressions, waiting to be used as input for the subsequent expression generation process based on the abstract syntax tree.
[0037] This part can be completed by the automatic test case generation module. Before selecting row pairs, the module is initialized and the source database is randomly filled. Take the following insert statement as an example. Assume that the schema of the randomly created library table T0 in step 1 above contains the primary key id, variable-length string s0, variable-length string s1 and integer i0. Here, three data that conform to the database schema definition are randomly inserted, INSERT INTO T0 (id, s0, s1, i0) VALUES inserts (1, 'Alice', 'Melo', 25), (2, 'Bob', 'Smith', 30), (3, 'Jack', 'Johns', 35). The above is only an example. In the actual operation process, the string and integer are random quantities without practical meaning; INSERT INTO T0 (id, s0, s1,i0) VALUES here means inserting the corresponding value into (id, s0, s1, i0).
[0038] The source database's table T0 inserts data serially, and the CDC tool generates a change log stream. The target database consumes these change log streams to update the state of the table T1 and obtain new data. The tool parses and records the randomly inserted data in the source database's table, the changed data in the target database, the change log stream id and offset tuples in this section, and outputs them to the trace log trace.log in the form of additional logs.
[0039] In the above example, the random row pair selection component in the automated test case generation module randomly selects a feature row pair based on the source database, the relationship recorded in the trace log trace.log, and the target database.<r0,r1> , suppose this time we randomly select a row (3, 'Jack', 'Johns', 35) from the source database, such as Figure 2 As shown in the figure, in the trace log trace.log, the change log stream id (lid) points to a log record in which the before field (indicating the data before the event) is Null, and the after field (indicating the data after the event) is {"id": 3, "s0": "'Jack'", "s1": "Johns" ...}. The source database primary key value (sid) points to the r0 data row in the feature row pair. The target database primary key value (tid) points to the r1 data row in the feature row pair.
[0040] Figure 2 The information in the change log stream and tracking log shown is information that can be understood by those skilled in the art in combination with the prior art. Since the content of different streams of the selected database is also different, it is impossible to fully explain it line by line. Therefore, only some content examples and related explanations are provided here.
[0041] (2) Generate an expression that conforms to the semantic specification based on the selected feature row pairs.
[0042] After selecting the row pairs, the present invention applies the principle similar to the PQS (Pivoted Query Synthesis) method to generate semantically standardized expressions. The core idea is to construct a main query that is expected to be included in the result set. The conditions in the query (such as WHERE and / or JOIN clauses) can be automatically generated to construct a large number of query instances. In the present invention, starting from the selected row pairs, two semantically equivalent AST trees (abstract syntax trees) are randomly constructed, corresponding to the expressions supported by the syntax of the source database and the target database respectively. These expressions are constructed in combination with logical operators (such as AND, OR, NOT) and comparison operators (such as >, <, =), covering a variety of possible logical conditions and query scenarios.
[0043] In the embodiment of the present invention, the following improvement scheme is provided: (2.1) Adapting to different database dialects: When the source database and the target database are isomorphic, two semantically equivalent AST trees are simplified to generate one AST tree. At this time, the subsequent test process is weakened to the PQS test of the stand-alone database system. In general, the source database and the target database of the database system framework of the integrated CDC tool tested are different. The present invention realizes dialect mapping by establishing conversion rules, and automatically adapts the functions and operators supported by the database during the AST tree generation process.
[0044] (2.2) Lightweight expression generation: The AST and transformation rules implemented by the present invention are simpler than the AST interpreter of the programming language, and are also simpler than the general database query engine model (such as the Volcano-style iteration model). There is no need to consider optimization at this stage, and there is no need to consider variable storage, and only literal values are operated. (For example, vectorized models or data-centric code generation models need to consider multi-line situations). In the specific implementation process, the expression generation AST can be incrementally expanded to gradually support more operation symbols, because a small number of symbols can already support the application of PQS rules to automatically generate a large number of test cases, and only the conditional part needs to be evaluated to obtain TRUE (true value) or FALSE (false value).
[0045] (2.3) Expression correction: After generating random expressions, it is necessary to ensure that the final return value of these expressions is TRUE when executed. This is the core requirement of PQS testing and is used to verify the semantic consistency of the source and target databases. However, since SQL uses a three-valued logic system (TRUE, FALSE, NULL), when expressions are evaluated in a Boolean context, they may produce unexpected results. The tool will correct / fill the expressions. In this process, in order to correct the generated expressions to return TRUE, the corresponding expressions of the source and target databases will be synchronously corrected until both evaluate to TRUE and can be used in the WHERE clause, thereby semantically ensuring that the result sets of the two queries contain their respective feature rows (pivot rows).
[0046] In the same way as in the above example, based on the selected row pair r0 = (3, 'Jack', 'Johns', 35), r1 = (3, 'Jack', 'Johns', 35), the random expression generation component of the automated test case generation module randomly constructs two semantically equivalent AST trees based on the selected row pair. In this example, assuming that the AST tree randomly constructed for the source database MySQL syntax generates the expression CONCAT(s0, ' ', s1) = 'Jack Johns' AND i0 > 30.
[0047] Combining the dialect mapping and grammar conversion rules provided by the present invention, an AST tree corresponding to the grammar of the target database PostgreSQL is obtained, such as Figure 3 The corresponding expression is, s0 || ' ' || s1 = 'Jack Johns' AND i0 > 30.
[0048] In the above construction process, the expression correction component will also be used to correct the expression to ensure that the final static evaluation result is TRUE, and the generated expression can return a TRUE value when executed as a WHERE clause. If the generated expression cannot meet the expected result, the AST will be automatically regenerated and corrected to meet the query conditions (that is, the returned value is TRUE).
[0049] 3. Execution and result verification.
[0050] In the embodiment of the present invention, the query statement (i.e., the expression corrected in the above text) is executed in the source database and the target database respectively, and verification is performed. For example, the row pair selected in the second step is<r0,r1> , construct expressions based on row pairs and modify them to build query expressions Qs(r0) and Qt(r1) that meet the specifications. Qs is used for the source database, and Qt is used for the target database. The execution results are rs0 and rs1 respectively, which should satisfy r0 ∈ rs0 and r1 ∈ rs1.
[0051] In the embodiment of the present invention, it is possible to configure to directly verify whether the two result sets rs0 and rs1 are equal. Because the property of r0 ∈ rs0 is guaranteed by the correctness of the source database in a single machine, when this condition is accepted, the present invention only focuses on the possible vulnerabilities of the CDC tool and its related modules. At this time, the equality of the result sets implies that the characteristic row pairs belong to the two result sets. In each round of testing, when the verification fails, it is considered that a vulnerability is detected, and a detailed report is further output to the log for analysis. After a round of testing is completed, it is determined whether to adjust the table structure or data distribution according to the configuration, and the next round of testing is started.
[0052] Combining the above examples, the corrected expressions are as follows, corresponding to the source database (SourceExpression) and the target database (Target Expression) respectively: [Source Expression] SELECT * FROM T0 WHERE CONCAT(s0, ' ', s1) = 'Jack Johns' AND i0 > 30; [Target Expression] SELECT * FROM T1 WHERE s0 || ' ' || s1 = 'JackJohns' AND i0 > 30; The corresponding result sets are denoted as rs0 and rs1.
[0053] Verify the following conditions: whether the result set of the source database contains r0, that is, r0 ∈ rs0, whether the result set of the target database contains r1 ∈ rs1, and (optionally) whether the result sets are equal rs0 == rs1.
[0054] According to the analysis and records of the verification results, if: [Validation Result] Source Result Set: [(3, 'Jack', 'Johns', 35)] Target Result Set: [(3, 'Jack', 'Johns', 35)] Validation Status: PASS This means the test has passed (PASS), and this round of testing is over. The configuration determines whether to reset the database, and the automatic test case generation module continues to generate and test the next random test case.
[0055] If you get: [Validation Result] Source Result Set: [(3, 'Jack', 'Johns', 35)] Target Result Set: [] Validation Status: BUG If the test fails, the detailed table structure, initial state, extracted row pairs, AST tree and expression, and related logs of this round of construction are output to the error log directory (bug-report-timestamp) and marked as a suspected vulnerability (BUG).
[0056] The four lines in each of the two parts of the verification results represent the following meanings: verification result, result set of source database, result set of target database, and verification status (including pass or vulnerability).
[0057] Considering that the logical operators listed in the text of the embodiments of the present invention and the drawings are all common symbols in the art (for example, || is a logical OR operator), their meanings can also be understood in conjunction with the prior art, so they are not elaborated herein.
[0058] In the embodiment of the present invention, supporting log recording and exception analysis steps are also included, which are mainly responsible for recording key data and exception information during the test process, and providing automatic analysis and report generation functions. Log recording is responsible for comprehensively recording the generation, modification and query results of SQL expressions during the test process, capturing abnormal situations found during the execution process (such as unsupported syntax, inconsistent result sets, etc.), and exception analysis generates detailed diagnostic reports based on logs to help testers locate vulnerabilities.
[0059] The above solution provided by the embodiment of the present invention supports multi-threaded testing. In order to prevent different test threads from modifying the same table, threads and table names are marked for division. At the same time, through the description of the above implementation methods, technicians in this field can clearly understand that the present invention is also applicable to different database systems (such as MySQL, PostgreSQL, Oracle, etc.) and mainstream change data capture tools (such as Debezium, Flink CDC, TiCDC, etc.), providing general testing support for various data management scenarios.
[0060] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above embodiments can be implemented by software, or by means of software plus necessary general hardware platforms. Based on such understanding, the technical solutions of the above embodiments can be embodied in the form of software products, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.), including several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in the various embodiments of the present invention.
[0061] Embodiment 2 The present invention also provides a database change capture tool automated testing system, which is mainly used to implement the method provided in the above embodiment, such as Figure 4 As shown, the database change capture tool realizes the synchronization from the source database to the target database, and the three of them constitute the database system to be tested. The database change capture tool automated testing system provided by the embodiment of the present invention mainly includes: a change capture tool monitoring module, a database initialization module, a test language management module, an automated test case generation module and an execution and result verification module.
[0062] (1) A change capture tool monitoring module is used to determine the database change capture tool to be tested based on given configuration information, start the database change capture tool and monitor the data flow detected by the database change capture tool, and monitor the activity of the database change capture tool itself.
[0063] In the specific implementation process, the following can be configured internally: managing the CDC tool dependency environment component, which is used to detect the CDC tool dependency environment, thereby starting the database change capture tool; the CDC tool heartbeat detection component, which detects whether the database change capture tool is working normally; the CDC task registration component, which is used to register tasks, thereby monitoring the database change capture tool.
[0064] (2) Database initialization module, used to determine the source database and target database versions according to the given configuration information, and obtain the corresponding source database and target database; and randomly initialize the library table structure in the source database, and build the library table structure in the target database according to the data flow detected by the database change capture tool, so that the library table structure of the source database is semantically consistent with the library table structure of the target database. The module stores the configuration file internally, so that before the test starts, the source database and target database specified in the configuration file are pulled and connected for testing.
[0065] (3) Test oracle management module, which is used to manage the types of test oracle and set up test oracle in combination with configuration information.
[0066] The following can be configured internally: test oracle selector, which is used to set the specified test oracle; test expression generation logic, which is responsible for defining the expression generation logic. The subsequent randomly constructed expression is determined by the logic defined here.
[0067] (4) An automated test case generation module is used to randomly select a row of data from the source database’s table, construct a tracking log to find the corresponding row of data in the target database’s table, and use the two rows of data as a feature row pair for verification; combined with the set test prediction, it randomly constructs an expression that can query the selected feature row pair and conforms to the semantic specifications of the source and target database query languages.
[0068] In the specific implementation process, the following components can be configured internally: random row pair selection component, random expression generation component and expression correction component. The specific work contents of the above three components can be found in the introduction of the above embodiments, which will not be repeated here.
[0069] (5) Result verification module, which is used to execute the corresponding expressions in the source database and the target database respectively, obtain the corresponding execution results, and determine the test results based on the execution results.
[0070] During the specific implementation process, the following can be configured internally: a vulnerability determination component, which makes determinations based on test results; and a cyclic test management component, which is responsible for initiating multiple rounds of testing.
[0071] Similarly, the system will also configure corresponding modules to complete the log recording and exception analysis steps. Specifically, the log module is used to record the change log stream, and the exception analysis module is configured to perform exception analysis. Specifically, the exception configuration analysis module can also configure the SQL statement refinement tool and the crash exception capture component.
[0072] Considering that the specific tasks of each module of the system have been introduced in detail in the previous embodiments, they will not be repeated here.
[0073] Technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the system can be divided into different functional modules to complete all or part of the functions described above.
[0074] Embodiment 3 The present invention also provides a processing device, such as Figure 5 As shown, it mainly includes: one or more processors; a memory for storing one or more programs; wherein, when the one or more programs are executed by the one or more processors, the one or more processors implement the methods provided in the aforementioned embodiments.
[0075] Furthermore, the processing device also includes at least one input device and at least one output device; in the processing device, the processor, memory, input device, and output device are connected via a bus.
[0076] In the embodiment of the present invention, the specific types of the memory, input device and output device are not limited; for example: The input device may be a touch screen, an image acquisition device, a physical button or a mouse, etc.; The output device may be a display terminal; The memory may be a random access memory (RAM) or a non-volatile memory such as a disk storage.
[0077] Embodiment 4 The present invention also provides a readable storage medium storing a computer program, which implements the method provided in the above embodiment when the computer program is executed by a processor.
[0078] In the embodiment of the present invention, the readable storage medium as a computer-readable storage medium can be set in the aforementioned processing device, for example, as a memory in the processing device. In addition, the readable storage medium can also be a U disk, a mobile hard disk, a read-only memory (ROM), a disk or an optical disk, etc., which can store program codes.
[0079] The above is only a preferred specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by any technician familiar with the technical field within the technical scope disclosed in the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims. The information disclosed in the background technology section of this article is only intended to deepen the understanding of the overall background technology of the present invention, and should not be regarded as an admission or in any form that the information constitutes prior art known to those skilled in the art.
Claims
1. An automated testing method for a database change capture tool, wherein the database change capture tool realizes synchronization from a source database to a target database, characterized in that: include: According to the given configuration information, determine the source database and target database versions associated with the database change capture tool to be tested, obtain the corresponding source database and target database, and start the database change capture tool; Randomly initialize the library and table structure in the source database, and build the library and table structure in the target database based on the data flow detected by the database change capture tool; Randomly select a row of data from the source database table, and find the corresponding row of data in the target database table, and use these two rows of data as a feature row pair; combined with the set test prediction, randomly construct an expression that can query the selected feature row pair and conform to the semantic specifications of the query language of the source database and the target database; Execute the corresponding expressions in the source database and the target database respectively, obtain the actual corresponding execution results, and determine the test results based on the execution results.
2. The automated testing method for a database change capture tool according to claim 1, characterized in that: The randomly initializing the library table structure in the source database and constructing the library table structure in the target database according to the data flow detected by the database change capture tool includes: In the source database, randomly generate a library table structure to obtain the corresponding library table; The database change capture tool is used to capture the initial status data changes of the source database and synchronize them to the target database. Then, the database change capture tool's data flow is used to build the library and table structure corresponding to the target database.
3. The automated testing method for a database change capture tool according to claim 2, characterized in that: The method of capturing the initialization state data changes of the source database by using the database change capture tool and synchronizing the data changes to the target database includes: Automatically register database change capture tasks, initiate configuration requests through the row state transfer interface, specify the connection to be used, the data to be captured, and the library tables of the source database, and realize change capture of the source database and real-time synchronization of the target database.
4. The automated testing method for a database change capture tool according to claim 1, characterized in that: The randomly constructed expressions that can query the selected feature row pairs and comply with the semantic specifications of the source database and target database query languages include: Using feature row pairs, two semantically equivalent abstract syntax trees are randomly constructed, each corresponding to the expressions supported by the syntax of the source database and the target database. The expressions are constructed by combining logical operators and comparison operators, covering a variety of logical conditions and query scenarios. Among them, the abstract syntax tree corresponding to the source database is first constructed, and then the dialect mapping is implemented through the syntax conversion rules to obtain the abstract syntax tree corresponding to the target database.
5. The automated testing method for a database change capture tool according to claim 1 or 4, characterized in that: After randomly constructing the expression that meets the semantic specification corresponding to the feature row pair, the method further includes: correcting the expression so that after the source database and the target database execute the corresponding corrected expression, the final returned value is TRUE, and the TRUE indicates that the calculation result is a true value.
6. The automated testing method for a database change capture tool according to claim 1, characterized in that: Determining the test result in combination with the execution result includes: The feature row pairs are denoted as<r0,r1> , where r0 is a row of data randomly selected from the source database, r1 is the corresponding row of data in the target database, and the data in the feature row pair is uniquely corresponding; The execution result of the source database is result set rs0, and the execution result of the target database is result set rs1; If r0 ∈ rs0 and r1 ∈ rs1, the test passes; otherwise, the test fails.
7. The automated testing method for a database change capture tool according to claim 1 or 6, characterized in that: Also includes: Record the expressions generated during the test, as well as the test results, and generate log records; When the test results indicate the existence of a vulnerability, perform an exception analysis in conjunction with the log records to locate the cause of the vulnerability.
8. A database change capture tool automated testing system, characterized in that: The method for implementing any one of claims 1 to 7 comprises: A change capture tool monitoring module is used to determine the database change capture tool to be tested, start the database change capture tool and monitor the data flow detected by the database change capture tool, and monitor the activity of the database change capture tool itself; The database initialization module is used to determine the source database and target database versions according to the given configuration information, and obtain the corresponding source database and target database; and randomly initialize the library table structure in the source database, and build the library table structure in the target database according to the data flow detected by the database change capture tool; The test language management module is used to manage the types of test oracles and set test oracles in combination with configuration information; The automatic test case generation module is used to randomly select a row of data from the library table of the source database, find the corresponding row of data in the library table of the target database, and use these two rows of data as a feature row pair; combined with the set test prediction, randomly construct an expression that can query the selected feature row pair and conform to the semantic specifications of the query language of the source database and the target database; The result verification module is used to execute the corresponding expressions in the source database and the target database respectively, obtain the corresponding execution results, and determine the test results in combination with the execution results.
9. A processing device, characterized in that: include: one or more processors; A memory for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 7.
10. A readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Log-based heterogeneous database synchronization method
CN118069667A
SQL statement generation method and device, computer equipment and storage medium
CN118568123A
Database testing method and device and program product
CN118585458A
System, method and computer program product for database change management
US10268709B1