Database test method, device, equipment, medium and product

By capturing application database access traffic to generate test cases and executing assertions in the auxiliary database, the problems of heavy workload and high labor costs in database version acceptance were solved, automated testing was implemented, and the functional correctness and stability of the new version of the database were ensured.

CN120723628APending Publication Date: 2025-09-30INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510789784.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-13
Publication Date
2025-09-30

AI Technical Summary

Technical Problem

During the database transformation and upgrade process, existing technologies rely on manual operation verification, resulting in a large workload and high labor costs for database version acceptance. In addition, the testing time is limited, which makes omissions prone to occur and affects the quality and stability of the database transformation.

Method used

By capturing the access traffic of the application database to generate a structured query language statement traffic file, initial test cases are automatically generated, and these cases are executed in the auxiliary database to determine the assertions, and then target test cases are generated. Finally, the target test cases are executed in the new version database to achieve automated testing.

Benefits of technology

It improves test coverage and diversity, reduces labor costs and technical entry barriers, ensures that test cases closely match real business scenarios, and ensures the functional correctness and stability of the new version of the database.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120723628A_ABST
    Figure CN120723628A_ABST
Patent Text Reader

Abstract

The invention discloses a database testing method, device and equipment, a medium and a product. The method comprises the steps of capturing access traffic of an application database through a database traffic capturing agent, and generating a structured query language statement traffic file; the application database is used for testing application functions; generating an initial test case according to each structured query language statement in each file; executing the initial test case in an auxiliary database; the auxiliary database and the application database have the same version; determining an assertion of the initial test case according to the execution result, and determining a target test case according to the initial test case and the assertion thereof; executing the target test case in a to-be-accepted database according to arrangement; the to-be-accepted data library is a new version database constructed based on the application database. According to the embodiment of the invention, the test case of the to-be-accepted database can be automatically generated based on the service flow of the application to complete acceptance of the to-be-accepted database.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of database testing, and in particular to a database testing method, device, equipment, medium and product. Background Art

[0002] During database transformation and upgrades, the existing backend database needs to be upgraded or switched to a different database type. Testing and acceptance of the new database version is required to verify compatibility. The short iteration cycle for database version optimization results in a significant workload for version acceptance. Furthermore, database acceptance is the last line of defense for version quality and plays a crucial role in database transformation. Currently, database version acceptance primarily relies on manual verification. Key test points are extracted based on the database changes, and test cases are designed, basic data is prepared, and executed one by one. Finally, a test acceptance report is issued. Database version acceptance testing requires coverage testing based on the changes. However, each version covers a wide range of test areas, and basic data preparation is relatively tedious and complex, requiring significant manpower. The rapid pace of database version iteration results in a short version acceptance cycle. Furthermore, testers have very limited testing time, limiting their ability to select key core features for verification. This incomplete coverage of existing functionality that remains unchanged in the current version can lead to omissions and potentially production issues. Summary of the Invention

[0003] The present invention provides a database testing method, device, equipment, medium and product to effectively reduce labor input costs. By collecting the business traffic of applications, the traffic is automatically converted into test cases, improving test coverage, increasing test diversity, avoiding scenario omissions, and also lowering the entry threshold for testers' capabilities.

[0004] According to one aspect of the present invention, a database testing method is provided, comprising:

[0005] Capturing access traffic to an application database through a database traffic capture agent to generate a structured query language statement traffic file; the application database is used for application function testing;

[0006] generating initial test cases according to each structured query language statement in each file;

[0007] Executing the initial test case in an auxiliary database; the auxiliary database has the same version as the application database;

[0008] determining assertions of the initial test case based on the execution result, and determining a target test case based on the initial test case and its assertions;

[0009] The target test case is executed in the database to be accepted according to the arrangement; the database to be accepted is a new version database built based on the application database.

[0010] According to another aspect of the present invention, there is provided a database testing device, comprising:

[0011] Traffic capture module, used to capture access traffic of application database through database traffic capture agent and generate structured query language statement traffic file; the application database is used for application function testing;

[0012] An initial test case module, for generating initial test cases according to each structured query language statement in each file;

[0013] a target test case module, configured to execute the initial test case in an auxiliary database having the same version as the application database; determine assertions of the initial test case based on the execution result, and determine a target test case based on the initial test case and its assertions;

[0014] The test module is used to execute the target test case in the database to be accepted according to the arrangement; the database to be accepted is a new version database built based on the application database.

[0015] According to another aspect of the present invention, a computer program product is provided, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements the database testing method according to any embodiment of the present invention.

[0016] According to another aspect of the present invention, an electronic device is provided, comprising:

[0017] 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 execute the database testing method described in any embodiment of the present invention.

[0018] 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 database testing method according to any embodiment of the present invention when executed.

[0019] According to another aspect of the present invention, a computer program product is provided, comprising a computer program / instruction, wherein when the computer program / instruction is executed by a processor, the database testing method according to any embodiment of the present invention is implemented.

[0020] The embodiment of the present invention generates a structured query language (SQL) statement flow file by capturing the application database access traffic, and then generates initial test cases, executes these cases in an auxiliary database with the same version as the application database, and determines assertions based on the results to form target test cases, and executes the target test cases in a new version of the database to be accepted built based on the application database. It can accurately capture the actual operation of the application on the database, ensure that the test cases are closely aligned with the real business scenarios, ensure comprehensive coverage testing and test diversity of the data to be accepted, and effectively reduce labor costs and technical or business entry barriers. The initial test cases are executed with the help of an auxiliary database with the same version as the application database, so as to generate assertions based on the execution results, and then obtain target test cases to support automated testing of the database to be accepted. Finally, executing the target test cases in the database to be accepted can effectively verify the functional correctness and stability of the new version of the database, and ensure the smooth launch and subsequent stable operation of the new version of the database.

[0021] 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

[0022] 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.

[0023] Figure 1 This is a first flow chart of a database testing method provided by an embodiment of the present invention;

[0024] Figure 2 is a second flow chart of a database testing method provided by an embodiment of the present invention;

[0025] Figure 3 This is a schematic diagram of the structure of a database testing device provided by an embodiment of the present invention;

[0026] Figure 4 It is a schematic structural diagram of an electronic device implementing an embodiment of the present invention. DETAILED DESCRIPTION

[0027] 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.

[0028] 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.

[0029] Figure 1 This is the first flow chart of a database testing method provided by an embodiment of the present invention. This embodiment can be applied to the situation where test cases are automatically generated based on application business traffic to perform test acceptance of a new version of a database. The method can be executed by a database testing device, which can be implemented in the form of hardware and / or software. The device can be configured in an electronic device with corresponding data processing capabilities.

[0030] like Figure 1 As shown, the method includes:

[0031] S110 , capturing access traffic of the application database through a database traffic capture agent, and generating a structured query language statement traffic file.

[0032] The application database is a database used for application function testing in a test environment. The access operations of various business scenarios on the application side to the database are more in line with real business scenarios than the manually constructed database acceptance process. A database traffic capture agent is deployed in the application database server to capture the access traffic of the application database through the database traffic capture agent. The captured raw traffic data is filtered and cleaned to remove noise data and irrelevant information. For example, some network protocol header information is filtered out, and only the core Structured Query Language (SQL) statements, user information that initiates access requests, and other content are retained. A Structured Query Language statement traffic file is generated based on the access traffic of the application database, and the file includes at least one Structured Query Language statement.

[0033] S120: Generate initial test cases according to each structured query language statement in each file.

[0034] Each Structured Query Language (SQL) statement contained in each file is parsed to extract key information about the statement, such as table name, field name, operation type (such as query, insert, update, delete, etc.), and conditional constraints. Based on the key information of the statement, combined with business logic and test requirements, and in accordance with the standardized test case template, the test purpose, preconditions, and operation steps are described in detail to generate an initial test case. An initial test case is generated based on each Structured Query Language statement in each file. Each Structured Query Language statement corresponds to an initial test case. The initial test case includes the Structured Query Language statement, but does not include the assertion of the Structured Query Language statement. Assertions are the basic building blocks in testing and are used to verify whether the execution results of the Structured Query Language statement meet expectations.

[0035] S130: Execute the initial test case in the auxiliary database.

[0036] S140: Determine assertions of the initial test case according to the execution result, and determine a target test case according to the initial test case and its assertions.

[0037] The auxiliary database, which uses the same version as the application database, assists in generating assertions for the initial test case. Specifically, the automated testing framework schedules the execution of the initial test case in the auxiliary database. The assertions for the initial test case are determined based on the execution results. The target test case is then determined based on the initial test case and its assertions. The target test case includes a Structured Query Language statement and its assertions.

[0038] S150: Execute the target test case in the database to be accepted according to the arrangement.

[0039] The database to be accepted is a new version of the database built based on the application database. The database to be accepted can be of the same type as the application database but a different version, or a different type but compatible. Target test cases are orchestrated and executed in the database to be accepted using the automated testing framework according to the orchestration, performing automated testing on the database to be accepted. Target test cases can be executed multiple times in the database to be accepted, leading to multiple rounds of testing to complete the acceptance of the database. The automated testing framework enables scheduling of target test cases, querying execution results, and downloading detailed results. Target test cases are automatically triggered according to pre-set scheduling strategies, eliminating the need for manual intervention and ensuring that testing tasks proceed on schedule and in an orderly manner. During execution, execution results are queried in real time, providing timely feedback on test status and facilitating rapid problem identification. After execution, a detailed results download function is provided, allowing testers to analyze test data in detail and thoroughly investigate potential defects, significantly reducing manual operation costs and improving the overall efficiency and accuracy of testing.

[0040] The embodiment of the present invention generates a structured query language (SQL) statement flow file by capturing the application database access traffic, and then generates initial test cases. These cases are executed in an auxiliary database with the same version as the application database, and assertions are determined based on the results to form target test cases. The target test cases are executed in a new version of the database to be accepted based on the application database. This can accurately capture the actual operation of the application on the database, ensure that the test cases are closely aligned with the real business scenarios, ensure comprehensive coverage testing and test diversity of the data to be accepted, and effectively reduce labor costs and technical or business entry barriers. The initial test cases are executed with the help of an auxiliary database with the same version as the application database, so that assertions are generated based on the execution results, and then the target test cases are obtained to support the automated testing of the database to be accepted. Finally, executing the target test cases in the database to be accepted can effectively verify the functional correctness and stability of the new version of the database, ensuring the smooth launch and subsequent stable operation of the new version of the database. A faster, more automated, more comprehensive, and low-threshold automated test case based on application business traffic automatically generates automated test cases for the data to be accepted, completing the automated testing of the database to be accepted.

[0041] In an optional embodiment, the method further includes: before capturing the access traffic of the application database through the database traffic capture agent, synchronizing the full amount of data in the application database as basic data to the auxiliary database and the database to be accepted, so that the auxiliary database and the database to be accepted are both in an initial state; before executing the target test case in the database to be accepted according to the arrangement, restoring the database to be accepted to its initial state.

[0042] Specifically, before executing a test case, you need to prepare the corresponding basic data to support the accurate execution of the initial test case in the auxiliary database and the target test case in the database to be accepted. The initial and target test cases are derived from the access traffic of the application database. The basic data in the auxiliary database and the database to be accepted must be consistent with the basic data before the application database access traffic was captured. In other words, the full data in the application database before traffic capture serves as the basic data. This basic data is synchronized to the auxiliary database and the database to be accepted, bringing both the auxiliary database and the database to their initial state.

[0043] After generating the target test case, it supports multiple calls to the target test case in the database to be accepted so as to perform multiple tests on the database to be accepted. Before executing the target test case in the database to be accepted according to the arrangement, it is necessary to ensure that the data in the database to be accepted is basic data. If it is not the first execution of the target test case, the database to be accepted needs to be restored to its initial state before the target test case is executed.

[0044] By fully synchronizing the basic data in the application database before traffic capture with the auxiliary database and the database to be accepted, ensuring that the basic data in the auxiliary and databases strictly corresponded to the basic data in the application database before traffic capture, we successfully established a testing foundation that was highly consistent with the real business environment. Subsequent assertion generation and the entire testing process were executed smoothly within the stable and realistic database environment under test, effectively avoiding test deviations caused by differences in basic data and laying a solid foundation for subsequent accurate performance and functionality evaluation of the new database. This also eliminated the need for extensive manual effort to build basic data.

[0045] In an optional embodiment, the capturing of the access traffic of the application database by the database traffic capture agent includes: triggering the database traffic capture agent to capture the transmission control protocol request at the network card level by running the existing automated test cases on the application side, and capturing the access traffic of the application database.

[0046] During application development, automated testing of application functionality is required. This requires building automated test cases on the application side, invoking existing automated test cases, initiating function calls within the application, and triggering the database traffic capture agent to capture Transmission Control Protocol (TCP) requests at the network interface card (NIC) level, thereby capturing the application database access traffic. By scheduling existing automated test cases on the application side to capture TCP requests at the NIC level, database traffic capture is achieved, fully utilizing existing automated test cases without the additional labor and resources required to redesign test scenarios, significantly improving testing efficiency.

[0047] Database traffic capture agents capture database access traffic in real time, ensuring completeness and avoiding missing any critical SQL statements. For example, in highly concurrent business scenarios, a large number of SQL requests may be sent to the database simultaneously. The agent must have sufficient processing power to handle this high volume of traffic and prevent data loss due to excessive traffic. Deploying multiple traffic capture agents at key network nodes provides redundant capture and improves the reliability of capturing critical SQL statements. Capturing TCP requests at the network interface card (NIC) level comprehensively and comprehensively captures real-world application database access traffic, covering both normal and abnormal business operations. This ensures the integrity and authenticity of traffic data, providing a solid and reliable data foundation for generating accurate test cases based on this traffic and comprehensively evaluating database performance and functionality, effectively ensuring the effectiveness and accuracy of database testing. Through basic data preparation, traffic collection, automated test case generation, and case scheduling and execution, rapid acceptance of new database versions is achieved while ensuring comprehensive testing coverage and diversity, effectively reducing labor costs and technical or business entry barriers.

[0048] Figure 2 This is the second flow chart of a database testing method provided by an embodiment of the present invention. This embodiment is optimized and improved on the basis of the above embodiment. Figure 2 As shown, the method includes:

[0049] S210: Capture access traffic of the application database through a database traffic capture agent to generate a structured query language statement traffic file.

[0050] The application database is used for application function testing.

[0051] S220: Generate initial test cases according to each structured query language statement in each file.

[0052] S230: Execute the initial test case in the auxiliary database.

[0053] The auxiliary database has the same version as the application database.

[0054] S240: Determine the type of the structured query language statement according to the keywords in the structured query language statement in the initial test case.

[0055] S250: Generate an assertion according to the type and execution result of the structured query language statement.

[0056] Parse the Structured Query Language (SQL) statements in the initialization test case and determine the statement type based on the keywords in the statement. Different statement types correspond to different execution results, and generate assertions based on the SQL statement type and execution results. Determining the statement type based on SQL statement keywords and generating assertions based on the execution results accurately matches statement characteristics with expected results, efficiently verifies the correctness of database operations, quickly catches exceptions, and improves test accuracy and reliability.

[0057] Optionally, an assertion is generated based on the type of the structured query language statement and the execution result, including: if the type of the structured query language statement is an insert statement, an assertion is generated based on the execution result to verify whether the number of inserted data rows meets expectations, and check whether the value of the inserted data is correct based on the returned primary key value or generated field.

[0058] If the Structured Query Language statement type is a query statement, an assertion is generated based on the execution result to verify whether the number of rows and field values ​​in the result set meet expectations. If the Structured Query Language statement type is an update statement, an assertion is generated based on the execution result to verify whether the number of affected rows and updated field values ​​meet expectations. If the Structured Query Language statement type is a delete statement, an assertion is generated based on the execution result to verify whether the number of affected rows meets expectations and check whether the related data is changed synchronously. If it is a stored procedure, an assertion is generated based on the execution result to verify whether the output result meets expectations.

[0059] Specifically, the assertion is generated according to the type and execution result of the structured query language statement, and is implemented through the following process:

[0060] 1. SQL statement parsing

[0061] Use the SQL parser to convert SQL statements into an abstract syntax tree (AST). Extract keywords (such as SELECT, WHERE, INSERT INTO) and operation objects (such as table names and field names). This allows you to identify the SQL statement type (SELECT / INSERT / UPDATE / DELETE, etc.) and key operations (such as conditions, fields, and table names).

[0062] 2. Execution result analysis

[0063] Execute SQL statements and capture the results (e.g., via JDBC, an ORM framework, or a database driver). Record key information about the results (e.g., number of rows in the query result, number of rows affected by the update, and inserted primary key values). This allows you to obtain the actual results of the SQL statement (e.g., number of rows returned, field values, and status code).

[0064] 3. Assertion generation rule settings

[0065] Query Statement (SELECT): Generates assertions to verify that the result set's row count, field values, sorting, or paging meet expectations. Assertions can be generated based on the SQL type and execution result. For example, if a query returns 3 rows of data, the assertion is assertresult.size() == 3.

[0066] INSERT statement: Generates an assertion to verify that the number of rows inserted is 1 and checks the returned primary key value or generated field (such as auto-increment ID, timestamp). For example, the assertion is assert_id == 1001.

[0067] Update statements (UPDATE): Generate assertions to verify that the number of affected rows matches the expected number and check the updated field values. For example, the assertion is assert rows_affected == 1 and SELECT column FROM table WHERE id = 1001 returns the new value.

[0068] DELETE statements generate assertions to verify the expected number of affected rows and check whether related data has been updated synchronously. For example, the assertion is assert rows_affected == 1 and that there is no residual data in the related tables.

[0069] Stored Procedure: Generate assertions to verify whether the output results of the stored procedure meet expectations.

[0070] 4. Assertion Optimization and Verification

[0071] Filter out redundant assertions (such as assertions on non-critical fields). Use a testing framework to verify the correctness of assertions to ensure that the generated assertions are executable and meaningful.

[0072] Optionally, set up an assertion template library: predefine assertion templates for various SQL statements and fill in variables (such as table name, field name, expected value) based on the parsing results.

[0073] By parsing the Structured Query Language (SQL) statements in the initialization test cases, determining the statement type based on keywords, and then generating assertions based on the execution results corresponding to different statement types, assertion generation is made more targeted and accurate. For insert statements, the number of data rows and primary key values ​​are verified to ensure that data is inserted correctly. For query statements, the number of result set rows and field values ​​are verified to ensure that the query results are correct. For update statements, the number of affected rows and updated field values ​​are verified to ensure that data updates meet expectations. For delete statements, the number of affected rows and related data changes are verified to ensure that data deletion is complete and related. The output parameters of stored procedures are verified to ensure that their running results are correct. This allows for a comprehensive and accurate evaluation of the execution effect of SQL statements, effectively improving the quality and reliability of database testing.

[0074] S260. Determine a target test case based on the initial test case and its assertions.

[0075] Add the assertions corresponding to the SQL statements in the initial test case to the target test case. The target test case can be directly used for unit testing or integration testing of the database to be verified to verify the correctness and completeness of SQL operations.

[0076] S270: Execute the target test case in the database to be accepted according to the arrangement.

[0077] The database to be accepted is a new version database built based on the application database.

[0078] Database usage is closely tied to application-side business logic, yet the acceptance of new database versions focuses on the database itself, disconnected from specific application-side usage scenarios. Manually constructing test cases to simulate actual application-side usage scenarios presents numerous pain points, such as application data preparation and connectivity between upstream and downstream application business environments. These pain points are exacerbated by the rapid iteration of database versions and the short acceptance cycle. Furthermore, the acceptance of new database versions presents a significant technical barrier to entry for testers, requiring a solid understanding of the database's deployment model, system structure, underlying system functions, and system tables.

[0079] The embodiment of the present invention generates a structured query language (SQL) statement flow file by capturing application database access traffic, thereby generating initial test cases. These cases are executed in an auxiliary database of the same version as the application database, and assertions are determined based on the results to form target test cases. The target test cases are then executed in a new version of the database to be accepted, which is constructed based on the application database. This can accurately capture the actual operation of the application on the database, ensure that the test cases closely match the real business scenarios, and ensure comprehensive coverage and test diversity of the data to be accepted, without the need for manual construction of test data. The initial test cases are executed with the help of an auxiliary database of the same version as the application database, so that assertions are generated based on the execution results, and then the target test cases are obtained to support automated testing of the database to be accepted, reducing labor costs and technical or business entry barriers. Finally, executing the target test cases in the database to be accepted can effectively verify the functional correctness and stability of the new version of the database, ensuring the smooth launch and subsequent stable operation of the new version of the database. The embodiment of the present invention can more quickly, automatically, cover more comprehensively, and have a low threshold to automatically generate test cases for the database to be accepted based on the application business traffic to complete the acceptance of the new version of the database.

[0080] In an optional embodiment, executing the target test case in the database to be accepted according to the arrangement includes: responding to data access requests initiated by at least two users, determining whether there is a data access conflict in structured query language statements in the target test cases of any two users; if there is a data access conflict, executing the target test case with the data access conflict according to the corresponding access time and user priority; otherwise, executing the target test cases of the any two users concurrently.

[0081] In response to a data access request initiated by a single user, the target test case of the single user is executed serially in the order of access to ensure transaction integrity and data consistency. User A initiates the "query balance → transfer → query balance again" operation, and it is necessary to ensure that the transfer is completed between the two queries to avoid data inconsistency. In response to data access requests initiated by at least two users, determine whether there is a data access conflict in the structured query language statements in the target test cases of any two users; if there is a data access conflict, execute the target test case with data access conflict according to the corresponding access time and user priority. For example, if user D and user E update the balance of account 1 at the same time, it is necessary to execute it serially according to user priority or timestamp; otherwise, execute the target test cases of any two users concurrently. Among them, if the data access requests of any two users access the same data object (such as a table or row), or there is a read-write conflict (such as one user writes and the other user reads), it is determined that there is a data access conflict in the structured query language statements in the target test cases of the two users.

[0082] Serialized execution of single-user target test cases ensures transaction integrity and data consistency. Parallel execution of multi-user non-conflicting target test cases improves test efficiency and enables further stress testing. Regularized serialization of multi-user conflicting target test cases ensures fairness and correctness. The orchestration of target test cases balances test efficiency and accuracy, and enables simultaneous database access by multiple users to implement stress testing of acceptance data.

[0083] Figure 3 This is a schematic diagram of the structure of a database testing device provided by an embodiment of the present invention. Figure 3 As shown, the device includes:

[0084] Traffic capture module 310, used to capture access traffic of application database through database traffic capture agent and generate structured query language statement traffic file; the application database is used for application function testing;

[0085] An initial test case module 320 is configured to generate an initial test case based on each structured query language statement in each file;

[0086] a target test case module 330 configured to execute the initial test case in an auxiliary database having the same version as the application database; determine assertions of the initial test case based on the execution result, and determine a target test case based on the initial test case and its assertions;

[0087] The testing module 340 is configured to execute the target test case in the database to be accepted according to the arrangement; the database to be accepted is a new version database constructed based on the application database.

[0088] The database testing device provided in the embodiment of the present invention can execute the database testing method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0089] Optional, target test case module, including:

[0090] a statement type determination unit, configured to determine the type of a structured query language statement according to keywords in the structured query language statement in the initial test case;

[0091] The assertion generating unit is used to generate an assertion according to the type and execution result of the structured query language statement.

[0092] Optionally, an assertion generation unit is specifically used to: if the type of the structured query language statement is an insert statement, generate an assertion based on the execution result, verify whether the number of inserted data rows meets the expectation, and check whether the value of the inserted data is correct based on the returned primary key value or generated field.

[0093] Optionally, the testing module includes a case orchestration unit, which is used to respond to data access requests initiated by at least two users and determine whether there is a data access conflict in the structured query language statements in the target test cases of at least two users; if there is a data access conflict, execute the target test case with the data access conflict according to the corresponding access time and user priority; otherwise, execute the target test cases of the at least two users concurrently.

[0094] Optionally, the device further includes:

[0095] A basic data module is used to synchronize the full amount of data in the application database as basic data to the auxiliary database and the database to be accepted before capturing the access traffic of the application database through the database traffic capture agent, so that the auxiliary database and the database to be accepted are both in an initial state;

[0096] The state restoration module is used to restore the database to be accepted to its initial state before executing the target test case in the database to be accepted according to the arrangement.

[0097] Optionally, the traffic capture module is specifically used to: trigger the database traffic capture agent to capture the transmission control protocol request at the network card level by running the existing application-side automated test cases, and capture the access traffic of the application database.

[0098] The database testing device further described can also execute the database testing method provided by any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0099] According to an embodiment of the present invention, the present invention further provides an electronic device, a readable storage medium and a computer program product.

[0100] Figure 4 A schematic diagram of the structure of an electronic device 40 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.

[0101] like Figure 4 As shown, the electronic device 40 includes at least one processor 41 and a memory, such as a read-only memory (ROM) 42, a random access memory (RAM) 43, etc., which is communicatively connected to the at least one processor 41. The memory stores a computer program that can be executed by the at least one processor, and the processor 41 can perform various appropriate actions and processes according to the computer program stored in the read-only memory (ROM) 42 or the computer program loaded from the storage unit 48 into the random access memory (RAM) 43. Various programs and data required for the operation of the electronic device 40 can also be stored in the RAM 43. The processor 41, ROM 42, and RAM 43 are connected to each other via a bus 44. An input / output (I / O) interface 45 is also connected to the bus 44.

[0102] Multiple components in the electronic device 40 are connected to the I / O interface 45, including an input unit 46, such as a keyboard, a mouse, etc.; an output unit 47, such as various types of displays, speakers, etc.; a storage unit 48, such as a magnetic disk, an optical disk, etc.; and a communication unit 49, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 49 allows the electronic device 40 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.

[0103] Processor 41 can be various general-purpose and / or specialized processing components with processing and computing capabilities. Some examples of processor 41 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 appropriate processor, controller, microcontroller, etc. Processor 41 executes the various methods and processes described above, such as the database testing method.

[0104] In some embodiments, the database testing method can be implemented as a computer program tangibly embodied in a computer-readable storage medium, such as storage unit 48. In some embodiments, part or all of the computer program can be loaded and / or installed on electronic device 40 via ROM 42 and / or communication unit 49. When the computer program is loaded into RAM 43 and executed by processor 41, one or more steps of the database testing method described above can be performed. Alternatively, in other embodiments, processor 41 can be configured to perform the database testing method in any other suitable manner (e.g., via firmware).

[0105] Various embodiments of the systems and techniques described herein 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), system-on-chip systems (SOCs), 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.

[0106] 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.

[0107] 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.

[0108] 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).

[0109] 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.

[0110] 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.

[0111] 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.

[0112] 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. A database testing method, characterized in that: The method comprises: Capturing access traffic to an application database through a database traffic capture agent to generate a structured query language statement traffic file; the application database is used for application function testing; generating initial test cases according to each structured query language statement in each file; Executing the initial test case in an auxiliary database; the auxiliary database has the same version as the application database; determining assertions of the initial test case based on the execution result, and determining a target test case based on the initial test case and its assertions; The target test case is executed in the database to be accepted according to the arrangement; the database to be accepted is a new version database built based on the application database.

2. The method according to claim 1, characterized in that Determining the assertion of the initial test case according to the execution result includes: determining a type of a structured query language statement according to a keyword in the structured query language statement in the initial test case; An assertion is generated according to the type and execution result of the structured query language statement.

3. The method according to claim 2, characterized in that Generating assertions according to the type and execution result of the structured query language statement, including: If the Structured Query Language statement type is an insert statement, an assertion is generated based on the execution result to verify whether the number of inserted data rows meets the expectation, and to check whether the value of the inserted data is correct based on the returned primary key value or generated field.

4. The method according to claim 1, wherein The executing the target test case in the database to be accepted according to the arrangement includes: In response to data access requests initiated by at least two users, determining whether there is a data access conflict in structured query language statements in target test cases of any two users; If there is a data access conflict, the target test case with the data access conflict is executed according to the corresponding access time and user priority; Otherwise, the target test cases of any two users are executed concurrently.

5. The method according to claim 1, wherein The method further comprises: Before capturing the access traffic of the application database through the database traffic capture agent, all the data in the application database is synchronized as basic data to the auxiliary database and the database to be accepted, so that the auxiliary database and the database to be accepted are both in the initial state; Before executing the target test case in the database to be accepted according to the arrangement, the database to be accepted is restored to an initial state.

6. The method according to claim 1, characterized in that Capturing the access traffic of the application database by using the database traffic capture agent includes: By running the existing automated test cases on the application side, the database traffic capture agent is triggered to capture the transmission control protocol requests at the network card level and capture the access traffic of the application database.

7. A database testing device, characterized in that: The device comprises: Traffic capture module, used to capture access traffic of application database through database traffic capture agent and generate structured query language statement traffic file; the application database is used for application function testing; An initial test case module, for generating initial test cases according to each structured query language statement in each file; a target test case module, configured to execute the initial test case in an auxiliary database having the same version as the application database; determine assertions of the initial test case based on the execution result, and determine a target test case based on the initial test case and its assertions; The test module is used to execute the target test case in the database to be accepted according to the arrangement; the database to be accepted is a new version database built based on the application database.

8. An electronic device, characterized in that: The electronic device comprises: at least one processor; and a memory communicatively coupled to the at least one processor; 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 so that the at least one processor can execute the database testing method according to any one of claims 1 to 6.

9. 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 database testing method according to any one of claims 1 to 6 when executed.

10. A computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements the database testing method according to any one of claims 1 to 6.