Search

CN-122019847-A - Method for testing database connector and computing device

CN122019847ACN 122019847 ACN122019847 ACN 122019847ACN-122019847-A

Abstract

A method for testing a database connector comprises a plurality of test case generation prompt words, wherein each test case generation prompt word is constructed according to different database domain knowledge, the database domain knowledge describes at least one of database connection attribute, database mode, database function and critical condition, the method comprises a plurality of test procedures which are executed in iteration, the test procedures of any turn comprise a historical selected number and a reward value corresponding to each test case generation prompt word, a target prompt word is determined in the plurality of test case generation prompt words, the historical selected number of the target prompt word is updated, a large language model is utilized, a test case code is generated according to the target prompt word, the test case code is executed by the connector to be tested, the reward value is updated according to the execution result of the connector to be tested, the automatic test of the database connector is realized, and the test degree and the test depth can be considered in the test procedure.

Inventors

  • LIN LI
  • WEI CHANGZHENG
  • WU XINGXING
  • YAN YING
  • Lv Ce
  • ZHAO MINGHAO

Assignees

  • 蚂蚁区块链科技(上海)有限公司
  • 华东师范大学

Dates

Publication Date
20260512
Application Date
20260212

Claims (10)

  1. 1. A method for testing a database connector relates to a plurality of test case generation prompt words, wherein each test case generation prompt word is constructed according to different database domain knowledge, the database domain knowledge is described for at least one of database connection attribute, database mode, database function and critical condition, the method comprises a plurality of test cases iteratively executed test processes, and the test process of any round specifically comprises the following steps: according to the historical selected times and the rewarding values corresponding to the generated prompting words of each test case, determining target prompting words in the generated prompting words of the plurality of test cases, and updating the historical selected times of the target prompting words; Generating test case codes according to the target prompt words by using a large language model; executing the test case code by using the connector to be tested; and updating the reward value of the target prompt word according to the execution result of the connector to be tested.
  2. 2. The method of claim 1, wherein the test case code is executed using a connector under test, specifically comprising: Respectively executing the test case codes by using a plurality of connectors to be tested, wherein the configuration parameters of each connector to be tested are not completely the same; Updating the reward value of the target prompt word according to the execution result of the connector to be tested, and specifically comprises the following steps: updating the reward value of the target prompt word according to the execution results of the connectors to be tested.
  3. 3. The method of claim 2, wherein updating the prize value of the target prompt according to the execution results of the plurality of connectors to be tested specifically comprises: if the execution results of the plurality of connectors to be tested are different, the rewarding value of the target prompt word is increased.
  4. 4. The method of claim 3, wherein the determining the target prompting word among the plurality of test case generating prompting words according to the historical selected times and the rewarding value corresponding to each test case generating prompting word specifically comprises: Determining the test benefits corresponding to the test case generation prompt words, and determining the test case generation prompt word with the highest corresponding test benefits as a target prompt word, wherein the higher the reward value is, the higher the test benefits are, and the lower the historical selected times are, the higher the test benefits are.
  5. 5. The method of claim 1, wherein the test case generation hint words specifically include descriptive text for a test target, database connection criteria, and code format descriptions.
  6. 6. The method of claim 1, wherein the execution results include a database final state, an exception report, and an interface return value.
  7. 7. The method of claim 1, wherein if the execution result of the connector under test shows an anomaly, the method further comprises: and generating an exception summary document according to the test case code and the execution result by using a large language model, wherein the exception summary document is at least an exception reproduction code and an exception description.
  8. 8. The method of claim 2, wherein the plurality of connectors under test are different deployment instances of the same application or the plurality of connectors under test are different applications.
  9. 9. The method of claim 5, wherein the plurality of test case generation hint words are constructed according to the steps of: Determining a parameterized hint template comprising fixed content and variable content, wherein the fixed content comprises at least the database connection criteria and the code format description, the variable content showing a number of selectable parameters that are descriptive text for test targets, each test target corresponding to a partial concept contained in at least one of database connection attributes, database patterns, database functions, and critical conditions; And combining each optional parameter with the fixed content respectively, and determining the test case corresponding to each optional parameter to generate a prompt word.
  10. 10. A computing device comprising a memory having executable code stored therein and a processor, which when executing the executable code, implements the method of any of claims 1-9.

Description

Method for testing database connector and computing device Technical Field The embodiment of the specification belongs to the technical field of database testing, and particularly relates to a method for testing a database connector and computing equipment. Background The Database connector (Database Connector), also called a Database driver, is a protocol adaptation layer and communication middleware between an application and a Database management system, and its core logic is to implement a communication protocol (process connection handshake, authentication negotiation, protocol packet of SQL request and response unpacking) of a specific Database management system (Database MANAGEMENT SYSTEM, DBMS), translate standard API calls of the application into protocol messages conforming to a target Database management system, maintain a correspondence between each running instance of the application and a Database connection, and manage a connection pool between the application and the Database management system. Through the database connector, the application can implement standardized database access, ignoring the communication implementation details of the database management system. At present, for various application programs written by different programming languages, relatively perfect database connection standards have been established, such as database connection standard JDBC (Java Database Connectivity) capable of supporting Java language as a call statement and database connection standard ODBC (Open Database Connectivity) constructed based on C language and capable of supporting various languages as a call statement. The database connection standard specifies the functions and interface names that the standardized application programming interface (Application Programming Interface, API) needs to implement, while the database connector is a software component that implements the various types of database connection standards (JDBC or ODBC) described above. The database connector internally realizes the functions defined in the database connection standard through the own code logic, and a standardized API interface is exposed to the outside for calling an application program. Since the database connection standard has a certain interpretation space for the functional definition of each API interface, and vendors developing database connectors may make nonstandard optimizations for performance or compatibility, even code logic declaring each database connector built based on the same database connection standard may differ. These differences may lead to defects (bugs) in certain scenarios (e.g., complex transactions, special configuration parameter combinations) where the running results are inconsistent with expectations. At present, in the prior art, the implementation thinking is that basic functions such as adding, deleting, modifying, searching and data storage of the database kernel are tested through SQL query examples by using a database related testing tool such as SQLsmith, SQLancer, and the method does not involve adjustment of configuration parameters of a database connector, and naturally is difficult to access key logics such as protocol processing, state management and connection pool of the database connector. In practice, an alternative implementation is to manually write test cases specific to the database connector. However, the operation result of the database connector is highly dependent on tens of configuration parameters, and as the number increases, the combination space of the configuration parameters also grows exponentially, so that on one hand, the efficiency is lower, and on the other hand, it is difficult to ensure that various scenes which may cause abnormality are covered, and defects caused by specific parameter combinations are omitted. Accordingly, the present specification provides an automated test database connector solution to at least partially address the above-mentioned problems. Disclosure of Invention Embodiments of the present specification are directed to a method of testing a database connector and a computing device, including: The first aspect of the specification provides a method for testing a database connector, the method relates to a plurality of test case generation prompt words, each test case generation prompt word is constructed according to different database domain knowledge, the database domain knowledge describes at least one of a database connection attribute, a database mode, a database function and a critical condition, the method comprises a plurality of test case generation prompt words, the test process of any round of iterative execution comprises the following steps: according to the historical selected times and the rewarding values corresponding to the generated prompting words of each test case, determining target prompting words in the generated prompting words of the plurality of test cases, and updating the historical sele