Database test method and system, electronic equipment and storage medium

By introducing the data microservice unit and syntax translation module into the database test system, the problem of flexibility and adaptability of existing tools in the face of ultra-large-scale data traffic is solved, efficient traffic data recording and playback is achieved, and the system is improved. The scalability and scalability support large-scale, high-concurrency database testing.

CN118550814APending Publication Date: 2024-08-27STATE GRID ZHEJIANG ELECTRIC POWER CO LTD +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410477492.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-04-19
Publication Date
2024-08-27

AI Technical Summary

Technical Problem

Existing database testing tools are difficult to flexibly configure and adjust in the face of ultra-large-scale data traffic, and have poor adaptability to high-concurrency environments. It is difficult to accurately capture and playback all traffic data, resulting in high complexity and high dependency in recording and playback methods. , it is difficult to cope with ultra-large-scale traffic data.

Method used

By introducing the data microservice unit into the database test system, the recording module and the playback module are used to record and play back the traffic data, and the syntax translation module is used to translate the traffic data into the test database language according to the maximum translatable syntax difference comparison table, and through collection, The recording and storage sub-module performs data collection, preprocessing and storage to achieve asynchronous processing and high scalability.

Benefits of technology

It improves the flexibility and versatility of recording and playback tools, can effectively handle ultra-large-scale traffic data, reduces the coupling of functional components, achieves better scalability and scalability, and supports large-scale and high concurrency. SQL traffic playback test and performance comparison.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118550814A
    Figure CN118550814A
Patent Text Reader

Abstract

The invention provides a database testing method and system, electronic equipment and a storage medium. The method is applied to a database test system, the database test system comprises a data micro-service unit, an original database and a test database, and the data micro-service unit comprises a recording module and a playback module; the recording module and the playback module are respectively added into the database test system through a recording plug-in and a playback plug-in; the method comprises the following steps: the recording module records the traffic data of the original database according to a preset traffic data recording requirement; the playback module plays back the flow data in the test database to obtain test data; the test data is used for indicating a performance test result and a function test result of the test database. According to the method and the device, the flexibility of recording and playback tools can be improved, the universality is improved, and super-large-scale traffic data challenges can be coped with.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of database technology, and in particular to a database testing method, system, electronic device and storage medium. Background Art

[0002] A database is a "warehouse that organizes, stores, and manages data according to data structures." It is a collection of large amounts of data that is stored in a computer for a long time, organized, shareable, and uniformly managed.

[0003] In the process of database migration or upgrade, the database can be automatically tested by recording and replaying data traffic. In the related art, traffic recording and playback tools are usually used for data recording and playback. However, these tools have general difficulties and cannot cope with problems such as ultra-large-scale data traffic. Summary of the invention

[0004] In view of this, the purpose of this application is to solve the technical problems raised by the background technology and to propose a database testing method, system, electronic device and storage medium.

[0005] Based on the above purpose, the present application provides a database testing method, which is applied to a database testing system, wherein the database testing system includes: a data microservice unit, an original database and a test database, wherein the data microservice unit includes a recording module and a playback module; the recording module and the playback module are respectively added to the database testing system through a recording plug-in and a playback plug-in, including:

[0006] The recording module records the flow data of the original database according to the preset flow data recording requirements;

[0007] The playback module plays back the traffic data in the test database to obtain test data; the test data is used to indicate the performance test results and function test results of the test database.

[0008] Optionally, the data microservice unit further includes a syntax translation module; the syntax translation module is added to the database testing system through a syntax transfer plug-in;

[0009] Before the playback module plays back the traffic data in the test database, the playback module also includes:

[0010] The syntax translation module translates the traffic data into a test database language according to a maximum translatable syntax difference comparison table; the maximum translatable syntax difference comparison table is configured according to program parameters.

[0011] Optionally, the recording module includes a collection submodule;

[0012] The recording module records the flow data of the original database according to the preset flow data recording requirements, including:

[0013] The collection submodule collects the flow data in response to meeting a preset flow data collection condition; the flow data collection condition is determined according to a configuration file.

[0014] Optionally, the flow data collection condition includes collecting the flow data before and after a preset cut-off point, and the cut-off point includes when the original database executes the flow data.

[0015] Optionally, the recording module further includes a recording submodule;

[0016] The method comprises:

[0017] The recording submodule pre-processes the flow data to obtain processed flow data, and records the processed flow data into a corresponding log according to the data type; the data content of the data in the log includes a timestamp, a primary key and a foreign key.

[0018] Optionally, the method further includes a storage submodule;

[0019] The method comprises:

[0020] The storage submodule constructs the data in the log into a time series according to the timestamp and stores it in a time series database; the time series database is constructed according to the timestamp and the primary key index.

[0021] Optionally, after obtaining the test data, the method further includes:

[0022] The test data is compared with the return data after the original database executes the traffic data to obtain a comparison result; the comparison result indicates whether the processing results of the test database are consistent with those of the source data, and whether the functions and performances of the test database are consistent with those of the original database.

[0023] Based on the same inventive concept, one or more embodiments of the present application further provide a database testing system, including:

[0024] A data microservice unit, an original database and a test database, wherein the data microservice unit includes a recording module and a playback module; the recording module and the playback module are added to the database test system through a recording plug-in and a playback plug-in respectively;

[0025] The recording module is configured to record the flow data of the original database according to a preset flow data recording requirement;

[0026] The playback module is configured to play back the traffic data in the test database to obtain test data; the test data is used to indicate the performance test results and function test results of the test database.

[0027] Optionally, the data microservice unit further includes a syntax translation module; the syntax translation module is added to the database testing system through a syntax transfer plug-in;

[0028] The syntax translation module is configured to translate the traffic data into a test database language according to a maximum translatable syntax difference comparison table; the maximum translatable syntax difference comparison table is configured according to program parameters.

[0029] Optionally, the recording module includes a collection submodule;

[0030] The collection submodule is configured to collect the flow data in response to meeting a preset flow data collection condition; the flow data collection condition is determined according to a configuration file.

[0031] Optionally, the recording module further includes a recording submodule;

[0032] The recording submodule is configured to pre-process the flow data to obtain processed flow data, and record the processed flow data into a corresponding log according to the data type; the data content of the data in the log includes a timestamp, a primary key and a foreign key.

[0033] Optionally, the recording module further includes a storage submodule;

[0034] The storage submodule is configured to construct the data in the log into a time series according to the timestamp and store it in a time series database; the time series database is indexed according to the timestamp and the primary key.

[0035] Based on the same inventive concept, one or more embodiments of the present application also provide an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, a database testing method as described in any one of the above is implemented.

[0036] Based on the same inventive concept, one or more embodiments of the present application further provide a non-transitory computer-readable storage medium, wherein the non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute any of the above-mentioned database testing methods.

[0037] As can be seen from the above, the database testing method provided by the present application is applied to a database testing system, wherein the database testing system includes: a data microservice unit, an original database and a test database, wherein the data microservice unit includes a recording module and a playback module; the recording module and the playback module are respectively added to the database testing system through a recording plug-in and a playback plug-in, and the method records the traffic data of the original database according to preset traffic data recording requirements through the recording module; the playback module plays back the traffic data in the test database to obtain test data; the test data is used to indicate the performance test results and functional test results of the test database.

[0038] Through the method provided by this application, traffic data recording and playback can be added to the data testing system of the microservice architecture through plug-ins, and traffic data recording and traffic data playback can be performed step by step. The traffic data recording is performed according to the preset recording requirements. Through the technical solution provided by this application, the flexibility of recording and playback tools can be improved, the versatility can be improved, and the challenges of ultra-large-scale traffic data can be met.

[0039] The database testing system, electronic device and computer-readable storage medium provided in the present application are all capable of implementing the steps of the above-mentioned database testing method, and therefore also have the beneficial effects of the above-mentioned database testing method. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] In order to more clearly illustrate the technical solutions in the present application or related technologies, the drawings required for use in the embodiments or related technical descriptions are briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0041] Figure 1 A flowchart of a database testing method according to one or more embodiments of the present application;

[0042] Figure 2 A schematic diagram of the structure of a database testing system according to one or more embodiments of the present application;

[0043] Figure 3 A schematic diagram of the structure of an application system of one or more embodiments of the present application;

[0044] Figure 4 A schematic diagram of the structure of an application system of one or more embodiments of the present application;

[0045] Figure 5 A schematic diagram of the structure of an electronic device according to one or more embodiments of the present application. DETAILED DESCRIPTION

[0046] In order to make the objectives, technical solutions and advantages of the present application more clearly understood, the present application is further described in detail below in combination with specific embodiments and with reference to the accompanying drawings.

[0047] It should be noted that, unless otherwise defined, the technical terms or scientific terms used in the embodiments of the present application should be the usual meanings understood by people with ordinary skills in the field to which the present application belongs. The "first", "second" and similar words used in the embodiments of the present application do not represent any order, quantity or importance, but are only used to distinguish different components. "Including" or "comprising" and similar words mean that the elements or objects appearing in front of the word cover the elements or objects listed after the word and their equivalents, without excluding other elements or objects. "Connect" or "connected" and similar words are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. "Up", "down", "left", "right" and the like are only used to indicate relative positional relationships. When the absolute position of the described object changes, the relative positional relationship may also change accordingly.

[0048] As described in the background art, during the process of migrating or upgrading a database, it is necessary to perform automated testing on the database.

[0049] For example, in the energy Internet power marketing system of one embodiment of the present application, considering that the Oracle database has great limitations in business support, system development, and operation and maintenance, which seriously restricts the development of the above-mentioned marketing system, it is planned to replace the Oracle database in the original information system with a domestic relational database. That is, before the new system is officially launched, it is necessary to simulate the functional testing and stress testing of the database of the new system in the real online environment. In order to achieve the most realistic and comprehensive testing as possible, it is necessary to build a flow data recording and flow data playback tool, record all read and write requests and loads in the original Oracle database without intrusion, and obtain the performance indicators corresponding to all read and write requests, and then play back the read and write requests in the original database in turn according to the real flow and load into the replaced domestic relational database. By comparing the functional and performance differences between the domestic relational database and the Oracle database, the real request results are used to predict the performance problems that may be encountered in advance and repair them, and the system performance is improved before the system goes online.

[0050] In another embodiment of the present application, it is necessary to optimize the existing database for problems such as slowness. Many database optimization problems require a large amount of data query. By analyzing the recorded traffic data, it can assist in slowness diagnosis, database testing, optimizer tuning, and other tasks.

[0051] In all the above scenarios, the database needs to be automatically tested. From the perspective of all service environments, only the online environment has rich scenarios, real data, and comprehensive coverage. Therefore, recording the request data of the online environment and simulating user requests in the specified environment for playback can effectively simulate the test environment in the actual application scenario to test the test database.

[0052] Related technologies usually use certain tools to record and replay traffic based on a Web server, application layer, or network protocol stack. For example, in the Web server recording method, you can use tools such as Burp Suite and Fiddler to intercept business data, establish requests and responses between the browser and the Web server to record traffic; in the application layer recording method, use tools such as tcpflow and tcpdump to capture network traffic and record traffic; in the network protocol stack recording method, use tools such as Wireshark and tcpdump to capture underlying network traffic and record traffic.

[0053] The above methods require in-depth understanding of the implementation methods of specific Web servers, application layers or network protocol stacks, and the use of tools to accurately capture and parse traffic data, which is highly complex. They need to be tightly integrated with specific network devices, operating systems or applications, resulting in strong dependence on specific environments, high coupling and poor portability. Due to their implementation methods and strong dependence, these methods are usually difficult to achieve flexible configuration and adjustment, and difficult to adapt to different network environments and traffic characteristics. In the case of high concurrency, traffic data presents dynamic changes, and the above recording and playback methods may be difficult to accurately capture and replay all traffic data. At the same time, in the face of ultra-large-scale traffic data, the need to capture, store and analyze a large amount of traffic data has put forward higher requirements for hardware resources and processing capabilities. The above traffic recording and playback methods may face storage and processing bottlenecks.

[0054] That is, traditional traffic recording and playback methods based on Web servers, application layers, and network protocol stacks are highly complex, highly dependent, lack flexibility, and face challenges in terms of ultra-large scale and concurrency.

[0055] In response to the above technical problems, the present application proposes a database testing method, which adds the recording microservice module and the playback microservice module to the existing microservice architecture system through a plug-in, records all read and write requests and loads in the original database, and plays them back to the test database, so as to test the function and performance of the test database. This technical solution can improve the scalability, concurrent processing capabilities and coupling control capabilities of traditional methods; at the same time, combined with the test method based on traffic playback, it can more effectively perform large-scale, high-concurrency SQL traffic playback tests and performance comparisons. The technical solution of this application can effectively reduce the general difficulty and can cope with ultra-large-scale traffic data.

[0056] The database testing method of one or more embodiments of the present application is applied to Figure 2 The database testing system shown in the figure comprises: a data microservice unit, an original database and a test database. The data microservice unit comprises a recording module and a playback module. The recording module and the playback module are respectively added to the database testing system through a recording plug-in and a playback plug-in.

[0057] Microservices refer to service units with high cohesion formed by splitting according to business capabilities and business relevance. They can be deployed, run, upgraded, and evolved independently.

[0058] The recording module and playback module in this application can use microservice technology and be added to the above-mentioned database test system through plug-ins. In the face of ultra-large-scale system architecture, the above-mentioned database test system can be implemented using microservice architecture. Microservice architecture refers to an application architecture for business capability planning. The services in the microservice architecture are business modules extracted according to business capabilities. They are independently developed and deployed, but they need to cooperate with each other to complete the entire business function.

[0059] By building a traffic data recording module and a traffic data playback module based on microservice technology, the coupling degree of functional components can be reduced in the system architecture, and the recording and playback functions can be decoupled to achieve asynchronous processing of recording and playback. By adding the above recording module and the callback module to the above database test system through plug-ins, functional customization can be achieved, reducing maintenance costs without modifying the architecture code; and requests can be decoupled from processing, and the architecture and database access-related functions can be separated to achieve better scalability and extensibility, and the architecture has the ability to support ultra-large-scale data volumes.

[0060] The above-mentioned original database and test database can be centralized databases or distributed databases. Centralized databases refer to databases in stand-alone or master-slave mode, such as relational databases such as Oracle and MySQL. Distributed databases refer to database systems that use storage technologies such as distributed transaction processing, automatic data sharding, and multiple copies of data to connect multiple logically related nodes scattered in a computer network and jointly provide services to the outside world. The above-mentioned data microservice unit is connected to both the original database and the test database.

[0061] In the following embodiments of the present application, the use request of the database is explained in Structured Query Language (SQL). The present application does not limit the programming language of the query statement.

[0062] The technical solutions of one or more embodiments of the present application are described in detail below through specific examples.

[0063] refer to Figure 1 , the above method comprises the following steps:

[0064] Step S101: the recording module records the traffic data of the original database according to the preset traffic data recording requirements.

[0065] The recording module is used to acquire, record and store traffic data. The traffic data includes a request to use the original database. The request may include a read and write request.

[0066] Preferably, the recording module includes one or more of a collection submodule, a recording submodule and a storage submodule. The collection submodule of the present application can be used to collect all usage requests of the original database in the digital system. The collected data may include one or more of flow data, parameter data, return data, original database performance data, original database connection data and the like.

[0067] It should be noted that this application requires the collection of traffic data including usage requests and processing results of usage requests.

[0068] Aspect Oriented Programming (AOP) is a technology that achieves unified maintenance of program functions through pre-compilation and runtime dynamic proxy. AOP can be used to isolate various parts of business logic, thereby reducing the coupling between the various parts of business logic, improving the reusability of the program, and improving development efficiency.

[0069] This application can adopt the AOP method, that is, to collect traffic data based on application recording. AOP allows the definition of cross-cutting concerns, which can be applied to multiple modules or classes without modifying specific code. In database operations, traffic data recording can be implemented through the AOP method. The logging function for database operations can be added without modifying the original code, which helps to improve the maintainability and security of the digital system.

[0070] Specifically, using the AOP method to implement traffic data collection includes: defining an aspect, defining the behavior of the cross-cutting concern (Joint Point). Creating an aspect for the recording behavior of traffic data, the aspect will execute the above behavior before and after each traffic data is executed. Optionally, the behavior can be set through a configuration file.

[0071] Optionally, the above behavior (Advice) can be designed as the original database executing the use request for the original database. In this way, the use of the before-advice (Before Advice) means that it is executed before the original database executes the above use request and collects the use request; the after-advice (After Advice) means that it is executed after the original database executes the above use request and collects the processing result of the original database on the above use request.

[0072] Most programming languages ​​have AOP frameworks, which support the implementation of traffic data collection logic. You can adjust the aspects by configuring the AOP framework to correctly intercept and collect traffic data. By using AOP to collect all SQL traffic, you can avoid code intrusion.

[0073] The recording submodule is used to clean and record the above-collected traffic data. Data cleaning can include one or more cleaning methods such as removing comments and processing special characters. Recording includes recording the traffic data in a corresponding log in a certain way.

[0074] It should be noted that in the process of SQL traffic recording, special data types also need to be recorded. For example, Oracle database BLOB is a binary large object. Since the maximum capacity supported by the BLOB data type of general databases is limited, it needs to be stored in the file in the form of binary byte stream to complete data recording; Oracle database CLOB is a text large object, which also needs to be stored in the file in the form of text byte stream to complete data recording.

[0075] Optionally, the above logs may include one or more of a traffic data log, a parameter data log, a return data log, a database performance log, and a database connection log. The traffic data log mainly focuses on the execution of the use request, including the execution frequency and the time consumed in the database; the parameter data log can record the parameters and their values ​​of the use request; and the return data log can record the data returned by the use request. The database performance log can comprehensively record the database performance indicators of the use request. The database performance log can help understand the execution of the use request in the database, including CPU consumption, IO consumption, waiting time, row number check and modification, buffer acquisition times, lock waiting information, transaction related information, and some performance indicators at the database level. Through these data, the performance bottlenecks and potential problems of the database can be better analyzed, and targeted optimization and improvement can be carried out. The database connection log can record the relevant information of the database connection, such as the IP address of the connection, the duration of the connection, etc. For the database connection, the correspondence between the database name and the database connection string is constructed, and the database connection acquisition function is designed to obtain the corresponding connection string through the connection database name specified by the current digital system, and then create a database connection. The type, quantity and recorded content of the above logs are not limited.

[0076] It should be noted that when recording traffic data in the corresponding log, the recorded data content needs to include timestamp, primary key and foreign key. The timestamp can be used for subsequent construction of time series database and data retrieval; the primary key can be used for subsequent data retrieval and can be set by auto-increment; the foreign key can be used to associate other logs.

[0077] Therefore, the data of the traffic data log may include: time_stamp: timestamp, sql_log_id: primary key, which can be assigned by auto-increment, sql_statement: traffic text, execution_duration: execution duration, execution_count: number of executions, user_id: user identification code that executes the request, which is a foreign key used to associate with the user table, database_name: database name, client_ip: client IP address, client_port: client port number, server_ip: server IP address, server_port: server port number, client_application: client application name, database_version: database version information, sql_parameters: request parameters, which can be stored in JSON format.

[0078] The data of the parameter data log may include: time_stamp: timestamp, sql_param_id: primary key, which can be assigned a value in an auto-incremental manner, sql_log_id: foreign key, used to associate with the log table, parameter_name: parameter name, parameter_value: parameter value, parameter_type: parameter type, such as string, integer, etc., parameter_length: parameter length.

[0079] The data returned in the data log may include: time_stamp: timestamp, return_data_id: primary key, which can be assigned in an auto-incremental manner, sql_log_id: foreign key, which can be associated with the log table, row_count: the number of rows returned, data: the returned data content, which can be stored in binary or other formats, data_format: the returned data format, such as JSON, XML, etc., data_size: the returned data size.

[0080] The data of the database performance log may include: time_stamp: timestamp, performance_stat_id: primary key, which can be assigned in an auto-incremental manner, sql_log_id: foreign key, used to associate with the log table, cpu_time: CPU consumption time, io_time: IO consumption time, wait_time: waiting time, rows_examined: number of rows examined, rows_modified: number of rows modified, buffer_gets: number of buffer get times, lock_wait_time: lock wait time, lock_wait_count: number of lock waits, lock_wait_type: lock wait type, such as shared lock, exclusive lock, etc., lock_wait_object: lock wait object, such as table, row, etc., transaction_id: transaction ID, transaction_isolation_level: transaction isolation level, transaction_id_id_level ... transaction_duration: transaction duration, transaction_status: transaction status, such as committed, rolled back, etc., transaction_type: transaction type, such as read, write, etc., database_page_faults: number of database page faults, database_page_splits: number of database page splits, database_deadlocks: number of database deadlocks, database_temp_page_writes: number of database temporary page writes, database_checkpoint_pages: number of database checkpoint pages, database_log_bytes_written: number of database log written bytes, database_log_bytes_read: number of database log read bytes, database_log_ios_waiting: number of database log waiting IO times.

[0081] The data of the database connection log may include: time_stamp: timestamp, connection_info_id: primary key, which can be assigned in an auto-incremental manner, sql_log_id: foreign key, used to associate with the SQL log table, ip_address: connected IP address, port: port number used for connection, protocol: protocol used, such as TCP / IP, connection_duration: connection duration, session_id: session ID, client_application: client application name, client_user_agent: client user agent information, database_session_state: database session state, such as connected, disconnected, etc.

[0082] The collected and recorded traffic data needs to be persisted, and the following considerations need to be taken into account: the amount of collected traffic data may be large, and it needs to be reasonably compressed and stored; the collected traffic data needs to be encrypted and protected to prevent data leakage and tampering; the collected traffic data needs to be identified and classified for subsequent playback and analysis. The storage submodule can be used to store the data in the above logs.

[0083] Time Series Data (TSD) is a string of data indexed by the time dimension. This type of data describes the measurement value of a measured subject at each time point within a time range. The present application can design a data model based on time series data to store traffic data, so as to effectively store traffic data logs, parameter data logs, return data logs, database performance logs, database connection logs and other logs according to timestamp information. Time series data can also include collection indicators, such as query per second (QPS), etc.

[0084] Timestamps help organize, query, and compare data, and it is necessary to ensure that the timestamp format of all log data is unified. This application can use UTC time or local time to ensure time consistency when processing and comparing different log data.

[0085] It should be noted that when inserting log data into the database table, ensure that the timestamp and each log primary key are the key fields of the record, so that the data can be sorted and retrieved based on the timestamp and primary key later.

[0086] This application also needs to select a data storage structure suitable for storing time series data. Preferably, methods such as column storage and time series indexing can be used to improve query performance. Use an efficient data insertion mechanism to ensure that traffic data can be quickly collected and stored. Use batch insertion, asynchronous insertion and other technologies to improve insertion performance. Use data compression and indexing, and select a suitable compression algorithm to reduce storage space usage based on the characteristics of the data and usage scenarios. At the same time, in order to improve query performance, appropriate indexes can be created, such as timestamp indexes, type indexes, etc.

[0087] Therefore, in some embodiments, the recording module of the present application includes a collection submodule, a recording submodule and a storage submodule. After the collection submodule collects the use request of the original database and the processing result of the use request of the original database, the recording submodule can clean the above traffic data and record it in the corresponding log, and finally the storage submodule stores the data in the above log. Through the above steps, the user can analyze and query the target data through the timestamp or primary key information, and can view, search and filter the data through the log.

[0088] Step S102: the playback module plays back the traffic data in the test database to obtain test data; the test data is used to indicate the performance test results and function test results of the test database.

[0089] After recording the traffic data, you need to replay the traffic in the test environment to verify the performance and stability of the test database. That is, by simulating real usage scenarios, you can help discover potential problems in the migration process or optimization of the test database, thereby improving the reliability and stability of the system.

[0090] Traffic data playback is to collect, record and store traffic data of digital systems in production environments, and then replay the traffic in a test environment to test the performance and stability of applications. Traffic playback can simulate real usage scenarios and help discover potential problems in the process of test database migration or optimization, thereby improving the reliability and stability of the system. Traffic playback is a method of automated testing that can greatly reduce the workload of testing and improve the accuracy and reliability of testing.

[0091] In order to ensure the business support capability after going online, migration drills and verifications at the database and application levels are conducted in a bypass verification environment before the online trial operation to ensure that the business system functions and performance fully meet business needs and reduce the risk of business application production. When comparison and verification are required, enable the request information collected in the log, access the business system in the parallel verification environment, and then operate the target domestic distributed database. Through traffic playback and data comparison, it is possible to verify whether the business function performance is consistent and whether the processing results of the target domestic database are consistent, and complete the parallel verification of database + application.

[0092] The application system is deeply integrated with the original database ecosystem, and there will be a large number of data access methods with the genes of the original database in the application. There are significant differences between different databases, such as Oracle database and domestic databases, in data definition language, data operation language, data control language and many other aspects. Therefore, before traffic playback, it is necessary to build a difference comparison table between the Oracle database and the test database, that is, the maximum convertible syntax difference comparison table.

[0093] The maximum translatable syntax difference comparison table plug-in consists of all translatable syntax difference comparison tables between the original database and the test database, which can be configured and generated through program parameters.

[0094] The translatable syntax difference comparison table is the largest set of translatable syntax difference comparison tables between the test database and the original database, that is, it contains all translatable syntax difference comparison tables. The translatable syntax difference comparison table refers to the database syntax elements that can be translated from the original database syntax into the test database syntax. It can be considered as a partial set of elements in the original database syntax elements used by the digital system that can be automatically translated into other database management system languages, listed in the form of a list. Its specific presentation form is a syntax element comparison table between the original database and other database management systems, which can be configured and generated through program parameters.

[0095] In constructing the maximum convertible grammatical difference comparison table, it is necessary to fully investigate the application scope, content and other specific contents of the original database in the digital system, especially the access methods of the original database in the business layer, to form the grammar set of the original database in the digital system; using the grammar set of the original database in the digital system as a benchmark, compare and analyze it with the test database, analyze the correspondence between the grammatical elements, special usages, special functions, etc. in the grammar set and the test database, or the way to convert it to the test database, retain the convertible parts common to the two database systems, and construct the maximum convertible grammar difference indicator set between the test database and the original database.

[0096] The comparison table of the maximum convertible syntax differences between the test database and the original database can at least include database connection methods, naming rules (including database name, table name, field name, etc.), common field types, primary keys, common functions, etc. As for indexes, partitions, stored procedures, packages, triggers, etc. that do not conform to the agreement, they can be manually migrated or executed by the DBA after completing the migration of table structure and table data. This constitutes the entire convertible syntax system of the test database and the original database, which can be defined as:

[0097] Syntax O-C =<Name,Field,PK,Conn>

[0098] In Syntax O-C In the quaternion:

[0099] Name: A set of naming rules to ensure that object names between two database management systems are consistent or convertible;

[0100] Field: field type collection;

[0101] PK: primary key definition rule set;

[0102] Conn: A collection of database connection rules.

[0103] Through the traffic data playback method based on the maximum transferable syntax difference comparison table, the migration drill verification and performance comparison between the original database and the test database are supported. The above test database can be any database.

[0104] According to the above content, a database testing method proposed in this application has the following advantages:

[0105] Strong scalability. Customized plug-ins for traffic data recording and playback modules are built into the system to reduce the coupling of functional components, making the system more flexible, maintainable and scalable. The modular design makes it easy to add new functions according to the needs of different scenarios, as well as modify or expand existing functions.

[0106] No code intrusion. The AOP method can realize traffic data collection without modifying the original code, avoiding the problem of code intrusion and further reducing the cost of modifying the existing digital system.

[0107] Comprehensive logging. The collected traffic data is recorded in an organized manner to form a variety of logs, such as traffic data logs, parameter data logs, return data logs, database performance logs, and database connection logs. This comprehensive logging helps with subsequent analysis and troubleshooting. At the same time, persistent storage in the form of time series data ensures data security and traceability, and facilitates subsequent query and analysis.

[0108] Support for multiple databases. The traffic data playback method based on the maximum transferable syntax difference comparison table not only facilitates the migration drill verification and performance comparison of the Oracle database, but also supports a variety of domestic distributed databases, improving the versatility and practicality of the method.

[0109] Convenient intelligent analysis and processing. Many database optimization problems require a large number of query operations. By analyzing the recorded traffic data, it can assist in slow diagnosis, database testing, optimizer tuning, etc. By automatically summarizing a large number of traffic data samples to form a key sample set, the database conversion only needs to focus on a small number of key samples to ensure consistency, greatly reducing the workload of manual analysis.

[0110] It should be noted that the method of the embodiment of the present application can be performed by a single device, such as a computer or server. The method of this embodiment can also be applied to a distributed scenario and completed by multiple devices cooperating with each other. In the case of such a distributed scenario, one of the multiple devices can only perform one or more steps in the method of the embodiment of the present application, and the multiple devices will interact with each other to complete the described method.

[0111] It should be noted that the above describes some embodiments of the present application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the above embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0112] Based on the same inventive concept, corresponding to any of the above-mentioned embodiment methods, the present application also provides a database testing system.

[0113] refer to Figure 2 The database test system includes: a data microservice unit 1, an original database 2 and a test database 3. The data microservice unit 1 includes a recording module 11 and a playback module 12. The recording module 11 and the playback module 12 are added to the database test system through a recording plug-in and a playback plug-in respectively.

[0114] The recording module 11 is configured to record the traffic data of the original database according to a preset traffic data recording requirement;

[0115] The playback module 12 is configured to playback the traffic data in the test database to obtain test data; the test data is used to indicate the performance test results and function test results of the test database.

[0116] Preferably, the data microservice unit 1 further includes a syntax translation module 13; the syntax translation module 13 is added to the database test system via a syntax transfer plug-in;

[0117] The syntax translation module 13 is configured to translate the traffic data into the test database language according to a maximum translatable syntax difference comparison table; the maximum translatable syntax difference comparison table is configured according to program parameters.

[0118] Preferably, the recording module 11 includes a collection submodule 111;

[0119] The collection submodule 111 is configured to collect the flow data in response to meeting a preset flow data collection condition; the flow data collection condition is determined according to a configuration file.

[0120] Preferably, the recording module 11 further includes a recording submodule 112;

[0121] The recording submodule 112 is configured to pre-process the traffic data to obtain processed traffic data, and record the processed traffic data into a corresponding log according to the data type; the data content of the data in the log includes a timestamp, a primary key and a foreign key.

[0122] Preferably, the recording module 11 further includes a storage submodule 113;

[0123] The storage submodule 113 is configured to construct the data in the log into a time series according to the timestamp and store it in a time series database; the time series database is indexed according to the timestamp and the primary key.

[0124] In some embodiments of the present application, the database testing method is applied to an application system of a microservice architecture, and the application system may include a front-end application, a microservice application layer, and a database. Taking one of the embodiments as an example, the embodiment includes 6 test databases and 143 microservice applications. The system involves 20 object classes such as Oracle database tables, views, triggers, etc., including 5156 data tables; there are 7 data field types such as varchar2, including 2 custom data types; the database uses 62 functions.

[0125] like Figure 3 As shown, the data microservice unit of the present application can be distinguished from the microservice application, and is set between the microservice application and the database, and is connected to the microservice application layer, the original database and the test database. That is, the data service unit obtains the microservice application layer's use request for the original database, and the return result of the original database.

[0126] In another implementation, Figure 4 As shown, the data microservice layer unit is added to the original microservice application layer, and the data recording module and playback module are set together with the existing microservice module in the microservice application layer. The data is obtained by the service unit from other microservice applications in the microservice application layer to use the original database, as well as the return result of the original database.

[0127] For the convenience of description, the above device is described in terms of functions divided into various modules. Of course, when implementing the present application, the functions of each module can be implemented in the same or multiple software and / or hardware.

[0128] The device of the above embodiment is used to implement the corresponding database testing method in any of the above embodiments, and has the beneficial effects of the corresponding method embodiment, which will not be repeated here.

[0129] Based on the same inventive concept, corresponding to any of the above-mentioned embodiments and methods, the present application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the database testing method described in any of the above embodiments is implemented.

[0130] Figure 5 A more specific schematic diagram of the hardware structure of an electronic device provided in this embodiment is shown, and the device may include: a processor 1010, a memory 1020, an input / output interface 1030, a communication interface 1040, and a bus 1050. The processor 1010, the memory 1020, the input / output interface 1030, and the communication interface 1040 are connected to each other through the bus 1050 in the device.

[0131] The processor 1010 can be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this specification.

[0132] The memory 1020 may be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage device, dynamic storage device, etc. The memory 1020 may store an operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented by software or firmware, the relevant program codes are stored in the memory 1020 and are called and executed by the processor 1010.

[0133] The input / output interface 1030 is used to connect the input / output module to realize information input and output. The input / output module can be configured in the device as a component (not shown in the figure), or it can be externally connected to the device to provide corresponding functions. The input device may include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output device may include a display, a speaker, a vibrator, an indicator light, etc.

[0134] The communication interface 1040 is used to connect a communication module (not shown) to realize communication interaction between the device and other devices. The communication module can realize communication through a wired mode (such as USB, network cable, etc.) or a wireless mode (such as mobile network, WIFI, Bluetooth, etc.).

[0135] The bus 1050 includes a path that transmits information between the various components of the device (eg, the processor 1010, the memory 1020, the input / output interface 1030, and the communication interface 1040).

[0136] It should be noted that, although the above device only shows the processor 1010, the memory 1020, the input / output interface 1030, the communication interface 1040 and the bus 1050, in the specific implementation process, the device may also include other components necessary for normal operation. In addition, it can be understood by those skilled in the art that the above device may also only include the components necessary for implementing the embodiments of the present specification, and does not necessarily include all the components shown in the figure.

[0137] The electronic device of the above embodiment is used to implement the corresponding database testing method in any of the above embodiments, and has the beneficial effects of the corresponding method embodiment, which will not be described in detail here.

[0138] Based on the same inventive concept, corresponding to any of the above-mentioned embodiment methods, the present application also provides a non-transitory computer-readable storage medium, wherein the non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute the database testing method described in any of the above embodiments.

[0139] The computer-readable medium of this embodiment includes permanent and non-permanent, removable and non-removable media, and information storage can be implemented by any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, read-only compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device.

[0140] The computer instructions stored in the storage medium of the above embodiment are used to enable the computer to execute the database testing method described in any of the above embodiments, and have the beneficial effects of the corresponding method embodiments, which will not be repeated here.

[0141] Those skilled in the art should understand that the discussion of any of the above embodiments is merely illustrative and is not intended to imply that the scope of the present application (including the claims) is limited to these examples. In line with the concept of the present application, the technical features in the above embodiments or different embodiments may be combined, the steps may be implemented in any order, and there are many other variations of the different aspects of the embodiments of the present application as described above, which are not provided in detail for the sake of simplicity.

[0142] In addition, to simplify the description and discussion, and in order not to make the embodiments of the present application difficult to understand, the known power supply / ground connection with the integrated circuit (IC) chip and other components may or may not be shown in the provided drawings. In addition, the device can be shown in the form of a block diagram to avoid making the embodiments of the present application difficult to understand, and this also takes into account the fact that the details of the implementation of these block diagram devices are highly dependent on the platform to be implemented in the embodiments of the present application (that is, these details should be fully within the scope of understanding of those skilled in the art). In the case of elaborating specific details (e.g., circuits) to describe exemplary embodiments of the present application, it is obvious to those skilled in the art that the embodiments of the present application can be implemented without these specific details or when these specific details are changed. Therefore, these descriptions should be considered to be illustrative rather than restrictive.

[0143] Although the present application has been described in conjunction with specific embodiments of the present application, many replacements, modifications and variations of these embodiments will be apparent to those skilled in the art from the foregoing description. For example, other memory architectures (e.g., dynamic RAM (DRAM)) may use the embodiments discussed.

[0144] The embodiments of the present application are intended to cover all such substitutions, modifications and variations that fall within the broad scope of the appended claims. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the embodiments of the present application should be included in the scope of protection of the present application.

Claims

1. A database testing method, characterized in that: Applied to a database test system, the database test system includes: a data microservice unit, an original database and a test database, the data microservice unit includes a recording module and a playback module; the recording module and the playback module are added to the database test system through a recording plug-in and a playback plug-in respectively; The method comprises: The recording module records the flow data of the original database according to the preset flow data recording requirements; The playback module plays back the traffic data in the test database to obtain test data; the test data is used to indicate the performance test results and function test results of the test database.

2. The method according to claim 1, characterized in that: The data microservice unit also includes a syntax translation module; the syntax translation module is added to the database testing system through a syntax transfer plug-in; Before the playback module plays back the traffic data in the test database, the playback module also includes: The syntax translation module translates the traffic data into a test database language according to a maximum translatable syntax difference comparison table; The maximum convertible syntax difference comparison table is configured according to program parameters.

3. The method according to claim 2, characterized in that The recording module includes a collection submodule; The recording module records the flow data of the original database according to the preset flow data recording requirements, including: The collection submodule collects the flow data in response to meeting a preset flow data collection condition; The flow data collection conditions are determined according to the configuration file.

4. The method according to claim 3, characterized in that The flow data collection condition includes collecting the flow data before and after a preset cut-off point, and the cut-off point includes when the original database executes the flow data.

5. The method according to claim 3 or 4, characterized in that: The recording module also includes a recording submodule; The method comprises: The recording submodule pre-processes the flow data to obtain processed flow data, and records the processed flow data into a corresponding log according to the data type; the data content of the data in the log includes a timestamp, a primary key and a foreign key.

6. The method according to claim 5, characterized in that The recording module also includes a storage submodule; The method comprises: The storage submodule constructs the data in the log into a time series according to the timestamp and stores it in a time series database; the time series database is constructed according to the timestamp and the primary key index.

7. The method according to claim 4, characterized in that After obtaining the test data, the method further includes: The test data is compared with the return data after the original database executes the traffic data to obtain a comparison result; the comparison result indicates whether the processing results of the test database are consistent with those of the source data, and whether the functions and performances of the test database are consistent with those of the original database.

8. A database testing system, comprising: A data microservice unit, an original database and a test database, wherein the data microservice unit includes a recording module and a playback module; The recording module and the playback module are added to the database testing system through a recording plug-in and a playback plug-in respectively; The recording module is configured to record the flow data of the original database according to a preset flow data recording requirement; The playback module is configured to play back the traffic data in the test database to obtain test data; The test data is used to indicate the performance test results and the functional test results of the test database.

9. The system according to claim 8, characterized in that The data microservice unit also includes a syntax translation module; the syntax translation module is added to the database testing system through a syntax transfer plug-in; The syntax translation module is configured to translate the traffic data into a test database language according to a maximum translatable syntax difference comparison table; the maximum translatable syntax difference comparison table is configured according to program parameters.

10. The system according to claim 8 or 9, characterized in that The recording module includes a collection submodule; The collection submodule is configured to collect the flow data in response to meeting a preset flow data collection condition; The flow data collection conditions are determined according to the configuration file.

11. The system according to claim 10, characterized in that The recording module also includes a recording submodule; The recording submodule is configured to pre-process the flow data to obtain processed flow data, and record the processed flow data into a corresponding log according to the data type; the data content of the data in the log includes a timestamp, a primary key and a foreign key.

12. The system according to claim 11, characterized in that The recording module also includes a storage submodule; The storage submodule is configured to construct the data in the log into a time series according to the timestamp and store it in a time series database; the time series database is indexed according to the timestamp and the primary key.

13. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method according to any one of claims 1 to 7 is implemented.

14. A non-transitory computer-readable storage medium storing computer instructions, characterized in that: The computer instructions are used to enable a computer to execute the method according to any one of claims 1 to 7.