Heterogeneous database synchronization function test method, equipment, medium and product
Through automated testing methods, determine the type of database data type mapping type, generate test tables and perform synchronous testing, solve the problem of the heterogeneous database synchronization function test workload and the burden of testers. Essence
Patent Information
- Application Number
- CN202411591776.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-08
- Publication Date
- 2025-01-21
AI Technical Summary
In the prior art, the testing method of heterogeneous database synchronization function has problems such as high workload and heavy burden on testers. Especially when the types of databases increase, the number of test combinations increases exponentially.
By determining the data type mapping type of the source and destination database, the heterogeneous synchronization group is formed, the test table is generated, and the random value is written in the source database. Automation of database synchronization function.
It effectively reduces the workload of manual testing, reduces the workload of testers, improves testing efficiency, and improves the accuracy of test results for heterogeneous database synchronization functions.
Smart Images

Figure CN119336607A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of database testing, and in particular to a method, device, medium and product for testing synchronization functions of heterogeneous databases. Background Art
[0002] The data security life cycle includes the stages of collection, transmission, storage, processing, exchange and destruction. The data exchange stage involves the transfer of data, and the information security risk is very high, so the importance of data security exchange is particularly prominent. In order to cope with the security challenges in data exchange, the cross-network data security exchange system came into being. The system is based on the technology of network gates and single-way optical gates, and uses security measures such as device authentication and format checking to achieve a platform for data synchronization between servers in two different network business areas. The system includes synchronization modules for various data types such as file synchronization and database synchronization. Among them, the database synchronization function can synchronize multiple tables and various types of data in the source database to the destination database.
[0003] Considering the diverse needs of business scenarios for database types, the source database and the destination database can be of the same type and version, or different versions, or even different types. The function of synchronizing from one database to another is called heterogeneous database synchronization. At present, the test method for the synchronization function of heterogeneous databases is generally manual testing. However, as the types of databases supported by data exchange equipment increase, the number of heterogeneous synchronization combinations will increase exponentially, which leads to a large workload for testing and a heavy workload for testers. Summary of the invention
[0004] The purpose of the present application is to provide a heterogeneous database synchronization function testing method, device, medium and product, aiming to solve the problem of large testing workload and heavy workload faced by testers in the related art testing method for heterogeneous database synchronization function.
[0005] In a first aspect, the present application provides a method for testing heterogeneous database synchronization functions, including: determining a mapping type that satisfies heterogeneous synchronization at both ends according to the data type of a source database and the data type of a destination database; determining multiple pairs of heterogeneous synchronization groups according to the mapping type, and generating test tables in the source database and the destination database according to the heterogeneous synchronization groups; the test table corresponds to a primary key and a data type; after writing random values of the corresponding primary key and the corresponding data type into the test table of the source database, checking the test table of the destination database, and determining whether the synchronization is successful based on the check result.
[0006] In the above implementation process, according to the data types at both ends of the source database and the destination database, the mapping types that meet the heterogeneous synchronization requirements of both ends are determined, and multiple pairs of heterogeneous synchronization groups are formed according to the determined mapping types. Then, test tables are generated in the source database and the destination data according to the heterogeneous synchronization groups, and then the corresponding primary key and random values of the corresponding data types are written to the test table of the source database. After writing the values at the source, the test table of the destination database is checked to determine whether the synchronization is successful. In this way, by mapping the data types of heterogeneous databases to the same type, automatically generating synchronization data, and automatically judging the synchronization results, the automated testing of the synchronization function of heterogeneous databases is realized, which effectively reduces the workload of manual testing and reduces the workload of testers.
[0007] Further, in some embodiments, determining the mapping type that satisfies heterogeneous synchronization at both ends based on the data type of the source database and the data type of the destination database includes: filtering out the data types common to both ends from all data types of the source database and the destination database; and matching the mapping types that satisfy heterogeneous synchronization at both ends from a type mapping table based on the filtered data types.
[0008] In the above implementation process, among all the data types in the source and destination databases, the data types unique to each end are eliminated, and then based on the remaining types and type mapping tables, the mapping types that meet the heterogeneous synchronization requirements of the source and destination databases are quickly and accurately extracted. In this way, data types that cannot be synchronized are excluded, useless test points are reduced, and test efficiency is improved.
[0009] Furthermore, in some embodiments, before matching the mapping types that satisfy heterogeneous synchronization at both ends from the type mapping table based on the filtered data types, it includes: dividing the filtered data types into numeric types, character types, binary types, and time types; collecting range information of the numerical values corresponding to each data type in the numeric type, and length information of the numerical values corresponding to each data type in the character type and the binary type.
[0010] In the above implementation process, the screened data types are divided into numeric types, character types, binary types and time types, and range information and length information are collected, so that types with different mapping types, different value ranges or lengths can also test the synchronization results between them.
[0011] Further, in some embodiments, determining multiple pairs of heterogeneous synchronization groups according to the mapping type includes: using permutations and combinations to match the data types in the source database and the target database according to the same or similar mapping types to form multiple pairs of heterogeneous synchronization groups; each pair of the heterogeneous synchronization groups includes a data type of the source database and a data type of the target database; if the currently matched data types are all numeric types, and the range of numeric values corresponding to the data type of the source database is larger than the range of numeric values corresponding to the data type of the target database, skipping the currently matched data type.
[0012] In the above implementation process, a specific method of establishing test points in the process of testing the heterogeneous database synchronization function is provided, thereby improving the accuracy of the test results of the heterogeneous database synchronization function.
[0013] Furthermore, in some embodiments, the value size or range of the random value is the intersection of the values of the data types of the test tables at both ends of the source database and the destination database.
[0014] In the above implementation process, when writing the corresponding primary key and the random value of the corresponding data type to the test table of the source database, the random value is set according to the intersection of the size or range of the numerical values corresponding to the data types at both ends. In this way, the format and size of the test data meet the requirements of the data type in the test tables of the databases at both ends, avoiding the problem of writing failure after synchronization to the destination.
[0015] Further, in some embodiments, the checking of the test table of the destination database and determining whether the synchronization is successful based on the checking result include: polling the test table of the destination database to see whether there is data of the primary key written by the source; if the test table is polled to see data of the primary key written by the source, comparing the MD5 value of the data in the test table of the source database with the MD5 value of the data in the test table of the destination database; if the comparison result indicates that the MD5 values are consistent, determining that the synchronization is successful, otherwise determining that the synchronization has failed.
[0016] In the above implementation process, a specific method is provided to determine whether the synchronization is successful based on the result of checking the test table of the destination database, that is, after writing the value on the source side, the test device polls the test table on the destination database to see whether there is data of the primary key written by the source side. After polling the value written on the destination side, the test device then verifies the MD5 value. When the MD5 value of the data written on the source side is consistent with the MD5 value of the data written on the destination side, the heterogeneous synchronization is determined to be successful.
[0017] Furthermore, in some embodiments, it also includes: if no data is detected in the test table of the target database after the polling times out, it is determined that the synchronization has failed, and the synchronization timeout result and the data in the test table of the source database are recorded.
[0018] In the above implementation process, if the corresponding data is not found in the destination database after the polling timeout, it means that the synchronization has failed. At this time, the test equipment records the synchronization timeout result and the value written by the synchronization source, which is convenient for testers to find out the cause of the synchronization failure.
[0019] In the second aspect, the present application provides a heterogeneous database synchronization function testing device, including: a determination module, used to determine the mapping type that satisfies the heterogeneous synchronization at both ends according to the data type of the source database and the data type of the destination database; a generation module, used to determine multiple pairs of heterogeneous synchronization groups according to the mapping type, and generate test tables in the source database and the destination database according to the heterogeneous synchronization groups; the test table corresponds to a primary key and a data type; a judgment module, used to write the corresponding primary key and the random value of the corresponding data type into the test table of the source database, and then check the test table of the destination database to determine whether the synchronization is successful according to the inspection result.
[0020] In a third aspect, the present application provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method described in any one of the first aspects when executing the computer program.
[0021] In a fourth aspect, the present application provides a computer-readable storage medium, on which instructions are stored. When the instructions are executed on a computer, the computer executes the method as described in any one of the first aspects.
[0022] In a fifth aspect, the present application provides a computer program product, which, when running on a computer, enables the computer to execute the method as described in any one of the first aspects.
[0023] Other features and advantages disclosed in the present application will be described in the following description, or some features and advantages can be inferred or determined without doubt from the description, or can be learned by implementing the above-mentioned technology disclosed in the present application.
[0024] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0026] Figure 1 A flowchart of a heterogeneous database synchronization function testing method provided in an embodiment of the present application;
[0027] Figure 2 A schematic diagram of the workflow of an automated testing solution for heterogeneous database synchronization function provided in an embodiment of the present application;
[0028] Figure 3 A block diagram of a heterogeneous database synchronization function testing device provided in an embodiment of the present application;
[0029] Figure 4 A structural block diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0030] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.
[0031] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. At the same time, in the description of this application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0032] As described in the background technology, the test method for heterogeneous database synchronization function in the related art has the problem of large test workload and heavy workload faced by testers. Based on this, the embodiment of the present application provides a heterogeneous database synchronization function test solution to solve the above problem.
[0033] Next, the implementation process of the embodiment of the present application is introduced:
[0034] like Figure 1 As shown, Figure 1It is a flowchart of a heterogeneous database synchronization function test method provided by an embodiment of the present application. The method can be applied to a test device, which is connected to a source database and a destination database respectively. The source database here refers to the database where the original data is stored, that is, the starting point of data migration or synchronization, and the destination database refers to the database where the data is finally stored, that is, the terminal of data migration or synchronization. Both databases can be relational databases, such as MySQL database, PostgreSQL database, etc. The scheme of this embodiment can be implemented as an automated test program on a test device to automatically test the synchronization function between the source database and the destination database.
[0035] The method comprises:
[0036] Step 101: Determine the mapping type that satisfies heterogeneous synchronization at both ends according to the data type of the source database and the data type of the target database;
[0037] The mapping type mentioned in this step can refer to the Java mapping type. The data types of heterogeneous databases can basically be mapped to Java types, so a prerequisite for supporting heterogeneous synchronization is that the data of the source and destination databases can support the same or similar Java mapping types. The relational database of the secure data exchange product has its corresponding JDBC (Java Database Connectivity) tool and can support specific versions. Therefore, during implementation, the test equipment can use the JDBC tool to match the Java mapping types of all data types of the database to be synchronized.
[0038] In some embodiments, this step may include: filtering out the data types common to both ends from all the data types of the source database and the destination database; and matching the mapping types that satisfy heterogeneous synchronization at both ends from the type mapping table according to the filtered data types. That is to say, since the database itself may have some data types that are unique to it, it is generally believed that it can only be synchronized between databases of the same type and does not support heterogeneous database synchronization. Therefore, when testing the heterogeneous synchronization function, the data types that are unique to the databases at both ends of the source and destination are eliminated, and the remaining data types are the data types common to both ends. Then, a table for recording the mapping relationship between the database data type and the Java mapping type, i.e., the type mapping table, is combined to match the mapping types that satisfy heterogeneous synchronization at both ends. In this way, the mapping types that satisfy heterogeneous synchronization at both ends of the source and destination are extracted quickly and accurately, laying a good foundation for realizing the automated testing of heterogeneous database synchronization functions.
[0039] In some embodiments, the aforementioned matching of the mapping types that satisfy heterogeneous synchronization at both ends from the type mapping table based on the filtered data types may include: dividing the filtered data types into numeric types, character types, binary types, and time types; collecting the range information of the numeric values corresponding to each data type in the numeric types, and the length information of the numeric values corresponding to each data type in the character types and the binary types. That is, after eliminating the data types that are unique to the heterogeneous databases at both ends, the remaining types can be divided into numeric types, character types, binary types, and time types, wherein the numeric types include data types such as smallint, middleint, int, bigint, float, and double, the character types include data types such as char, nchar, varchar, nvarchar, and clob, the binary types include data types such as binary, varbinary, and blob, and the event types include data types such as time, date, datetime, and timestamp. Through classification, the efficiency of obtaining the mapping types at both ends can be improved. For example, the several data types contained in the character type are all mapped to the Java String type, and the several data types contained in the binary type are all mapped to the Java Binary type. In addition, during the classification process, the range information of the values corresponding to the data types classified as numerical types, the length information of the values corresponding to the data types classified as character types, and the length information of the values corresponding to the data types classified as binary types are collected. As for the data types classified as time types, the time format, time zone and time range can be recorded. In this way, types with different mapping types, different value ranges or lengths can also test the synchronization results between them.
[0040] In step 102, multiple pairs of heterogeneous synchronization groups are determined according to the mapping type, and test tables are generated in the source database and the target database respectively according to the heterogeneous synchronization groups; the test table corresponds to a primary key and a data type;
[0041] The heterogeneous synchronization group mentioned in this step can be considered as a set of mapping relationships established between the source database and the destination database for data synchronization. A pair of heterogeneous synchronization groups is formed according to a certain data type in the source database and a data type with the same or similar mapping type in the destination database. The test device automatically generates a test table according to the heterogeneous synchronization group, and each test table only stores a primary key and a type to be tested. For example, the varchar type in the source database and the char type in the destination database can both be mapped to the String type in Java, and both meet the heterogeneous synchronization conditions. Therefore, these two data types can form a pair of heterogeneous synchronization groups. The test device generates a source test table in the source database, and the source test table contains two fields, namely, a primary key field for uniquely identifying a row and a field for testing a varchar type. Correspondingly, the test device also generates a destination test table in the destination database, and the destination test table also contains two fields, namely, a primary key field for uniquely identifying a row and a field for testing a char type. In this way, each test table is equivalent to a test point, and the test device can cover the data types of heterogeneous synchronization according to all generated test tables.
[0042] In some embodiments, determining multiple pairs of heterogeneous synchronization groups according to the mapping type mentioned in this step may include: using permutations and combinations to match the data types in the source database and the destination database according to the same or similar mapping types to form multiple pairs of heterogeneous synchronization groups; each pair of the heterogeneous synchronization groups includes a data type of the source database and a data type of the destination database; if the currently matched data types are all numeric types, and the range of numeric values corresponding to the data type of the source database is greater than the range of numeric values corresponding to the data type of the destination database, skip the currently matched data type.
[0043] That is to say, after extracting the mapping types that satisfy heterogeneous synchronization of the source and destination databases, the data tables to be synchronized are formed by permutation and combination. In terms of the combination method, the same mapping type is a pair of heterogeneous synchronization groups, such as the varchar type and char type mentioned above. At the same time, for numeric types, small numeric types can be synchronized to large numeric types. Their Java mapping types are different but they all belong to numeric types, that is, they belong to similar mapping types and can form a pair of heterogeneous synchronization groups. For example, the source database has smallint type and bigint type, and the destination database has middleint type and int type. Since the value range corresponding to smallint type is smaller than the value range corresponding to middleint type and int type, the smallint type on the source side and the middleint type on the destination side can form a pair of heterogeneous synchronization groups, and the smallint type on the source side and the int type on the destination side can form another pair of heterogeneous synchronization groups. Since the value range corresponding to bigint type is larger than the value range corresponding to middleint type and int type, the matching process of bigint type is skipped and the corresponding test table is not generated. In this way, appropriate test points can be established quickly and accurately, improving the accuracy of the test results of the heterogeneous database synchronization function.
[0044] In step 103, after writing the corresponding primary key and the random value of the corresponding data type into the test table of the source database, the test table of the target database is checked, and it is determined whether the synchronization is successful based on the check result.
[0045] The main application scenarios of this embodiment include secure data exchange products, which include a front-end machine and a back-end machine. When the data in the source database changes, the front-end machine will read the data in the source database and send it to the back-end machine, and the back-end machine will write the received data into the destination database to achieve database synchronization. In this embodiment, the test equipment writes the primary key and the corresponding type of random value to the source database. After the source writes the value, the secure data exchange platform will automatically synchronize the data to the destination. At this time, the test equipment detects the test table in the destination database to determine whether the synchronization is successful. In this way, by automatically generating synchronization data and automatically judging the synchronization results, the workload of manual testing is effectively reduced, which reduces the workload of testers.
[0046] In some embodiments, the value size or range of the random value mentioned in this step can be the intersection of the size or range of the numerical values corresponding to the data types of the test tables at both ends of the source database and the target database. In other words, when writing the corresponding primary key and the random value of the corresponding data type into the test table of the source database, the random value is set according to the intersection of the size or range of the numerical values corresponding to the data types at both ends. In this way, the format and size of the test data meet the requirements of the data type in the test tables of the databases at both ends, avoiding the problem of write failure after synchronization to the target end.
[0047] In some embodiments, the step of checking the test table of the destination database mentioned in this step, and determining whether the synchronization is successful according to the inspection result may include: polling the test table of the destination database whether there is data of the primary key written by the source; if the test table polls the data of the primary key written by the source, compare the MD5 value of the data in the test table of the source database and the MD5 value of the data in the test table of the destination database; if the comparison result indicates that the MD5 values are consistent, the synchronization is determined to be successful, otherwise the synchronization is determined to be failed. That is to say, after the source writes the value, the test device can poll the test table on the destination database to see whether there is data of the primary key written by the source. If yes, it means that the data has been synchronized. The test device then compares the MD5 values of the source data value and the destination data value. If they are the same, it means that the synchronization is successful, otherwise the synchronization fails. In this way, the automatic judgment of the synchronization result is realized, and the workload of manual testing is effectively reduced. In addition, when it is determined that the synchronization fails, the test device can record the synchronization failure result and the data value of the synchronization failure, which is convenient for troubleshooting synchronization problems.
[0048] In addition, in some embodiments, it also includes: if no data is detected in the test table of the destination database after the polling timeout, it is determined that the synchronization has failed. That is to say, when the test device does not detect data in the test table of the destination database, it can determine whether the polling has timed out. If it has not timed out, it will wait for a preset time and then re-query the destination database to reduce the situation where the database read and write delay is mistakenly judged as a database synchronization function failure. If the corresponding data is still not queried in the destination database after the polling timeout, it means that the synchronization has failed. At this time, the test device records the synchronization timeout result and the value written by the synchronization source, which is convenient for the test personnel to find out the cause of the synchronization failure.
[0049] The test equipment will test all test points. When all test points have been tested, the test equipment can integrate all test results and automatically generate a report, thereby reducing the workload of testers in manually arranging data and improving test efficiency.
[0050] In the embodiment of the present application, the mapping types that satisfy heterogeneous synchronization at both ends are determined according to the data types at both ends of the source database and the destination database, and multiple pairs of heterogeneous synchronization groups are formed according to the determined mapping types. Then, test tables are generated in the source database and the destination data according to the heterogeneous synchronization groups, and then the corresponding primary key and random values of the corresponding data types are written to the test table of the source database. After writing the values at the source end, the test table of the destination database is checked to determine whether the synchronization is successful. In this way, by mapping the data types of heterogeneous databases to the same type, automatically generating synchronization data, and automatically determining the synchronization results, the automated testing of the synchronization function of heterogeneous databases is realized, which effectively reduces the workload of manual testing and reduces the workload of testers.
[0051] In order to explain the solution of this application in more detail, a specific embodiment is introduced below:
[0052] This embodiment provides an automated testing solution for heterogeneous database synchronization functions, which is applied to automated testing programs on test equipment. The workflow of the solution is as follows: Figure 2 As shown, including:
[0053] S201, obtaining all data types of heterogeneous databases at both ends, eliminating their own unique data types, and classifying the remaining types into numeric types, character types, binary types, and time types, obtaining mapping types of these data types, and collecting length and range information of the mapping data;
[0054] Specifically, the numeric type classification includes smallint, middleint, int, bigint, float, double, etc. In addition to the known integer types and floating-point types with fixed ranges, there are also decimal numbers such as decimal that can dynamically specify the range, and its maximum range needs to be collected; character type classification includes char, nchar, varchar, nvarchar, clob, etc., they are all mapped to Java's String type, so you only need to know the maximum length of each mapping type; binary type classification includes binary, varbinary, blob, etc., they are all mapped to Java's Binary type, so you only need to know the maximum length of each mapping type; time type classification includes time, date, datetime, timestamp, etc., you need to pay attention to whether the time is only the date, or only the hour, minute, and second, or all of them, as well as the time zone and time range of the time;
[0055] S202, arranging and combining the data to be synchronized at both ends of the source and destination from the mapping data;
[0056] Specifically, after obtaining the mapping types at both ends, the automated test program matches the data types at both ends, and forms the data to be synchronized at both ends of the source and destination through permutations and combinations; the same mapping types, such as varchar and char types in the database, can be mapped to String types in Java, and can be combined into a pair of heterogeneous synchronization groups; and for numeric types, small numeric types can be synchronized to large numeric types, their Java mapping types are different but both belong to numeric types, so they can also be combined into a pair of heterogeneous synchronization groups;
[0057] Each pair of heterogeneous synchronization groups is equivalent to a test point. For each test point, the automated test program creates a test table in the source database and the target database respectively. Each test table only stores a primary key field and a field for testing the type to be tested.
[0058] S203, determine whether the synchronization data has been obtained, if yes, execute S215, otherwise execute S204;
[0059] S204, selecting a group of data combinations that have not been synchronized to synchronize;
[0060] S205. Write a random value of the data at the source end, where the size and range are the intersection of the values of the data types of the databases at both ends of the source and destination;
[0061] Specifically, the automated test program writes the primary key and a random value of the corresponding data type into the test table of the source database. The written data is a random value that is acceptable to both data types.
[0062] S206, polling the destination database;
[0063] S207, determining whether the primary key data written by the source end is read in the table of the target end database, if yes, executing S208, otherwise executing S212;
[0064] S208, calculating the MD5 value of the data at both ends of the source and destination;
[0065] Specifically, after polling the destination end to write the value, the automated test program verifies the MD5 value. When the MD5 value of the data written by the source end is consistent with the MD5 value of the data written by the destination end, the heterogeneous synchronization is determined to be successful.
[0066] S209, determine whether the MD5 values of the data at both ends of the source and destination are consistent, if yes, execute S210, otherwise execute S211;
[0067] S210, record the synchronization success result, and then return to S203;
[0068] S211, record the synchronization failure result and the data value of the synchronization failure, and then return to S203;
[0069] S212, determine whether the polling timeout occurs, if yes, execute S213, otherwise execute S214;
[0070] S213, record the synchronization timeout result and the value written by the synchronization source, and then return to S203;
[0071] S214, wait for 1 second, then return to S206;
[0072] Specifically, the 1 second here can be the synchronization interval set in the secure data exchange product. The automated test program detects the destination database every one second to check whether there is data of the primary key written by the source in its test table. If not, it continues to wait for the arrival of data. When a certain time threshold is exceeded, the synchronization is determined to have failed.
[0073] S215. The heterogeneous synchronization test is completed.
[0074] This embodiment of the invention determines the synchronization type according to the data type of the databases at both ends of the source and destination, automatically generates synchronization data, and automatically determines the synchronization result, which effectively reduces the workload of manual testing and reduces the workload of testers. It can effectively deal with the testing problems caused by the increase in database types supported by the database synchronization function of the secure data exchange product. In addition, during testing, heterogeneous synchronization types are divided, types that cannot be synchronized are excluded, and useless test points are reduced, thereby improving test efficiency.
[0075] Corresponding to the embodiments of the aforementioned method, the present application also provides embodiments of a heterogeneous database synchronization function testing device and a terminal using the same:
[0076] like Figure 3 As shown, Figure 3 : is a block diagram of a heterogeneous database synchronization function testing device provided in an embodiment of the present application, the device comprising:
[0077] A determination module 31 is used to determine the mapping type that satisfies heterogeneous synchronization at both ends according to the data type of the source database and the data type of the target database;
[0078] A generating module 32, configured to determine a plurality of pairs of heterogeneous synchronization groups according to the mapping type, and to generate a test table in the source database and the target database according to the heterogeneous synchronization groups; the test table corresponds to a primary key and a data type;
[0079] The determination module 33 is used to write the corresponding primary key and the random value of the corresponding data type into the test table of the source database, check the test table of the target database, and determine whether the synchronization is successful according to the check result.
[0080] The implementation process of the functions and effects of each module in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, which will not be repeated here.
[0081] This application also provides an electronic device, see Figure 4 , Figure 4 A block diagram of an electronic device provided in an embodiment of the present application. The electronic device may include a processor 410, a communication interface 420, a memory 430, and at least one communication bus 440. The communication bus 440 is used to realize direct connection and communication between these components. The communication interface 420 of the electronic device in the embodiment of the present application is used to communicate signaling or data with other node devices. The processor 410 may be an integrated circuit chip with signal processing capabilities.
[0082] The processor 410 may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application may be implemented or executed. The processor 410 may be a microprocessor, or the processor 410 may be any conventional processor, etc.
[0083] The memory 430 may be, but is not limited to, a random access memory (RAM), a read only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electric erasable programmable read-only memory (EEPROM), etc. The memory 430 stores computer-readable instructions. When the computer-readable instructions are executed by the processor 410, the electronic device can execute the above-mentioned Figure 1 The method embodiment involves various steps.
[0084] Optionally, the electronic device may further include a storage controller and an input / output unit.
[0085] The memory 430, storage controller, processor 410, peripheral interface, input and output unit components are directly or indirectly electrically connected to each other to achieve data transmission or interaction. For example, these components can be electrically connected to each other via one or more communication buses 440. The processor 410 is used to execute executable modules stored in the memory 430, such as software function modules or computer programs included in the electronic device.
[0086] The input and output unit is used to provide users with the task creation and to create a start optional time period or preset execution time for the task to realize the interaction between the user and the server. The input and output unit can be, but is not limited to, a mouse and a keyboard.
[0087] Understandably, Figure 4 The structure shown is for illustration only, and the electronic device may also include Figure 4 More or fewer components as shown, or with Figure 4 Different configurations are shown. Figure 4 Each component shown in the figure can be implemented by hardware, software or a combination thereof.
[0088] An embodiment of the present application further provides a storage medium having instructions stored thereon. When the instructions are run on a computer, the computer program is executed by a processor to implement the method described in the method embodiment. To avoid repetition, the method will not be described here.
[0089] The present application also provides a computer program product, which, when executed on a computer, enables the computer to execute the method described in the method embodiment.
[0090] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0091] In addition, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
[0092] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0093] The above description is only an embodiment of the present application and is not intended to limit the scope of protection of the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application should be included in the scope of protection of the present application. It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings.
[0094] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0095] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
Claims
1. A method for testing heterogeneous database synchronization function, characterized in that: include: According to the data types of the source database and the target database, determine the mapping types that meet the heterogeneous synchronization requirements on both ends. Determine a plurality of pairs of heterogeneous synchronization groups according to the mapping type, and generate test tables in the source database and the destination database respectively according to the heterogeneous synchronization groups; The test table corresponds to a primary key and a data type; After writing the corresponding primary key and the random value of the corresponding data type into the test table of the source database, the test table of the target database is checked, and whether the synchronization is successful is determined according to the check result.
2. The method according to claim 1, characterized in that The step of determining the mapping type that satisfies heterogeneous synchronization at both ends according to the data type of the source database and the data type of the target database includes: From all data types in the source database and the destination database, filter out the data types that are common to both ends; According to the filtered data types, the mapping types that meet the heterogeneous synchronization requirements at both ends are matched from the type mapping table.
3. The method according to claim 2, characterized in that According to the filtered data types, before matching the mapping types that satisfy heterogeneous synchronization at both ends from the type mapping table, the method includes: Classify the filtered data types into numeric type, character type, binary type and time type; The range information of the numerical value corresponding to each data type in the numerical value type and the length information of the numerical value corresponding to each data type in the character type and the binary type are collected.
4. The method according to claim 3, characterized in that: The determining of multiple pairs of heterogeneous synchronization groups according to the mapping type includes: Using a permutation and combination method, the data types in the source database and the target database are matched according to the same or similar mapping types to form multiple pairs of heterogeneous synchronization groups; each pair of the heterogeneous synchronization groups includes a data type in the source database and a data type in the target database; If all currently matched data types are numeric types, and the range of numeric values corresponding to the data type of the source database is larger than the range of numeric values corresponding to the data type of the target database, the currently matched data type is skipped.
5. The method according to claim 3, characterized in that: The value size or range of the random value is the intersection of the values of the data types of the test tables at both ends of the source database and the destination database.
6. The method according to claim 1, characterized in that The step of checking the test table of the target database and determining whether the synchronization is successful according to the checking result includes: Poll the test table of the target database to see whether there is data of the primary key written by the source end; If the test table contains data of the primary key written by the source, the MD5 value of the data in the test table of the source database is compared with the MD5 value of the data in the test table of the target database; If the comparison result indicates that the MD5 values are consistent, the synchronization is determined to be successful, otherwise the synchronization is determined to be failed.
7. The method according to claim 6, characterized in that Also includes: If no data is detected in the test table of the target database after the polling times out, synchronization is determined to have failed, and the synchronization timeout result and the data in the test table of the source database are recorded.
8. An electronic device, characterized in that: The method comprises a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the method according to any one of claims 1 to 7 is implemented.
9. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and when the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
10. A computer program product, characterized in that When the computer program product is executed on a computer, the computer is enabled to perform the method according to any one of claims 1 to 7.
Citation Information
Cited By
Heterogeneous data synchronization method and device for database and medium
CN121144419A
A heterogeneous data synchronization method, device and medium for a database
CN121144419B