Automatic test method and device for database migration, electronic equipment and medium
Obtaining target test interfaces and use cases through automated testing methods, solving the problem of inefficient manual operations in database migration, and achieving efficient and accurate database migration synchronization testing.
Patent Information
- Application Number
- CN202510596837.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-09
- Publication Date
- 2025-08-05
AI Technical Summary
In the prior art, database migration synchronization testing relies on manual operations, is inefficient and error-prone, especially when migrating from Oracle database to domestic GaussDB database, there is a lack of automated testing tools.
Provides automated testing methods for database migration, by obtaining target test interfaces, determining matching target test cases, and performing these use cases during data migration, generating test results, including automated testing of user interfaces and application programming interfaces.
It realizes the full process automation of database migration synchronization testing, improves testing efficiency, simplifies operational processes, avoids human errors, and ensures the accuracy and completeness of data migration.
Smart Images

Figure CN120429237A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of database migration synchronization testing, and in particular to an automated testing method, device, electronic equipment and medium for database migration. Background Art
[0002] As enterprises deepen their digital transformation, database migration and synchronization projects are increasing. In particular, the demand for migration and synchronization from traditional Oracle databases to domestically produced GaussDB databases has increased significantly. While some database migration and synchronization testing tools exist, the traditional data migration and synchronization testing process relies on manual operations, which is inefficient, cumbersome, and prone to errors. Summary of the Invention
[0003] The present invention provides an automated testing method, device, electronic device, and medium for database migration, which automatically performs data migration synchronization testing, greatly improving work efficiency, simplifying the operation process, and ensuring high accuracy of data processing, effectively avoiding human errors.
[0004] According to one aspect of the present invention, a method for automated testing of database migration is provided, the method comprising:
[0005] Obtaining a target test interface; wherein the target test interface includes a user interface and an application programming interface;
[0006] Determine a target test case that matches the target test interface;
[0007] During the process of migrating data information from the source database to the target database, the target test case is executed to obtain the test result; wherein, the source database is an Oracle database; and the target database is a GaussDB database.
[0008] According to another aspect of the present invention, there is provided an automated testing apparatus for database migration, the apparatus comprising:
[0009] A target test interface acquisition module is used to acquire a target test interface; wherein the target test interface includes a user interface and an application programming interface;
[0010] A target test case determination module, configured to determine a target test case that matches the target test interface;
[0011] The test result acquisition module is used to execute the target test case and obtain the test result during the process of migrating data information from the source database to the target database; wherein, the source database is an Oracle database; and the target database is a GaussDB database.
[0012] According to another aspect of the present invention, an electronic device is provided, comprising:
[0013] At least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to perform the automated testing method for database migration described in any embodiment of the present invention.
[0014] According to another aspect of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the automated testing method for database migration according to any embodiment of the present invention when executed.
[0015] The technical solution of the embodiment of the present invention obtains the target test interface, determines the target test case that matches the target test interface, and then executes the target test case to obtain the test result during the process of migrating the data information of the source database to the target database. Compared with the traditional manual testing mode, this technical solution realizes the full process automation of data migration synchronization testing, changing the previous inefficient situation of relying on manual writing and execution of test cases. It not only significantly improves the test execution efficiency and simplifies the operation process, but also effectively avoids test errors caused by negligence or improper operation by eliminating the manual operation link, ensuring the accuracy and completeness of the data migration process.
[0016] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present invention, nor is it intended to limit the scope of the present invention. Other features of the present invention will become readily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0018] Figure 1 This is a flowchart of the automated testing method for database migration provided in accordance with the first embodiment of the present invention;
[0019] Figure 2 Automated testing flow chart for database migration provided for implementation of this application;
[0020] Figure 3 This is a system architecture diagram for automated testing of database migration provided in Example 1 of the present application;
[0021] Figure 4 A flowchart of an automated testing process for database migration provided in the second embodiment of the present invention;
[0022] Figure 5 A schematic diagram of an automated testing process for database migration provided in Example 3 of the present invention;
[0023] Figure 6 This is a flowchart of the automated testing provided in Example 3 of this application;
[0024] Figure 7 A schematic diagram of another automated testing process for database migration provided in the fourth embodiment of the present invention;
[0025] Figure 8 This is a flowchart of the data comparison algorithm provided in Example 4 of the present application;
[0026] Figure 9 A schematic diagram of generating a test report provided in Example 4 of this application;
[0027] Figure 10 A schematic diagram of another automated testing method for database migration provided in Example 5 of the present invention;
[0028] Figure 11 This is a flowchart of system initialization provided in Example 5 of the present application;
[0029] Figure 12 A schematic diagram of the structure of an automated testing device for database migration provided in Example 6 of the present invention;
[0030] Figure 13 The figure is a schematic diagram of the structure of an electronic device for implementing the automated testing method for database migration according to an embodiment of the present invention. DETAILED DESCRIPTION
[0031] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the embodiments described 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 making creative efforts should fall within the scope of protection of the present invention.
[0032] It should be noted that the terms "first", "second", etc. in the description and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0033] Example 1
[0034] Figure 1 This is a flowchart of the automated testing method for database migration provided in accordance with the first embodiment of the present invention. This embodiment is applicable to situations where database migration testing is automatically performed. The method can be performed by an automated testing device for database migration. The automated testing device for database migration can be implemented in the form of hardware and / or software. The automated testing device for database migration can be configured in a device. For example, the device can be a background server or other device with communication and computing capabilities. Figure 1 As shown, the method includes:
[0035] S110 , obtaining a target test interface; wherein the target test interface includes a user interface and an application programming interface.
[0036] In this solution, the target test interface is used to interact with the source database and the target database during the database migration process to obtain data information during the migration process.
[0037] The user interface (UI) is the interface through which users interact with a software system. It enables users to use software features conveniently and efficiently. The UI includes various visual elements, such as buttons, menus, text boxes, and icons, through which users can input information and receive feedback, thereby enabling interaction with the software.
[0038] In this embodiment, an Application Programming Interface (API) is used to build software applications. It provides a way for different software components or systems to communicate and interact with each other. Developers can use the API to call the functions of other software or systems without having to understand their internal implementation details.
[0039] In this solution, the target test interface includes the user interface and the application programming interface. The target test interface can be selected according to the test requirements of the database migration, thereby ensuring the effectiveness and pertinence of the testing work.
[0040] S120: Determine a target test case that matches the target test interface.
[0041] Among them, the target test case refers to a collection of test steps, conditions and expected results designed to achieve specific test objectives.
[0042] In this embodiment, the test steps and expected results in the target test case are configured through Excel.
[0043] In this solution, since different target test interfaces are adapted to different target test cases, target test cases matching the target test interface are screened out according to the matching relationship between the preset test interface and the test case.
[0044] S130. During the process of migrating data information from the source database to the target database, execute the target test case to obtain a test result; wherein, the source database is an Oracle database; and the target database is a GaussDB database.
[0045] In this solution, the test result includes at least one of a data integrity test result, a data consistency test result, a function test result, a performance test result, and a security test result. Optionally, the test result is a data consistency test result, and the data consistency test result includes data consistency and data inconsistency.
[0046] In this embodiment, a data migration tool is used or a corresponding migration script is written to migrate the data information of the source database to the target database according to a predetermined migration strategy. Figure 2 The automated test flow chart for database migration provided for this application is as follows: Figure 2 As shown in the figure, you can perform structure migration operations by writing corresponding migration scripts to migrate data from the source database to the target database. For example, you can use the run_struct_full_sync_process function to perform structure migration operations.
[0047] Furthermore, after the data migration is complete, use a testing tool or written test code to connect to the target database to ensure normal access to the data in the target database. Execute the target test cases sequentially in the predetermined order. For each test case, query the relevant data from the target database according to its specific requirements and compare it with the expected results. As each test case executes, record the test results in detail. If the test case passes, record the pass information; if the test case fails, record the reason for the failure and specific error information, such as the specific data item that the query result does not match the expected result, the specific field with the wrong data type, etc.
[0048] In this plan, Figure 3 This is a system architecture diagram for automated testing of database migration provided in Example 1 of this application, such as Figure 3 As shown in the figure, the automated testing system architecture for database migration consists of configuration management, a database layer, continuous integration, a testing core, and a reporting system. Specifically, YAML configuration files are used to manage interface configuration, database connection information, and basic data. Pytest is used for test management and execution, supporting efficient scheduling and log management. Allure visual test reports are generated for easy analysis and debugging. Scheduled tasks are configured through Jenkins to automatically trigger the test process. Both manual execution and triggering mechanisms based on Git code changes are supported. Selenium drives user interface interaction and performs interface automation.
[0049] The technical solution of the embodiment of the present invention obtains the target test interface, determines the target test case that matches the target test interface, and then executes the target test case to obtain the test result during the process of migrating the data information of the source database to the target database. By implementing this technical solution, compared with the traditional manual testing mode, the full process automation of data migration synchronization testing is achieved, changing the previous inefficient situation of relying on manual writing and execution of test cases. Not only does it significantly improve the test execution efficiency and simplify the operation process, but it also effectively avoids test errors caused by negligence or improper operation by eliminating the manual operation link, ensuring the accuracy and completeness of the data migration process.
[0050] Example 2
[0051] Figure 4 This is a flowchart of an automated test process for database migration provided by the second embodiment of the present invention. The relationship between this embodiment and the above embodiment is a supplement to the target test case determination process. Figure 4 As shown, the method includes:
[0052] S410: Acquire a target test interface; wherein the target test interface includes a user interface and an application programming interface.
[0053] S420: When the target test interface is a user interface, use a predetermined first operation case as a target test case that matches the target test interface; wherein the first operation case is an interface operation case.
[0054] The first operational use case is the interface operation use case. This is a detailed description of the user's interaction with the software interface, focusing on the operational flow, results, and feedback of interface elements. It verifies whether the software's user interface meets design requirements and whether users can successfully complete various operations during use.
[0055] In this solution, when the target test interface is a user interface, a predefined first operation case is directly selected as a target test case for adapting the user interface interface.
[0056] Optionally, when the target test interface is a user interface, the method further includes:
[0057] Using a preset large model to monitor the user interface in real time, determining a target parameter of a change; wherein the target parameter includes at least one of an element position, an element attribute, and an element path;
[0058] The target positioning expression is adjusted according to the changed target parameter; wherein the target positioning expression is a tool for locating a specific element in an XML or HTML document.
[0059] In this embodiment, element position refers to the specific coordinate position of an element on a web page. Pixels are typically used as the unit to accurately describe the position of an element relative to the browser window or other parent elements. Element attributes refer to the various properties of an HTML element that describe its appearance, behavior, content, and other aspects. An element path refers to the path from the root node to a specific element in the Document Object Model tree. It is a method for locating and accessing specific elements on a web page.
[0060] In this solution, the user interface changes are monitored in real time based on the big model and the target parameters of the changes are determined. Specifically, the big model is used to analyze the HTML structure and DOM changes to detect the adjustment of the user interface components.
[0061] Furthermore, based on the large model and combined with historical UI structures, user interface operation strategies can be continuously optimized through intelligent analysis and dynamic modeling. This not only significantly improves the stability of the testing process but also enables adaptive adjustments to various UI changes, ensuring efficient and reliable testing and effectively handling complex and ever-changing application interface scenarios.
[0062] In this embodiment, the target positioning expression is a tool for locating a specific element in an XML or HTML document. Optionally, the target positioning expression is an XPath positioning expression.
[0063] Furthermore, when the user interface undergoes dynamic changes, the target parameters that trigger the changes are monitored in real time and accurately identified. Based on the changing target parameters, a dynamic update algorithm is used to intelligently reconstruct and calibrate the target positioning expression. By establishing a mapping relationship between parameter changes and positioning rules, adaptive optimization of the positioning expression is achieved.
[0064] S430. When the target test interface is an application programming interface, a predetermined second operation case is used as a target test case that matches the target test interface; wherein the second operation case is at least one of a full comparison case, an incremental comparison case, and an extended case.
[0065] In this example, the full comparison test case comprehensively compares two datasets or system states. By comparing all data items in the two datasets, it checks whether they are completely consistent. This is commonly used in scenarios such as data migration, data synchronization, and system backup and recovery to ensure data integrity and accuracy.
[0066] Incremental comparisons compare changes between two datasets or system states. They focus only on newly added, modified, or deleted data items and are often used in scenarios with frequent data updates to improve comparison efficiency and reduce unnecessary computing resource consumption.
[0067] In this solution, extended use cases are test cases that expand system functionality, business scenarios, or test scope based on existing use cases. They can be used to supplement missed functional tests, cover more business scenarios, and verify system behavior under different environments or conditions, thereby improving the comprehensiveness and effectiveness of testing.
[0068] Specifically, when the target test interface is an application programming interface, at least one of the full comparison case, the incremental comparison case, and the extended case is used as the target test case of the application programming interface.
[0069] In this solution, you can use YAML configuration files to manage application programming interface configurations, database connection information, and basic data.
[0070] S440. During the process of migrating data information from the source database to the target database, execute the target test case to obtain a test result; wherein, the source database is an Oracle database; and the target database is a GaussDB database.
[0071] This solution can also analyze the testing process based on the large model and optimize the execution order of target test cases, thereby improving testing efficiency. When executing target test cases, the pre-defined priority strategy will be strictly followed, with core test cases prioritized. This ensures that key business logic and core functions are fully verified, effectively ensuring system quality and stability.
[0072] Furthermore, based on historical test case data, the execution process of the target test case can be optimized to reduce unnecessary repetitive operations, increase the running speed, and improve the coverage of automated testing.
[0073] In this embodiment, if an anomaly is detected during the test, the large model is used to analyze the changes in the user interface and adjust the test logic to ensure the stability of the test. Optionally, in order to further enhance the robustness of the test and significantly improve the stability of the test, a combination of Selenium and the retry mechanism provided by Pytest can be used. Through this powerful combination, it is ensured that the test process can automatically perform reasonable retries when faced with various complex situations, thereby effectively reducing test failures caused by accidental factors and greatly improving the reliability and accuracy of the test results.
[0074] The technical solution of the embodiment of the present invention obtains the target test interface, determines the target test case that matches the target test interface, and then executes the target test case during the process of migrating data information from the source database to the target database to obtain the test results. By implementing this technical solution, the test execution efficiency is improved, the operation process is simplified, and by eliminating the manual operation link, test errors caused by negligence or improper operation are effectively avoided, ensuring the accuracy and completeness of the data migration process. At the same time, the large model technology automatically adapts to interface changes, reducing the workload of script maintenance.
[0075] Example 3
[0076] Figure 5 This is a schematic diagram of an automated test process for database migration provided by the third embodiment of the present invention. The relationship between this embodiment and the above embodiment is a detailed description of the database migration process. Figure 5 As shown, the method includes:
[0077] S510: Obtain data information from the source database.
[0078] In this solution, you can obtain database data information by executing SQL statements; or use Oracle database development tools to obtain data information from the source database.
[0079] S520: Determine whether the data information of the source database meets the preset full synchronization trigger condition.
[0080] Full synchronization refers to the process of copying all data in the source database to the target database at once.
[0081] In this embodiment, the full synchronization trigger condition refers to a trigger mechanism that drives a complete and comprehensive data synchronization operation. The full synchronization trigger condition includes at least one of the following: initial deployment or initialization, major changes to the data structure, and periodic full update strategies.
[0082] Among them, initial deployment or initialization: when the system is first launched, a new application module is connected to the source database, or the data warehouse is first built, all the data in the source database needs to be synchronized in order to establish a complete data copy in the target database. Major changes in data structure: The table structure in the source database has undergone major changes, such as adding or deleting important columns, modifying data types, etc., which may cause the data in the target database to be inconsistent with the source database. At this time, full synchronization is required to ensure that the target database can reflect the latest structure and data of the source database. Periodic full update strategy: Develop a periodic full synchronization strategy based on business needs, such as full synchronization once a month, quarterly, or annually.
[0083] In this solution, you can use the Requests library to trigger the full synchronization trigger condition.
[0084] S530: If the conditions are met, perform full synchronization on the data information of the source database, and migrate the data information of the source database to the target database.
[0085] In this program, if Figure 3 As shown in the figure, when the data in the source database meets the preset full synchronization trigger conditions, a full synchronization is performed on the source database data to migrate the source database data to the target database. For example, the full data synchronization task is executed using the run_full_sync_services function.
[0086] S540. If not, determine whether the data information of the source database meets the preset incremental synchronization trigger condition. If so, determine the newly added and / or modified data information in the source database, and perform incremental synchronization on the newly added and / or modified data information in the source database, and migrate the newly added and / or modified data information in the source database to the target database.
[0087] Incremental synchronization refers to synchronizing only the data that has changed since the last synchronization, that is, synchronizing only the newly added and / or modified data information in the database.
[0088] In this embodiment, the incremental synchronization trigger condition refers to the core mechanism that triggers the data synchronization system to execute synchronization operations only on modified data. Incremental synchronization trigger conditions include at least one of a timestamp trigger, a log record trigger, a data change identifier trigger, and a business operation trigger. Optionally, the incremental synchronization trigger condition can be triggered by dynamically obtaining the incremental synchronization SQL script.
[0089] Among them, timestamp trigger: the source database maintains a timestamp field for each data record, indicating the time when the data was last modified. The incremental synchronization task will regularly check the data in the source database whose timestamp is greater than the last synchronization time, and synchronize this data to the target database. Log record trigger: a change log is set in the database to record all modification operations on the data. By parsing these change logs, you can obtain the new, modified, and deleted information of the data, thereby triggering incremental synchronization. Data change identification trigger: In the source database, a specific identification field can be set to indicate whether the data has changed. When the application modifies the data, this identification field is also updated. The incremental synchronization task determines which data needs to be synchronized by checking this identification field. Business operation trigger: In some business scenarios, specific business operations will explicitly trigger incremental synchronization.
[0090] In this program, if Figure 3 As shown, during the data synchronization process, if the data status of the source database does not meet the preset full synchronization trigger conditions, the system will automatically enter the incremental synchronization detection phase. Specifically, the system will further verify whether the data in the source database meets the preset incremental synchronization trigger conditions. If the incremental synchronization trigger conditions are met, the system will use an efficient data capture mechanism to accurately identify and extract the newly added and / or modified data information in the source database. The newly added and / or modified data information in the source database is then systematically incorporated into the incremental synchronization process. After processing steps such as data conversion, cleansing, and verification, it is finally quickly migrated to the target database, ensuring data consistency and real-time performance between the target database and the source database. For example, the full data synchronization task is executed through the run_increment_sync_services function.
[0091] In this solution, after completing full and incremental synchronization, consistency verification is performed on the synchronization results to ensure data accuracy and integrity. This process aims to accurately identify and correct any data discrepancies between the source and target databases through systematic comparison and verification, thereby ensuring that data is not lost, incorrect, or inconsistent during the synchronization process, effectively maintaining data quality and the stable operation of the business system.
[0092] In this embodiment, Figure 6 The automated test flow chart provided in Example 3 of this application is as follows: Figure 6 As shown, full synchronization and / or incremental synchronization are used to synchronize data information from the source database to the target database.
[0093] The technical solution of the embodiment of the present invention obtains the data information of the source database and performs full synchronization and / or incremental synchronization of the data information of the source database to the target database. By executing this technical solution and building an efficient data synchronization mechanism, the full data and incremental change information of the source database can be captured in real time, and accurately and quickly synchronized to the target database. It not only supports flexible configuration of full synchronization and incremental synchronization modes, but also has a powerful synchronization testing function, which can conduct a comprehensive and in-depth evaluation of the accuracy, efficiency and stability of data synchronization from multiple dimensions such as data integrity, consistency, and timeliness, thereby providing scientific and reliable quality assurance for data migration and integration.
[0094] Example 4
[0095] Figure 7 This is a schematic diagram of another automated test process for database migration provided by the fourth embodiment of the present invention. The relationship between this embodiment and the above embodiment is a detailed description of the automated test process for database migration. Figure 7 As shown, the method includes:
[0096] S710: Acquire a target test interface; wherein the target test interface includes a user interface and an application programming interface;
[0097] S720, determining a target test case that matches the target test interface;
[0098] S730 . During the process of migrating data information from the source database to the target database, execute the target test case to obtain query results corresponding to the source database and query results corresponding to the target database.
[0099] In this solution, at different stages of data migration, target test cases are run in a predefined order. The same query instructions are sent to both the source and target databases, and the query results returned by each database are received and recorded. For example, the query results from both the source and target databases are retrieved using the retrieve_and_process_query_results function.
[0100] Furthermore, after obtaining the query results corresponding to the source database and the query results corresponding to the target database, all fields, types, precisions, and ranges are automatically extracted, and rule processing is performed on specific field types, including data type conversion and formatting.
[0101] S740. Compare the query results corresponding to the source database and the query results corresponding to the target database according to a preset target comparison method to obtain a test result; wherein the target comparison method includes result set comparison, MD5 comparison, random sampling comparison and massive table sampling comparison.
[0102] In this embodiment, result set comparison refers to comparing the query results corresponding to the source database with the query results corresponding to the target database, which is suitable for scenarios with small data volume or high accuracy requirements.
[0103] Among them, MD5 comparison refers to comparing the hash value of the query result corresponding to the source database with the hash value of the query result corresponding to the target database, which is suitable for large-scale data.
[0104] In this solution, random sampling comparison refers to performing sampling comparison between the query results corresponding to the source database and the query results corresponding to the target database, which can reduce computing overhead.
[0105] Among them, the massive table sampling comparison randomly selects a specified number of tables and compares them, reducing the comparison pressure.
[0106] Furthermore, in large-scale data processing scenarios, random sampling and comparison adopt a two-tier randomization strategy to ensure comprehensive and representative data verification coverage. The first is random sampling of data intervals: for large data sets, the get_random_interval function dynamically generates random data segments, effectively reducing the computational overhead of full comparison while ensuring sample independence; the second is table-level random selection: when faced with massive data tables, the generate_random_table_names function randomly extracts target data tables from the full table pool in a probabilistically balanced manner based on the set number of samples, accurately locating key verification objects. This tiered randomization mechanism can flexibly adapt to data environments of varying scale and complexity, significantly improving the efficiency and accuracy of data consistency verification.
[0107] In this solution, target comparison methods can include exact comparison and fuzzy comparison. Exact comparison achieves high-precision difference detection by meticulously scanning row and column by row. Fuzzy comparison uses a rapid screening strategy, focusing on identifying inconsistent row data while ignoring detailed differences at the column level.
[0108] Optionally, after obtaining the test result, the method further includes:
[0109] Based on the preset Allure format rules, convert the test results into a test report in Allure format;
[0110] The test report in the Allure format is displayed on a web page and / or sent via email; wherein, when displaying the test report in the Allure format, the server converts the test report in the Allure format into a format that can be recognized by the web page and deploys it under the target web page path.
[0111] Among them, a professional test report generation tool is used to convert the test results into a test report that complies with the Allure format.
[0112] Furthermore, based on the detailed test report generated in Allure format, a summary report in HTML format is created. This summary report should extract the key information of the test and present the overall test results in a concise and clear manner.
[0113] In this solution, the generated Allure detailed test report and HTML summary report are published using the Nginx server. First, configure the Nginx server to correctly point to the file path where the test report is stored. Then, use Nginx's HTTP service to provide the test report as a webpage for relevant personnel to access.
[0114] Furthermore, Nginx is used to deploy and display test reports, and old test reports, log files, and screenshots can be cleaned up through automated means to free up storage space.
[0115] In this embodiment, after the test process is completed and the test report is generated, an automated script implements an email notification function to ensure that relevant personnel receive test results in a timely manner. The email content should include links to the Allure detailed test report and HTML summary report, allowing direct access to the detailed results. A link to the latest test report is also provided to facilitate access to historical reports for easy querying of past test records.
[0116] In this plan, Figure 8 This is a flow chart of the data comparison algorithm provided in Example 4 of this application, as shown in FIG. Figure 8 As shown, based on at least one of result set comparison, MD5 comparison, random sampling comparison, and massive table sampling comparison, the query results corresponding to the source database and the query results corresponding to the target database are compared to obtain test results, and the test results are checked for consistency. When the test results are inconsistent, the test results are checked for differences, the comparison results are recorded, and the comparison report data is returned.
[0117] In this embodiment, Figure 9 The test report generation diagram provided in the fourth embodiment of the present application is as follows: Figure 9As shown, after the test is completed, the comparison results are collected, an Allure test report is generated, and the test report is displayed on the web page or in the form of an email.
[0118] Furthermore, you can call the compare_massive_results_by_md5 function to verify data consistency; for inconsistent data, call the check_difference function to locate the specific difference.
[0119] The technical solution of the embodiment of the present invention obtains the target test interface, determines the target test case that matches the target test interface, and then executes the target test case in the process of migrating the data information of the source database to the target database, obtains the query results, and compares the query results. By implementing this technical solution, the test execution efficiency is improved, the operation process is simplified, and by eliminating the manual operation link, the test errors caused by negligence or improper operation are effectively avoided, ensuring the accuracy and completeness of the data migration process. At the same time, the diversified report presentation forms provided by the system, combined with the intelligent automatic notification mechanism, can push abnormal information in real time, greatly improving the timeliness and accuracy of problem tracking and analysis, and effectively promoting efficient closed-loop management of testing work.
[0120] Example 5
[0121] Figure 10 This is a schematic diagram of another automated testing method for database migration provided by the fifth embodiment of the present invention. The relationship between this embodiment and the above embodiment is a description of the initialization process of the source database and the target database. Figure 10 As shown, the method includes:
[0122] S1010. Obtain link information and determine test cases based on the link information; start the service processes of the source database and the target database, and check the connection status of the services; execute SQL statements to delete tables and sequences in the target database; and insert preset initial data into the specified table of the source database.
[0123] In data transmission and storage systems, link information may be a path for data to be transmitted from one storage device or processing unit to another.
[0124] In this plan, Figure 11 The system initialization flow chart provided in Example 5 of this application is as follows: Figure 11 As shown, link information can be collected through script content. For example, define pytest_addoption in the contest.py file to add the --links command line parameter. Use the get_links method to parse the --links parameter and dynamically store link information based on the passed value.
[0125] Further, such as Figure 11 As shown, according to the obtained link information, the test case Excel file in the corresponding directory is automatically scanned and the test cases are collected.
[0126] In this embodiment, in a data migration scenario, the system initializes services for both the source and target databases. Specifically, the system implements automated service initialization for both the source and target databases through the initialize_db_services core function. This function dynamically parses the db_services.yml configuration file based on link information, extracts database connection parameters, and performs initialization operations on both the source and target databases.
[0127] Furthermore, during the initialization process, the system automatically verifies the database connection status, employing a multi-level health check mechanism to ensure connection validity and stability. If a connection anomaly is detected, an intelligent reconnection strategy is immediately triggered: after the initial failure, an exponential backoff algorithm is used to retry. If multiple retries fail, a detailed exception log is recorded, including the error code, error message, and connection attempt timestamp, to facilitate subsequent troubleshooting and location. The entire process strictly adheres to the database service lifecycle management specifications, ensuring that both the source and target databases remain available for subsequent data operations.
[0128] In this program, if Figure 11 As shown, execute SQL statements to delete tables and sequences in the target database. Write a clean_database function that automatically cleans up tables and sequences under a specified schema in the target database. It first retrieves information about all tables and sequences under the specified schema and then constructs the corresponding delete SQL statements to perform the cleanup. If a constraint issue causes partial deletion failure, the function automatically detects undeleted items and retries until the cleanup is complete.
[0129] Further, such as Figure 11 As shown, the preset initial data is inserted into the specified table of the source database. The setup_database function is called to automatically initialize the source database's SQL file. Based on the current link information, the SQL files in the specified directory are scanned and read. The SQL statements are parsed and the corresponding schema is automatically assembled to adapt the SQL statements to the target database structure. The SQL statements are executed sequentially. If any failure occurs during execution, a rollback mechanism is automatically triggered, and error information is recorded for subsequent troubleshooting.
[0130] S1020: Acquire a target test interface; wherein the target test interface includes a user interface and an application programming interface;
[0131] S1030, determining a target test case that matches the target test interface;
[0132] S1040. During the process of migrating data information from the source database to the target database, execute the target test case to obtain a test result; wherein, the source database is an Oracle database; and the target database is a GaussDB database.
[0133] The technical solution of the embodiment of the present invention initializes the system, then obtains the target test interface, determines the target test case that matches the target test interface, and then executes the target test case in the process of migrating data information from the source database to the target database, obtains the query results, and compares the query results. By implementing this technical solution, it is possible to ensure that the test environment is clean and available, and eliminate possible interference factors. It improves the efficiency of test execution, simplifies the operating process, and effectively avoids test errors caused by negligence or improper operation by eliminating manual operation links, ensuring the accuracy and completeness of the data migration process.
[0134] Example 6
[0135] Figure 12 This is a schematic diagram of the structure of the automated testing device for database migration provided by Example 6 of the present invention. Figure 12 As shown, the device includes:
[0136] The target test interface acquisition module 1210 is used to acquire the target test interface; wherein the target test interface includes a user interface and an application programming interface;
[0137] A target test case determination module 1220 is configured to determine a target test case that matches the target test interface;
[0138] The test result obtaining module 1230 is used to execute the target test case and obtain the test result during the process of migrating data information from the source database to the target database; wherein, the source database is an Oracle database; and the target database is a GaussDB database.
[0139] Optionally, the target test case determination module 1220 is specifically configured to:
[0140] When the target test interface is a user interface interface, a predetermined first operation case is used as a target test case matching the target test interface; wherein the first operation case is an interface operation case;
[0141] When the target test interface is an application programming interface, a predetermined second operation case is used as a target test case that matches the target test interface; wherein the second operation case is at least one of a full comparison case, an incremental comparison case, and an extended case.
[0142] Optionally, when the target test interface is a user interface, the target test case determination module 1220 is further configured to:
[0143] Using a preset large model to monitor the user interface in real time, determining a target parameter of a change; wherein the target parameter includes at least one of an element position, an element attribute, and an element path;
[0144] The target positioning expression is adjusted according to the changed target parameter; wherein the target positioning expression is a tool for locating a specific element in an XML or HTML document.
[0145] Optionally, the test result obtaining module 1230 includes:
[0146] A data information acquisition unit, used to acquire data information from a source database;
[0147] A data information determination unit, configured to determine whether the data information of the source database meets a preset full synchronization trigger condition;
[0148] A full synchronization unit, configured to perform full synchronization on the data information of the source database if the conditions are met, and migrate the data information of the source database to the target database;
[0149] The incremental synchronization unit is used to determine whether the data information of the source database meets the preset incremental synchronization trigger conditions if not met; if so, determine the new and / or modified data information in the source database, and perform incremental synchronization on the new and / or modified data information in the source database, and migrate the new and / or modified data information in the source database to the target database.
[0150] Optionally, the test result obtaining module 1230 is specifically configured to:
[0151] During the process of migrating data information from the source database to the target database, executing the target test case to obtain query results corresponding to the source database and query results corresponding to the target database;
[0152] The query results corresponding to the source database and the query results corresponding to the target database are compared according to a preset target comparison method to obtain a test result; wherein the target comparison method includes result set comparison, MD5 comparison, random sampling comparison and massive table sampling comparison.
[0153] Optionally, the test result obtaining module 1230 is further configured to:
[0154] Based on the preset Allure format rules, convert the test results into a test report in Allure format;
[0155] The test report in the Allure format is displayed on a web page and / or sent via email; wherein, when displaying the test report in the Allure format, the server converts the test report in the Allure format into a format that can be recognized by the web page and deploys it under the target web page path.
[0156] Optionally, the device further includes:
[0157] The initialization module is used to obtain link information and determine test cases based on the link information; start the service processes of the source database and the target database and check the connection status of the services; execute SQL statements to delete tables and sequences in the target database; and insert preset initial data into the specified table of the source database.
[0158] The automated testing device for database migration provided by the embodiment of the present invention can execute the automated testing method for database migration provided by any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0159] Example 7
[0160] Figure 13 A schematic diagram of the structure of an electronic device 10 that can be used to implement an embodiment of the present invention is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices (such as helmets, glasses, watches, etc.) and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present invention described and / or claimed herein.
[0161] like Figure 13As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12, a random access memory (RAM) 13, etc., which is communicatively connected to the at least one processor 11. The memory stores a computer program that can be executed by the at least one processor. The processor 11 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 12 or the computer program loaded from the storage unit 18 into the random access memory (RAM) 13. Various programs and data required for the operation of the electronic device 10 can also be stored in the RAM 13. The processor 11, ROM 12, and RAM 13 are connected to each other via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0162] Multiple components in the electronic device 10 are connected to the I / O interface 15, including an input unit 16, such as a keyboard, a mouse, etc.; an output unit 17, such as various types of displays, speakers, etc.; a storage unit 18, such as a magnetic disk, an optical disk, etc.; and a communication unit 19, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.
[0163] The processor 11 can be any general-purpose and / or specialized processing component with processing and computing capabilities. Some examples of the processor 11 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various specialized artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, a digital signal processor (DSP), and any other suitable processor, controller, microcontroller, etc. The processor 11 executes the various methods and processes described above, such as the automated testing method for database migration.
[0164] In some embodiments, the automated testing method for database migration can be implemented as a computer program tangibly contained in a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program can be loaded and / or installed on electronic device 10 via ROM 12 and / or communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more steps of the automated testing method for database migration described above can be performed. Alternatively, in other embodiments, processor 11 can be configured to execute the automated testing method for database migration in any other appropriate manner (e.g., via firmware).
[0165] Various embodiments of the systems and techniques described above can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on a chip (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system that includes at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0166] Computer programs for implementing the methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when the computer program is executed by the processor, the functions / operations specified in the flowcharts and / or block diagrams are implemented. The computer program may be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0167] In the context of the present invention, computer-readable storage media can be tangible media that can contain or store a computer program for use with an instruction execution system, device or equipment or used in combination with an instruction execution system, device or equipment. Computer-readable storage media can include but are not limited to electronic, magnetic, optical, electromagnetic, infrared or semiconductor systems, devices or equipment, or any suitable combination of the foregoing. Alternatively, computer-readable storage media can be machine-readable signal media. More specific examples of machine-readable storage media can include electrical connections based on one or more lines, portable computer disks, hard disks, random access memories (RAM), read-only memories (ROM), erasable programmable read-only memories (EPROM or flash memory), optical fibers, portable compact disk read-only memories (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0168] To provide interaction with a user, the systems and techniques described herein can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the electronic device. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0169] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), a blockchain network, and the Internet.
[0170] A computing system may include clients and servers. The clients and servers are typically remote from each other and typically interact via a communication network. This client-server relationship arises through computer programs running on the respective computers, creating a client-server relationship. The server may be a cloud server, also known as a cloud computing server or cloud host. This server is a hosting product within the cloud computing service ecosystem that addresses the management difficulties and limited scalability of traditional physical hosting and VPS services.
[0171] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in the present invention can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solution of the present invention can be achieved. This is not limited herein.
[0172] The above specific embodiments do not limit the scope of protection of the present invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may be made based on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention are intended to be included within the scope of protection of the present invention.
Claims
1. The automated testing method for database migration is characterized by: include: Obtaining a target test interface; wherein the target test interface includes a user interface and an application programming interface; Determine a target test case that matches the target test interface; During the process of migrating data information from the source database to the target database, the target test case is executed to obtain the test result; wherein, the source database is an Oracle database; and the target database is a GaussDB database.
2. The method according to claim 1, characterized in that Determine a target test case that matches the target test interface, including: When the target test interface is a user interface interface, a predetermined first operation case is used as a target test case matching the target test interface; wherein the first operation case is an interface operation case; When the target test interface is an application programming interface, a predetermined second operation case is used as a target test case that matches the target test interface; wherein the second operation case is at least one of a full comparison case, an incremental comparison case, and an extended case.
3. The method according to claim 2, characterized in that When the target test interface is a user interface, the method further includes: Using a preset large model to monitor the user interface in real time, determining a target parameter of a change; wherein the target parameter includes at least one of an element position, an element attribute, and an element path; The target positioning expression is adjusted according to the changed target parameter; wherein the target positioning expression is a tool for locating a specific element in an XML or HTML document.
4. The method according to claim 1, wherein During the process of migrating data information from the source database to the target database, the method further includes: Obtain data information from the source database; Determine whether the data information of the source database meets the preset full synchronization trigger conditions; If the conditions are met, a full synchronization is performed on the data information of the source database to migrate the data information of the source database to the target database; If not, determine whether the data information in the source database meets the preset incremental synchronization trigger conditions. If so, determine the new and / or modified data information in the source database, and perform incremental synchronization on the new and / or modified data information in the source database, and migrate the new and / or modified data information in the source database to the target database.
5. The method according to claim 1, characterized in that During the process of migrating data from the source database to the target database, executing the target test case and obtaining the test results include: During the process of migrating data information from the source database to the target database, executing the target test case to obtain query results corresponding to the source database and query results corresponding to the target database; The query results corresponding to the source database and the query results corresponding to the target database are compared according to a preset target comparison method to obtain a test result; wherein the target comparison method includes result set comparison, MD5 comparison, random sampling comparison and massive table sampling comparison.
6. The method according to claim 1 or 5, characterized in that The method further comprises: Based on the preset Allure format rules, convert the test results into a test report in Allure format; The test report in the Allure format is displayed on a web page and / or sent via email; wherein, when displaying the test report in the Allure format, the server converts the test report in the Allure format into a format that can be recognized by the web page and deploys it under the target web page path.
7. The method according to claim 1, characterized in that Before acquiring the target test interface, the method further includes: Obtain link information and determine test cases based on the link information; start the service processes of the source database and the target database and check the connection status of the services; execute SQL statements to delete tables and sequences in the target database; and insert preset initial data into the specified table of the source database.
8. The automated testing device for database migration is characterized by: include: A target test interface acquisition module is used to acquire a target test interface; wherein the target test interface includes a user interface and an application programming interface; A target test case determination module, configured to determine a target test case that matches the target test interface; The test result acquisition module is used to execute the target test case and obtain the test result during the process of migrating data information from the source database to the target database; wherein, the source database is an Oracle database; and the target database is a GaussDB database.
9. An electronic device, characterized in that: The electronic device comprises: At least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to perform the automated testing method for database migration according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a processor to implement the automated testing method for database migration according to any one of claims 1 to 7 when executed.