Database test method, medium and electronic equipment

By obtaining and formatting the output results of the database to be tested and the verification database, the problems of inefficient testing and difficulty in automatic comparison in the prior art are solved, and efficient database testing is achieved.

CN120216348APending Publication Date: 2025-06-27HUAWEI CLOUD COMPUTING TECHNOLOGIES CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311773909.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-12-21
Publication Date
2025-06-27

AI Technical Summary

Technical Problem

Existing database testing methods require testers to manually write the expected test results, resulting in inefficient testing and different output results formats of different databases, which lead to difficulty in automatic comparison.

Method used

By obtaining the output results of the database to be tested and the verification database, and using the target driver interface to convert the data format, we obtain the same format results, and then compare to determine the database performance.

Benefits of technology

Testers do not need to write expected test results, save time, improve database testing efficiency, and automatically compare the output results of different databases, reducing the need for manual verification.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120216348A_ABST
    Figure CN120216348A_ABST
Patent Text Reader

Abstract

The invention is applied to the technical field of computers, and provides a database testing method, a medium and electronic device.The method comprises the steps that output results of a to-be-tested database and a verification database based on test cases are obtained; according to different output data formats of the test database and the verification database, performing data format conversion on an output result of the to-be-tested database or the verification database to respectively obtain a to-be-tested result and a verification test result which are consistent in data format; generating a comparison result based on the to-be-tested result and the verification test result; and debugging the to-be-tested database based on the comparison result. And furthermore, a tester does not need to compile an expected test result, so that the time of the tester is saved, and the database test efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and particularly to a database testing method, a medium, and an electronic device. Background Art

[0002] With the complication of big data scenarios and the increasingly complex data analysis requirements nowadays, the amount of data stored in the database and the number of accesses are getting larger and larger, posing higher requirements for the performance of the database. Database testing is an effective means to ensure the normal and reliable performance of the database.

[0003] Currently, database testing usually involves testers writing test cases and expected test results. The test cases include structured query language (SQL) statements, such as query statements like select. After the database under test executes the test cases, the actual test results generated by the database under test will be compared with the expected test results, and the performance of the database will be confirmed according to the comparison results. However, for each test case, testers need to write corresponding expected test results, which takes a lot of time and reduces the efficiency of database testing. Summary of the Invention

[0004] In view of this, this application provides a database testing method, a medium, and an electronic device.

[0005] In a first aspect, a database testing method is provided, including: first obtaining the output result of the database under test based on a first test case, and obtaining the output result of a verification database based on the first test case. Then, corresponding to the different output data formats of the test database and the verification database, perform data format conversion on the output result of the database under test or the output result of the verification database to respectively obtain a test result with consistent data format and a verification test result; furthermore, generate a comparison result based on the test result and the verification test result; and debug the database under test based on the comparison result.

[0006] In the above solution, the test case can be run in the database under test and the verification database respectively, where the verification database can be any database with a different kernel from the database under test. Then, obtain the results output by the database under test and the verification database, and perform format conversion on the results output by the database under test and the verification database to obtain the test result of the database under test and the verification test result of the verification database.

[0007] Furthermore, through the data testing method provided by this application, the verification test results output by the existing traditional database can be used as the expected test results, and the results of the database to be tested and the results of the traditional database can be compared, so as to determine the performance of the database to be tested. The tester does not need to write the expected test results, saving the time of the tester and improving the database testing efficiency.

[0008] In combination with the first aspect, in some implementation manners, a target driving interface is called. The target driving interface is used to make the output results of the database to be tested and the output results of the verification database have consistent formats; data format conversion is performed on the output results of the database to be tested or the output results of the verification database, including: reading the output results of the database to be tested or the output results of the verification database through the target driving interface, and performing data format conversion on the output results.

[0009] In the above solution, since the formats adopted by the output results of different databases are different, but the target driving interface can normalize the formats of the output results, the output results of the database to be tested and the traditional database obtained can be directly compared, and there is no need for manual comparison of the output results in different formats, improving the database testing efficiency.

[0010] In combination with the first aspect, in some implementation manners, the method further includes: when executing the first test case based on the database to be tested, triggering an asynchronous execution interface in the first test case for triggering the execution of the second test case, and an asynchronous waiting interface for waiting for the execution of the second test case; executing the second test case based on the database to be tested, and obtaining the output result of the database to be tested based on the second test case.

[0011] In the above solution, multiple test cases are adopted in the test case, and the multiple test cases are set to be executed concurrently. For example, an association interface for triggering the execution of another test case is added to the test case, such as adding an asynchronous execution interface and an asynchronous waiting interface for waiting in the test case, which is used to simulate scenarios such as asynchronous execution and lock waiting. Furthermore, compared with the test method that can only execute a single test case sequentially, this method can simulate the performance of the database to be tested in various scenarios such as distributed transactions and concurrent execution, such as the situation where multiple users read and write the data of the database simultaneously, making the test results more comprehensive.

[0012] In combination with the first aspect, in some implementation manners, the method further includes: when executing the first test case based on the verification database, triggering an asynchronous execution interface in the first test case for triggering the execution of the second test case, and an asynchronous waiting interface for waiting for the execution of the second test case; executing the second test case based on the verification database, and obtaining the output result of the verification database based on the second test case.

[0013] In the above solution, the same multiple test cases are also used for the verification database to obtain the test results of the verification database under multiple test cases. Furthermore, compared with the test method that can only execute single test cases sequentially, this method can simulate the performance of the database under test in various scenarios such as distributed transactions and concurrent execution. For example, in the case where multiple users read and write data in the database simultaneously, the test results are more comprehensive.

[0014] Combined with the first aspect, in some implementation manners, the method further includes: obtaining the output result of the database under test based on the first test case, and multiple output results of the verification database based on the first test case; determining that the comparison result is that the output results of the database under test and the verification database based on the first test case are consistent based on the matching between the result under test and one or more of the multiple verification test results, where the multiple verification test results correspond to the multiple output results of the verification database, and the data formats of the multiple verification test results and the result under test are consistent.

[0015] In the above solution, multiple verification test results can be saved. For example, the verification database can execute the test case multiple times to save multiple verification test results. Furthermore, in the case where any one of the result under test and the multiple verification test results can match, it can be considered that the comparison result is consistent. In this way, the accuracy of database testing can be improved, and the situation of misjudging that the result under test and the verification test result are inconsistent can be avoided.

[0016] Combined with the first aspect, in some implementation manners, the method further includes: based on the first test case being a random test case, obtaining the output result of the database under test based on the first test case, and multiple output results of the verification database based on the first test case, where the random test case is used to randomly output the attribute data corresponding to at least one attribute according to multiple attributes of the database.

[0017] In the above solution, the output result corresponding to the test case is itself a random result. For example, the test case is to output any one of the attribute data from multiple attributes such as mobile phone number and name. To avoid the situation where the result under test and the verification test result output random results of different attributes, multiple verification test results can be saved.

[0018] Combined with the first aspect, in some implementation manners, the method further includes: based on the first test case being a real-time test case, determining the verification test range corresponding to the output result of the verification database according to the output result of the verification database based on the first test case; comparing the result under test and the verification test result based on the verification test range to obtain the comparison result.

[0019] In the above solution, the output results corresponding to the test cases change in real time. For example, if a test case needs to output the current time, due to the difference in the execution time of the test case between the database to be tested and the verification database, there may be a difference in the output results themselves. Furthermore, the comparison between the results to be tested and the verification test results can also use regular expressions. That is to say, as long as the results to be tested and the verification test results conform to the range defined by the regular expression, the comparison can be considered consistent. In this way, the accuracy of database testing can be improved, and the situation of misjudging that the results to be tested and the verification test results are inconsistent can be avoided.

[0020] Combined with the first aspect, in some implementation manners, the verification test range is a regular expression.

[0021] Combined with the first aspect, in some implementation manners, obtain the running time of the first test case for the database to be tested, and the running time of the first test case for the verification database; based on the running time of the database to be tested and the running time of the verification database, debug the database to be tested.

[0022] In the above solution, it is also possible to debug the database to be tested according to the running time of the database to be tested based on the test case and / or the running time of the verification database based on the test case. For example, based on the same test case, the running time of the database to be tested is greater than the running time of the verification database, or the running time of the database to be tested is greater than the running time of the verification database and the difference between the two running times is greater than the preset time, and then debug the database to be tested to improve the running efficiency of the database to be tested.

[0023] In a second aspect, the present application provides an electronic device, including a processor and a memory. The memory is used to store instructions, and the processor is used to execute the instructions. When the processor executes the instructions, the method described in the first aspect is executed.

[0024] In a third aspect, the present application provides a computer-readable storage medium, in which instructions are stored. When the instructions run on an electronic device, the method described in the first aspect is executed.

[0025] In a fourth aspect, the present application provides a computer program product, which includes computer instructions. When executed by a computing device, the computing device executes the method described in the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the accompanying drawings required for the description of the embodiments.

[0027] Figure 1 is a schematic diagram of the process of a database testing method provided by an embodiment of the present application;

[0028] Figure 2 is a flowchart of a database testing method provided by an embodiment of the present application;

[0029] Figure 3A is a flowchart of a method for concurrent execution of multiple test cases provided by an embodiment of the present application;

[0030] Figure 3B is an organizational structure diagram of a method for concurrent execution of multiple test cases provided by an embodiment of the present application;

[0031] Figure 4 is a process schematic diagram of another database testing method provided by an embodiment of the present application;

[0032] Figure 5 is a process schematic diagram of yet another database testing method provided by an embodiment of the present application;

[0033] Figure 6 is an effect schematic diagram of a database testing method provided by an embodiment of the present application;

[0034] Figure 7 is a structural schematic diagram of a database testing apparatus provided by an embodiment of the present application;

[0035] Figure 8 is a structural schematic diagram of an electronic device provided by an embodiment of the present application. Detailed implementation manners

[0036] Illustrative embodiments of the present application include, but are not limited to, database testing methods, media, and electronic devices.

[0037] As mentioned above, during the database testing process, testers need to determine the expected test results by themselves, which takes a lot of time. And currently, there are many types of databases, that is, different database kernels, such as database kernels of MySQL, Oracle, PostgreSQL (abbreviated as PG), etc., and there are also more and more self-developed databases, such as GaussDB, etc. The output results of different databases adopt different formats respectively. Furthermore, under the same test case, different types of databases may also produce test results in different formats. For example, the format of the output time of different databases can be "2023-08-01 11:28:20", or it can also be "23-AUG-01". Therefore, even if their output results are actually the same, due to the inconsistent output formats, the testing device / software may automatically misjudge them as inconsistent during comparison. Furthermore, testers still need to manually check whether the actual test results are consistent with the expected test results, resulting in low database testing efficiency.

[0038] To solve the problem of low efficiency in current database testing, this application provides a data testing method. The test cases are run separately in the database to be tested and the verification database. Among them, the verification database can be any database with a different kernel from the database to be tested. Then, the results output by the database to be tested and the verification database are obtained, and the formats of the results output by the database to be tested and the verification database are converted to obtain the test results of the database to be tested and the verification test results of the verification database. For example, the results output by the database to be tested and the verification database can be uniformly formatted through a target-driven interface, where the target-driven interface provides a unified output format for the output results of different databases. Then, the test results and the verification test results in the same data format are compared. If the comparison result indicates that the test results and the verification test results are inconsistent, the tester can debug the database to be tested.

[0039] For example, as Figure 1 shown, the tester can input the test cases into the database to be tested (Database A) and the verification database (Database B). The test cases can specifically be SQL statements. Database A and Database B each have their own corresponding database drivers. The database driver encapsulates a set of external application programming interfaces (APIs) for the database. For example, the database driver class name of the MySQL database is "MySQL Connector / J", which can also be abbreviated as "mysql_con", and the database driver class name of the Oracle database is "oracle.jdbc.OracleDriver". The database drivers of Database A and Database B are respectively denoted as database driver A1 and database driver B1.

[0040] Since the database drivers of different databases are different, and thus the data formats output from database driver A1 and database driver B1 are also different, the results of database driver A1 and database driver B1 are then passed through a unified target-driven interface, and thus data results in the same format can be obtained. The target-driven interface can obtain and identify the output results of different database drivers and convert the results of different databases into the same data format. The target-driven interface can be a Java Database Connectivity (JDBC) interface, or an Open Database Connectivity (ODBC) interface, etc.

[0041] Then, after the results output by database driver A1 and database driver B1 are made consistent in format based on the same target-driven interface, test results to be tested and verification test results with the same data format can be obtained. Then, the test results to be tested and the verification test results are directly compared to determine whether they are consistent, and a comparison result is generated.

[0042] If the comparison between the test results to be tested and the verification test results is consistent, it can be considered that the database to be tested can output correct results for this test case and its performance is stable. If the comparison between the test results to be tested and the verification test results is inconsistent, it can be considered that the database to be tested has output incorrect results, and testers need to debug the database to be tested.

[0043] Furthermore, through the data testing method provided in this application, the verification test results output by the existing traditional database can be used as the expected test results, and the results of the database to be tested are compared with those of the traditional database. Thus, the performance of the database to be tested can be determined. Testers do not need to write the expected test results, saving their time and improving the database testing efficiency. Also, since the output results of different databases are in different formats, but the target-driven interface can normalize the format of the output results, the output results of the database to be tested and the traditional database obtained can be directly compared, eliminating the need for manual comparison of output results in different formats and improving the database testing efficiency.

[0044] In some embodiments, the database drivers used by the database to be tested and / or the verification database are the unified target-driven interface. Thus, there is no need to convert the format of the results output by the database driver through the target-driven interface again. For example, the database driver used by the verification database is JDBC, and the database to be tested uses its own database driver, such as "mysql_con". Thus, the results output by JDBC in the verification database are the verification test results, and the results output by the database driver of the database to be tested need to be converted in format through JDBC to obtain the test results to be tested.

[0045] In some other embodiments, in order to comprehensively test the performance of a database, for example, the performance of the database to be tested in scenarios such as distributed transactions and concurrent execution, the method also uses multiple test cases in the test case and sets the multiple test cases to be executed concurrently. For example, an associated interface that triggers the execution of another test case is added to the test case, such as adding an asynchronous execution interface and a waiting asynchronous execution interface to the test case to simulate asynchronous execution and lock waiting scenarios. Furthermore, compared with the test method that can only execute a single test case sequentially, this method can simulate the performance of the database to be tested in various scenarios such as distributed transactions and concurrent execution, such as the situation where multiple users read and write data in the database simultaneously, making the test results more comprehensive.

[0046] In some other embodiments, the output result corresponding to the test case is itself a random result. For example, the test case is to output any one of the attribute data from multiple attributes such as mobile phone numbers and names. In order to avoid the situation that the result to be tested and the verified test result output random results of different attributes, in this method, multiple verified test results can also be saved. For example, the verification database can be made to execute this test case multiple times to save multiple verified test results. Furthermore, in the case where the result to be tested can match any one of the multiple verified test results, the comparison result can be considered consistent. In this way, the accuracy of database testing can be improved, and the situation of misjudging that the result to be tested and the verified test result are inconsistent can be avoided.

[0047] In some other embodiments, the output result corresponding to the test case changes in real time. For example, the test case needs to output the current time. Due to the difference in the time when the database to be tested and the verification database execute the test case, there may be a difference in the output results themselves. Furthermore, regular expressions can also be used for the comparison between the result to be tested and the verified test result. That is to say, as long as the result to be tested and the verified test result meet the range defined by the regular expression, the comparison can be considered consistent. In this way, the accuracy of database testing can be improved, and the situation of misjudging that the result to be tested and the verified test result are inconsistent can be avoided.

[0048] It should be understood that the above data testing method can be executed by a first device. The first device can be installed with a database to be tested, a verification database, and their database drivers, etc. The first device is used to input test cases to the database to be tested and the verification database, and is used to obtain the test results to be tested and the verification test results output by the target driver interface, and generate a comparison result. Alternatively, the database to be tested and the verification database can also be installed on a second device. The first device sends the test cases to the second device and obtains the test results to be tested and the verification test results output by the second device, and then generates a comparison result. Or, the database to be tested and the verification database can be respectively configured on a second device and a third device. The first device sends the test cases to the second device and the third device, and obtains the test results to be tested and the verification test results output by the second device and the third device. This application does not specifically limit the devices used to execute the data testing method and their quantities.

[0049] The above-mentioned electronic devices such as the first device, the second device, and the third device can be terminal devices such as mobile phones, tablet computers, wearable devices, in-vehicle devices, augmented reality (AR) / virtual reality (VR) devices, laptop computers, ultra-mobile personal computers (UMPCs), netbooks, personal digital assistants (PDAs), or dedicated cameras (such as single-lens reflex cameras, compact cameras), etc. The electronic device can also be a physical server or a cloud device, etc., such as an X86 server, an ARM server, etc. It can also be a virtual machine (VM) implemented based on a general physical server combined with network functions virtualization (NFV) technology. A virtual machine refers to a complete computer system with complete hardware system functions simulated by software and running in a completely isolated environment. This application does not impose any restrictions on the specific types of the electronic device.

[0050] The following combines Figure 2 to introduce the database testing method provided by this application. The database testing method can be applied to one or more of the aforementioned first device, second device, and third device. The following takes the application of the database testing method to the first device as an example for illustration. The first device is installed with a database to be tested and a verification database.

[0051] S210: Execute test cases based on the database to be tested.

[0052] The database to be tested is the database for which performance detection is required. The test case can specifically be one or more SQL statements. The test case is used to simulate the operations performed by the user on the database to be tested, such as inserting data, deleting data, modifying data, etc. For example, the test case can be ". / testcase / sql / query / testcase_001.sql", and the SQL statement it includes can be "select a.id,b.name from user a,info b where a.id=b.id", which means reading the id of a and the name of b where the ids of a and b are the same.

[0053] Optionally, the test case can be determined based on a file preset by the user. It can be pre-loaded during runtime or input via another port. The test case can also be any database language such as t-SQL, k-SQL, etc. This application does not specifically limit the type of database language used for the test case.

[0054] In some embodiments, the first device can also send multiple test cases to the database to be tested. Moreover, an associated interface for triggering the execution of other test cases is added to some of the test cases, which is used to trigger the concurrent execution of multiple test cases, thereby simulating the situation where multiple users or programs read and write data in the database simultaneously. In this way, the test cases are not only executed sequentially and individually, but there can also be a situation where the same piece of data is read and written by multiple test cases simultaneously, so as to obtain the test results of the database to be tested under the condition of concurrent execution of the above multiple test cases.

[0055] Among them, because the database has atomicity, consistency, isolation, and durability, that is, the ACID characteristics. Therefore, for the same piece of data, if a certain user is modifying this piece of data, then this piece of data will be locked, that is, the situation of lock waiting. After this user modifies this piece of data, other users can read and write this piece of data. Similarly, for a distributed scenario, such as the situation where the task of data modification is separately sent to different devices for execution, there will also be the situation where the above database is read and written by different distributed devices. Therefore, using multiple test cases to execute concurrently can simulate the above scenarios of concurrent execution by multiple users or in a distributed manner. The process of concurrent execution of multiple embodiments can also refer to the following description about Figure 3A of.

[0056] S220: Obtain the test result to be tested output by the database to be tested through the target-driven interface.

[0057] The database to be tested can execute the result based on the test case output. Since the data output formats of different databases are different, or different databases also have their corresponding database drivers, and the data output formats of different database drivers are also different. Therefore, it is necessary to normalize the format of the output result through a unified target driver interface. Among them, the target driver interface can be any driver interface that can obtain and identify the output results of different database drivers and convert the results of different databases into the same data format, such as JDBC or ODBC, etc.

[0058] S230: Execute the test case based on the verification database.

[0059] The verification database can be a traditional database with a mature database kernel, such as databases like MySQL, Oracle, PG, etc. Moreover, the test cases executed by the database to be verified and the verification database are the same test cases. For the description of the test cases, reference can also be made to the foregoing step S210.

[0060] In some embodiments, since some test cases will produce random output results, for example, the test case is to randomly print any one data from multiple data, the first device can let the verification database execute the test case multiple times and save the multiple verification test results obtained from the multiple executions.

[0061] It should be understood that step S230 can be executed before or after step S210, or step S210 and step S230 can be executed synchronously. This application does not specifically limit the execution order of step S210 and step S230.

[0062] S240: Obtain the verification test result output by the verification database through the target driver interface.

[0063] In order to unify the output results of the database to be tested and the verification database, the results output by the verification database also need to go through the target driver interface, so as to obtain the verification test results with the same data format as the test results to be tested.

[0064] It should be understood that step S240 can also be executed before or after step S220, or step S220 and step S240 can be executed synchronously. This application does not specifically limit the execution order of step S220 and step S220 either.

[0065] S250: Compare the test result to be tested with the verification test result to generate a comparison result.

[0066] The first device will automatically compare the to-be-tested result and the verification test result to determine whether they are consistent. If the to-be-tested result is consistent with the verification test result, it can be considered that the to-be-tested database can output the correct result for this test case. If the to-be-tested result is inconsistent with the verification test result, it can be considered that the to-be-tested database has output an incorrect result for this test case, and the tester needs to debug the to-be-tested database. It should be understood that this application does not specifically limit the operations performed on the to-be-tested database after generating the comparison result.

[0067] In some embodiments, when the first device compares the to-be-tested result and the verification test result, it can adopt the method of multi-value matching. That is to say, for the case where the test case outputs random results, in order to avoid the to-be-tested result and the verification test result outputting random results with different attributes. Furthermore, if the to-be-tested result can match any one of multiple verification test results, the comparison result can be considered consistent. In this way, the accuracy of database testing can be improved, and the situation of misjudging the inconsistency between the to-be-tested result and the verification test result can be avoided.

[0068] In other embodiments, when the first device compares the to-be-tested result and the verification test result, it can adopt the method of regular expression matching. That is to say, for the case where the test case is a real-time result, for example, the test case needs to output the current time, the comparison between the to-be-tested result and the verification test result can also use a regular expression. That is to say, as long as the to-be-tested result and the verification test result meet the range defined by the regular expression, the comparison can be considered consistent. In this way, the accuracy of database testing can be improved, and the situation of misjudging the inconsistency between the to-be-tested result and the verification test result can be avoided.

[0069] For example, when the test case is "select sysdate", which means it needs to print the current time. Furthermore, when the verification test result is "2023-11-03 11:28:20", the verification test result can be adjusted to the corresponding regular expression "regexp:2023-11-03reg{[0-9]{2}:[0-9]{2}:[0-9]{2}}". Furthermore, when the to-be-tested result is any time corresponding to "2023-11-03", the comparison can also be considered consistent.

[0070] In other embodiments, when the first device compares the to-be-tested result and the verification test result, it can simultaneously adopt the methods of multi-value matching and regular expression matching. Moreover, the first device can also adopt different matching methods according to the type of the test case, such as whether it is a random result or a real-time result.

[0071] Furthermore, through the data testing method provided by this application, the verification test results output by the existing traditional database can be used as the expected test results, and the results of the database to be tested can be compared with those of the traditional database, so as to determine the performance of the database to be tested. Testers do not need to write the expected test results, saving the time of testers and improving the database testing efficiency. Moreover, since the output results of different databases adopt different formats, but the target-driven interface can normalize the formats of the output results, the output results of the database to be tested and the traditional database obtained can be directly compared, without the need for manual comparison of results in different formats, thus improving the database testing efficiency.

[0072] The following Figure 3A illustrates the process of concurrently executing the above multiple test cases by taking the concurrent execution of Test Case - 1 and Test Case - 2 as an example. Specifically, Test Case - 1 is used as the main thread, and Test Case - 2 is an asynchronous thread pulled up by Test Case - 1.

[0073] 301: Test Case - 1 performs parallel parsing.

[0074] Test Case - 1 is set to be able to pull up other test cases, so there is an associated interface in Test Case - 1 to trigger the execution of other test cases. Test Case - 1 can parse the trigger function for the concurrent execution of multiple test cases and determine the degree of parallelism, that is, the number of threads to be executed in parallel.

[0075] 302: Test Case - 1 runs SQL normally. Test Case - 1 will normally execute the included SQL statements.

[0076] 303a: Test Case - 1 triggers the execution of an asynchronous thread (Post async SQL). When Test Case - 1 executes the SQL statement that triggers the pulling up of other test cases, it will trigger the pulling up of another asynchronous thread.

[0077] 303b: Test Case - 1 establishes a connection with the asynchronous thread (recv).

[0078] Test Case - 1 can establish a communication connection with Test Case - 2 through the recv function, and thus can obtain the execution results of the asynchronous thread (Test Case - 2), etc.

[0079] 303c: Test Case - 1 waits for the asynchronous thread to complete (wait for async finish).

[0080] 304: Test Case - 2 Output Result (write result). The asynchronous thread executes the SQL statement and obtains the output result.

[0081] 305: Test Case - 1 Normal SQL Execution (normal sql). When Test Case - 2 is executing, if the data to be read and written by Test Case - 1 is different from that of Test Case - 2, Test Case - 1 can also perform synchronous data reading and writing.

[0082] 306: Test Case - 1 Output Result (write result). Test Case - 1 executes the SQL statement and obtains the output result.

[0083] 307: Test Case - 1 Comparison Result (compare result). Both the database to be tested and the verification database will execute the above process, and the first device will compare the results output based on Test Case - 1 for the database to be tested and the verification database to generate the corresponding comparison result.

[0084] 308: Test Case - 2 Comparison Result (compare result). Similarly, the first device will also compare the results output based on Test Case - 2 for the database to be tested and the verification database to generate the corresponding comparison result. For example, if the comparison result is consistent, "ok" will be returned.

[0085] 309: Test Case - 2 Return Result (ok). Through the communication connection established between Test Case - 2 and Test Case - 1, Test Case - 2 can return the comparison result to Test Case - 1. For example, if the comparison result is consistent, "ok" will be returned.

[0086] 310: Test Case - 1 Return Result (ok). After Test Case - 1 obtains the comparison result and receives the comparison result returned by Test Case - 2, it will output the comparison results of Test Case - 1 and Test Case - 2 to the first device.

[0087] The above Figure 3A The process shown can also be manifested as the organizational logic shown in Figure 3B as follows, where Figure 3BTake the test case named "multi_001.tsql" as an example. By parsing, the parallelism of multi_001.tsql can be determined to be 2, that is, it has one asynchronous execution thread. Then, multi_001.tsql is recorded as session 1, and the other asynchronous execution thread is recorded as session 2. Session 1 triggers the start of the asynchronous thread. After the asynchronous thread starts, it will execute and pull up the shell script corresponding to the test case. Take the naming of another test case as an example of "async_exec / restart.sh". Then session 1 proposes a communication connection with session 2 and waits for the asynchronous thread to complete. For specific details, reference can also be made to the Figure 3A method steps shown above.

[0088] The following Figure 4 gives an example to illustrate the above data testing method.

[0089] The first device can run the database testing method through a scheduling file, and the scheduling file includes a scheduling policy and a comparison policy. The scheduling policy is used to obtain a test case set, send the test case set to the database to be tested and the verification database, and determine the storage paths of various files during the database testing process, etc. Here, take the test case (testcase) set including n test cases such as testcase-1, testcase-2 to testcase-n as an example, where n is a positive integer. And the test cases can also have the above-mentioned concurrently executed interfaces. For specific details, reference can be made to the Figure 3A and Figure 3B , which will not be elaborated here.

[0090] According to the output results of the database to be tested and the verification database, and through the target-driven interface, the output results can be normalized in data format, and then the results to be tested and the verification test results can be obtained. Take the results to be tested (result) including result-1, result-2 to result-n as an example, and result-1, result-2 to result-n and testcase-1, testcase-2 to testcase-n correspond one by one. The verification test results include expect-1, expect-2 to expect-m, where m is a positive integer and m is greater than or equal to n. It should be understood that in the case where m is equal to n, expect-1, expect-2 to expect-m and testcase-1, testcase-2 to testcase-n correspond one by one. When there are test cases for outputting random results in testcase-1, testcase-2 to testcase-n, there are multiple corresponding test results for this test case in the verification test results. Therefore, m is greater than or equal to n.

[0091] Then, compare the results to be tested with the verification test results to determine the comparison results corresponding to the results to be tested based on each test case, and count them as a comparison report. Among them, taking testcase-1, testcase-2, and testcase-3 as examples, based on testcase-1 and testcase-3, the results to be tested are consistent with the verification test results, and thus the comparison result is passed, as shown in Figure 4 which is represented as "ok". Based on testcase-2, the results to be tested are inconsistent with the verification test results, and thus the comparison result is failed, as shown in Figure 4 which is represented as "err". Finally, the ratio of the number of passed cases to the total number of test cases (passed cases / all case) for the overall comparison result is 2 / 3.

[0092] Moreover, the first device will also record the running time (cost time) of the database to be tested when running n test cases such as testcase-1, testcase-2 to testcase-n, such as costTime1, costTime2, and costTime3, as well as the running logs (runlog), specifically recorded as runlog-1, runlog-2 to runlog-n.

[0093] In some embodiments, the first device can also debug the database to be tested according to the running time of the database to be tested based on the test case and / or the running time of the verification database based on the test case. For example, based on the same test case, the running time of the database to be tested is greater than the running time of the verification database, or the running time of the database to be tested is greater than the running time of the verification database and the difference between their running times is greater than the preset time, and then debug the database to be tested to improve the running efficiency of the database to be tested.

[0094] In some embodiments, when the first device executes the above Figure 4 process, it can use database testing software. The file organizational structure of this database testing software can refer to Table 1 below.

[0095] Table 1

[0096]

[0097] Next, in combination with Figure 5Further, an example is given to illustrate the database testing method. When the database testing method runs on database testing software, the database testing software can integrate multiple database kernels. Taking GaussDB as an example, GaussDB itself integrates multiple database kernels, including oracle, MySQL, PG, and other self-developed databases based on GaussDB. In GaussDB, the corresponding database kernel can be selected by choosing the compatibility type (DBCOMPATIBILITY). The database testing software also includes multiple database drivers, such as jdbc.jar, gsjdbc.jar, obdc.jar, mysql_con, nector-, java.jar, and Postgresql, etc.

[0098] Taking the oracle in GaussDB as the verification database and the self-developed database of GaussDB (denoted as GaussDB) as the database to be tested as an example.

[0099] As Figure 5 shown, the test case set (such as the SQL test case set) is input into oracle and GaussDB. Among them, the database driver selected by oracle to connect is JDBC, and its class name is jdbc.jar. The database driver selected by GaussDB to connect is "mysql_con". Since the data output formats of different database drivers are different, Figure 5 exemplarily shows the data structures output by oracle, MySQL, PG, and GaussDB under different database drivers.

[0100] Since the database driver selected by oracle to connect is JDBC, therefore, the result output by JDBC can be directly read, which is the verification test result. Since the database driver connected by GaussDB is different from that of oracle, the result output by the database driver of GaussDB still needs to be converted by JDBC, and finally the result to be tested is obtained. Finally, the result to be tested and the verification test result are compared, and then the comparison result can be obtained.

[0101] In summary, the effects of the database testing method provided by this application can be referred to as Figure 6 shown. The database testing method includes three parts: test case execution, result persistence, and result comparison.

[0102] In the use case execution part, the database testing method can use one or more test cases to perform database testing, thereby achieving chaos testing for fault drill. Moreover, in addition to sequentially starting each test case in order, the database testing method can also set trigger execution between test cases, enabling multiple test cases to be executed in parallel. Thus, scenarios such as multi-user, distributed, and lock waiting can be simulated.

[0103] In the result persistence part, for multiple database kernels, the database testing method can normalize their different data formats, and then directly compare the output results of the database under test and the traditional database obtained, without the need for manual comparison of results in different formats, improving the database testing efficiency. Moreover, it can also count the time taken to execute test cases on the database under test, enrich the types of test results, and thus better evaluate the performance of the database under test.

[0104] In the result comparison part, the database testing method will match the result under test and the verification test result one by one, that is, full match. Moreover, without the need for testers to configure the expected test results, the verification test results can be generated based on the traditional database before or after the result under test (i.e., pre / post), and the verification test results are used as the expected test results, saving the time of testers and improving the database testing efficiency. The result comparison part can also select multi-value matching and regular matching methods, which can improve the accuracy of database testing for data of dictionary type (such as user information can include multiple dimensions of attributes such as name and mobile phone number) or data such as dates, and avoid misjudging the inconsistency between the result under test and the verification test result.

[0105] To solve the problem of low current database testing efficiency, this application provides a data testing device 700, as Figure 7 shown, including: an acquisition unit 710, a determination unit 720, a generation unit 730, a debugging unit 740, and a call unit 750.

[0106] The acquisition unit 710 is used to acquire the output result of the database under test based on the first test case, and acquire the output result of the verification database based on the first test case. The determination unit 720 is used to perform data format conversion on the output result of the database under test or the output result of the verification database respectively when the output data formats of the test database and the verification database are different, and obtain the result under test and the verification test result with consistent data formats. The generation unit 730 is used to generate a comparison result based on the result under test and the verification test result. The debugging unit 740 is used to debug the database under test based on the comparison result.

[0107] In some embodiments, the calling unit 750 is configured to call a target driver interface, and the target driver interface is configured to standardize the output results of the database under test and the output results of the verification database in terms of format. The obtaining unit 710 is further configured to read the output result of the database under test or the output result of the verification database through the target driver interface, and the determining unit 720 is further configured to perform data format conversion on the output result.

[0108] In other embodiments, when the determining unit 720 is further configured to execute the first test case based on the database under test, it triggers an asynchronous execution interface in the first test case for triggering the execution of the second test case, and an asynchronous waiting interface for waiting for the execution of the second test case. The generating unit 730 is further configured to execute the second test case based on the database under test to obtain the output result of the database under test based on the second test case.

[0109] In other embodiments, when the determining unit 720 is further configured to execute the first test case based on the verification database, it triggers an asynchronous execution interface in the first test case for triggering the execution of the second test case, and an asynchronous waiting interface for waiting for the execution of the second test case. The generating unit 730 is further configured to execute the second test case based on the verification database to obtain the output result of the verification database based on the second test case.

[0110] In other embodiments, the obtaining unit 710 is further configured to obtain the output result of the database under test based on the first test case, and multiple output results of the verification database based on the first test case; the determining unit 720 is further configured to determine that the comparison result is that the output results of the database under test and the verification database based on the first test case are consistent based on the matching of the test result to be tested and one or more of the multiple verification test results, wherein the multiple verification test results correspond to the multiple output results of the verification database, and the data formats of the multiple verification test results and the test result to be tested are consistent.

[0111] In other embodiments, when the first test case is a random test case, the obtaining unit 710 is further configured to obtain the output result of the database under test based on the first test case, and multiple output results of the verification database based on the first test case, wherein the random test case is used to randomly output attribute data corresponding to at least one attribute according to multiple attributes of the database.

[0112] In other embodiments, when the first test case is a real-time test case, the determining unit 720 is further configured to determine the verification test range corresponding to the output result of the verification database according to the output result of the verification database based on the first test case; the generating unit 730 is further configured to compare the test result to be tested and the verification test result based on the verification test range to obtain a comparison result.

[0113] In some other embodiments, the verification test range is a regular expression.

[0114] In some other embodiments, the obtaining unit 710 is further configured to obtain the running time of the database under test when running the first test case, and verify the running time of the database when running the first test case; and debug the database under test based on the running time of the database under test and the running time of the verification database.

[0115] Furthermore, through the data testing method provided in this application, the verification test results output by the existing traditional database can be used as the expected test results, and the results of the database under test can be compared with the results of the traditional database to determine the performance of the database under test. The tester does not need to write the expected test results, saving the time of the tester and improving the database testing efficiency. And, since the formats of the output results of different databases are different, but the target-driven interface can normalize the formats of the output results, the output results of the database under test and the traditional database obtained can be directly compared without manually comparing the results in different formats, improving the database testing efficiency.

[0116] The method of the embodiments of the present application is described in detail above. To facilitate better implementation of the above solutions of the embodiments of the present application, correspondingly, the following also provides related devices for cooperating to implement the above solutions.

[0117] Figure 8 It is a schematic structural diagram of an electronic device 100 provided by the present application. The electronic device 100 may be the occlusion recognition device 800 in the foregoing content. As Figure 8As shown in the figure, the electronic device 100 includes: a processor 810, a communication interface 820, and a memory 830. Among them, the processor 810, the communication interface 820, and the memory 830 can be interconnected through an internal bus 840, or can communicate through other means such as wireless transmission. In the embodiment of the present application, taking the connection through the bus 840 as an example, the bus 840 can be a Peripheral Component Interconnect Express (PCIe) bus, or an Extended Industry Standard Architecture (EISA) bus, a Unified Bus (Ubus or UB), a Compute Express Link (CXL), a Cache Coherent Interconnect for Accelerators (CCIX), etc. The bus 840 can be divided into an address bus, a data bus, a control bus, etc. In addition to the data bus, the bus 840 can also include a power bus, a control bus, a status signal bus, etc. However, for the sake of clear illustration, various buses are labeled as the bus 840 in the figure.

[0118] The processor 810 can be composed of at least one general-purpose processor, such as a Central Processing Unit (CPU), or a combination of a CPU and a hardware chip. The above-mentioned hardware chip can be an Application Specific Integrated Circuit (ASIC), a Programmable Logic Device (PLD), or a combination thereof. The above-mentioned PLD can be a Complex Programmable Logic Device (CPLD), a Field-Programmable Gate Array (FPGA), a Generic Array Logic (GAL), or any combination thereof. The processor 810 executes various types of digital storage instructions, such as digital storage instructions in software or firmware programs stored in the memory 830, and it can enable the electronic device 100 to provide various services.

[0119] The memory 830 is used to store program codes, and is controlled by the processor 810 to execute the processing steps of the occlusion recognition method in the above embodiments. The program codes can include one or more software modules, and these one or more software modules can be Figure 8The software modules provided in the embodiments, such as the acquisition unit, the generation unit, and the determination unit.

[0120] The memory 830 may include volatile memory, such as random access memory (RAM); the memory 830 may also include non-volatile memory (NVM), such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid-state drive (SSD); the memory 830 may further include a combination of the above types. The memory 830 may store program codes, specifically executing Figure 2 Steps S210 - S250 and their optional steps in the embodiments, which will not be elaborated here.

[0121] The communication interface 820 may be an internal interface (such as a high-speed serial computer expansion bus), a wired interface (such as an Ethernet interface), or a wireless interface (such as a cellular network interface or a wireless local area network interface), and is used to communicate with other devices or modules.

[0122] It should be noted that Figure 8 is merely a possible implementation manner of the embodiments of the present application. In practical applications, the electronic device 100 may further include more or fewer components, which are not limited here. Regarding the content not shown or described in the embodiments of the present application, reference may be made to the relevant descriptions in the foregoing Figure 2 embodiments, which will not be elaborated here.

[0123] It should be understood that this embodiment may be implemented by a general physical server. For example, an ARM server or an X86 server, or it may also be implemented by a virtual machine based on a general physical server combined with NFV technology. A virtual machine refers to a complete computer system with complete hardware system functions simulated by software and running in a completely isolated environment. The present application does not make specific limitations.

[0124] Figure 8 The illustrated electronic device 100 may also be a computer cluster composed of at least one server, which is not specifically limited in the present application.

[0125] The embodiments of the present application further provide a computer-readable storage medium. Instructions are stored in the computer-readable storage medium, and when they run on a processor, Figure 2 the shown method flow is realized.

[0126] The embodiments of the present application also provide a computer program product. When the computer program product runs on a processor, Figure 2 the method flow shown is implemented.

[0127] The above embodiments can be implemented in whole or in part by software, hardware, firmware, or any other combination. When implemented using software, the above embodiments can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded or executed on a computer, the processes or functions described in the embodiments of the present invention are generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from a website, computer, server, or data center to another website, computer, server, or data center by wire (such as coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that the computer can access or a data storage device such as a server or data center that contains one or more collections of available media. The available media can be magnetic media (such as floppy disks, hard disks, magnetic tapes), optical media (such as high-density digital video discs (DVDs)), or semiconductor media. The semiconductor media can be SSDs.

[0128] As described above, the above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art within the technical scope disclosed by the present invention can easily think of various equivalent modifications or substitutions, and these modifications or substitutions should be covered by the protection scope of the present invention. Therefore, the protection scope of the present invention should be subject to the protection scope of the claims.

Claims

1. A database testing method, characterized in that, The method includes: Obtaining the output result of the database to be tested based on the first test case, and obtaining the output result of the verification database based on the first test case; Corresponding to the different data formats of the output data of the test database and the verification database, performing data format conversion on the output result of the database to be tested or the output result of the verification database, respectively obtaining a test result with consistent data format and a verification test result; Generating a comparison result based on the test result and the verification test result; Debugging the database to be tested based on the comparison result.

2. The method according to claim 1, wherein It further includes: Invoking a target driver interface, where the target driver interface is used to make the output results of the database to be tested and the verification database have consistent formats; The performing data format conversion on the output result of the database to be tested or the output result of the verification database includes: Reading the output result of the database to be tested or the output result of the verification database through the target driver interface, and performing data format conversion on the output result.

3. The method according to claim 1, characterized in that The output result of the database to be tested further includes the output result based on the second test case; the method further includes: When executing the first test case based on the database to be tested, triggering the asynchronous execution interface in the first test case for triggering the execution of the second test case, and the asynchronous waiting interface for waiting for the execution of the second test case; Executing the second test case based on the database to be tested, and obtaining the output result of the database to be tested based on the second test case.

4. The method according to claim 1, wherein The output result of the verification database further includes the output result based on the second test case, and the method further includes: When executing the first test case based on the verification database, triggering the asynchronous execution interface in the first test case for triggering the execution of the second test case, and the asynchronous waiting interface for waiting for the execution of the second test case; Executing the second test case based on the verification database, and obtaining the output result of the verification database based on the second test case.

5. The method according to claim 1, wherein The obtaining the output result of the database to be tested based on the first test case, and obtaining the output result of the verification database based on the first test case includes: Obtaining the output result of the database to be tested based on the first test case, and multiple output results of the verification database based on the first test case; The generating a comparison result based on the test result and the verification test result includes: Based on the matching of the test result and one or more of the multiple verification test results, determining that the comparison result is that the output results of the database to be tested and the verification database based on the first test case are consistent, where the multiple verification test results correspond to the multiple output results of the verification database, and the data formats of the multiple verification test results and the test result are consistent.

6. The method according to claim 5, characterized in that The obtaining the output result of the database to be tested based on the first test case, and the multiple output results of the verification database based on the first test case includes: Based on the first test case being a random test case, obtain the output result of the database under test based on the first test case, and multiple output results of the verification database based on the first test case, where the random test case is used to randomly output attribute data corresponding to at least one attribute according to multiple attributes of the database.

7. The method according to claim 1, characterized in that, The method further includes: Based on the first test case being a real-time test case, determine the verification test range corresponding to the output result of the verification database according to the output result of the verification database based on the first test case; The generating a comparison result based on the result of the test under test and the verification test result includes: Based on the verification test range, compare the result of the test under test and the verification test result to obtain the comparison result.

8. The method according to claim 7, wherein The verification test range is a regular expression.

9. The method according to claim 1, wherein The method further includes: Obtain the running time of the database under test when running the first test case, and the running time of the verification database when running the first test case; Based on the running time of the database under test and the running time of the verification database, debug the database under test.

10. An electronic device, characterized in that, Comprising a processor and a memory, the memory is used to store instructions, the processor is used to execute the instructions, and when the processor executes the instructions, the method according to any one of claims 1 to 9 is executed.

11. A computer-readable storage medium, characterized in that, Comprising instructions, when the instructions run on an electronic device, the electronic device is caused to execute the method according to any one of claims 1 to 9.