Database migration assessment method, device, equipment and medium
By analyzing and combining the syntax tree structure of database stored procedures, multiple branch stored procedures are generated and input parameters are automatically generated, which solves the problems of low coverage and high cost of database migration in the existing technology, and realizes efficient and accurate database migration Evaluate.
Patent Information
- Application Number
- CN202210319744.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-29
- Publication Date
- 2025-02-18
- Estimated Expiration
- 2042-03-29
AI Technical Summary
The existing technology cannot effectively cover all stored procedures for testing and verification during database migration. The generation of test scripts is inefficient and costly, resulting in long test time and low efficiency.
By analyzing the syntax tree structure data of stored procedures to be tested in the source database, determining the conditional branch data, and generating multiple branch stored procedures through combination and calculation. Using the automatically generated input parameters, all branch stored procedures of the stored procedures to be tested are tested, the first test case and the second test case are generated, and the output results are compared to determine the evaluation results of the branch stored procedures.
Improves the test coverage of stored procedures during database migration, reduces testing costs and time, and improves testing efficiency and accuracy.
Smart Images

Figure CN114911770B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the financial field, and in particular to a database migration evaluation method, device, electronic device, computer-readable storage medium, and computer program product. Background Art
[0002] Database migration requires converting a large number of stored procedures in the source database to obtain stored procedures that are suitable for the target database program structure. To verify the correctness of the stored procedures during database migration, a large number of automated test scripts or manual tests are required.
[0003] The test scripts used in the related art are written by testers based on their experience. These test scripts cannot cover all stored procedures, cannot perform sufficient test verification, and have low test script generation efficiency and high generation costs. In addition, when using these test scripts for testing, program errors will lead to long test time and low test efficiency. Summary of the invention
[0004] In view of the above problems, the present disclosure provides a method, device, electronic device, computer-readable storage medium and computer program product for evaluating database migration, which are used to evaluate the correctness of storage procedures during database migration.
[0005] According to a first aspect of the present disclosure, a method for evaluating database migration is provided, comprising: determining input parameters of a stored procedure to be tested and a plurality of branch stored procedures according to a stored procedure to be tested in a source database; determining evaluation results of a branch stored procedure among the plurality of branch stored procedures to obtain a plurality of evaluation results; and determining an evaluation result of database migration according to the evaluation results of the plurality of branch stored procedures; wherein determining the evaluation results of a branch stored procedure among the plurality of branch stored procedures to obtain the plurality of evaluation results comprises: determining a first test case and a second test case corresponding to the branch stored procedure, the first test case being a simulation test case of the source database, and the second test case being a test case in the form of a target database; outputting a first test result and a second test result according to the input parameters, the first test case, and the second test case, the first test result being a test result corresponding to the first test case, and the second test result being a test result corresponding to the second test case; and determining the evaluation result of the branch stored procedure according to the first test result and the second test result.
[0006] According to an embodiment of the present disclosure, determining the input parameters of the stored procedure to be tested and multiple branch stored procedures based on the stored procedure to be tested in the source database includes: determining the syntax tree structure data of the stored procedure to be tested based on the program structure of the stored procedure to be tested; determining the conditional branch data in the stored procedure to be tested based on the syntax tree structure data; and combining and calculating the conditional branch data to determine multiple branch stored procedures.
[0007] According to an embodiment of the present disclosure, determining the input parameters of the stored procedure to be tested and multiple branch stored procedures based on the stored procedure to be tested in the source database includes: obtaining the original output result of the stored procedure to be tested; and generating multiple input parameters based on the original output result, the input parameters including the original input parameters and the input parameters that satisfy the original output result.
[0008] According to an embodiment of the present disclosure, the first test result includes a first output parameter and a first output result, and the second test result includes a second output parameter and a second output result; wherein, determining the evaluation result of the branch stored procedure based on the first test result and the second test result includes: when it is determined that the first output parameter and the second output parameter are the same, comparing the first output result and the second output result to determine the comparison result; and when it is determined that the comparison results are consistent, determining the evaluation result of the branch stored procedure.
[0009] According to an embodiment of the present disclosure, the method further includes: when it is determined that the comparison result is inconsistent, outputting error reporting data, the error reporting data including at least one of: error type, error keyword.
[0010] According to an embodiment of the present disclosure, determining the first test case and the second test case corresponding to the branch stored procedure includes: setting the branch condition corresponding to the branch stored procedure to true to obtain a code case of the branch stored procedure; simulating the code case to determine the first test case; and determining the second test case by calling a target conversion tool based on the code case.
[0011] According to an embodiment of the present disclosure, outputting a first test result and outputting a second test result according to input parameters, a first test case, and a second test case includes: determining an intermediate storage process according to the input parameters; determining first intermediate data and second intermediate data according to the input parameters and the intermediate storage process, the first intermediate data satisfying the data form of a source database, and the second intermediate data satisfying the data form of a target database; and outputting the first test result and outputting the second test result according to the first intermediate data, the second intermediate data, the first test case, and the second test case.
[0012] According to a second aspect of the present disclosure, there is provided an evaluation device for database migration, comprising: a first determination module, for determining input parameters of a stored procedure to be tested and a plurality of branch stored procedures according to the stored procedure to be tested in a source database; a second determination module, for determining evaluation results of a branch stored procedure among the plurality of branch stored procedures to obtain a plurality of evaluation results; and an evaluation module, for determining the evaluation result of the database migration according to the evaluation results of the plurality of branch stored procedures; wherein the second determination module comprises: a first determination unit, for determining a first test case and a second test case corresponding to the branch stored procedure, the first test case being a simulation test case of the source database, and the second test case being a test case in the form of a target database; a second determination unit, for outputting a first test result and a second test result according to the input parameters, the first test case and the second test case, the first test result being a test result corresponding to the first test case, and the second test result being a test result corresponding to the second test case; and a third determination unit, for determining the evaluation result of the branch stored procedure according to the first test result and the second test result.
[0013] According to a third aspect of the present disclosure, there is provided an electronic device, comprising: one or more processors; and a memory for storing one or more instructions, wherein when the one or more instructions are executed by the one or more processors, the one or more processors implement the above-mentioned database migration evaluation method.
[0014] According to a fourth aspect of the present disclosure, a computer-readable storage medium is provided, on which executable instructions are stored, and when the instructions are executed by a processor, the processor implements the above-mentioned database migration evaluation method.
[0015] According to a fifth aspect of the present disclosure, a computer program product is provided. The computer program product includes computer executable instructions, and when the instructions are executed, they are used to implement the above-mentioned database migration evaluation method. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The above contents and other purposes, features and advantages of the present disclosure will become more apparent through the following description of the embodiments of the present disclosure with reference to the accompanying drawings, in which:
[0017] Figure 1 The system architecture of the method for evaluating database migration according to an embodiment of the present disclosure is schematically shown;
[0018] Figure 2 A flowchart schematically illustrates a method for evaluating database migration according to an embodiment of the present disclosure;
[0019] Figure 3 A flowchart of a method for determining multiple branch storage processes according to an embodiment of the present disclosure is schematically shown;
[0020] Figure 4 A flowchart of a method for generating multiple input parameters according to an embodiment of the present disclosure is schematically shown;
[0021] Figure 5 A flowchart of a method for determining an evaluation result of a branch storage process according to an embodiment of the present disclosure is schematically shown;
[0022] Figure 6 A flowchart of a method for determining a first test case and a second test case according to an embodiment of the present disclosure is schematically shown;
[0023] Figure 7 Schematically shows a flow chart of outputting a first test result and outputting a second test result according to an embodiment of the present disclosure;
[0024] Figure 8 A structural block diagram schematically shows a database migration evaluation device according to an embodiment of the present disclosure; and
[0025] Fig. 9 A block diagram of an electronic device suitable for a database migration evaluation method according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION
[0026] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present disclosure. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present disclosure.
[0027] The terms used herein are only for describing specific embodiments and are not intended to limit the present disclosure. The terms "comprise", "include", etc. used herein indicate the existence of the features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.
[0028] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification, and should not be interpreted in an idealized or overly rigid manner.
[0029] When using expressions such as "at least one of A, B, and C, etc.", they should generally be interpreted according to the meaning of the expression commonly understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).
[0030] An embodiment of the present disclosure provides an evaluation method for database migration, comprising: determining input parameters of a stored procedure to be tested and multiple branch stored procedures according to a stored procedure to be tested in a source database; determining evaluation results of branch stored procedures among the multiple branch stored procedures to obtain multiple evaluation results; and determining evaluation results of database migration according to the evaluation results of the multiple branch stored procedures; wherein determining the evaluation results of branch stored procedures among the multiple branch stored procedures to obtain multiple evaluation results comprises: determining a first test case and a second test case corresponding to the branch stored procedure, the first test case being a simulation test case of the source database, and the second test case being a test case in the form of a target database; outputting a first test result and a second test result according to the input parameters, the first test case, and the second test case, the first test result being a test result corresponding to the first test case, and the second test result being a test result corresponding to the second test case; determining the evaluation result of the branch stored procedure according to the first test result and the second test result.
[0031] Figure 1 The system architecture of the database migration evaluation method according to the embodiment of the present disclosure is schematically shown.
[0032] like Figure 1 As shown, the system architecture 100 according to this embodiment may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.
[0033] Users can use terminal devices 101, 102, 103 to interact with server 105 through network 104 to receive or send messages, etc. Various applications can be installed on terminal devices 101, 102, 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only examples).
[0034] The terminal devices 101 , 102 , and 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, and desktop computers.
[0035] The server 105 may be a server that provides various services, such as a background management server (only an example) that provides support for websites browsed by users using the terminal devices 101, 102, and 103. The background management server may analyze and process the received data such as user requests, and feed back the processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal device.
[0036] It should be noted that the evaluation method for database migration provided in the embodiment of the present disclosure can generally be executed by the server 105. Accordingly, the evaluation device for database migration provided in the embodiment of the present disclosure can generally be set in the server 105. The evaluation method for database migration provided in the embodiment of the present disclosure can also be executed by a server or server cluster that is different from the server 105 and can communicate with the terminal devices 101, 102, 103 and / or the server 105. Accordingly, the evaluation device for database migration provided in the embodiment of the present disclosure can also be set in a server or server cluster that is different from the server 105 and can communicate with the terminal devices 101, 102, 103 and / or the server 105.
[0037] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to the implementation requirements.
[0038] The following will be based on Figure 1 The system architecture described by Figure 2 to Figure 7 The application review method of the disclosed embodiment is described in detail.
[0039] Figure 2 The flowchart of the method for evaluating database migration according to the embodiment of the present disclosure is schematically shown.
[0040] like Figure 2 As shown, the method includes operations S210 to S230.
[0041] In operation S210 , input parameters of the stored procedure to be tested and a plurality of branch stored procedures are determined according to the stored procedure to be tested in the source database.
[0042] According to the embodiments of the present disclosure, a stored procedure is a database object and can be regarded as a function or subroutine of a database. A stored procedure includes multiple selection statements, and one selection statement corresponds to the execution operations of multiple branches, that is, the stored procedure includes multiple branch conditions. Database migration refers to migrating a stored procedure from a source database to a new target database. The evaluation of database migration refers to the evaluation of the migrated stored procedure. When a conversion tool is used to achieve the conversion of the target database format, the evaluation can also be an evaluation of the conversion tool. The principle of unchanged functional characteristics after the stored procedure conversion is that for the same functional stored procedure, the output results of the source database and the target database based on the input data are the same.
[0043] According to the embodiments of the present disclosure, the stored procedure to be tested includes multiple branch conditions. Generally, only some branches of the stored procedure to be tested can be applied to a case, and data of all branches of the stored procedure to be tested is required. The stored procedure to be tested of the source database is structurally analyzed to determine all branches of the stored procedure to be tested, and the obtained branches are combined and calculated to obtain multiple branch stored procedures that can be implemented. Based on the evaluation results of the multiple branch stored procedures, the evaluation results of the stored procedure to be tested during the database migration process can be determined.
[0044] According to an embodiment of the present disclosure, the stored procedure to be tested is a stored procedure of a source database, a test case of the stored procedure is obtained, and the test case is parsed to automatically generate multiple input parameters that meet the input conditions of the stored procedure.
[0045] In operation S220 , evaluation results of branch stored procedures among the plurality of branch stored procedures are determined to obtain a plurality of evaluation results.
[0046] According to an embodiment of the present disclosure, when the input parameters of the stored procedure to be tested and the multiple branch stored procedures are determined, the multiple input parameters are input into the stored procedure of the source database and the stored procedure corresponding to the target database, and the output result of the source database is compared with the output result of the target database. The evaluation result of the stored procedure to be tested during the database migration process is determined using the output results of the multiple input parameters, so as to evaluate the situation of the database migration.
[0047] According to an embodiment of the present disclosure, a stored procedure includes multiple branch stored procedures. During the database migration process, the output result of each branch stored procedure of the source database must be compared with the output result of the branch stored procedure corresponding to the target database. Specifically, for the branch stored procedure of the stored procedure to be tested, a first test case and a second test case corresponding to the branch stored procedure are determined. The first test case is a simulated test case of the source database, and the second test case is a test case in the form of the target database. After determining the first test case and the second test case, there is a program to implement the specific functions of the branch stored procedure.
[0048] According to an embodiment of the present disclosure, after determining the first test case and the second test case of the branch stored procedure, multiple input parameters are respectively input into the first test case and the second test case, and the first test result and the second test result are respectively output. The first test result is the test result corresponding to the first test case, and the second test result is the test result corresponding to the second test case. By comparing the first test result and the second test result, the evaluation result of the branch stored procedure can be determined.
[0049] According to an embodiment of the present disclosure, the results of the branch storage process include normal and abnormal.
[0050] For example, the stored procedure M to be tested includes multiple branch stored procedures, wherein the first test case of the branch stored procedure m is A, and the second test case is B. Input parameters are respectively input into the first test case A and the second test case B to obtain the first test result A1 and the second test result B1. The first test result A1 and the second test result B1 are the same, indicating that the evaluation result of the branch stored procedure m is normal; the first test result A1 and the second test result B1 are different, indicating that the evaluation result of the branch stored procedure m is abnormal.
[0051] In operation S230 , an evaluation result of database migration is determined according to the evaluation results of the plurality of branch stored procedures.
[0052] According to the evaluation results of multiple branch stored procedures, the evaluation results of all branch stored procedures of the stored procedure to be tested can be obtained. Specifically, when the evaluation results of all branch stored procedures of the stored procedure to be tested are normal, it indicates that the evaluation of this database migration is normal, and the target database can achieve the same functions as the source database.
[0053] According to an embodiment of the present disclosure, the evaluation results of multiple branch storage results can also be denoised to obtain specific comparison results of the target database and the source database, and determine the evaluation results of the database migration, so that testers can verify and repair the evaluation results.
[0054] For example, the stored procedure M to be tested in the source database includes two branch stored procedures m1 and m2. m1 implements the function of querying the input account balance, and m2 implements the function of querying the input account's loan amount. The source database obtains the input user's balance based on the input parameters, using the branch stored procedure of m1; the target database obtains the input account's loan amount based on the input parameters, using the branch stored procedure of m2, that is, the two databases obtain different results based on the same input parameter, so the evaluation result of the database migration is abnormal. The balance of the input account is also obtained in the target database, that is, the branch stored procedure of m1 is used, but the balance result is different from that of the source database, and the evaluation result is also abnormal.
[0055] The present invention analyzes the stored procedure to be tested, obtains all branch stored procedures of the stored procedure to be tested through calculation and combination, and uses automatically generated input parameters to test all branch stored procedures of the stored procedure to be tested. There is no need for testers to write a large number of test cases to realize the verification of all branch stored procedures, which improves the test efficiency, reduces the test cost, and at the same time improves the test coverage, thereby realizing full verification of the stored procedure to be tested.
[0056] Figure 3 The flowchart of the method for determining multiple branch storage procedures according to an embodiment of the present disclosure is schematically shown.
[0057] like Figure 3 As shown, the method for determining multiple branch storage processes in this embodiment includes operations S311 to S313, which can be used as a specific embodiment of operation S210.
[0058] According to an embodiment of the present disclosure, operation S220 is in response to a test operation within a preset period. Multiple test operations may be performed within the preset period. Each test operation may test a different portion of the target code, that is, the target code includes multiple branch test codes.
[0059] In operation S311 , the syntax tree structure data of the stored procedure to be tested is determined according to the program structure of the stored procedure to be tested.
[0060] According to an embodiment of the present disclosure, the form of the stored procedure to be tested is in the code form that conforms to the source database, and the program result of the stored procedure to be tested is obtained by parsing the stored procedure to be tested, and then the syntax tree result data of the stored procedure to be tested is obtained. Specifically, the syntax result of each stored procedure can be analyzed, and the program structure can be converted into an abstract syntax tree (AST) structure.
[0061] In operation S312, conditional branch data in the stored procedure to be tested is determined based on the syntax tree structure data.
[0062] According to an embodiment of the present disclosure, according to the syntax tree structure data obtained by parsing, each branch node on the syntax tree structure is a conditional branch of the stored procedure to be tested. According to the syntax tree result data, all conditional branches in the stored procedure to be tested can be determined to obtain conditional branch data, for example, the position information of each conditional branch.
[0063] In operation S313, the conditional branch data is combined and calculated to determine a plurality of branch storage procedures.
[0064] According to an embodiment of the present disclosure, after obtaining the conditional branch data, the conditional branch data is combined and calculated to obtain all the branch stored procedures that can be implemented. Specifically, the conditional branch data is calculated using the basic path coverage method to obtain multiple branch stored procedures of the stored procedure to be tested in the source database. The target database can generate multiple target branch stored procedures corresponding to the multiple branch stored procedures to ensure that the test code covers all test situations during the database migration process.
[0065] For example, the stored procedure M to be tested includes conditional branch a and conditional branch b, where conditional branch a corresponds to two paths a1 and a2, and there is conditional branch b on path a2, and conditional branch b corresponds to two paths b1 and b2. The conditional branch data obtained according to the syntax tree structure data are conditional branch a and conditional branch b, and their corresponding paths a1 and a2, b1 and b2. After combination, three paths a1, a2-b1, and a2-b2 are obtained. After calculation, a2-b2 cannot be realized, so two paths a1 and a2-b1 are finally obtained. The two branch paths a1 and a2-b1 can realize different functions.
[0066] The present disclosure generates multiple branch storage processes of the source database by combining and calculating all branches of the storage path to be tested, thereby ensuring that all test situations are involved in the test process and ensuring the test accuracy of the database migration process.
[0067] Figure 4 The flowchart of the method for generating multiple input parameters according to an embodiment of the present disclosure is schematically shown.
[0068] like Figure 4 As shown, the generating of multiple input parameters in this embodiment includes operations S411 to S412, which can be used as a specific embodiment of operation S210.
[0069] According to an embodiment of the present disclosure, operation S210 is to determine input parameters that conform to the stored procedure to be tested according to the stored procedure to be tested. Since the stored procedure to be tested is a process of obtaining output data according to input data, a certain output data can be obtained from the input data, but when generating input data from output data, there may be multiple input data that conform to the output data.
[0070] In operation S411, the original output result of the stored procedure to be tested is obtained.
[0071] According to an embodiment of the present disclosure, after determining the stored procedure to be tested, test data of the stored procedure to be tested is obtained, and the test data may be written by a tester according to actual functions, or may be obtained after processing real data. The original output result corresponding to the test data is determined based on the obtained test data.
[0072] In operation S412, a plurality of input parameters are generated according to the original output result.
[0073] According to an embodiment of the present disclosure, the input parameters include original input parameters and input parameters that satisfy the original output results.
[0074] According to the embodiments of the present disclosure, by automatically generating a plurality of qualified input parameters using the original output results, it is possible to increase the diversity of test data from the source of the data and ensure the accuracy of the evaluation of database migration.
[0075] Figure 5 The flowchart of the method for determining the evaluation result of the branch storage process according to the embodiment of the present disclosure is schematically shown.
[0076] like Figure 5 As shown, the method for determining the evaluation result of the branch storage process in this embodiment includes operations S521 to S522, which can be used as a specific embodiment of operation S220.
[0077] In operation S521, when it is determined that the first output parameter and the second output parameter are the same, the first output result and the second output result are compared to determine a comparison result.
[0078] According to an embodiment of the present disclosure, the first test result includes a first output parameter and a first output result, and the second test result includes a second output parameter and a second output result. The output parameter includes the functional status of the branch storage procedure, such as operation success and operation failure; the output result includes a specific output result, such as the balance data after the transfer operation.
[0079] According to an embodiment of the present disclosure, after obtaining the first output parameter and the first output result of the first test case, the second output parameter and the second output result of the second test case, the first output parameter and the second output parameter are compared. The first output parameter and the second output parameter are different, indicating that the function of the current branch storage procedure is not successful, and the generated first test case and the second test case need to be modified. Modifying the test case when the first output parameter and the second output parameter are different can reduce the test time and improve the test efficiency.
[0080] According to an embodiment of the present disclosure, when the first output parameter and the second output parameter are the same, the first output result and the second output result are compared to determine the comparison result. For example, still taking the transfer operation as an example, the first output parameter of the first test case is a successful transfer, and the second output parameter of the second test case is a failed transfer. Obviously, the functional implementations of the first test case and the second test case are different, and there are errors in the database migration process, which need to be checked and modified.
[0081] In operation S522 , when it is determined that the comparison results are consistent, an evaluation result of the branch storage process is determined.
[0082] According to an embodiment of the present disclosure, when the comparison result of the first output result and the second output result is consistent, the evaluation result of the branch stored procedure is determined to be correct, and then the test of the next branch stored procedure is automatically called. When the comparison result is inconsistent, the evaluation result of the branch stored procedure is determined to be incorrect, and the test of the branch stored procedure is stopped.
[0083] For example, still taking the transfer operation as an example, when both the first output parameter and the second output parameter indicate that the transfer is successful, the first output result is "balance 1000 yuan", and the second output result is "balance is 1000 yuan", which indicates that the evaluation result of the branch stored procedure in the database migration process is correct. Continue to test the next branch stored procedure.
[0084] According to an embodiment of the present disclosure, before inputting input parameters into the first test case and the second test case, it is necessary to ensure that the input data format of the first test case and the second test case are consistent, and the specific data included are consistent, for example, the account balances of the first test case and the second test case are the same before the transfer.
[0085] According to an embodiment of the present disclosure, when it is determined that the comparison results of the first output result and the second output result are inconsistent, error reporting data is output so that the tester can determine whether to continue the test according to the error reporting data. The error reporting data includes error type and error keyword.
[0086] According to an embodiment of the present disclosure, the error reporting data may be in the form of an error reporting log, an error reporting identifier, an error reporting path, and the like.
[0087] Figure 6 The flowchart of the method for determining the first test case and the second test case according to an embodiment of the present disclosure is schematically shown.
[0088] like Figure 6 As shown, the method for determining the first test case and the second test case in this embodiment includes operations S621 to S623, which can be used as a specific embodiment of operation S220.
[0089] According to an embodiment of the present disclosure, operation S220 determines the evaluation result of a branch stored procedure in a plurality of branch stored procedures, specifically including inputting input parameters into the first test case and the second test case. Operations S621 to S623 can be used as a specific embodiment of generating the first test case and the second test case.
[0090] In operation S621, a branch condition corresponding to the branch stored procedure is set to true, and a code case of the branch stored procedure is obtained.
[0091] According to an embodiment of the present disclosure, after determining the stored procedure to be tested that needs to be tested, it is necessary to determine the specific branch stored procedure, and then generate a test case in the source database format and a test case for the target database. Generating a specific test case requires specific test code, so the conditional branch position is determined according to the stored procedure to be tested, and the branch condition for obtaining the branch stored procedure is forcibly set to true. It should be noted that true at this time is relative to false, and is the condition required to obtain the branch stored procedure. After setting the branch condition corresponding to the branch stored procedure to true, the specific code case of the branch stored procedure can be determined from the stored procedure to be tested.
[0092] In operation S622, a code case is simulated to determine a first test case.
[0093] According to an embodiment of the present disclosure, after a code case of the branch stored procedure is determined, the code case is simulated to generate a first test case.
[0094] In operation S623 , based on the code case, a second test case is determined by calling a target conversion tool.
[0095] According to an embodiment of the present disclosure, the code case determined at this time is the code form of the stored procedure to be tested in the source database, so it is necessary to call a target conversion tool to convert the code case of the branch stored procedure into the form of the target database to obtain the converted second test case.
[0096] Figure 7The flowchart of outputting the first test result and the second test result according to the embodiment of the present disclosure is schematically shown.
[0097] like Figure 7 As shown, the method of outputting the first test result and the second test result of this embodiment includes operations S721 to S723, which can be used as a specific embodiment of operation S220.
[0098] According to an embodiment of the present disclosure, operation S220 includes outputting a first test result and outputting a second test result according to the input parameter, the first test case and the second test case. Operations S721 to S723 may be used as a specific embodiment of this step.
[0099] According to the embodiments of the present disclosure, the design structure of some stored procedures is not suitable for direct calling, but only suitable for calling through other stored procedures. Therefore, when executing a case, it is necessary to call and execute through an intermediate stored procedure.
[0100] In operation S721, an intermediate stored procedure is determined according to input parameters.
[0101] In operation S722 , first intermediate data and second intermediate data are determined according to the input parameters and the intermediate stored procedure.
[0102] In operation S723, a first test result is output and a second test result is output according to the first intermediate data, the second intermediate data, the first test case, and the second test case.
[0103] According to an embodiment of the present disclosure, when it is determined that the first test case and the second test case include a stored procedure that cannot be directly called, the intermediate stored procedure required for the call is determined according to the input parameters. Then the input parameters are input into the intermediate stored procedure, and the first intermediate data and the second intermediate data are output. The first intermediate data meets the data form of the source database, and the second intermediate data meets the data form of the target database.
[0104] According to an embodiment of the present disclosure, the intermediate stored procedure may include multiple intermediate stored procedures, which are respectively used to call the first test case and the second test case.
[0105] According to an embodiment of the present disclosure, after the intermediate stored procedure outputs the first intermediate data and the second intermediate data, the first intermediate data is used to call the stored procedure that cannot be directly called in the first test case, and the first test result is output; the second intermediate data is used to call the stored procedure that cannot be directly called in the second test case, and the second test result is output.
[0106] The present disclosure utilizes intermediate stored procedures to implement stored procedures that cannot be directly called during the evaluation of database migration, thereby ensuring the comprehensiveness and accuracy of the evaluation stored procedures.
[0107] Figure 8 The structural block diagram of the database migration evaluation device according to the embodiment of the present disclosure is schematically shown.
[0108] like Figure 8 As shown, the device 800 for determining code coverage in this embodiment includes a first determining module 810 , a second determining module 820 and an evaluating module 830 .
[0109] The first determination module 810 is used to determine the input parameters of the stored procedure to be tested and multiple branch stored procedures according to the stored procedure to be tested in the source database. In one embodiment, the first determination module 810 can be used to perform the operation S210 described above, which will not be described in detail here.
[0110] The second determination module 820 is used to determine the evaluation results of the branch storage processes among the multiple branch storage processes to obtain multiple evaluation results. In one embodiment, the second determination module 820 can be used to perform the operation S220 described above, which will not be described in detail here.
[0111] The evaluation module 830 is used to determine the evaluation result of the database migration according to the evaluation results of the multiple branch stored procedures. In one embodiment, the evaluation module 830 can be used to perform the operation S230 described above, which will not be described in detail here.
[0112] The second determination module 820 further includes a first determination unit, a second determination unit and an umbrella determination unit.
[0113] The first determination unit is used to determine a first test case and a second test case corresponding to the branch stored procedure, the first test case is a simulation test case of the source database, and the second test case is a test case in the form of a target database. In one embodiment, the first determination unit can be used to perform the operation S220 described above, which will not be repeated here.
[0114] The second determination unit is used to output a first test result and a second test result according to the input parameters, the first test case and the second test case, wherein the first test result is a test result corresponding to the first test case and the second test result is a test result corresponding to the second test case. In one embodiment, the second determination unit can be used to perform the operation S220 described above, which will not be described in detail herein.
[0115] The third determining unit is used to determine the evaluation result of the branch storage process according to the first test result and the second test result. In one embodiment, the third determining unit can be used to perform the operation S220 described above, which will not be described in detail here.
[0116] According to an embodiment of the present disclosure, the first determination module 810 includes a first parsing unit, a second parsing unit, and a third parsing unit.
[0117] The first parsing unit is used to determine the syntax tree structure data of the stored procedure to be tested according to the program structure of the stored procedure to be tested. In one embodiment, the first parsing unit can be used to perform the operation S311 described above, which will not be described in detail here.
[0118] The second parsing unit is used to determine the conditional branch data in the stored procedure to be tested based on the syntax tree structure data. In one embodiment, the second parsing unit can be used to perform the operation S312 described above, which will not be described in detail here.
[0119] The third parsing unit is used to combine and calculate the conditional branch data to determine multiple branch storage procedures. In one embodiment, the third parsing unit can be used to perform the operation S313 described above, which will not be repeated here.
[0120] According to an embodiment of the present disclosure, the first determining module 810 further includes an acquiring unit and a generating unit.
[0121] The acquisition unit is used to acquire the original output result of the stored procedure to be tested. According to the first identification information, the total number of branches of the target code is determined. In one embodiment, the acquisition unit can be used to perform the operation S411 described above, which will not be repeated here.
[0122] The generating unit is used to generate a plurality of input parameters according to the original output result, wherein the input parameters include the original input parameters and the input parameters satisfying the original output result. The total number of branches of the target code is determined according to the first identification information. In one embodiment, the generating unit can be used to perform the operation S412 described above, which will not be described in detail here.
[0123] According to an embodiment of the present disclosure, the third determining unit includes a first determining subunit and a second determining subunit.
[0124] The first determining subunit is used to compare the first output result with the second output result to determine a comparison result when the first output parameter and the second output parameter are determined to be the same. In one embodiment, the first determining subunit can be used to perform the operation S521 described above, which will not be described in detail here.
[0125] The second determination subunit is used to determine the evaluation result of the branch storage process when the comparison results are determined to be consistent. In one embodiment, the second determination subunit can be used to perform the operation S522 described above, which will not be described in detail here.
[0126] According to an embodiment of the present disclosure, the first determining unit includes a third determining subunit, a fourth determining subunit, and a fifth determining subunit.
[0127] The third determining subunit is used to set the branch condition corresponding to the branch stored procedure to true, and obtain a code example of the branch stored procedure. In one embodiment, the third determining subunit can be used to perform the operation S621 described above, which will not be described in detail here.
[0128] The fourth determination subunit is used to simulate the code case and determine the first test case. In one embodiment, the fourth determination subunit can be used to perform the operation S622 described above, which will not be described in detail here.
[0129] The fifth determining subunit is used to determine the second test case by calling the target conversion tool based on the code case. In one embodiment, the fifth determining subunit can be used to perform the operation S623 described above, which will not be described in detail here.
[0130] According to an embodiment of the present disclosure, the second determining unit includes a sixth determining subunit, a seventh determining subunit, and an output subunit.
[0131] The sixth determination subunit is used to determine the intermediate storage process according to the input parameters. In one embodiment, the sixth determination subunit can be used to perform the operation S721 described above, which will not be described in detail here.
[0132] The seventh determination subunit is used to determine the first intermediate data and the second intermediate data according to the input parameters and the intermediate storage process, the first intermediate data meets the data format of the source database, and the second intermediate data meets the data format of the target database. In one embodiment, the seventh determination subunit can be used to perform the operation S722 described above, which will not be repeated here.
[0133] The output subunit is used to output the first test result and the second test result according to the first intermediate data, the second intermediate data, the first test case and the second test case. In one embodiment, the output subunit can be used to perform the operation S723 described above, which will not be described in detail here.
[0134] Fig. 9 A block diagram of an electronic device suitable for a database migration evaluation method according to an embodiment of the present disclosure is schematically shown.
[0135] like Fig. 9As shown, the electronic device 900 according to an embodiment of the present disclosure includes a processor 901, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 902 or a program loaded from a storage part 908 into a random access memory (RAM) 903. The processor 901 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 901 may also include an onboard memory for caching purposes. The processor 901 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present disclosure.
[0136] In RAM 903, various programs and data required for the operation of electronic device 900 are stored. Processor 901, ROM 902 and RAM 903 are connected to each other via bus 904. Processor 901 performs various operations of the method flow according to the embodiment of the present disclosure by executing the program in ROM 902 and / or RAM 903. It should be noted that the program can also be stored in one or more memories other than ROM 902 and RAM 903. Processor 901 can also perform various operations of the method flow according to the embodiment of the present disclosure by executing the program stored in the one or more memories.
[0137] According to an embodiment of the present disclosure, the electronic device 900 may further include an input / output (I / O) interface 905, which is also connected to the bus 904. The electronic device 900 may further include one or more of the following components connected to the I / O interface 905: an input portion 906 including a keyboard, a mouse, etc.; an output portion 907 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage portion 908 including a hard disk, etc.; and a communication portion 909 including a network interface card such as a LAN card, a modem, etc. The communication portion 909 performs communication processing via a network such as the Internet. A drive 910 is also connected to the I / O interface 905 as needed. A removable medium 911, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 910 as needed, so that a computer program read therefrom is installed into the storage portion 908 as needed.
[0138] The present disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present disclosure is implemented.
[0139] According to an embodiment of the present disclosure, a computer-readable storage medium may be a non-volatile computer-readable storage medium, for example, may include but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, an apparatus, or a device. For example, according to an embodiment of the present disclosure, a computer-readable storage medium may include the ROM 902 and / or RAM 903 described above and / or one or more memories other than ROM 902 and RAM 903.
[0140] The embodiment of the present disclosure also includes a computer program product, which includes a computer program, and the computer program contains program code for executing the method shown in the flowchart. When the computer program product is run in a computer system, the program code is used to enable the computer system to implement the database migration evaluation method provided by the embodiment of the present disclosure.
[0141] The above functions defined in the system / device of the embodiment of the present disclosure are performed when the computer program is executed by the processor 901. According to the embodiment of the present disclosure, the system, device, module, unit, etc. described above can be implemented by a computer program module.
[0142] In one embodiment, the computer program may be based on a tangible storage medium such as an optical storage device, a magnetic storage device, etc. In another embodiment, the computer program may also be transmitted and distributed in the form of a signal on a network medium, and downloaded and installed through the communication part 909, and / or installed from a removable medium 911. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0143] In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 909, and / or installed from the removable medium 911. When the computer program is executed by the processor 901, the above functions defined in the system of the embodiment of the present disclosure are performed. According to the embodiment of the present disclosure, the system, device, means, module, unit, etc. described above can be implemented by a computer program module.
[0144] According to an embodiment of the present disclosure, the program code for executing the computer program provided by the embodiment of the present disclosure can be written in any combination of one or more programming languages. Specifically, these computing programs can be implemented using high-level process and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, Java, C++, python, "C" language or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on the remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (for example, using an Internet service provider to connect through the Internet).
[0145] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0146] It will be appreciated by those skilled in the art that the features described in the various embodiments and / or claims of the present disclosure may be combined and / or combined in a variety of ways, even if such combinations and / or combinations are not explicitly described in the present disclosure. In particular, the features described in the various embodiments and / or claims of the present disclosure may be combined and / or combined in a variety of ways without departing from the spirit and teachings of the present disclosure. All of these combinations and / or combinations fall within the scope of the present disclosure.
[0147] The specific embodiments described above further illustrate the purpose, technical solutions and beneficial effects of the present disclosure. It should be understood that the above description is only a specific embodiment of the present disclosure and is not intended to limit the present disclosure. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present disclosure should be included in the protection scope of the present disclosure.
Claims
1. A database migration evaluation method, comprising: Get the original output results of the stored procedure to be tested in the source database; Generate a plurality of input parameters according to the original output result, wherein the input parameters include original input parameters and input parameters that satisfy the original output result; Determine the syntax tree structure data of the stored procedure to be tested according to the program structure of the stored procedure to be tested; Based on the syntax tree structure data, determining conditional branch data in the stored procedure to be tested; Combining and calculating the conditional branch data to determine a plurality of branch storage procedures; Determine evaluation results of branch storage processes among the multiple branch storage processes to obtain multiple evaluation results; as well as Determine the evaluation result of database migration based on the evaluation results of multiple branch stored procedures; The step of determining the evaluation results of the branch storage processes in the plurality of branch storage processes to obtain the plurality of evaluation results comprises: Determine a first test case and a second test case corresponding to the branch stored procedure, wherein the first test case is a simulation test case of the source database, and the second test case is a test case in the form of a target database; Outputting a first test result and a second test result according to the input parameters, the first test case and the second test case, wherein the first test result is a test result corresponding to the first test case and the second test result is a test result corresponding to the second test case; An evaluation result of the branch stored procedure is determined according to the first test result and the second test result.
2. The method according to claim 1, wherein the first test result comprises a first output parameter and a first output result, and the second test result comprises a second output parameter and a second output result; wherein, Determining the evaluation result of the branch stored procedure according to the first test result and the second test result includes: When it is determined that the first output parameter and the second output parameter are the same, comparing the first output result and the second output result to determine a comparison result; and When it is determined that the comparison results are consistent, an evaluation result of the branch storage process is determined.
3. The method according to claim 2, further comprising: When it is determined that the comparison result is inconsistent, error reporting data is output, and the error reporting data includes at least one of: an error type and an error keyword.
4. The method according to claim 1, wherein: Determining the first test case and the second test case corresponding to the branch stored procedure includes: Setting the branch condition corresponding to the branch stored procedure to true to obtain a code example of the branch stored procedure; Simulating the code case to determine a first test case; and Based on the code case, a second test case is determined by calling a target conversion tool.
5. The method according to claim 1, wherein: Outputting a first test result and outputting a second test result according to the input parameter, the first test case, and the second test case includes: Determine an intermediate storage process according to the input parameters; Determine, according to the input parameter and the intermediate stored procedure, first intermediate data and second intermediate data, wherein the first intermediate data satisfies the data form of the source database and the second intermediate data satisfies the data form of the target database; and The first test result and the second test result are outputted according to the first intermediate data, the second intermediate data, the first test case and the second test case.
6. A database migration evaluation device, comprising: The first determination module is used to obtain the original output result of the stored procedure to be tested in the source database; Generate a plurality of input parameters according to the original output result, wherein the input parameters include original input parameters and input parameters that satisfy the original output result; Determine the syntax tree structure data of the stored procedure to be tested according to the program structure of the stored procedure to be tested; Based on the syntax tree structure data, determining conditional branch data in the stored procedure to be tested; Combining and calculating the conditional branch data to determine a plurality of branch storage procedures; A second determination module is used to determine the evaluation results of the branch storage processes in the multiple branch storage processes to obtain multiple evaluation results; as well as An evaluation module, used to determine an evaluation result of database migration according to evaluation results of multiple branch stored procedures; Wherein, the second determining module includes: A first determining unit, configured to determine a first test case and a second test case corresponding to the branch stored procedure, wherein the first test case is a simulation test case of the source database, and the second test case is a test case in the form of a target database; A second determining unit, configured to output a first test result and a second test result according to the input parameter, the first test case, and the second test case, wherein the first test result is a test result corresponding to the first test case, and the second test result is a test result corresponding to the second test case; The third determining unit is used to determine the evaluation result of the branch storage process according to the first test result and the second test result.
7. An electronic device comprising: one or more processors; a memory for storing one or more instructions, Wherein, when the one or more instructions are executed by the one or more processors, the one or more processors are enabled to implement the method according to any one of claims 1 to 5.
8. A computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, enables the processor to implement the method according to any one of claims 1 to 5.
9. A computer program product, comprising computer executable instructions, wherein the instructions are used to implement the method according to any one of claims 1 to 5 when executed.
Citation Information
Patent Citations
Database migration evaluation method, device, equipment and computer storage medium
CN111708753A
Data migration test method and device
CN111966665A