Database testing method and system and electronic equipment

By entering structured query statements to different versions of databases and comparing execution results when the database version is updated, the problems of database stability and reliability testing are solved, which improves the accuracy and efficiency of the test, reduces risks, and improves the User experience.

CN119179690AInactive Publication Date: 2024-12-24湖南亚信安慧科技有限公司
View PDF 8 Cites 0 Cited by

Patent Information

Application Number
CN202411679785.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-22
Publication Date
2024-12-24
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

During the database version update process, how to effectively test the stability and reliability of the database is an urgent problem to be solved.

Method used

By obtaining structured query statements, inputting them into the target database of different versions for execution, and comparing the execution results, determining whether there are exceptions in the database version update, so as to achieve testing of database updates and improve the accuracy and efficiency of the test.

Benefits of technology

Testing the stability and reliability after database version update is realized, reducing the risk of database version update and improving user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119179690A_ABST
    Figure CN119179690A_ABST
Patent Text Reader

Abstract

The invention discloses a database testing method and system and electronic equipment. The method comprises the steps that a structured query statement is obtained; the structured query statement is input into at least two target databases, so that the at least two target databases execute the structured query statement respectively, and the at least two target databases are databases of different versions; obtaining execution results of the structured query statements executed by the at least two target databases; and comparing the execution results of the at least two target databases to obtain a comparison result, so as to determine whether the at least two target databases meet requirements or not based on the comparison result, the comparison result being used for representing whether the execution results of the at least two target databases are the same or not.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] With the rapid development of database technology, database version updates have become an indispensable part of daily enterprise operations. However, various problems may occur during the database version update process. Therefore, how to effectively test the stability and reliability of the database has become an urgent problem to be solved in the industry. Summary of the invention

[0003] In view of this, the present application provides a database testing method, system and electronic device, and the specific scheme thereof is as follows:

[0004] A database testing method, comprising:

[0005] Get structured query statements;

[0006] Inputting the structured query statement into at least two target databases so that the at least two target databases respectively execute the structured query statement, wherein the at least two target databases are databases of different versions;

[0007] Obtaining execution results of the structured query statements respectively executed by the at least two target databases;

[0008] The execution results of the at least two target databases are compared to obtain a comparison result, so as to determine whether the at least two target databases meet the requirements based on the comparison result, and the comparison result is used to indicate whether the execution results of the at least two target databases are the same.

[0009] Furthermore, the step of obtaining a structured query statement includes:

[0010] generating a random structured query statement based on the characteristics of the at least two target databases;

[0011] or,

[0012] A structured query statement is obtained from a configuration database, where the structured query statement stored in the configuration database is pre-stored.

[0013] Further, the obtaining of a structured query statement from a configuration database includes:

[0014] Obtain testing instructions;

[0015] Determine whether the test instruction includes a replay identifier, where the replay identifier can represent identification information of the structured query statement to be replayed;

[0016] If it is determined that the test instruction contains the replay identifier, the structured query statement to be replayed corresponding to the replay identifier is obtained from the configuration database.

[0017] Furthermore, the generating of random structured query statements based on the characteristics of the at least two target databases includes:

[0018] Obtain testing instructions;

[0019] If it is determined that the test instruction does not include a replay identifier, generating a first random structured query statement based on the characteristics of the at least two target databases;

[0020] Obtain configuration parameters stored in the configuration database;

[0021] If it is determined that the first random structured query statement includes the data to be replaced specified by the configuration parameter, determining a replacement value corresponding to the data to be replaced in the configuration parameter;

[0022] The to-be-replaced data included in the first random structured query statement is changed into the replacement value to obtain a second random structured query statement, so that the at least two target databases can execute the second random structured query statement.

[0023] Furthermore, the generating a first random structured query statement based on the characteristics of the at least two target databases includes:

[0024] Identify specific fields;

[0025] A first random structured query statement sorted according to the specific field is generated based on the characteristics of the at least two target databases.

[0026] Further, the comparing the execution results of the at least two target databases to obtain a comparison result includes:

[0027] Determine summary information of each of the execution results of the at least two target databases;

[0028] The summary information of each execution result is compared to obtain a comparison result.

[0029] Furthermore, it also includes:

[0030] If the comparison result indicates that the execution results of the at least two target databases are inconsistent, obtaining the target filtering parameters stored in the configuration database;

[0031] It is determined that the structured query statement satisfies the target filtering parameter, and the execution results of the structured query statement and / or the at least two target databases are filtered.

[0032] Furthermore, it also includes:

[0033] The comparison result and the structured query statement corresponding to the comparison result are stored in a configuration database.

[0034] A database testing system, comprising:

[0035] A first obtaining unit, used for obtaining a structured query statement;

[0036] An input unit, used for inputting the structured query statement into at least two target databases, so that the at least two target databases respectively execute the structured query statement, wherein the at least two target databases are databases of different versions;

[0037] A second obtaining unit is used to obtain the execution results of the structured query statement executed by the at least two target databases respectively;

[0038] A comparison unit is used to compare the execution results of the at least two target databases to obtain a comparison result, so as to determine whether the at least two target databases meet the requirements based on the comparison result, and the comparison result is used to indicate whether the execution results of the at least two target databases are the same.

[0039] An electronic device, comprising:

[0040] A processor is used to obtain a structured query statement; input the structured query statement into at least two target databases so that the at least two target databases respectively execute the structured query statement, wherein the at least two target databases are databases of different versions; obtain execution results of the at least two target databases respectively executing the structured query statement; compare the execution results of the at least two target databases to obtain a comparison result, so as to determine whether the at least two target databases meet the requirements based on the comparison result, and the comparison result is used to indicate whether the execution results of the at least two target databases are the same;

[0041] The memory is used to store the program for the processor to execute the above processing process.

[0042] It can be seen from the above technical scheme that the database testing method, system and electronic device disclosed in the present application obtain a structured query statement; input the structured query statement into at least two target databases so that at least two target databases execute the structured query statement respectively, wherein at least two target databases are databases of different versions; obtain the execution results of at least two target databases executing the structured query statement respectively; compare the execution results of at least two target databases to obtain a comparison result, so as to determine whether at least two target databases meet the requirements based on the comparison result, and the comparison result is used to characterize whether the execution results of at least two target databases are the same. In this scheme, when the database version is updated, in order to determine whether the version update of the database is abnormal, the same structured query statement is input into at least two target databases respectively, so that at least two target databases execute the same structured query statement at the same time, and obtain the execution result, compare the execution results based on at least two target databases, and determine whether the execution results are the same, so as to determine whether the target database version update is abnormal based on the comparison result of whether the execution results are the same, and realize the test of stability and reliability after the database version is updated, improve the accuracy and efficiency of testing after the database version is updated, and improve the user experience. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0044] Figure 1 A flowchart of a database testing method disclosed in an embodiment of the present application;

[0045] Figure 2 A flowchart of another database testing method disclosed in an embodiment of the present application;

[0046] Figure 3 A flowchart of another database testing method disclosed in an embodiment of the present application;

[0047] Figure 4 A flowchart of another database testing method disclosed in an embodiment of the present application;

[0048] Figure 5 A schematic diagram of a database test framework disclosed in an embodiment of the present application;

[0049] Figure 6 A schematic diagram of the structure of a database testing system disclosed in an embodiment of the present application;

[0050] Figure 7 A schematic diagram of the structure of an electronic device disclosed in an embodiment of the present application. DETAILED DESCRIPTION

[0051] The following describes the embodiments of the present application in conjunction with the drawings in the embodiments of the present application. The terms used in the implementation method section of the present application are only used to explain the specific embodiments of the present application, and are not intended to limit the present application.

[0052] The embodiments of the present application are described below in conjunction with the accompanying drawings. Those skilled in the art will appreciate that, with the development of technology and the emergence of new scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.

[0053] The terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and need not be used to describe a specific order or sequential order. It should be understood that the terms used in this way can be interchangeable under appropriate circumstances, which is only to describe the distinction mode adopted by the objects of the same attributes when describing in the embodiments of the present application. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, so that the process, method, system, product or equipment comprising a series of units need not be limited to those units, but may include other units that are not clearly listed or inherent to these processes, methods, products or equipment.

[0054] This application discloses a database testing method, and its flow chart is as follows: Figure 1 As shown, including:

[0055] Step S11, obtaining a structured query statement;

[0056] Step S12: inputting the structured query statement into at least two target databases, so that the at least two target databases respectively execute the structured query statement, wherein the at least two target databases are databases of different versions;

[0057] Step S13, obtaining execution results of the structured query statements respectively executed by at least two target databases;

[0058] Step S14: compare the execution results of at least two target databases to obtain a comparison result, so as to determine whether the at least two target databases meet the requirements based on the comparison result, and the comparison result is used to indicate whether the execution results of the at least two target databases are the same.

[0059] With the rapid development of database technology, database version updates have become an indispensable part of daily enterprise operations. However, various problems may occur during the database version update process. Therefore, how to effectively test the stability and reliability of the database has become an urgent problem to be solved in the industry.

[0060] Based on this, in this solution, the same structured query statement is input into at least two target databases of different versions respectively, so that at least two target databases execute the same structured query statement to obtain execution results, so that it is possible to determine whether there is an abnormality in the database version update based on the comparison of the execution results, thereby realizing the test of the database update, improving the efficiency and accuracy of the database update test, and reducing the risk of the database version update.

[0061] Structured Query Language (SQL) is a programming language used to access data and query, update, and manage relational database systems.

[0062] After the structured query language is obtained, the structured query language is input into at least two target databases, so that the at least two target databases can respectively obtain the structured query language and execute it.

[0063] The target database is a database that needs to be tested, and at least two target databases are databases of different versions.

[0064] When at least two target databases receive the same structured query language, the at least two target databases respectively execute the received structured query language to obtain execution results.

[0065] The structured query statements are executed respectively on at least two target databases. After the execution is completed, the execution results of the structured query statements executed respectively on the at least two target databases are sent to the database testing system on which the database testing method disclosed in this embodiment is based, so that the database testing system can obtain the execution results of the structured query statements executed respectively by the at least two target databases.

[0066] After the database test system obtains the execution results of at least two target databases executing structured query statements respectively, the execution results can be compared to determine whether the execution results are consistent. Taking two target databases as an example, when two databases of the same type and different versions execute the same structured query statement, their execution results should be the same. If the execution results are different, it can be determined that one of the target databases has an abnormality. Since the two target databases are of the same type and different versions of data, it can be determined that the target database with the abnormality is the database after the version is updated, so it can be determined that the version update has an abnormality, thereby completing the test of the updated database.

[0067] Comparing the execution results of at least two target databases to obtain a comparison result, if the comparison result indicates that the execution results of at least two target databases are the same, it can be determined that at least two target databases meet the requirements, at this time, no matter which version of the at least two target databases is the updated version, no abnormality is determined based on the execution result;

[0068] If the comparison result indicates that the execution results of at least two target databases are different, it can be determined that at least two databases do not meet the requirements. At this time, there is an abnormal database among the at least two target databases, and the version of the abnormal database is an updated version. Based on the versions of the at least two target databases, it can be determined which database is the abnormal database.

[0069] The database testing method disclosed in the present embodiment obtains a structured query statement; inputs the structured query statement into at least two target databases so that at least two target databases respectively execute the structured query statement, wherein at least two target databases are databases of different versions; obtains the execution results of at least two target databases respectively executing the structured query statement; compares the execution results of at least two target databases to obtain a comparison result, so as to determine whether at least two target databases meet the requirements based on the comparison result, and the comparison result is used to characterize whether the execution results of at least two target databases are the same. In this scheme, when the database version is updated, in order to determine whether the version update of the database is abnormal, the same structured query statement is input into at least two target databases respectively, so that at least two target databases execute the same structured query statement at the same time, and obtains the execution result, compares the execution results of at least two target databases, and determines whether the execution results are the same, so as to determine whether the target database version update is abnormal based on the comparison result of whether the execution results are the same, thereby realizing the test of the stability and reliability of the database version after the update, improving the accuracy and efficiency of the test after the database version is updated, and improving the user experience.

[0070] This embodiment discloses a database testing method, and its flow chart is as follows: Figure 2 As shown, including:

[0071] Step S21, obtaining a structured query statement from a configuration database, where the structured query statement stored in the configuration database is pre-stored;

[0072] Step S22: inputting the structured query statement into at least two target databases, so that the at least two target databases respectively execute the structured query statement, and the at least two target databases are databases of different versions;

[0073] Step S23, obtaining execution results of the structured query statements respectively executed by at least two target databases;

[0074] Step S24: compare the execution results of at least two target databases to obtain a comparison result, so as to determine whether the at least two target databases meet the requirements based on the comparison result, and the comparison result is used to indicate whether the execution results of the at least two target databases are the same.

[0075] The test for the version update of the database can be: controlling at least two target databases to execute the same structured query statement respectively, obtaining the execution results, and comparing the execution results to determine whether the execution results are the same, thereby determining whether the at least two target databases meet the requirements, that is, whether the version update of the database passes the test.

[0076] The structured query statement may be directly obtained from a configuration database, and the structured query statement stored in the configuration database is pre-stored.

[0077] The configuration database is used to pre-store structured query statements. When it is necessary to control the target database to execute the structured query statements, the pre-stored structured query statements can be directly obtained from the configuration database, so that the target database can directly execute the structured query statements obtained from the configuration database, thereby ensuring the execution efficiency and accuracy of the structured query statements.

[0078] Furthermore, the structured query statement obtained from the configuration database may be:

[0079] Obtain a test instruction; determine whether the test instruction contains a replay identifier, where the replay identifier can represent identification information of a structured query statement to be replayed; if it is determined that the test instruction contains a replay identifier, obtain the structured query statement to be replayed corresponding to the replay identifier from a configuration database.

[0080] Only when the test instruction is obtained can it be determined that the target database needs to be tested, that is, it is necessary to control at least two target databases to execute structured query statements, and after obtaining the execution results, compare the execution results, and determine the test results of the target database based on the comparison results of the execution results.

[0081] After obtaining the test instruction, it can be determined whether the test instruction includes a replay flag, wherein the replay flag is the identification information of the structured query statement to be replayed. The test instruction can be presented in the form of a command line, and the structured query statement to be replayed can be specified in the command line, that is, if there is a structured query statement that needs to be replayed, the structured query statement to be replayed will be specified in the command line, and if there is no structured query statement that needs to be replayed, the command line will not include information about the structured query statement to be replayed.

[0082] If the test instruction contains a replay identifier, such as a serial number id, which is a serial number related to the structured query statement stored in the configuration database, the structured query statement to be replayed must be determined based on the test instruction and obtained from the configuration database.

[0083] Replay means that it has been executed before and needs to be executed again. That is, when the structured query statement was executed before, its related information was stored in the configuration database. This time it needs to be executed again, that is, the structured query statement is to be replayed. It can be determined that the related information of the structured query statement to be replayed has been stored in the configuration database before. Therefore, at this time, the structured query statement to be replayed can be directly obtained from the configuration database.

[0084] Specifically, when the database test system executes a non-replayed structured query statement, a serial number id (i.e., the replay identifier mentioned above) is generated, and the structured query statement SQL executed this time and the serial number id are stored in a table. The serial number id is not an identifier of the structured query statement, but a digital serial number. The table storing the structured query statement SQL executed this time and the serial number id can be stored in the configuration database, so that the identification information of the structured query statement to be replayed can be determined based on the serial number id during replay, thereby determining the structured query statement to be replayed, and sending it to at least two target databases for execution.

[0085] It should be noted that when a test instruction is obtained, the test instruction is analyzed. The test instruction may specify multiple structured query statements to be executed. The multiple structured query statements to be executed may include structured query statements to be replayed, and may also include non-replayed structured query statements. As long as the multiple structured query statements to be executed include structured query statements to be replayed, the test instruction will include a replay identifier. In addition, for the structured query statements to be replayed, since the relevant information is already stored in the configuration database, they can be obtained from the configuration database, while for the non-replayed structured query statements, since the relevant information is not stored in the configuration database, they cannot be obtained from the configuration database.

[0086] The database testing method disclosed in this embodiment obtains a structured query statement from a configuration database, and the structured query statement stored in the configuration database is pre-stored; the structured query statement is input into at least two target databases, so that at least two target databases respectively execute the structured query statement, and at least two target databases are databases of different versions; the execution results of the structured query statement respectively executed by at least two target databases are obtained; the execution results of at least two target databases are compared to obtain a comparison result, so as to determine whether at least two target databases meet the requirements based on the comparison result, and the comparison result is used to characterize whether the execution results of at least two target databases are the same. This solution directly obtains the structured query statement from the configuration database without manual writing, which ensures the efficiency and accuracy of the target database in executing the structured query statement.

[0087] The database testing method disclosed in this embodiment has a flow chart as shown in Figure 3 As shown, including:

[0088] Step S31, generating a random structured query statement based on the characteristics of at least two target databases;

[0089] Step S32: inputting the structured query statement into at least two target databases, so that the at least two target databases respectively execute the structured query statement, and the at least two target databases are databases of different versions;

[0090] Step S33, obtaining execution results of the structured query statements respectively executed by at least two target databases;

[0091] Step S34: compare the execution results of at least two target databases to obtain a comparison result, so as to determine whether the at least two target databases meet the requirements based on the comparison result, and the comparison result is used to indicate whether the execution results of the at least two target databases are the same.

[0092] The test for the version update of the database can be: controlling at least two target databases to execute the same structured query statement respectively, obtaining the execution results, and comparing the execution results to determine whether the execution results are the same, thereby determining whether the at least two target databases meet the requirements, that is, whether the version update of the database passes the test.

[0093] The structured query statement may be: generating a random structured query statement based on characteristics of at least two target databases.

[0094] That is, when it is determined that there is a target database that needs to be tested, the target database is analyzed to determine the characteristics of the target database so as to randomly generate structured query statements based on the characteristics of the target database.

[0095] Different target databases correspond to different structured query statements, and at least two target databases are databases of the same type but with different versions. Therefore, by analyzing one of the target databases, a structured query statement that can be executed by at least two target databases and is applicable to at least two target databases can be obtained.

[0096] There may be multiple structured query statements that can be generated based on the characteristics of the target database, but in this embodiment, only one structured query statement needs to be randomly generated to implement testing of at least two target databases.

[0097] Furthermore, the random structured query statement generated based on the characteristics of at least two target databases may be:

[0098] Obtain a test instruction; if it is determined that the test instruction does not contain a replay identifier, generate a first random structured query statement based on the characteristics of at least two target databases; obtain configuration parameters stored in a configuration database; if it is determined that the first random structured query statement includes data to be replaced specified by the configuration parameters, determine a replacement value corresponding to the data to be replaced in the configuration parameters; change the data to be replaced included in the first random structured query statement to the replacement value, and obtain a second random structured query statement, so that at least two target databases can execute the second random structured query statement.

[0099] Obtain a test instruction and determine whether the test instruction contains a replay identifier. If the replay identifier is contained, it is necessary to obtain the structured query statement to be replayed corresponding to the replay identifier from the configuration database. If the replay identifier is not contained, it indicates that the structured query statement currently to be executed is not a replay, and the relevant information is not stored in the configuration database, and it needs to be randomly generated. Then, a first random structured query statement is generated based on the characteristics of at least two target databases.

[0100] After the first random structured query statement is generated, it can be directly sent to at least two target databases so that the at least two target databases execute it; or, it can also be: after the first random structured query statement is generated, it is processed to obtain a second random structured query statement, and the second random structured query statement is sent to at least two target databases so that the at least two target databases execute it.

[0101] The processing of the first random structured query statement may specifically include: determining whether the first random structured query statement includes data to be replaced, and determining which data needs to be replaced may be determined by configuration parameters stored in the configuration database.

[0102] Configuration parameters are set in the configuration database in advance, and the configuration parameters include the need to replace certain specific data in the structured query statement with target data.

[0103] When generating the first random structured query statement, the configuration parameters set in the configuration database are obtained to determine whether the first random structured query statement includes specific data, that is, whether the first random structured query statement includes the data to be replaced specified by the configuration parameters.

[0104] If the first random structured query statement does not include the data to be replaced specified by the configuration parameter, directly sending the first random structured data as the final random structured data to the target database so that the target database executes the random structured data;

[0105] If the first random structured query statement includes the data to be replaced specified by the configuration parameters, a replacement value corresponding to the data to be replaced in the configuration parameters is determined, and the data to be replaced included in the first random structured query statement is changed to the replacement value to obtain a second random structured query statement. The second random structured query statement no longer includes the data to be replaced specified in the configuration parameters. At this time, the second random structured query statement can be sent to at least two target databases, and the at least two target databases respectively execute the second random structured query statement to ensure that the structured query statement executed by the target database is more in line with actual needs.

[0106] For example, the replace_func of the configuration parameter is configured as: random:3, that is, if the random function appears in the first random structured query statement, the random function is replaced with 3 to obtain the second random structured query statement, and the random function no longer exists in the second random structured query statement.

[0107] Furthermore, in this embodiment, when generating the first random structured query statement, it can be:

[0108] A specific field is determined, and a first random structured query statement sorted according to the specific field is generated based on characteristics of at least two target databases.

[0109] The specific fields may be preset, and the specific fields may be set in a configuration database. The specific fields stored in the configuration database have a certain order.

[0110] When a test instruction is obtained and a first random structured query statement needs to be generated, specific fields need to be obtained from a configuration database, and the first random structured query statement is generated in the order of the specific fields, so that multiple specific fields appearing in the first random structured query statement are arranged in the order of the specific fields in the configuration database, so as to facilitate comparison of execution results obtained after executing a second random structured query statement generated based on this on at least two target databases.

[0111] The database testing method disclosed in this embodiment generates random structured query statements based on the characteristics of at least two target databases; inputs the structured query statements into at least two target databases so that at least two target databases respectively execute the structured query statements, and at least two target databases are databases of different versions; obtains the execution results of the structured query statements respectively executed by at least two target databases; compares the execution results of at least two target databases to obtain comparison results, so as to determine whether at least two target databases meet the requirements based on the comparison results, and the comparison results are used to characterize whether the execution results of at least two target databases are the same. When it is necessary to test at least two target databases, this solution generates random structured query statements based on the characteristics of at least two target databases, that is, randomly generates structured query statements to ensure the accuracy of the test.

[0112] This embodiment discloses a database testing method, and its flow chart is as follows: Figure 4 As shown, including:

[0113] Step S41, obtaining a structured query statement;

[0114] Step S42: inputting the structured query statement into at least two target databases, so that the at least two target databases respectively execute the structured query statement, wherein the at least two target databases are databases of different versions;

[0115] Step S43, obtaining execution results of the structured query statements respectively executed by at least two target databases;

[0116] Step S44, determining summary information of each execution result in the execution results of at least two target databases;

[0117] Step S45: Compare the summary information of each execution result to obtain a comparison result, so as to determine whether at least two target databases meet the requirements based on the comparison result. The comparison result is used to indicate whether the execution results of at least two target databases are the same.

[0118] A structured query statement is obtained, and the structured query statement is sent to at least two target databases. The at least two target databases respectively obtain the structured query statement, and respectively execute the structured query statement to obtain an execution result.

[0119] After obtaining the execution results of the structured query statements respectively executed by at least two target databases, the execution results can be directly compared to determine whether the execution results corresponding to the at least two target databases are the same, thereby determining whether there is an abnormal target database in the at least two target databases, so as to implement the test of the updated version of the target database, and directly compare the execution results to ensure the accuracy of the comparison results, and avoid the situation where the comparison results are inaccurate;

[0120] Alternatively, instead of directly comparing the execution results corresponding to the at least two target databases, summary information of each execution result is extracted and only the summary information is compared, so as to improve comparison efficiency.

[0121] Specifically, MD5 (Message-Digest Algorithm 5) can be used to determine the summary information of each execution result, and only the summary information of each execution result can be compared. If it is determined that the summary information of the execution results of at least two target databases is the same, it can be determined that the execution results of at least two target databases are the same, thereby determining that at least two target databases meet the requirements; if it is determined that the summary information of the execution results of at least two target databases is different, it can be determined that the execution results of at least two target databases are different, thereby determining that there is a target database that does not meet the requirements in at least two target databases, that is, the target database version update test has not passed.

[0122] Regardless of whether the comparison result is determined based on direct comparison of the execution results or based on comparison of summary information of the execution results, when it is determined that the comparison result indicates that the execution results of at least two target databases are inconsistent, the following may also be included:

[0123] Obtain target filtering parameters stored in the configuration database; determine that the structured query statement satisfies the target filtering parameters, and filter the execution results of the structured query statement and / or at least two target databases.

[0124] The target filtering parameter may specifically be a content filtering parameter, which is stored in the configuration database in advance. When there is an execution result that meets the content filtering parameter, the execution result is filtered without comparison to avoid different execution results due to different content filtering parameters.

[0125] When comparing the execution results corresponding to at least two target databases, if it is determined that the execution results are different, and the structured query statement executed when the execution results of at least two target databases are different includes a content filtering parameter, the execution result is filtered out.

[0126] For example: the configuration database includes content filtering parameter 1, target database 1 and target database 2 respectively execute structured query statement SQL1, target database 1 executes SQL1 to obtain execution result 1, and target database 2 executes SQL1 to obtain execution result 2. If execution result 1 is different from execution result 2, it is determined that SQL1 includes content filtering parameter 1, then execution result 1 and execution result 2 are directly filtered out at this time, and the current execution result is not determined as an inconsistent execution result.

[0127] The content filtering parameter may be: an IP address where the target database is deployed. When the IP addresses of two target databases are different, the execution results of the two target databases may be filtered out.

[0128] The target filtering parameter can also be a statement filtering parameter, which is stored in the configuration database in advance. When there is an execution result that meets the statement filtering parameter, the execution result is filtered. Alternatively, as long as it is determined that there is a structured query statement that meets the statement filtering parameter, the structured query statement is directly filtered out without executing the structured query statement and comparing the execution results.

[0129] That is, when the target filtering parameter is a statement filtering parameter, it can be first determined whether the structured query statement includes the statement filtering parameter. If not, the structured query statement is executed by at least two target databases, and the execution results are compared; if included, the structured query statement is directly filtered without sending it to at least two target databases, and the at least two target databases do not need to execute it and compare the execution results; or, it can also be: when the target filtering parameter is a statement filtering parameter, regardless of whether the structured query statement includes the statement filtering parameter, the structured query statement is sent to at least two target databases, and the at least two target databases execute it to obtain execution results, and the execution results are compared. When it is determined that the execution results are inconsistent, it is determined whether the structured query statement includes the statement filtering parameter. If the statement filtering parameter is included, the current execution result is directly filtered out, and the structured query statement can also be filtered out to reduce the number of structured query statements with inconsistent execution results.

[0130] After filtering out some structured query statements and / or execution results based on the target filtering parameters, the remaining structured query statements and execution results with inconsistent execution results can be stored in a configuration database and a file, wherein the file is used to save records of inconsistent execution results of at least two target databases after executing the structured query statement.

[0131] Specifically, the block diagram based on the database testing method disclosed in this embodiment can be as follows: Figure 5 As shown, it includes: a configuration database, at least two target databases (in Figure 5 1 and 2), a file for writing inconsistent structured query statements SQL and execution results, and a database testing system. The database testing system can be composed of a structured query statement SQL generation module, a comparison and analysis module, a data recording module and a database connection management module.

[0132] Among them, the SQL generation module is used to obtain the structured query statement to be replayed from the configuration database, or randomly generate a structured query statement; the comparison and analysis module is used to compare the execution results of the target database 1 and the target database 2, and filter out some structured query statements and / or execution results according to the target filtering parameters configured in the configuration database, and send the processed structured query statements and execution results to the data recording module; the data recording module is used to save the generated random structured query statements to the configuration database, and save the structured query statements and execution results whose execution results are inconsistent after being processed by the comparison and analysis module to the configuration database and files; the database connection management module is used to call the corresponding database driver API to connect, read the configuration database and the target database, and execute the generated structured query statement on the target database, obtain the execution result of the corresponding structured query statement, and write the comparison result of the execution result to the configuration database and files.

[0133] The database testing method disclosed in this embodiment obtains a structured query statement; inputs the structured query statement into at least two target databases so that at least two target databases respectively execute the structured query statement, wherein at least two target databases are databases of different versions; obtains the execution results of the structured query statement respectively executed by at least two target databases; determines the summary information of each execution result in the execution results of at least two target databases; compares the summary information of each comparison result to obtain a comparison result, so as to determine whether at least two target databases meet the requirements based on the comparison result, and the comparison result is used to characterize whether the execution results of at least two target databases are the same. When obtaining the execution results of at least two target databases and comparing them, this scheme does not directly compare the execution results, but obtains the summary information of each execution result and compares the summary information to simplify the comparison process and improve the comparison efficiency of the execution results.

[0134] This embodiment discloses a database testing system, and its structural diagram is shown in FIG. Figure 6 As shown, including:

[0135] A first obtaining unit 61 , an input unit 62 , a second obtaining unit 63 and a comparing unit 64 .

[0136] Wherein, the first obtaining unit 61 is used to obtain a structured query statement;

[0137] The input unit 62 is used to input the structured query statement into at least two target databases, so that the at least two target databases respectively execute the structured query statement, wherein the at least two target databases are databases of different versions;

[0138] The second obtaining unit 63 is used to obtain the execution results of the structured query statements respectively executed by at least two target databases;

[0139] The comparison unit 64 is used to compare the execution results of at least two target databases to obtain a comparison result, so as to determine whether the at least two target databases meet the requirements based on the comparison result. The comparison result is used to indicate whether the execution results of the at least two target databases are the same.

[0140] Furthermore, the first obtaining unit is used for:

[0141] A random structured query statement is generated based on the characteristics of at least two target databases; or a structured query statement is obtained from a configuration database, where the structured query statement stored in the configuration database is pre-stored.

[0142] Furthermore, the first obtaining unit is used for:

[0143] Obtain a test instruction; determine whether the test instruction contains a replay identifier, where the replay identifier can represent identification information of a structured query statement to be replayed; if it is determined that the test instruction contains a replay identifier, obtain the structured query statement to be replayed corresponding to the replay identifier from a configuration database.

[0144] Furthermore, the first obtaining unit is used for:

[0145] Obtain a test instruction; if it is determined that the test instruction does not contain a replay identifier, generate a first random structured query statement based on the characteristics of at least two target databases; obtain configuration parameters stored in a configuration database; if it is determined that the first random structured query statement includes data to be replaced specified by the configuration parameters, determine a replacement value corresponding to the data to be replaced in the configuration parameters; change the data to be replaced included in the first random structured query statement to the replacement value, and obtain a second random structured query statement, so that at least two target databases can execute the second random structured query statement.

[0146] Furthermore, the first obtaining unit is used for:

[0147] Determine a specific field; and generate a first random structured query statement sorted according to the specific field based on the characteristics of at least two target databases.

[0148] Furthermore, the comparison unit is used to:

[0149] Determine summary information of each execution result in the execution results of at least two target databases; compare the summary information of each comparison result to obtain a comparison result.

[0150] Furthermore, the database testing system disclosed in this embodiment may also include:

[0151] The filtering unit is used to obtain the target filtering parameters stored in the configuration database when it is determined that the comparison result indicates that the execution results of at least two target databases are inconsistent; determine that the structured query statement meets the target filtering parameters, and filter the execution results of the structured query statement and / or at least two target databases.

[0152] Furthermore, the database testing system disclosed in this embodiment may also include:

[0153] The storage unit is used to store the comparison result and the structured query statement corresponding to the comparison result in the configuration database.

[0154] The database testing system disclosed in this embodiment is implemented based on the database testing method disclosed in the above embodiment, which will not be described in detail here.

[0155] The database testing system disclosed in the present application obtains a structured query statement; inputs the structured query statement into at least two target databases so that at least two target databases respectively execute the structured query statement, wherein at least two target databases are databases of different versions; obtains the execution results of the structured query statement respectively executed by at least two target databases; compares the execution results of at least two target databases to obtain a comparison result, so as to determine whether the at least two target databases meet the requirements based on the comparison result, and the comparison result is used to characterize whether the execution results of at least two target databases are the same. When the database version is updated, in order to determine whether the version update of the database is abnormal, the same structured query statement is input into at least two target databases respectively, so that at least two target databases execute the same structured query statement at the same time, and obtain the execution result, compare the execution results based on the at least two target databases, and determine whether the execution results are the same, so as to determine whether the target database version update is abnormal based on the comparison result of whether the execution results are the same, thereby realizing the test of the stability and reliability of the database version after the update, improving the accuracy and efficiency of the test after the database version is updated, and improving the user experience.

[0156] This embodiment discloses an electronic device, and its structural diagram is as follows: Figure 7 As shown, including:

[0157] Processor 71 and memory 72.

[0158] The processor 71 is used to obtain a structured query statement; input the structured query statement into at least two target databases so that the at least two target databases respectively execute the structured query statement, wherein the at least two target databases are databases of different versions; obtain execution results of the at least two target databases respectively executing the structured query statement; compare the execution results of the at least two target databases to obtain a comparison result, so as to determine whether the at least two target databases meet the requirements based on the comparison result, and the comparison result is used to indicate whether the execution results of the at least two target databases are the same;

[0159] The memory 72 is used to store the program for the processor to execute the above-mentioned processing process.

[0160] The electronic device disclosed in this embodiment is implemented based on the database testing method disclosed in the above embodiment, which will not be described in detail here.

[0161] The electronic device disclosed in the present application obtains a structured query statement; inputs the structured query statement into at least two target databases so that at least two target databases respectively execute the structured query statement, wherein at least two target databases are databases of different versions; obtains the execution results of at least two target databases respectively executing the structured query statement; compares the execution results of at least two target databases to obtain a comparison result, so as to determine whether at least two target databases meet the requirements based on the comparison result, and the comparison result is used to characterize whether the execution results of at least two target databases are the same. When the database version is updated, in order to determine whether the version update of the database is abnormal, the same structured query statement is input into at least two target databases respectively, so that at least two target databases simultaneously execute the same structured query statement, and obtain the execution result, compare the execution results based on the at least two target databases, and determine whether the execution results are the same, so as to determine whether the target database version update is abnormal based on the comparison result of whether the execution results are the same, thereby realizing the test of the stability and reliability of the database version after the update, improving the accuracy and efficiency of the test after the database version is updated, and improving the user experience.

[0162] The embodiment of the present application also provides a readable storage medium on which a computer program is stored. The computer program is loaded and executed by a processor to implement the various steps of the above-mentioned database testing method. The specific implementation process can refer to the description of the corresponding part of the above-mentioned embodiment, which will not be repeated in this embodiment.

[0163] The present application also proposes a computer program product or a computer program, which includes a computer instruction stored in a computer-readable storage medium. The processor of the electronic device reads the computer instruction from the computer-readable storage medium, and the processor executes the computer instruction, so that the electronic device executes the method provided in various optional implementations of the above-mentioned database test method or database test system. The specific implementation process can refer to the description of the above-mentioned corresponding embodiment, and will not be repeated.

[0164] It should also be noted that the device embodiments described above are merely schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed over multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. In addition, in the drawings of the device embodiments provided by the present application, the connection relationship between the modules indicates that there is a communication connection between them, which may be specifically implemented as one or more communication buses or signal lines.

[0165] Through the description of the above implementation mode, the technicians in the field can clearly understand that the present application can be implemented by means of software plus necessary general hardware, and of course, it can also be implemented by special hardware including special integrated circuits, special CPUs, special memories, special components, etc. In general, all functions completed by computer programs can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be various, such as analog circuits, digital circuits or special circuits. However, for the present application, software program implementation is a better implementation mode in more cases. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a readable storage medium, such as a computer floppy disk, a U disk, a mobile hard disk, a ROM, a RAM, a disk or an optical disk, etc., including a number of instructions to enable a computer device (which can be a personal computer, a training device, or a network device, etc.) to execute the methods described in each embodiment of the present application.

[0166] In the above embodiments, all or part of the embodiments may be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments may be implemented in the form of a computer program product.

[0167] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, a computer, a training device, or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, training device, or data center. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device, a data center, etc. that includes one or more available media integrations. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)), etc.

Claims

1. A database testing method, characterized in that: include: Get structured query statements; Inputting the structured query statement into at least two target databases so that the at least two target databases respectively execute the structured query statement, wherein the at least two target databases are databases of different versions; Obtaining execution results of the structured query statements respectively executed by the at least two target databases; The execution results of the at least two target databases are compared to obtain a comparison result, so as to determine whether the at least two target databases meet the requirements based on the comparison result, and the comparison result is used to indicate whether the execution results of the at least two target databases are the same.

2. The method according to claim 1, characterized in that The obtaining of the structured query statement comprises: generating a random structured query statement based on the characteristics of the at least two target databases; or, A structured query statement is obtained from a configuration database, where the structured query statement stored in the configuration database is pre-stored.

3. The method according to claim 2, characterized in that The step of obtaining a structured query statement from a configuration database includes: Obtain testing instructions; Determine whether the test instruction includes a replay identifier, where the replay identifier can represent identification information of the structured query statement to be replayed; If it is determined that the test instruction contains the replay identifier, the structured query statement to be replayed corresponding to the replay identifier is obtained from the configuration database.

4. The method according to claim 2, characterized in that: The generating of random structured query statements based on the characteristics of the at least two target databases includes: Obtain testing instructions; If it is determined that the test instruction does not include a replay identifier, generating a first random structured query statement based on the characteristics of the at least two target databases; Obtain configuration parameters stored in the configuration database; If it is determined that the first random structured query statement includes the data to be replaced specified by the configuration parameter, determining a replacement value corresponding to the data to be replaced in the configuration parameter; The to-be-replaced data included in the first random structured query statement is changed into the replacement value to obtain a second random structured query statement, so that the at least two target databases can execute the second random structured query statement.

5. The method according to claim 4, characterized in that The generating a first random structured query statement based on the characteristics of the at least two target databases includes: Identify specific fields; A first random structured query statement sorted according to the specific field is generated based on the characteristics of the at least two target databases.

6. The method according to claim 1, characterized in that The comparing the execution results of the at least two target databases to obtain a comparison result includes: Determine summary information of each of the execution results of the at least two target databases; The summary information of each execution result is compared to obtain a comparison result.

7. The method according to claim 1, characterized in that Also includes: If the comparison result indicates that the execution results of the at least two target databases are inconsistent, obtaining the target filtering parameters stored in the configuration database; It is determined that the structured query statement satisfies the target filtering parameter, and the execution results of the structured query statement and / or the at least two target databases are filtered.

8. The method according to claim 2, characterized in that: Also includes: The comparison result and the structured query statement corresponding to the comparison result are stored in a configuration database.

9. A database testing system, characterized in that: include: A first obtaining unit, used for obtaining a structured query statement; An input unit, used for inputting the structured query statement into at least two target databases, so that the at least two target databases respectively execute the structured query statement, wherein the at least two target databases are databases of different versions; A second obtaining unit is used to obtain the execution results of the structured query statement executed by the at least two target databases respectively; A comparison unit is used to compare the execution results of the at least two target databases to obtain a comparison result, so as to determine whether the at least two target databases meet the requirements based on the comparison result, and the comparison result is used to indicate whether the execution results of the at least two target databases are the same.

10. An electronic device, characterized in that: include: A processor is used to obtain a structured query statement; input the structured query statement into at least two target databases so that the at least two target databases respectively execute the structured query statement, wherein the at least two target databases are databases of different versions; obtain execution results of the at least two target databases respectively executing the structured query statement; compare the execution results of the at least two target databases to obtain a comparison result, so as to determine whether the at least two target databases meet the requirements based on the comparison result, and the comparison result is used to indicate whether the execution results of the at least two target databases are the same; The memory is used to store the program for the processor to execute the above processing process.

Citation Information

Patent Citations

  • Database compatibility detection method and device

    CN105512017A

  • Database test method and system, electronic equipment and storage medium

    CN113076240A

  • Database version upgrading test method, equipment and computer readable medium

    CN113742200A

  • System version upgrading method and device for double-cluster database

    CN115269560A

  • Database compatibility testing method and device and electronic equipment

    CN117370204A