A data synchronization test method for RTSync file source and file target
By parsing the mapping configuration file between the database source and target, establishing an RTSync tool link and comparing the data table, the problem of the lack of automated testing of the RTSync tool is solved, automated data synchronization testing from the file source to the file target is realized, and testing efficiency is improved. and coverage.
Patent Information
- Application Number
- CN202410897278.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-05
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2044-07-05
AI Technical Summary
Existing RTSync synchronization tools lack automated testing tools. In particular, it is difficult to automatically compare the binary file synchronization results of the file source and file destination, making it inconvenient to check the synchronization results.
Provides a data synchronization test method for RTSync file source and file target. By parsing the mapping configuration file between the database source and target, creating the database and data table, establishing RTSync tool deployment files for the two links, and executing services through these tools. data, and finally compare the data tables of the target library and the source library to obtain test results and implement automated testing.
Automated testing of data synchronization from file source to file target is realized, which improves the scale, efficiency and coverage of the test, and ensures the accuracy and automated comparison of synchronization results.
Smart Images

Figure CN118427111B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of synchronization tool testing, and in particular to a data synchronization testing method for an RTSync file source and a file target end. Background Art
[0002] The RTSync tool is a software tool used for synchronization, mainly used for synchronization of multiple data sources, including database sources, Kafka sources and file sources.
[0003] However, there is no corresponding automated testing tool for the synchronization tool, and it is impossible to achieve automatic comparison of the results, especially since both the file source and the file target are binary files, which makes it inconvenient to check the synchronization results. Summary of the invention
[0004] The present invention aims to solve at least one of the technical problems existing in the related art. To this end, the present invention provides a data synchronization test method for an RTSync file source and a file target.
[0005] The present invention provides a data synchronization test method for an RTSync file source and a file target end, comprising:
[0006] S1: Parse the mapping configuration file between the database source and the database target, and create a database and data table based on the source and target libraries obtained by parsing;
[0007] S2: Establish a first link from the source library to the file target end and a second link from the file source end to the target library, and create a deployment file of the first RTSync tool and a deployment file of the second RTSync tool respectively according to the mapping configuration file of the first link and the mapping configuration file of the second link;
[0008] S3: deploy and start the first RTSync tool and the second RTSync tool;
[0009] S4: Execute the service data through the first RTSync tool and the second RTSync tool to obtain an execution result;
[0010] S5: Compare the target library data table of the target library in the execution result with the source library data table of the source library to obtain a test result.
[0011] According to a data synchronization test method for an RTSync file source and a file target provided by the present invention, the database in step S1 includes a source database and a target database; the data table in step S1 includes a source library data table of the source database and a target library data table of the target database.
[0012] According to a data synchronization test method for an RTSync file source and a file target provided by the present invention, the source database and the target database are both created through a JDBC driver; the source library data table and the target library data table are both connected to the corresponding database through an SSH connection tool to execute test case file creation.
[0013] According to a data synchronization test method for an RTSync file source and a file target provided by the present invention, the synchronization mechanism of the first link in step S2 is:
[0014] S211: When there is data change in the source library, the changed data is obtained by reading through the reading end component;
[0015] S212: Cache the changed data into a message queue;
[0016] S213: The message queue writes the changed data to the file target end through the write-end component.
[0017] According to a data synchronization test method for an RTSync file source and a file target provided by the present invention, the synchronization mechanism of the second link in step S2 is:
[0018] S221: When there is data to be synchronized in the consumption path specified by the file source, the data to be synchronized is obtained by reading through the reading end component;
[0019] S222: Cache the data to be synchronized into a message queue;
[0020] S223: The message queue writes the data to be synchronized into the target library through the write-end component.
[0021] According to a data synchronization test method for an RTSync file source and a file target provided by the present invention, the business data in step S4 is a test case, and the test case includes:
[0022] Write concurrent write tests, single-threaded write tests, file breakpoint resume tests, zookeeper breakpoint resume tests, idempotence tests, case sensitivity tests and data type tests.
[0023] According to a data synchronization test method for an RTSync file source and a file target provided by the present invention, in step S4, both the first RTSync tool and the second RTSync tool are connected to a database through an SSH connection tool to implement business data execution.
[0024] According to a data synchronization test method for an RTSync file source and a file target provided by the present invention, step S5 specifically includes:
[0025] When each field of the target database data table in the execution result is consistent with that of the source database data table, the test result is that the test is passed;
[0026] When any field of the target database data table in the execution result is inconsistent with that of the source database data table, the test result is test failure.
[0027] The present invention provides a method for testing data synchronization between an RTSync file source and a file target end. The method tests data synchronization from a file source to a file target end through two links. The first link is a synchronization test from a database source to a file target end, and the second link is a synchronization test from a file source to a database target end. Subsequently, the database source of the first link and the database target end of the second link are used to verify the results of the data in the two databases.
[0028] For the source data acquisition problem, the present invention adopts database source to file target end test, actively generates files, and then uses the generated files as source data to test the file source to the database target end, indirectly completing the file source to file target end test, and indirectly comparing the source file and the target file by comparing the data of the database source with the data of the database target end; for realizing automated testing, a program is written in java to realize the generation of data tables in the source library and the target library, the configuration and startup of RTSync, the execution of test cases and the comparison of results, thereby realizing the automation of database synchronization testing and ensuring the scale, efficiency and coverage of the test.
[0029] Additional aspects and advantages of the present invention will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0031] Figure 1 The present invention provides a flow chart of a data synchronization test method for an RTSync file source and a file target.
[0032] Figure 2 It is a flow chart of the synchronization mechanism of the first link provided by an embodiment of the present invention.
[0033] Figure 3 It is a flow chart of the synchronization mechanism of the second link provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0034] In order to make the purpose, technical scheme and advantages of the present invention clearer, the technical scheme of the present invention will be clearly and completely described below in conjunction with the drawings in the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present invention. The following embodiments are used to illustrate the present invention, but cannot be used to limit the scope of the present invention.
[0035] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the embodiment of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.
[0036] Combine the following Figures 1 to 3 Embodiments of the present invention are described.
[0037] like Figure 1 As shown, the present invention provides a data synchronization test method for an RTSync file source and a file target, comprising:
[0038] S1: Parse the mapping configuration file between the database source and the database target, and create a database and data table based on the source and target libraries obtained by parsing;
[0039] In this phase, the configuration files of the database source and database target mapping are parsed first, and then the databases and data tables of the database source and database target are created.
[0040] The database in step S1 includes a source database and a target database; the data table in step S1 includes a source database data table of the source database and a target database data table of the target database.
[0041] Among them, the source database and the target database are both created through JDBC driver; the source database data table and the target database data table are both connected to the corresponding database through SSH connection tool to execute test case file creation.
[0042] Specifically, in step S1, first, according to the configuration file of the database source and database target mapping, the source library and target library for data synchronization are obtained, and the source database and the target database are created through the JDBC driver; secondly, the source database is connected through SSH, the test case file is executed, and the data table in the source library is created; then, the target database is connected through SSH, the test case file is executed, and the data table in the target library is created.
[0043] S2: Establish a first link from the source library to the file target end and a second link from the file source end to the target library, and create a deployment file of the first RTSync tool and a deployment file of the second RTSync tool respectively according to the mapping configuration file of the first link and the mapping configuration file of the second link;
[0044] In this stage, we use the database source to the file target end, that is, the first link, and then the file source to the database target end, that is, the second link. Then we generate the RTSync tool configuration file based on the two links and upload it to the deployment tool to facilitate the subsequent deployment of two sets of RTSync.
[0045] like Figure 2 As shown, the synchronization mechanism of the first link in step S2 is:
[0046] S211: When there is data change in the source library, the changed data is obtained by reading through the reading end component;
[0047] S212: Cache the changed data into a message queue;
[0048] S213: The message queue writes the changed data to the file target end through the write-end component.
[0049] like Figure 3 As shown, the synchronization mechanism of the second link in step S2 is:
[0050] S221: When there is data to be synchronized in the consumption path specified by the file source, the data to be synchronized is obtained by reading through the reading end component;
[0051] S222: Cache the data to be synchronized into a message queue;
[0052] S223: The message queue writes the data to be synchronized into the target library through the write-end component.
[0053] Specifically, first in the first link, data changes occur at the database source end. After the RTSync read-end component captures the changed data, it temporarily caches the data in the middleware kafka. The RTSync write-end component then writes the synchronized content into the file. Then in the second link, after the file to be synchronized appears in the specified path, the RTSync read-end component captures it and also temporarily caches the data in the middleware kafka. The RTSync field component then writes the synchronized content into the target database.
[0054] S3: deploy and start the first RTSync tool and the second RTSync tool;
[0055] These two links require the deployment of two sets of RTSync:
[0056] In the first link, parse the mapping configuration file from database source to file target, generate the RTSync tool main configuration file config_task.xml from database source to file target, generate the RTSync tool main configuration file config_kafka_8tto8tMQ.properties and config_zookeeper.properties configuration files from database source to file target; upload the three configuration files from database source to file target to the corresponding path of RTSync server.
[0057] In the second link, parse the mapping configuration file from the file source to the database target, generate the main configuration file config_task.xml of the RTSync tool from the file source to the database target. Note that this file source uses the file generated by the file target source described above; generate the main configuration file config_kafka_8tto8tMQ.properties and config_zookeeper.properties of the RTSync tool from the file source to the database target; upload the three configuration files from the file source to the database target to the corresponding path of the RTSync server.
[0058] S4: Execute the service data through the first RTSync tool and the second RTSync tool to obtain an execution result;
[0059] The business data in step S4 is a test case, and the test case includes:
[0060] Write concurrent write tests, single-threaded write tests, file breakpoint resume tests, zookeeper breakpoint resume tests, idempotence tests, case sensitivity tests and data type tests.
[0061] During the specific execution process, the test cases executed are business test scripts such as concurrent writing test, single-threaded writing test, file breakpoint resumption test, zookeeper breakpoint resumption test, idempotence test, case sensitivity test and data type test. They only need to be written for the first time. When the business is updated, the use case script content is increased as needed, avoiding the need to rewrite the test cases for each test.
[0062] Wherein, in step S4, both the first RTSync tool and the second RTSync tool are connected to the database through the SSH connection tool to implement business data execution.
[0063] During the specific execution process, the database is connected through SSH, and the above test cases are executed at the database source end of the first link. Since the file source in the second link uses the file generated by the file target source in the first link, after the first link generates the file, the RTSync reader in the second link can immediately mine the data and then synchronize it to the target database. After the above process is completed, it sleeps for a while. After the data is synchronized, the RTSync tools in the first link and the second link are stopped.
[0064] S5: Compare the target library data table of the target library in the execution result with the source library data table of the source library to obtain a test result.
[0065] Wherein, step S5 specifically includes:
[0066] When each field of the target database data table in the execution result is consistent with that of the source database data table, the test result is that the test is passed;
[0067] When any field of the target database data table in the execution result is inconsistent with that of the source database data table, the test result is test failure.
[0068] Furthermore, after step S4 is executed, the result statistics are performed, and statistical comparison is performed table by table and field by field. If the statistical values of all fields in all tables in the target database and the source database are consistent, the comparison is successful, otherwise the comparison fails.
[0069] The present invention provides a test method for data synchronization between an RTSync file source and a file target. First, the configuration files of the database source and database target mapping are parsed to create databases and data tables of the database source and database target; secondly, the mapping configuration files of the database source to the file target (first link) and the mapping configuration files of the file source to the database target (second link) are parsed respectively to create configuration files of the RTSync synchronization tools of the two links and upload them to the RTSync tool deployment server; then two sets of RTSync synchronization tools are started; the database source executes business data; finally, the data of each table of the database source and the database target are counted and the results are compared. The present invention provides an automated test program for data synchronization from a file source to a file target through the above method; at the same time, the test cases are configured to facilitate the maintenance of the test cases; and the automatic completion of the comparison of synchronization test results is also achieved.
[0070] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A data synchronization test method for an RTSync file source and a file target, characterized in that: include: S1: Parse the mapping configuration file between the database source and the database target, and create a database and data table based on the source and target libraries obtained by the analysis; S2: Establish a first link from the source library to the file target end and a second link from the file source end to the target library, and create a deployment file of the first RTSync tool and a deployment file of the second RTSync tool respectively according to the mapping configuration file of the first link and the mapping configuration file of the second link; the synchronization mechanism of the first link is: S211: When there is data change in the source library, the changed data is obtained by reading through the reading end component; S212: Cache the changed data into a message queue; S213: The message queue writes the changed data to the file target end through the write end component; The synchronization mechanism of the second link is: S221: When there is data to be synchronized in the consumption path specified by the file source, the data to be synchronized is obtained by reading through the reading end component; S222: Cache the data to be synchronized into a message queue; S223: The message queue writes the to-be-synchronized data into the target database through the write-end component; S3: deploy and start the first RTSync tool and the second RTSync tool. In the first link, parse the mapping configuration file from the database source to the file target, generate the RTSync tool main configuration file from the database source to the file target; upload the RTSync tool main configuration file from the database source to the file target to the corresponding path of the RTSync server; In the second link, a mapping configuration file from a file source to a database target is parsed to generate an RTSync tool main configuration file from the file source to the database target, wherein the file source uses the file generated by the file target; Upload the RTSync tool main configuration file from the file source to the database target to the corresponding path of the RTSync server; S4: Execute the service data through the first RTSync tool and the second RTSync tool to obtain an execution result; S5: Compare the target library data table of the target library in the execution result with the source library data table of the source library to obtain a test result.
2. A data synchronization test method for an RTSync file source and a file target according to claim 1, characterized in that: The database in step S1 includes a source database and a target database; The data table in step S1 includes a source database data table of the source database and a target database data table of the target database.
3. A data synchronization test method for an RTSync file source and a file target according to claim 2, characterized in that: The source database and the target database are both created through JDBC driver; The source database data table and the target database data table are both connected to the corresponding database through the SSH connection tool to execute the test case file creation.
4. A data synchronization test method for RTSync file source and file target end according to claim 1, characterized in that: The business data in step S4 is a test case, and the test case includes: Write concurrent write tests, single-threaded write tests, file breakpoint resume tests, zookeeper breakpoint resume tests, idempotence tests, case sensitivity tests and data type tests.
5. The data synchronization test method of a RTSync file source and a file target according to claim 1, characterized in that: In step S4, both the first RTSync tool and the second RTSync tool are connected to the database through the SSH connection tool to implement business data execution.
6. A data synchronization test method for RTSync file source and file target end according to claim 1, characterized in that: Step S5 specifically includes: When each field of the target database data table in the execution result is consistent with that of the source database data table, the test result is that the test passed; When any field of the target database data table in the execution result is inconsistent with that of the source database data table, the test result is test failure.
