Database testing method and device

By building and populating the test database to reproduce the environment of the problem database, the data security risks and fault replication problems between database users and service providers are solved, and efficient database testing and data security guarantees are achieved.

CN118885405BActive Publication Date: 2025-02-14TIANJIN NANKAI UNIV GENERAL DATA TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411390600.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-08
Publication Date
2025-02-14
Estimated Expiration
2044-10-08

AI Technical Summary

Technical Problem

In different situations between database users and database service providers, when database users provide the database environment to database service providers, there are data security risks, and it is difficult to reproduce the failure of SQL statements only. Database environment.

Method used

Provide a database testing method and device, which determines the error information and problem commands of the problem database by responding to the database error reported by the user, determines the database information, data table information and column information based on the problem command, builds the test database structure, and generates fill data , fill in the test database structure, execute problem commands and compare output information to determine the test results.

Benefits of technology

It can reproduce the environment for problem command execution without the need for data from the problem database, avoid data leakage, ensure data security, and improve database testing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118885405B_ABST
    Figure CN118885405B_ABST
Patent Text Reader

Abstract

The present invention provides a database testing method and device, which can be applied to the fields of data processing and software testing technology. The method includes: in response to a database error report submitted by a user, determining error information and a problem command of a problem database, wherein the error information is generated when the problem command is executed on the problem database, and the problem database includes one or more databases; based on the problem command, determining database information, data table information and column information of the problem database; constructing a test database structure based on the database information, data table information and multiple field names; generating fill data based on multiple field names and associated column information; filling the test database structure with the fill data to obtain a test database; executing the problem command on the test database to obtain output information; and determining the test result of the problem database using the test database when the output information and the error information are the same.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] Database software products are a type of widely used underlying data storage and computing software. Various faults may occur during the use of the software. Usually, the fault can be quickly analyzed, located, and repaired by re-executing the Structured Query Language (SQL) that caused the fault on the database environment, so as to ensure data security and improve user experience.

[0003] In the process of implementing the present invention, the inventors found that the prior art has at least the following problems: when the database user and the database service provider are different, there may be data security risks when the database user provides the database environment to the database service provider, and it is difficult to reproduce the database environment when the failure occurs only by using the SQL statement that causes the failure. Summary of the invention

[0004] In view of the above problems, the present invention provides a database testing method and device.

[0005] According to a first aspect of the present invention, a database testing method is provided, comprising: in response to a database error report submitted by a user, determining error information and a problem command of a problem database, wherein the error information is generated when the problem command is executed on the problem database, and the problem database includes one or more databases; based on the problem command, determining database information, data table information and column information of the problem database, wherein the column information includes a plurality of field names, and in the case where the problem database includes a plurality of databases, the column information also includes associated column information; based on the database information, data table information and a plurality of field names, constructing a test database structure; based on the plurality of field names and the associated column information, generating fill-in data; filling the test database structure with the fill-in data to obtain a test database; executing the problem command on the test database to obtain output information; and in the case where the output information and the error information are the same, determining the test result of the problem database using the test database.

[0006] According to an embodiment of the present invention, based on the question command, the database information, data table information and column information of the question database are determined, including: determining the command structure of the question command, wherein the command structure includes projection column information, condition column information, association column information and query source information, and the query source information includes database information and data table information; determining the column information based on the projection column information, condition column information and association column information; and using a character segmentation method to process the query source information to determine the database information and data table information.

[0007] According to an embodiment of the present invention, a test database structure is constructed based on database information, data table information and multiple field names, including: determining a test database definition language for generating the test database structure based on the database information, data table information and multiple field names; and executing the test database definition language to construct the test database structure.

[0008] According to an embodiment of the present invention, a test database definition language for generating a test database structure is determined based on database information, data table information and multiple field names, including: determining a database definition language for building a database based on the database information; determining a database definition language for building a table based on the data table information and multiple field names, wherein the field type of the database definition language for building a table is a character type; and determining a test database definition language based on the database definition language for building a database and the database definition language for building a table.

[0009] According to an embodiment of the present invention, filling data is generated based on multiple field names and associated column information, including: based on the associated column information, determining the field sequence number of the field corresponding to the associated column information in the multiple field names; based on the field sequence number, generating a preset number of row data; and based on the preset number of row data, determining the filling data.

[0010] According to an embodiment of the present invention, a preset number of rows of data is generated based on a field sequence number, including: determining the number of associations in which field values ​​corresponding to associated column information of each of multiple databases are successfully matched based on a preset ratio and a preset number; determining a target number of rows based on the number of associations and the preset number, wherein the target number of rows is obtained by evenly distributing the number of associations in the preset number; configuring multiple rows of data different from the target number of rows using a random number generation method; and configuring multiple rows of data of the target number of rows using a target configuration method.

[0011] According to an embodiment of the present invention, a target configuration method is used to configure multiple row data of a target number of rows, including: using a random number generation method to configure field values ​​of fields other than the fields corresponding to the associated column information; and using preset fixed values ​​to configure the field values ​​of the fields corresponding to the associated column information.

[0012] According to an embodiment of the present invention, filling a test database structure with filling data to obtain a test database includes: saving the filling data in a data file; and loading the data file to write the filling data into the test database structure to obtain the test database.

[0013] According to an embodiment of the present invention, the database testing method further includes: when the output information and the error information are different, determining that the cause of the problem database error does not include database information, data table information and column information.

[0014] A second aspect of the present invention provides a database testing device, comprising:

[0015] An error determination module, configured to determine error information and a problem command of a problem database in response to a database error condition submitted by a user, wherein the error information is generated when the problem command is executed on the problem database, and the problem database includes one or more databases;

[0016] An information determination module, used to determine database information, data table information and column information of the problem database based on the problem command, wherein the column information includes a plurality of field names, and when the problem database includes a plurality of databases, the column information also includes associated column information;

[0017] Database construction module, used to build test database structure based on database information, data table information and multiple field names;

[0018] A data generation module, used to generate fill data based on multiple field names and associated column information;

[0019] A database filling module is used to fill the test database structure with filling data to obtain a test database;

[0020] The output determination module is used to execute the problem command on the test database and obtain output information;

[0021] The result determination module is used to determine the test result of the problem database using the test database when the output information and the error information are the same.

[0022] A third aspect of the present invention provides an electronic device, comprising: one or more processors; a memory for storing one or more computer programs, wherein the one or more processors execute the one or more computer programs to implement the steps of the above method.

[0023] The fourth aspect of the present invention further provides a computer-readable storage medium on which a computer program or instruction is stored, and the steps of the above method are implemented when the above computer program or instruction is executed by a processor.

[0024] The fifth aspect of the present invention also provides a computer program product, including a computer program or instructions, which implement the steps of the above method when executed by a processor.

[0025] According to an embodiment of the present invention, in response to a database error situation submitted by a user, a problem command is determined, and based on the problem command, partial database information, data table information and column information of the problem database are determined, and a test database structure is constructed. By parsing the problem command, the test database structure can be automatically and quickly constructed, thereby improving the efficiency of database testing. For multiple field names and associated column information of the column information, fill data is generated and the test database structure is filled to obtain a test database. When the output information obtained by executing the problem command on the test database is the same as the error information in the database error situation, the test database is checked to determine the test result of the problem database. The environment in which the problem command is executed can be reproduced without the need for data from the problem database, thereby avoiding data leakage and ensuring data security. By executing the problem command on the reproduced environment, i.e., the test database, the environment in which the problem command is executed on the problem database is restored, thereby improving the efficiency of database testing. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] The above contents and other objects, features and advantages of the present invention will become more apparent through the following description of the embodiments of the present invention with reference to the accompanying drawings.

[0027] Figure 1 An application scenario diagram of a database testing method, apparatus, device, medium, and program product according to an embodiment of the present invention is shown.

[0028] Figure 2 A flowchart of a database testing method according to an embodiment of the present invention is shown.

[0029] Figure 3A A data table of a test database constructed according to the database testing method of an embodiment of the present invention is shown.

[0030] Figure 3B Another data table of the test database constructed according to the database testing method of the embodiment of the present invention is shown.

[0031] Figure 3C The diagram shows the query results obtained by executing the structured query language on the test database according to the database testing method of the embodiment of the present invention.

[0032] Figure 4 A structural block diagram of a database testing device according to an embodiment of the present invention is shown.

[0033] Figure 5A block diagram of an electronic device suitable for implementing a database testing method according to an embodiment of the present invention is shown. DETAILED DESCRIPTION

[0034] Below, embodiments of the present invention will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present invention. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of embodiments of the present invention. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of concepts of the present invention.

[0035] The terms used herein are only for describing specific embodiments and are not intended to limit the present invention. The terms "comprise", "include", etc. used herein indicate the existence of the features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.

[0036] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification and should not be interpreted in an idealized or overly rigid manner.

[0037] When using expressions such as "at least one of A, B, and C, etc.", they should generally be interpreted according to the meaning of the expression commonly understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).

[0038] In the technical solution of the present invention, the user information (including but not limited to user personal information, user image information, user device information, such as location information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved are all information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, invention and application of the relevant data comply with relevant laws, regulations and standards, take necessary confidentiality measures, do not violate public order and good morals, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0039] In the scenario of using personal information for automated decision-making, the methods, devices, and systems provided by the embodiments of the present invention provide users with corresponding operation portals for users to choose to agree or reject the automated decision-making results; if the user chooses to reject, the expert decision-making process will be entered. The expression "automated decision-making" here refers to the activity of automatically analyzing and evaluating an individual's behavioral habits, interests and hobbies, or economic, health, credit status, etc. through computer programs, and making decisions. The expression "expert decision-making" here refers to the activity of making decisions by people who specialize in a certain field, have specialized experience, knowledge and skills, and have reached a certain level of professionalism.

[0040] An embodiment of the present invention provides a database testing method, comprising: in response to a database error report submitted by a user, determining error information and a problem command of a problem database, wherein the error information is generated when the problem command is executed on the problem database, and the problem database includes one or more databases; based on the problem command, determining database information, data table information and column information of the problem database, wherein the column information includes multiple field names, and when the problem database includes multiple databases, the column information also includes associated column information; based on the database information, data table information and multiple field names, constructing a test database structure; based on the multiple field names and the associated column information, generating fill data; filling the test database structure with the fill data to obtain a test database; executing the problem command on the test database to obtain output information; and when the output information and the error information are the same, determining the test result of the problem database using the test database.

[0041] Figure 1 An application scenario diagram of a database testing method, apparatus, device, medium, and program product according to an embodiment of the present invention is shown.

[0042] like Figure 1 As shown, the application scenario 100 according to this embodiment may include a first terminal device 101, a second terminal device 102, a third terminal device 103, a network 104, and a server 105. The network 104 is used to provide a medium for a communication link between the first terminal device 101, the second terminal device 102, the third terminal device 103, and the server 105. The network 104 may include various connection types, such as wired, wireless communication links, or optical fiber cables, etc.

[0043] The user can use the first terminal device 101, the second terminal device 102, and the third terminal device 103 to interact with the server 105 through the network 104 to receive or send messages, etc. Various communication client applications can be installed on the first terminal device 101, the second terminal device 102, and the third terminal device 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only for example).

[0044] The first terminal device 101, the second terminal device 102, and the third terminal device 103 may be various electronic devices having display screens and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.

[0045] The server 105 may be a server that provides various services, such as a background management server (only as an example) that provides support for websites browsed by users using the first terminal device 101, the second terminal device 102, and the third terminal device 103. The background management server may analyze and process the received data such as user requests, and feed back the processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal device.

[0046] It should be noted that the database testing method provided in the embodiment of the present invention can generally be executed by the server 105. Accordingly, the database testing device provided in the embodiment of the present invention can generally be set in the server 105. The database testing method provided in the embodiment of the present invention can also be executed by a server or server cluster that is different from the server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103 and / or the server 105. Accordingly, the database testing device provided in the embodiment of the present invention can also be set in a server or server cluster that is different from the server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103 and / or the server 105.

[0047] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to the implementation requirements.

[0048] The following will be based on Figure 1 The scene described by Figure 2 , Figure 3A , Figure 3B , Figure 3C The database testing method according to the embodiment of the present invention is described in detail.

[0049] Figure 2A flowchart of a database testing method according to an embodiment of the present invention is shown.

[0050] like Figure 2 As shown, the database testing method of this embodiment includes operations S210 to S270.

[0051] In operation S210, in response to a database error condition submitted by a user, error information and a problem command of the problem database are determined.

[0052] In operation S220, based on the problem command, database information, data table information and column information of the problem database are determined, wherein the column information includes a plurality of field names, and when the problem database includes a plurality of databases, the column information also includes associated column information.

[0053] In operation S230 , a test database structure is constructed based on the database information, the data table information, and the plurality of field names.

[0054] In operation S240 , fill data is generated based on the plurality of field names and associated column information.

[0055] In operation S250, the test database structure is filled with filling data to obtain a test database.

[0056] In operation S260, the question command is executed on the test database to obtain output information.

[0057] In operation S270, when the output information and the error information are the same, a test result of the problem database is determined using the test database.

[0058] According to an embodiment of the present invention, when a user uses a database to perform various addition, deletion, modification and query operations, an error may occur. When an error occurs in the database, the user submits the database error situation to the database management end, wherein the problem database includes one or more databases where an error occurs, the problem command includes the SQL statement submitted when the error occurs, and the error information includes the error information output by the database console after the problem command is submitted to the problem database.

[0059] According to an embodiment of the present invention, in response to a database error submitted by a user, error information and a problem command of a problem database are determined. Based on the problem command, database information, data table information, and column information involved in the operation task corresponding to the problem command can be determined, wherein the column information includes multiple field names. When the problem database includes multiple databases, the column information also includes associated column information. The associated column information includes field names used when performing joint queries in multiple databases, which may be foreign keys used to establish connections with primary keys of other data tables, etc.

[0060] According to an embodiment of the present invention, based on the above-mentioned database information, data table information and column information, a test database structure is constructed using a database definition language (DDL), wherein the constructed test database structure has database information, data table information and column information corresponding to the problem command.

[0061] According to an embodiment of the present invention, fill data is generated based on multiple field names and associated column information, so that the fill data includes associated column information that matches successfully and associated column information that fails to match, wherein when the values ​​corresponding to the associated columns in multiple databases are the same, the associated column information matches successfully, and when the values ​​corresponding to the associated columns in multiple databases are different, the associated column information fails to match.

[0062] According to an embodiment of the present invention, after the test database structure is filled with fill data to obtain the test database, the problem command is executed on the test database to obtain output information. Since the test database has database information, data table information and column information corresponding to the problem command, and the fill data includes the associated column information of successful matching and the associated column information of failed matching, executing the problem command on the test database can simulate the situation of executing the problem command in the problem database.

[0063] According to the embodiment of the present invention, when the output information and the error information are the same, it indicates that the problem occurring in the problem database has been successfully reproduced by using the test database, and thus the test result of the problem database can be determined by using the test database.

[0064] According to an embodiment of the present invention, in response to a database error situation submitted by a user, a problem command is determined, and based on the problem command, partial database information, data table information and column information of the problem database are determined, and a test database structure is constructed. By parsing the problem command, the test database structure can be automatically and quickly constructed, thereby improving the efficiency of database testing. For multiple field names and associated column information of the column information, fill data is generated and the test database structure is filled to obtain a test database. When the output information obtained by executing the problem command on the test database is the same as the error information in the database error situation, the test database is checked to determine the test result of the problem database. The environment in which the problem command is executed can be reproduced without the need for data from the problem database, thereby avoiding data leakage and ensuring data security. By executing the problem command on the reproduced environment, i.e., the test database, the environment in which the problem command is executed on the problem database is restored, thereby improving the efficiency of database testing.

[0065] According to an embodiment of the present invention, based on the question command, the database information, data table information and column information of the question database are determined, including: determining the command structure of the question command, wherein the command structure includes projection column information, condition column information, association column information and query source information, and the query source information includes database information and data table information; determining the column information based on the projection column information, condition column information and association column information; and using a character segmentation method to process the query source information to determine the database information and data table information.

[0066] According to an embodiment of the present invention, a command structure of a problem command is determined, wherein the command structure includes projection column information, condition column information, associated column information and query source information, and the query source information includes database information and data table information, wherein each information in the command structure can be determined by extracting the character string after the keyword using string processing technology, and the keywords include "FROM", "JOIN", "WHERE", "SELECT" and other keywords used to guide SQL statements, wherein the character string guided after the "JOIN" keyword is the associated column information, the character string guided after the "FROM" keyword is the query source information, the character string guided after the "WHERE" keyword is the condition column information, and the character string guided after the "SELECT" keyword is the projection column information. For example, the regular expression "?<=FROM|JOIN)[\s]+[\S]" can be used to obtain the character string after "FROM" or "JOIN".

[0067] According to an embodiment of the present invention, column information is determined based on projection column information, condition column information, and association column information.

[0068] According to an embodiment of the present invention, a character segmentation method is used to divide the query source information into database information and data table information using ".". For example, when the query source information is "OMDATA.CBS_CL_DRAWDOWN_TBL", the database information is "OMDATA" and the data table information is "CBS_CL_DRAWDOWN_TBL".

[0069] According to an embodiment of the present invention, in the case where the query source information includes alias information of a data table, the associated column information may include the alias and the associated column name or the table name and the associated column name.

[0070] According to an embodiment of the present invention, when information such as query source information and command structure is not case-sensitive, a string processing method may be used to convert letters in a string corresponding to the information into uppercase.

[0071] According to an embodiment of the present invention, a string processing method is used to determine the command structure from the problem command, and the projection column information, condition column information, associated column information and query source information therein are determined, and a character segmentation method is used to process the query source information, determine the database information and data table information, and finally determine the database information, data table information and column information of the problem database, which can improve the information determination efficiency and accuracy.

[0072] According to an embodiment of the present invention, a test database structure is constructed based on database information, data table information and multiple field names, including: determining a test database definition language for generating the test database structure based on the database information, data table information and multiple field names; and executing the test database definition language to construct the test database structure.

[0073] According to an embodiment of the present invention, a test database definition language for generating a test database structure is determined based on database information, data table information, and multiple field names, wherein a template of the test database definition language can be pre-set, and placeholders in the template of the test database definition language are replaced with the database information, data table information, and multiple field names to determine the test database definition language. The test database definition language is executed to construct a test database structure.

[0074] According to an embodiment of the present invention, based on database information, data table information and multiple field names, a test database definition language is determined, and the test database definition language is executed to obtain a test database structure, which can automatically construct a test database structure and improve the efficiency of environmental reproduction.

[0075] According to an embodiment of the present invention, a test database definition language for generating a test database structure is determined based on database information, data table information and multiple field names, including: determining a database definition language for building a database based on the database information; determining a database definition language for building a table based on the data table information and multiple field names, wherein the field type of the database definition language for building a table is a character type; and determining a test database definition language based on the database definition language for building a database and the database definition language for building a table.

[0076] According to an embodiment of the present invention, the template of the test database definition language may include a template of the database definition language for building a database and a template of the database definition language for building a table. Based on the database information, the database definition language for building a database is determined, and based on the data table information and multiple field names, the database definition language for building a table is determined, wherein the placeholders in the template of the database definition language for building a database are replaced with the database information to determine the database definition language for building a database, the placeholders in the template of the database definition language for building a table are replaced with the data table information and multiple field names, and the field types of the multiple field names are specified as character types, and the database definition language for building a table is determined.

[0077] According to an embodiment of the present invention, a test database definition language is determined based on a library building database definition language and a table building database definition language.

[0078] According to an embodiment of the present invention, the database definition language for database building is determined by using database information and a template of the database definition language for database building, and the database definition language for table building is determined by using data table information, multiple field names and a template of the database definition language for table building, thereby determining the test database definition language. It is ensured that the data table information, database information and multiple field names of the data table in the test database definition language are the same as the problem command, thereby ensuring that the database test using the test database structure can accurately reproduce the structure of the problem database.

[0079] According to an embodiment of the present invention, filling data is generated based on multiple field names and associated column information, including: based on the associated column information, determining the field sequence number of the field corresponding to the associated column information in the multiple field names; based on the field sequence number, generating a preset number of row data; and based on the preset number of row data, determining the filling data.

[0080] According to an embodiment of the present invention, based on the associated column information, the field serial numbers of the fields corresponding to the associated column information in the plurality of field names in each data table are determined.

[0081] According to an embodiment of the present invention, a preset number of rows of data are generated based on the field sequence number, wherein the number of data included in each row of data is the same as the number of field names, and the data at the field sequence number in each row of data is generated in a different manner from the data at other positions. The preset number can be set to 10000, 100000, etc., and the preset number of rows of data can be aggregated to obtain the fill data.

[0082] According to an embodiment of the present invention, based on the associated column information, the field number of the field corresponding to the associated column information in multiple field names is determined, so that row data is generated based on the field number, and based on a preset number of row data, the fill data is determined, so that the data located at the field number position in the row data has matching success and matching failure situations, thereby reproducing the environment of the problem database.

[0083] According to an embodiment of the present invention, a preset number of rows of data is generated based on a field sequence number, including: determining the number of associations in which field values ​​corresponding to associated column information of each of multiple databases are successfully matched based on a preset ratio and a preset number; determining a target number of rows based on the number of associations and the preset number, wherein the target number of rows is obtained by evenly distributing the number of associations in the preset number; configuring multiple rows of data different from the target number of rows using a random number generation method; and configuring multiple rows of data of the target number of rows using a target configuration method.

[0084] According to an embodiment of the present invention, based on a preset ratio and a preset number, the number of associations in which field values ​​corresponding to the associated column information of each of the multiple databases are successfully matched is determined, wherein the preset ratio is the ratio of the field values ​​corresponding to the associated column information of each of the multiple databases that are successfully matched, which can be set to 1 / 100, etc.

[0085] According to an embodiment of the present invention, a target number of rows is determined based on the associated number and the preset number, wherein the target number of rows is obtained by evenly distributing the associated number in the preset number.

[0086] For example, the preset number is 10,000, the preset ratio is 1 / 100, and among the 10,000 data generated, the number of field values ​​corresponding to the associated column information of multiple databases that are successfully matched is 100. The 100 successfully matched row data are evenly distributed to the 10,000 row data. It can be set that 1 successfully matched row data is generated after every 99 failed matching row data are generated. Then the target number of rows is N*100, where N is a positive integer less than 101.

[0087] According to an embodiment of the present invention, a random number generation method is used to configure multiple rows of data different from the target number of rows, and a target configuration method is used to configure multiple rows of data of the target number of rows, wherein the random number generation method may include a random date generation method.

[0088] According to an embodiment of the present invention, based on a preset number and a preset ratio, the associated number and the target number of rows are determined, and the data at the field number position in the row data of the target number of rows and the data different from the field number position are configured using a target configuration method, and the row data different from the target number of rows are configured using a random number generation method to obtain a preset number of row data, ensuring that the target number of rows in which the associated columns are successfully matched is evenly distributed in the preset number of row data, which is closer to the situation of real data, thereby improving the probability of successful reproduction of the problem database and the probability of successful database testing.

[0089] According to an embodiment of the present invention, a target configuration method is used to configure multiple row data of a target number of rows, including: using a random number generation method to configure field values ​​of fields other than the fields corresponding to the associated column information; and using preset fixed values ​​to configure the field values ​​of the fields corresponding to the associated column information.

[0090] According to an embodiment of the present invention, a random number generation method is used to configure the field values ​​of fields other than the fields corresponding to the associated column information, and preset fixed values ​​are used to configure the field values ​​of the fields corresponding to the associated column information, so that when an outer join clause "JOIN" is used to perform a joint query on multiple data tables, the field values ​​configured with preset fixed values ​​can be filtered out, so that the query results are not empty.

[0091] According to an embodiment of the present invention, the field values ​​of other fields and fields corresponding to the associated column information are configured using a random number generation method and a preset fixed value, respectively, to ensure that row data of multiple target numbers of rows configured using the target configuration method can be successfully matched, so that the query results when the test database is queried using the question command are not empty, thereby increasing the probability of successful database testing.

[0092] According to an embodiment of the present invention, filling a test database structure with filling data to obtain a test database includes: saving the filling data in a data file; and loading the data file to write the filling data into the test database structure to obtain the test database.

[0093] According to an embodiment of the present invention, the filling data is saved in a data file, which may include a log file. The data file is loaded and parsed using a loading function of a database to obtain the filling data, and the filling data is written into a test database structure to obtain a test database.

[0094] According to an embodiment of the present invention, the fill data is saved in a data file, and the data file is loaded to write the data to obtain a test database, which can ensure the integrity of the written data, that is, ensure that the data written into the test database structure includes data with successful matching of field values ​​corresponding to the associated column information of multiple databases, and also includes data with failed matching of field values ​​corresponding to the associated column information of multiple databases, thereby achieving reproduction of the database structure and data of the problem database and improving the efficiency of database testing.

[0095] According to an embodiment of the present invention, the database testing method further includes: when the output information and the error information are different, determining that the cause of the problem database error does not include database information, data table information and column information.

[0096] According to an embodiment of the present invention, a problem command is executed on a test database to obtain output information, wherein the output information and the error information are different include: the output information indicates that the problem command is executed normally on the test database, the output information indicates that the problem command is executed incorrectly on the test database, and the error information is different from the error information.

[0097] According to an embodiment of the present invention, when the output information and the error information are different, it can be determined that the cause of the error in the problem database does not include database information, data table information and column information, but because the structure of the test database and the problem database may be different, and the stored data are different, it is impossible to determine that the cause of the error in the problem database is an error in the stored data in the problem database or other structures in the problem database that cause the error.

[0098] According to an embodiment of the present invention, when the output information and the error information are different, it is possible to quickly rule out errors in the problem database caused by the structure of the database information, data table information and column information, thereby performing other aspects of the problem database troubleshooting, which can narrow the possible error scope of the problem database and improve the efficiency of database testing.

[0099] Figure 3A A data table of a test database constructed according to the database testing method of an embodiment of the present invention is shown.

[0100] like Figure 3A As shown, the problem analysis command determines that the data table information of the problem database includes data table A, and the projection column information of data table A includes a, b, c and d, which are recorded as Aa, Ab, Ac and Ad. The associated column information of data table A and data table B includes x, that is, both data table A and data table B include x columns, which are recorded as Ax and Bx respectively. According to the data table information and multiple field names, the test database definition language is determined, and the test database structure is obtained by execution.

[0101] Figure 3B Another data table of the test database constructed according to the database testing method of the embodiment of the present invention is shown.

[0102] like Figure 3B As shown, the problem analysis command determines that the data table information of the problem database includes data table B, and the projection column information of data table B includes 1 and 2, which are recorded as B.1 and B.2. The associated column information of data table A and data table B includes x, that is, both data table A and data table B include x columns, which are recorded as Ax and Bx respectively. According to the data table information and multiple field names, the test database definition language is determined, and the test database structure is obtained by executing.

[0103] A random number generation method is used to generate random date data to fill in columns Aa, Ab, Ac, Ad, B.1 and B.2, and a preset fixed value is used to fill in part of the associated column information. In this embodiment, the preset fixed value is 0.

[0104] After determining the filling data, use the filling data to fill Figure 3A and Figure 3B The test database structure in is obtained, wherein rows 311 and 312 are rows in data table A that use preset fixed values ​​to fill in associated column information, and rows 321, 322, and 323 are rows in data table B that use preset fixed values ​​to fill in associated column information.

[0105] Figure 3C The diagram shows the query results obtained by executing the structured query language on the test database according to the database testing method of the embodiment of the present invention.

[0106] right Figure 3A and Figure 3B The test database shown executes the SQL statement used to query the same values ​​of the associated columns in Table A and Table B. The query results are as follows Figure 3C The query result includes row 311 and row 321, row 311 and row 322, row 311 and row 323, row 312 and row 321, row 312 and row 322, and row 312 and row 323.

[0107] Based on the above database testing method, the present invention also provides a database testing device. Figure 4 The device is described in detail.

[0108] Figure 4 A structural block diagram of a database testing device according to an embodiment of the present invention is shown.

[0109] like Figure 4 As shown, the database testing device 400 of this embodiment includes an error determination module 410 , an information determination module 420 , a database construction module 430 , a data generation module 440 , a database filling module 450 , an output determination module 460 and a result determination module 470 .

[0110] The error determination module 410 is used to determine the error information and the problem command of the problem database in response to the database error reported by the user, wherein the error information is generated when the problem command is executed on the problem database, and the problem database includes one or more databases. In one embodiment, the error determination module 410 can be used to perform the operation S210 described above, which will not be described in detail here.

[0111] The information determination module 420 is used to determine the database information, data table information and column information of the problem database based on the problem command, wherein the column information includes multiple field names, and when the problem database includes multiple databases, the column information also includes associated column information. In one embodiment, the information determination module 420 can be used to perform the operation S220 described above, which will not be repeated here.

[0112] The database construction module 430 is used to construct a test database structure based on database information, data table information and multiple field names. In one embodiment, the database construction module 430 can be used to perform the operation S230 described above, which will not be described in detail here.

[0113] The data generation module 440 is used to generate fill data based on multiple field names and associated column information. In one embodiment, the data generation module 440 can be used to perform the operation S240 described above, which will not be described in detail here.

[0114] The database filling module 450 is used to fill the test database structure with filling data to obtain a test database. In one embodiment, the database filling module 450 can be used to perform the operation S250 described above, which will not be described in detail here.

[0115] The output determination module 460 is used to execute the question command on the test database to obtain output information. In one embodiment, the output determination module 460 can be used to perform the operation S260 described above, which will not be described in detail here.

[0116] The result determination module 470 is used to determine the test result of the problem database using the test database when the output information and the error information are the same. In one embodiment, the result determination module 470 can be used to perform the operation S270 described above, which will not be described in detail here.

[0117] According to an embodiment of the present invention, the information determination module 420 includes a structure determination submodule, a column information determination submodule and a table information determination submodule.

[0118] The structure determination submodule is used to determine the command structure of the problem command, wherein the command structure includes projection column information, condition column information, association column information and query source information, and the query source information includes database information and data table information.

[0119] The column information determination submodule is used to determine the column information based on the projection column information, the condition column information and the associated column information.

[0120] The table information determination submodule is used to process the query source information using the character segmentation method to determine the database information and data table information.

[0121] According to an embodiment of the present invention, the database construction module 430 includes a language generation submodule and a database construction submodule.

[0122] The language generation submodule is used to determine the test database definition language used to generate the test database structure based on the database information, the data table information and the multiple field names.

[0123] The database construction submodule is used to execute the test database definition language and build the test database structure.

[0124] According to an embodiment of the present invention, the language generation submodule includes a library building language generation unit, a table building language generation unit and a language generation unit.

[0125] The database building language generation unit is used to determine the database building database definition language based on the database information.

[0126] The table building language generating unit is used to determine the table building database definition language based on the data table information and multiple field names, wherein the field type of the table building database definition language is character type.

[0127] The language generation unit is used to determine the test database definition language based on the database definition language for building a library and the database definition language for building a table.

[0128] According to an embodiment of the present invention, the data generation module 440 includes a sequence number determination submodule, a row data generation submodule and a data generation submodule.

[0129] The sequence number determination submodule is used to determine the field sequence number of the field corresponding to the associated column information among the multiple field names based on the associated column information.

[0130] The row data generation submodule is used to generate a preset number of row data based on the field sequence number.

[0131] The data generation submodule is used to determine the filling data based on a preset number of rows of data.

[0132] According to an embodiment of the present invention, the row data generation submodule includes a quantity determination unit, a row number determination unit, a first row data configuration unit and a second row data configuration unit.

[0133] The quantity determination unit is used to determine the number of associations in which the field values ​​corresponding to the association column information of each of the multiple databases are successfully matched based on a preset ratio and a preset number.

[0134] The row number determination unit is used to determine a target row number based on the associated number and the preset number, wherein the target row number is obtained by evenly distributing the associated number in the preset number.

[0135] The first row data configuration unit is used to configure a plurality of row data different from the target row number by using a random number generation method.

[0136] The second row data configuration unit is used to configure a plurality of row data of a target number of rows by using a target configuration method.

[0137] According to an embodiment of the present invention, the second row data configuration unit includes a first field configuration subunit and a second field configuration subunit.

[0138] The first field configuration subunit is used to configure field values ​​of other fields except the field corresponding to the associated column information by using a random number generation method.

[0139] The second field configuration subunit is used to configure the field value of the field corresponding to the associated column information using a preset fixed value.

[0140] According to an embodiment of the present invention, the database filling module 450 includes a data saving submodule and a data writing submodule.

[0141] The data saving submodule is used to save the filled data in the data file.

[0142] The data writing submodule is used to load the data file, write the fill data into the test database structure, and obtain the test database.

[0143] According to an embodiment of the present invention, the database testing device 400 further includes a result checking module.

[0144] The result troubleshooting module is used to determine that the cause of the problem database error does not include database information, data table information and column information when the output information and the error information are different.

[0145] According to an embodiment of the present invention, any multiple modules among the error determination module 410, the information determination module 420, the database construction module 430, the data generation module 440, the database filling module 450, the output determination module 460 and the result determination module 470 can be combined in one module for implementation, or any one of the modules can be split into multiple modules. Alternatively, at least part of the functions of one or more of these modules can be combined with at least part of the functions of other modules and implemented in one module. According to an embodiment of the present invention, at least one of the error determination module 410, the information determination module 420, the database construction module 430, the data generation module 440, the database filling module 450, the output determination module 460 and the result determination module 470 can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or can be implemented in any one of the three implementation methods of software, hardware and firmware or in any appropriate combination of any of them. Alternatively, at least one of the error determination module 410, the information determination module 420, the database construction module 430, the data generation module 440, the database filling module 450, the output determination module 460 and the result determination module 470 can be at least partially implemented as a computer program module, which can perform the corresponding function when the computer program module is executed.

[0146] Figure 5 A block diagram of an electronic device suitable for implementing a database testing method according to an embodiment of the present invention is shown.

[0147] like Figure 5As shown, the electronic device 500 according to an embodiment of the present invention includes a processor 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage part 508 to a random access memory (RAM) 503. The processor 501 may include, for example, a general-purpose microprocessor (such as a CPU), an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (for example, an application-specific integrated circuit (ASIC)), etc. The processor 501 may also include an onboard memory for caching purposes. The processor 501 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present invention.

[0148] In RAM 503, various programs and data required for the operation of electronic device 500 are stored. Processor 501, ROM 502 and RAM 503 are connected to each other via bus 504. Processor 501 performs various operations of the method flow according to the embodiment of the present invention by executing the program in ROM 502 and / or RAM 503. It should be noted that the program can also be stored in one or more memories other than ROM 502 and RAM 503. Processor 501 can also perform various operations of the method flow according to the embodiment of the present invention by executing the program stored in the one or more memories.

[0149] According to an embodiment of the present invention, the electronic device 500 may further include an input / output (I / O) interface 505, which is also connected to the bus 504. The electronic device 500 may further include one or more of the following components connected to the input / output (I / O) interface 505: an input portion 506 including a keyboard, a mouse, etc.; an output portion 507 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage portion 508 including a hard disk, etc.; and a communication portion 509 including a network interface card such as a LAN card, a modem, etc. The communication portion 509 performs communication processing via a network such as the Internet. A drive 510 is also connected to the input / output (I / O) interface 505 as needed. A removable medium 511, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 510 as needed, so that the computer program read therefrom is installed into the storage portion 508 as needed.

[0150] The present invention also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiment; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present invention is implemented.

[0151] According to an embodiment of the present invention, the computer-readable storage medium may be a non-volatile computer-readable storage medium, for example, may include but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present invention, the computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, an apparatus or a device. For example, according to an embodiment of the present invention, the computer-readable storage medium may include the ROM 502 and / or RAM 503 described above and / or one or more memories other than ROM 502 and RAM 503.

[0152] The embodiment of the present invention also includes a computer program product, which includes a computer program, and the computer program contains program code for executing the method shown in the flowchart. When the computer program product is run in a computer system, the program code is used to enable the computer system to implement the method provided by the embodiment of the present invention.

[0153] The computer program executes the above functions defined in the system / device of the embodiment of the present invention when it is executed by the processor 501. According to the embodiment of the present invention, the system, device, module, unit, etc. described above can be implemented by a computer program module.

[0154] In one embodiment, the computer program may rely on tangible storage media such as optical storage devices, magnetic storage devices, etc. In another embodiment, the computer program may also be transmitted and distributed in the form of signals on a network medium, and downloaded and installed through the communication part 509, and / or installed from the removable medium 511. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.

[0155] In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 509, and / or installed from the removable medium 511. When the computer program is executed by the processor 501, the above functions defined in the system of the embodiment of the present invention are performed. According to the embodiment of the present invention, the system, device, means, module, unit, etc. described above can be implemented by a computer program module.

[0156] According to an embodiment of the present invention, the program code for executing the computer program provided by the embodiment of the present invention can be written in any combination of one or more programming languages. Specifically, these computing programs can be implemented using high-level process and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages ​​include, but are not limited to, Java, C++, python, "C" language or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on the remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (e.g., using an Internet service provider to connect through the Internet).

[0157] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0158] It will be appreciated by those skilled in the art that the features described in the various embodiments of the present invention may be combined and / or combined in various ways, even if such combinations or combinations are not explicitly described in the present invention. In particular, without departing from the spirit and teachings of the present invention, the features described in the various embodiments of the present invention may be combined and / or combined in various ways. All of these combinations and / or combinations fall within the scope of the present invention.

[0159] The embodiments of the present invention are described above. However, these embodiments are only for the purpose of illustration, and are not intended to limit the scope of the present invention. Although each embodiment is described above, it does not mean that the measures in each embodiment cannot be used in combination advantageously. Without departing from the scope of the present invention, those skilled in the art may make various substitutions and modifications, which should all fall within the scope of the present invention.

Claims

1. A database testing method, characterized in that: The method comprises: In response to a database error condition submitted by a user, determining error information and a problem command of a problem database, wherein the error information is generated when the problem command is executed on the problem database, and the problem database includes a plurality of databases; Based on the problem command, determine database information, data table information and column information of the problem database, wherein the column information includes a plurality of field names and associated column information; Building a test database structure based on the database information, the data table information and the multiple field names; Generate fill data based on the multiple field names and the associated column information; Filling the test database structure with the filling data to obtain a test database; Executing the problem command on the test database to obtain output information; and In the case where the output information and the error information are the same, the test result of the problem database is determined using the test database.

2. The method according to claim 1, characterized in that: The step of determining database information, data table information, and column information of the problem database based on the problem command includes: Determine a command structure of the question command, wherein the command structure includes projection column information, condition column information, the associated column information and query source information, and the query source information includes the database information and the data table information; determining the column information based on the projection column information, the condition column information and the associated column information; and The query source information is processed using a character segmentation method to determine the database information and the data table information.

3. The method according to claim 1, characterized in that The step of constructing a test database structure based on the database information, the data table information and the multiple field names includes: Determining a test database definition language for generating the test database structure based on the database information, the data table information and the plurality of field names; and The database definition language is executed to construct the test database structure.

4. The method according to claim 3, characterized in that The step of determining a test database definition language for generating the test database structure based on the database information, the data table information and the plurality of field names includes: Based on the database information, determine the database definition language for building the database; Determine a table-building database definition language based on the data table information and the plurality of field names, wherein the field type of the table-building database definition language is a character type; and The test database definition language is determined based on the library building database definition language and the table building database definition language.

5. The method according to claim 1, characterized in that The generating of filling data based on the multiple field names and the associated column information includes: Based on the associated column information, determining a field sequence number of a field corresponding to the associated column information among the multiple field names; Based on the field sequence number, generating a preset number of rows of data; and The filling data is determined based on the preset number of rows of data.

6. The method according to claim 5, characterized in that The generating a preset number of rows of data based on the field sequence number includes: Based on a preset ratio and the preset number, determining the number of associations in which the field values ​​corresponding to the association column information of each of the multiple databases have successfully matched; Determining a target number of rows based on the associated number and the preset number, wherein the target number of rows is obtained by evenly distributing the associated number in the preset number; Using a random number generation method, configuring a plurality of row data different from the target number of rows; and A target configuration method is used to configure a plurality of rows of data of the target number of rows.

7. The method according to claim 6, characterized in that The method of using the target configuration method to configure the target number of rows of data includes: Using the random number generation method, configuring field values ​​of other fields other than the field corresponding to the associated column information; and The field value of the field corresponding to the associated column information is configured using a preset fixed value.

8. The method according to claim 1, characterized in that The step of filling the test database structure with the filling data to obtain a test database includes: Saving the filling data in a data file; and The data file is loaded, and the filling data is written into the test database structure to obtain the test database.

9. The method according to claim 1, characterized in that: The method further comprises: In the case that the output information is different from the error information, it is determined that the cause causing the error of the problem database does not include the database information, the data table information and the column information.

10. A database testing device, characterized in that: The device comprises: an error determination module, configured to determine error information and a problem command of a problem database in response to a database error condition submitted by a user, wherein the error information is generated when the problem command is executed on the problem database, and the problem database includes a plurality of databases; An information determination module, used to determine database information, data table information and column information of the problem database based on the problem command, wherein the column information includes a plurality of field names and associated column information; A database construction module, used to construct a test database structure based on the database information, the data table information and the multiple field names; A data generation module, used for generating filling data based on the multiple field names and the associated column information; A database filling module, used to fill the test database structure with the filling data to obtain a test database; an output determination module, configured to execute the question command on the test database to obtain output information; and A result determination module is used to determine the test result of the problem database using the test database when the output information and the error information are the same.

Citation Information

Patent Citations

  • Database testing method, system and device

    CN114968748A

  • Data construction method and system based on big data general test

    CN115729937A