Test data generation method, device and equipment
Through reverse SQL instructions to process database operation result data of online business requests, the test data for simulation test is generated, which solves the complex and high-cost problems caused by relying on manual experience in the existing technology, realizes automated test data preparation, and improves the Efficiency and stability.
Patent Information
- Application Number
- CN202411426829.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-12
- Publication Date
- 2025-01-03
AI Technical Summary
Existing software test data generation methods rely on a lot of manual business experience, resulting in complex processes, inefficient and high cost.
By obtaining the database operation result data of the online service request executed by the target service type, and processing the data using reverse SQL instructions, the test data is generated for the simulation test environment.
It realizes automated preparation of test data without relying on a large amount of manual business experience, reducing labor costs and improving the efficiency and stability of data preparation.
Smart Images

Figure CN119248654A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of software testing technology, and in particular to a test data generation method, a test data generation device and a test data generation equipment. Background Art
[0002] In the process of software development and maintenance, software testing plays a key role in ensuring software quality. The construction of the test environment is an important link to ensure that software testing can proceed smoothly and produce accurate results. The construction of the test environment includes hardware environment, software environment, network environment, data environment, tool environment and other aspects. In the preparation of the test environment, the preparation of test data in the data environment is particularly important. Test data is the basis for executing test cases and directly affects the effectiveness and integrity of the test.
[0003] In the related art, test data can be prepared by synchronizing online data and then modifying the synchronized data. However, such a data preparation solution requires a lot of reliance on business experience. For example, how to modify the synchronized data is very dependent on business experience. Therefore, the data preparation process is complicated, inefficient, and has extremely high labor costs.
[0004] In view of this, it is necessary to provide a convenient method for preparing test data without relying heavily on manual business experience. Summary of the invention
[0005] In view of this, the embodiments of the present application provide a test data generation method, apparatus and device to solve the problems of existing test data generation methods, such as heavy reliance on manual business experience, complex processes and high costs.
[0006] According to a first aspect of an embodiment of the present application, a test data generating method is provided, comprising: Acquire execution result data obtained by executing a first database operation; the first database operation is a database operation executed by a first program in response to an online business request of a target business type; the first program is a first version of a target program; Determine a reverse SQL instruction corresponding to the online service request of the target service type; The second database operation indicated by the reverse SQL instruction is performed on the execution result data to obtain test data; the test data is used when a second program in a simulation test environment executes a test business request of the target business type; the second program is a second version of the target program.
[0007] According to a second aspect of an embodiment of the present application, there is provided a test data generating device, including: an execution result data acquisition module, used to acquire execution result data obtained by executing a first database operation; the first database operation is a database operation executed by a first program in response to an online business request of a target business type; the first program is a first version of a target program; A reverse SQL instruction determination module, used to determine a reverse SQL instruction corresponding to the online service request of the target service type; A test data generation module is used to perform the second database operation indicated by the reverse SQL instruction on the execution result data to obtain test data; the test data is used when a second program in a simulation test environment executes a test business request of the target business type; the second program is the second version of the target program.
[0008] According to a third aspect of an embodiment of the present application, a test data generating device is provided, including: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to: Acquire execution result data obtained by executing a first database operation; the first database operation is a database operation executed by a first program in response to an online business request of a target business type; the first program is a first version of a target program; Determine a reverse SQL instruction corresponding to the online service request of the target service type; The second database operation indicated by the reverse SQL instruction is performed on the execution result data to obtain test data; the test data is used when a second program in a simulation test environment executes a test business request of the target business type; the second program is a second version of the target program.
[0009] An embodiment of the present specification can at least achieve the following beneficial effects: by obtaining execution result data obtained after a first program executes a first database operation in response to an online business request of a target business type, and using a reverse SQL instruction corresponding to the target business type to execute a second database operation on the execution result data, test data for testing a second program of a different version from the first program under the same business scenario in a simulation test environment is obtained, thereby achieving automated preparation of test data without relying heavily on manual business experience, with low labor costs, a simple and efficient process, and high stability of the data obtained. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] In order to more clearly illustrate the embodiments of this specification or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0011] Figure 1 A schematic diagram of an application scenario of a method for generating test data provided in an embodiment of this specification; Figure 2 A flowchart of a test data generation method provided in an embodiment of this specification; Figure 3 A schematic diagram of the overall process of a technical solution for determining data generation rules and preparing simulation test data using the data generation rules in an actual application scenario provided by an embodiment of this specification; Figure 4 The embodiments of this specification provide corresponding to Figure 2 A structural schematic diagram of a test data generating device; Figure 5 The embodiments of this specification provide corresponding to Figure 2 A structural schematic diagram of a test data generating device. DETAILED DESCRIPTION
[0012] Many specific details are described in the following description to facilitate a full understanding of the present application. However, the present application can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of the present application, so the present application is not limited by the specific implementation disclosed below.
[0013] The terms used in one or more embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of the present application. The singular forms of "a", "said" and "the" used in one or more embodiments of the present application and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in one or more embodiments of the present application refers to and includes any or all possible combinations of one or more associated listed items.
[0014] It should be understood that, although the terms first, second, etc. may be used to describe various information in one or more embodiments of the present application, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of the present application, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0015] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards in the relevant regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0016] A simulation test environment is an environment that simulates the actual environment or specific conditions, and is used for further testing and verification before the software is delivered to customers. You can simulate various conditions that may occur in the actual production environment in the simulation test environment. For example, you can simulate various complex and extreme conditions (such as high load, low resources, etc.) to test the stability and performance of the software under these conditions, which helps to discover potential problems and risks.
[0017] The construction of the test environment is a high-cost link in realizing automated testing, especially the preparation of test data. Test data is the basis for executing test cases and directly affects the effectiveness and completeness of the test. In related technologies, the preparation of test data can be achieved by synchronizing online data and then modifying the synchronized data. However, such data preparation solutions are heavily dependent on business experience. For example, it is necessary to determine the scope of data that needs to be synchronized and how to modify the synchronized data based on business experience. As a result, the data preparation process is complicated, inefficient, and has extremely high labor costs.
[0018] In view of this, an embodiment of the present specification provides a solution for automatically implementing test data preparation according to pre-prepared data synchronization and data modification rules.
[0019] The technical solutions provided by the embodiments of this specification are described in detail below in conjunction with the accompanying drawings.
[0020] Figure 1 A schematic diagram of an application scenario of a method for generating test data provided in an embodiment of this specification.
[0021] like Figure 1As shown, in the production environment 110, the production server 112 can execute a business operation in response to a business request of the terminal device 111. In the process of executing the business operation, a database operation (e.g., a data creation operation, a data reading operation, a data update operation, a data deletion operation, etc.) is executed on the production database 113, thereby causing the data in the production database 113 to change.
[0022] In the embodiment of this specification, in order to achieve the purpose of testing, on the one hand, the request data under the production environment 110 can be synchronized to the test environment 120, specifically, the request data can be synchronized from the production server 112 to the test server 122 or the test database 123 corresponding to the test server 122, for generating a test request; on the other hand, the business data under the production environment 110 can be synchronized to the test environment 120, specifically, the post-execution data obtained after the database operation in the production database 113 can be synchronized to the test database 123, and then, the data inverse processing rules provided in the embodiment of this specification are used to process the post-execution data to obtain test data. Then, in the test environment 120, the program to be tested can be used to respond to the test request and perform corresponding test operations based on the test data, thereby obtaining the test execution result. Then, according to the test execution result, it is determined whether the program to be tested has passed the test.
[0023] The test request synchronized from the production environment 110 to the test environment 120 and the post-execution data synchronized from the production environment 110 to the test environment 120 may correspond to each other. Specifically, the post-execution data may be the post-execution data obtained by executing the corresponding database operation in response to the test request.
[0024] In an embodiment of the present specification, in the test environment 120, the data inverse processing rule used to process the post-execution data to obtain the test data may be a data inverse processing rule corresponding to the business type of the test request executed when generating the post-execution data. In an embodiment of the present specification, the data inverse processing rule corresponding to the target business type may actually be a data preparation rule for the test data used to test the program in the business scenario of the target business type. In the description of the present specification, the data inverse processing rule and the data preparation rule may represent substantially the same meaning.
[0025] Based on the scheme of the embodiments of this specification, the data preparation rules corresponding to the business scenarios of each business type can be determined in advance, and then, when the program needs to be tested, the pre-built data preparation rules can be used to automatically prepare the data. Specifically, it is possible to automatically obtain the business request information of the target business type and the post-execution data corresponding to the business request information from the online; then, the pre-built data preparation rules corresponding to the target business type can be used to automatically execute the acquired post-execution data to achieve the automated preparation of test data in the target business type scenario; further, in the simulation test environment, the business request information synchronized from the online production environment and the prepared test data can be used to achieve automated simulation testing of the program.
[0026] In the embodiments of the present specification, the data preparation rules can be used to generate reverse SQL instructions, and more specifically, can be used to generate reverse SQL instruction sequences. By executing the database operations indicated by these reverse SQL instruction sequences on the post-execution data, it is possible to roll back the post-execution data to the baseline data before the execution, that is, to achieve data preparation for simulation testing and provide conditions for automated simulation testing.
[0027] Based on the solution of the embodiments of the present specification, it is possible to pre-construct data preparation rules corresponding to each business type, and when an actual business request of the target business type occurs in the online production environment, synchronize the business request information in the online production environment and the post-execution data obtained by performing business operations in response to the actual business request to the simulation test environment, so that in the simulation test environment, the data preparation rules corresponding to the target business type can be used to automatically prepare test data, thereby automatically implementing simulation tests based on the prepared test data.
[0028] In such Figure 1 In the application scenario shown, the server 112 may be connected to one or more terminal devices 111 via a local area network connection, a wide area network connection, an Internet connection, or other types of data networks. Figure 1 The terminal device 111 may include but is not limited to a smart phone, a tablet computer, a laptop computer, a PDA, a personal computer, a smart home device, a vehicle-mounted device, etc. Figure 1 The server 112 or server 122 may include but is not limited to any device, equipment, platform, device cluster, etc. with computing and processing capabilities.
[0029] In the embodiments of this specification, a test data generating method is provided. The present application also relates to a test data generating apparatus and a test data generating device, which are described in detail one by one in the following embodiments.
[0030] Figure 2 A flowchart of a test data generation method provided in an embodiment of this specification.
[0031] From the program perspective, the execution subject of the process can be a program installed on the application server. It can be understood that the method can be executed by any device, equipment, platform, or device cluster with computing and processing capabilities.
[0032] Specifically, in the embodiments of this specification, the application server may specifically include a test server.
[0033] like Figure 2 As shown, the process may include the following steps: Step 202: Acquire execution result data obtained by executing a first database operation; the first database operation is a database operation executed by a first program in response to an online business request of a target business type; the first program is a first version of a target program.
[0034] In actual application, in an online production environment, a first version of a target program, or referred to as a first program, can be run. The first program can be a tested and online program. When the target program is modified for purposes such as program update or maintenance, a second version of a modified target program, or referred to as a second program, can be obtained. At this time, in order to ensure that the business functions of the modified second program are normal, it is necessary to perform a simulation test on the second program in a simulation test environment before putting the second program online. In an embodiment of the present specification, the second version can be a newer version than the first version, or in other words, the second version can be a modified version based on the first version.
[0035] When it is necessary to test the second program in a simulation test environment, the test can be implemented by making the second program execute the same business operation as the first program and comparing the business execution results, or in other words, the test can be implemented by making the second program receive a business request of the same business type as the first program. Therefore, the online business request sent to the first program recorded in step 202 can belong to the same business type as the test business request sent to the second program recorded in step 206, that is, both belong to the target business type. In an embodiment of the present specification, the business type can be the type of business handled by the target program, for example, it can include a registration business type, a login business type, a payment business type, an information push business type, etc., and is not limited to these examples. In actual application, the business type can be divided according to the key parameters carried in the business request (for example, the identifier of the called interface, the parameter name of the carried input parameter, etc.), so that when actually executed, the server can determine the business type of the business request according to the key parameters carried in the business request.
[0036] When testing the second program in a simulation test environment, the data that the second program relies on when executing business operations (including second database operations) can be generated based on the execution result data obtained at the database level after the online first program executes business operations (including first database operations). In other words, the test data of the second program can be prepared based on the execution result data obtained after the online first program executes the first database operation. In the embodiments of this specification, Figure 2 It shows a process of determining test data used for testing a second program in a simulation test environment based on execution result data obtained after an online first program executes a first database operation.
[0037] In an embodiment of the present specification, the first database operation may include at least one of a data creation operation (Create), a data reading operation (Read), a data update operation (Update), and a data deletion operation (Delete). Among them, the data creation operation can be used to add new records or data to the database, and usually involves an insert operation (INSERT) to store new data items in the database. The data read operation can be used to retrieve or query data from the database, and can be implemented through various query operations (such as SELECT) to retrieve data stored in the database. The data update operation can be used to modify existing records or data in the database, and usually involves an update operation (UPDATE) to change the value of existing data. The data deletion operation can be used to remove records or data from the database, and can be implemented through a delete operation (DELETE) to permanently remove data items from the database.
[0038] Step 204: Determine a reverse SQL instruction corresponding to the online service request of the target service type.
[0039] In an embodiment of the present specification, data preparation rules corresponding to each business type can be generated in advance. When it is necessary to prepare test data under the target business type, the data preparation rules corresponding to the target business type can be obtained, and the reverse SQL instructions corresponding to the target business type can be determined based on the data preparation rules corresponding to the target business type.
[0040] As described in step 204, the reverse SQL instruction corresponds to the online business request of the target business type, which means that the reverse SQL instruction can be used to reversely process the execution result data obtained by the first database operation executed in response to the online business request. It can be understood that, from another perspective, the reverse SQL instruction can correspond to the test business request of the target business type, which means that the reverse SQL instruction can be used to generate the test data required to be relied upon when executing the second database operation in response to the test business request.
[0041] The reverse SQL instruction in step 204 may specifically refer to a reverse SQL instruction sequence, which includes one or more reverse SQL instructions. In actual application, since the first database operation may correspond to a business SQL instruction sequence, that is, to one or more business SQL instructions, the second database operation for executing the execution result data obtained by executing the first database operation may be a reverse SQL instruction sequence, that is, to one or more reverse SQL instructions. And more specifically, each reverse SQL instruction in the reverse SQL instruction sequence may form a one-to-one correspondence with the corresponding business SQL instruction arranged in reverse order in the business SQL instruction sequence. That is, if the business SQL instructions in the business SQL instruction sequence are arranged in chronological order or execution order, for example, A, B, C..., then the reverse SQL instructions in the corresponding reverse SQL instruction sequence may be arranged in reverse order, for example, C', B', A'..., where C' is a reverse SQL instruction for canceling the C operation, B' is a reverse SQL instruction for canceling the B operation, and so on.
[0042] Step 206: Execute the second database operation indicated by the reverse SQL instruction on the execution result data to obtain test data; the test data is used when a second program in a simulation test environment executes a test business request of the target business type; the second program is the second version of the target program.
[0043] The second database operation includes at least one of a data creation operation (Create), a data reading operation (Read), a data update operation (Update), and a data deletion operation (Delete). In actual application, the second database operation may be the inverse operation of the first database operation. The meanings and functions of the data creation operation, the data reading operation, the data update operation, and the data deletion operation have been introduced above and will not be described in detail here.
[0044] It should be understood that in the methods described in one or more embodiments of this specification, the order of some steps can be adjusted according to actual needs, or some steps can be omitted.
[0045] Figure 2 The method obtains execution result data obtained after the first program executes the first database operation in response to the online business request of the target business type, and uses the reverse SQL instruction corresponding to the target business type to execute the second database operation on the execution result data, thereby obtaining test data for testing the second program of a different version from the first program in the same business scenario in a simulation test environment, thereby realizing the automatic preparation of test data without relying heavily on manual business experience, with low labor cost, simple and efficient process and high stability of the obtained data.
[0046] based on Figure 2 The present specification also provides some improved implementation methods of the method, which are described below.
[0047] In one or more embodiments of the present specification, a technical solution for determining a reverse SQL instruction is provided. The reverse SQL instruction can be used to execute a second database operation in response to an online business request to execute the execution result data obtained by executing the first database operation, so as to roll back the execution result data to the benchmark data before executing the first database operation, and the benchmark data can be used as test data for testing in a simulation test environment.
[0048] In actual application, the method for determining the reverse SQL instruction can be determined based on the execution information of the virtual business request executed in the simulation test environment. Specifically, in the simulation test environment, a small number of virtual business requests as samples can be sent to the first program, and the aspect data collection tool can be used to collect the execution information of the first program in response to the execution of these virtual business requests, and then the data reverse processing rules corresponding to the execution information can be determined by analyzing the execution information.
[0049] Based on this solution, for each business scenario (or business request of each business type), it is possible to collect aspect data based on a business request to obtain execution information, and then obtain the data inverse processing rules corresponding to the corresponding business scenario (or business request of the corresponding business type) by analyzing the execution information. In other words, it is possible to analyze a data inverse processing rule for inverse processing of dependent data involved in the database operation corresponding to the business request for a business request, and then apply the data inverse processing rule to other business requests of the same business type. In this way, it is possible to determine the data inverse processing rules corresponding to each business scenario at a relatively low operating cost.
[0050] Specifically, the method for determining a reverse SQL instruction may include: collecting a business SQL instruction corresponding to a third database operation, wherein the third database operation is a database operation performed on benchmark data in response to a virtual business request of the target business type; then, based on the business SQL instruction, determining a reverse SQL instruction corresponding to the business SQL instruction; the reverse SQL instruction is used to change the post-execution data generated by executing the third database operation to the benchmark data.
[0051] The virtual business request may be a business request of the target business type. The business SQL instruction corresponding to the third database operation may specifically include a business SQL instruction sequence, which may include one, two or more business SQL instructions that are executed in sequence to implement the business requested by the virtual business request.
[0052] In actual applications, in order to still be able to obtain the benchmark data on which the database operation depends when executing the database operation, database virtualization technology can be used to isolate the data after the database operation is executed from the benchmark data on which the database operation depends.
[0053] More specifically, the process of executing a third database operation in response to a virtual business request in a simulation test environment may include: in the simulation test environment, obtaining a virtual business request of the target business type; in response to the virtual business request, executing a third database operation on the benchmark data to obtain post-execution data; and storing the post-execution data separately from the benchmark data.
[0054] Among them, the virtual business request can carry a virtual identifier; the virtual identifier is used to indicate that the post-execution data generated when the business SQL instruction corresponding to the virtual business request is executed is stored separately from the benchmark data on which the execution of the business SQL instruction depends, so as to avoid the problem that the benchmark data on which the database operation depends cannot be obtained after the database operation corresponding to the business request is executed.
[0055] In one or more embodiments of the present specification, a technical solution is provided for determining a corresponding reverse SQL instruction for each business SQL instruction in the execution information.
[0056] Specifically, determining the reverse SQL instruction corresponding to the business SQL instruction based on the business SQL instruction may specifically include: parsing operation object information in the business SQL instruction; and generating the reverse SQL instruction corresponding to the business SQL instruction based on the operation object information.
[0057] The operation object may generally refer to a physical or logical entity in a database, such as a database, a table, a view, an index, a column (field), a data type, a stored procedure, a function, etc. In an embodiment of the present specification, the operation object may include at least one of a table and a column. Accordingly, the operation object information may include a table name or a column name. When the operation object information includes a column name, the operation object information may also include a value corresponding to the column name.
[0058] Optionally, the service SQL instruction may include a data insertion instruction, and correspondingly, the reverse SQL instruction may include a data deletion instruction.
[0059] Specifically, the parsing of the operation object information in the business SQL instruction specifically includes: parsing the forward data insertion instruction to determine the table name of the data table into which the data is to be inserted, the primary key column name of the data table, and the primary key column value corresponding to the primary key column name. Accordingly, the generating of the reverse SQL instruction corresponding to the business SQL instruction based on the operation object information specifically includes: generating a reverse data deletion instruction corresponding to the forward data insertion instruction based on the table name, the primary key column name, and the primary key column value; the reverse data deletion instruction is used to delete the data of the data row corresponding to the primary key column value.
[0060] In actual application, by parsing the operation object information in the forward data insertion instruction, the non-primary key column names of the data table and the values corresponding to the non-primary key column names can also be determined.
[0061] The forward data insertion instruction may specifically include an INSERT INTO statement. The INSERT INTO statement is used to insert a new data row into a data table. The format of the INSERT INTO statement may be as follows: INSERT INTO table_name(column1, column2, column3, ...) VALUES (value1, value2, value3, ...). INSERT INTO is followed by the table name and column name (column name is optional, if not specified, values must be provided for all columns); VALUES is followed by the values to be inserted, and the order of the values matches the order of the column names.
[0062] A practical example of a forward data insertion instruction is given here: INSERT INTO process_component(id, name, description) VALUES (123, '李四', '大学生'). Based on this SQL statement, an insertion operation can be performed to insert a new row of data into the process_component table. This row of data contains three fields: id (value: 123), name (value: 李四), and description (value: 大学生).
[0063] In this practical example, the operation object information obtained by parsing the forward data insertion instruction may include the table name process_component, the primary key column name id, and the primary key column value 123. This information can be used to construct a reverse data deletion instruction.
[0064] The reverse data deletion instruction may specifically include a DELETE statement. The DELETE statement is used to delete data from a database table. The format of the DELETE statement can be as follows: DELETE FROM table_name WHERE condition. Among them, the table name to delete records from is followed after DELETE FROM; the WHERE clause is used to specify which records need to be deleted.
[0065] Continuing with the above practical example of the forward data insertion instruction, based on the table name process_component, the primary key column name id, and the primary key column value 123, a reverse data deletion instruction can be generated: DELETE FROM process_component WHERE id = 123. This SQL statement can be used to delete all rows in the process_component table in the database where the value of the id column is equal to 123.
[0066] In the embodiments of the present specification, the words "forward" and "reverse" in the descriptions related to instructions are for the purpose of convenience of description, in order to distinguish one instruction from another. Generally, instructions for the purpose of business execution can be called "forward", and related instructions for the purpose of data rollback stage can be called "reverse". "Forward" and "reverse" do not constitute a limitation on the instruction structure. For example, the forward data insertion instruction may also be called a data insertion instruction; the reverse data deletion instruction may also be called a data deletion instruction. For another example, the forward data update instruction and the reverse data update instruction hereinafter may both be called data update instructions. For another example, the forward data query instruction hereinafter may also be called a data query instruction; the first reverse data insertion instruction may also be called a data insertion instruction. For another example, the forward data deletion instruction hereinafter may also be called a data deletion instruction; the second reverse data insertion instruction may also be called a data insertion instruction.
[0067] In one or more embodiments of the present specification, a technical solution for generating a reverse SQL instruction based on operation object information is also provided.
[0068] Specifically, generating a reverse SQL instruction corresponding to the business SQL instruction based on the operation object information may specifically include: first, generating a query SQL instruction based on the operation object information; the query SQL instruction is used to query the dependent data on which the execution of the business SQL instruction depends; then, using the query SQL instruction to query the dependent data required to execute the business SQL instruction from the benchmark data; thereafter, generating a reverse SQL instruction corresponding to the business SQL instruction based on the operation object information and the dependent data.
[0069] Optionally, the service SQL instruction may include a first data update instruction, and correspondingly, the reverse SQL instruction may include a second data update instruction.
[0070] Specifically, parsing the operation object information in the service SQL instruction may specifically include: parsing the forward data update instruction to determine the table name of the data table for updating data, the column name of the column to which the data to be updated belongs, and the update condition information that the row to which the data to be updated belongs should satisfy; correspondingly, generating a query SQL instruction based on the operation object information may specifically include: generating a first data query instruction corresponding to the forward data update instruction based on the table name and the update condition information; the first data query instruction is used to query the value before the update of the data to be updated; correspondingly, generating a reverse SQL instruction corresponding to the service SQL instruction based on the operation object information and the dependent data may specifically include: generating a reverse data update instruction corresponding to the forward data update instruction based on the table name, the column name of the column to which the data to be updated belongs, the value before the update of the data to be updated, and the update condition information; the reverse data update instruction is used to update the data to be updated to the value before the update.
[0071] In practical applications, by parsing the operation object information in the forward data update instruction, the value after the update of the data to be updated can also be determined.
[0072] Among them, the forward data update instruction may specifically include an UPDATE statement. The UPDATE statement is used to modify the data in the database table. The format of the UPDATE statement may be as follows: UPDATE table_name SET column1 = value1, column2 = value2,... WHERE condition. Among them, the table name to be modified is followed after UPDATE; SET specifies the columns to be modified and the new values; the WHERE clause is used to specify which records need to be updated.
[0073] Here is a practical example of the forward data update instruction: UPDATE process_component SET name = ‘张三’ WHERE id = 123. After executing this SQL statement, the name column of all rows with id = 123 in the process_component table will be updated to “张三”.
[0074] In this practical example, the operation object information obtained by parsing the forward data update instruction may include the table name process_component, the column name name of the column to which the updated data belongs, and the update condition information id = 123 that the row to which the updated data belongs should satisfy. These information can be used to construct the first data query instruction and the reverse data deletion instruction.
[0075] The first data query instruction may specifically include a SELECT statement. The SELECT statement is used to retrieve data from a database table. The format of the SELECT statement may be as follows: SELECT column1, column2, ... FROM table_nameWHERE condition ORDER BY column1 [ASC|DESC], column2 [ASC|DESC], .... SELECT is followed by the column name to be selected; FROM specifies which table to retrieve data from; WHERE is optional and is used to specify the condition for retrieving data; ORDER BY is also optional and is used to sort the results.
[0076] Following the actual example of the forward data update instruction above, the first data query instruction can be generated based on the table name process_component and the update condition information id=123: ELECT * FROM process_component WHERE id=123. This SQL statement indicates the execution of a query operation to retrieve data from all columns (indicated by *) in the process_component table, and specifically queries the data in the table that meets the condition "id=123", and more specifically, queries the data in the rows in the table where the value of the id column is equal to "123". Specifically, it can be found that in the row where the value of the id column is equal to 123, the value of the name column is, for example, "Li Si". Among them, "Li Si" is the value before the update obtained by the query.
[0077] The reverse data update instruction may specifically include an UPDATE statement.
[0078] Following the actual examples of the forward data update instruction and the first data query instruction above, the reverse data update instruction can be generated based on the table name process_component, the column name of the column to which the updated data belongs, the value before update "Li Si", and the update condition information id=123 that the row to which the updated data belongs should satisfy, as follows: UPDATE process_component SETname = 'Li Si' WHERE id=123. This SQL statement can be used to update the name column of all rows in the process_component table with id 123 to "Li Si".
[0079] Optionally, the business SQL instruction may include a data query instruction, and correspondingly, the reverse SQL instruction may include a data insertion instruction.
[0080] Specifically, the parsing of the operation object information in the business SQL instruction may specifically include: parsing the forward data query instruction to determine the table name of the data table of the queried data and the query condition information that the row to which the queried data belongs should satisfy; accordingly, generating the query SQL instruction based on the operation object information may specifically include: generating a second data query instruction corresponding to the forward data query instruction based on the table name and the query condition information; the second data query instruction is used to query the queried data; accordingly, generating the reverse SQL instruction corresponding to the business SQL instruction based on the operation object information and the dependent data may specifically include: generating a first reverse data insertion instruction corresponding to the forward data query instruction based on the table name, the query condition information and the queried data; the first reverse data insertion instruction is used to insert the queried data into the data table.
[0081] The forward data query instruction may specifically include a SELECT statement.
[0082] Here is a practical example of a forward data query instruction: SELECT * FROM process_component WHERE id=123. This SQL statement instructs to execute a query operation to retrieve data from all columns (indicated by *) in the process_component table, and specifically queries the data in the table that meets the condition "id=123", and more specifically, queries the data in the rows in the table where the value of the id column is equal to "123".
[0083] In this actual example, the operation object information obtained by parsing the forward data query instruction may include the table name process_component and the query condition information id=123, which may be used to construct the second data query instruction and the first reverse data insertion instruction.
[0084] The second data query instruction may specifically include a SELECT statement.
[0085] Following the actual example of the forward data query instruction above, a second data query instruction can be generated based on the table name process_component and the query condition information id=123: SELECT * FROM process_component WHEREid=123. In an embodiment of the present specification, the second data query instruction can be the same as the forward data query instruction. The SQL instruction indicates to execute a query operation to retrieve data of all columns (indicated by *) from the process_component table, and specifically queries the data in the table that meets the condition "id=123", and more specifically, queries the data in the rows in the table whose id column value is equal to "123".
[0086] In actual application, if there are multiple columns in the table (such as name column, description column, etc.), and there is at least one row whose id column value is 123, then the query result will include all column data of this row (that is, the value of the name column, the value of the description column, etc. corresponding to the row whose id column value is 123). If there is no row in the table whose id column value is 123, then the query result will be empty. Assume that, according to id=123, the value of the name column is "Li Si" and the value of the description column is "College Student" in the process_component table, then the queried data can include the value of the name column "Li Si" and the value of the description column "College Student".
[0087] The first reverse data insertion instruction may specifically include an INSERT INTO statement.
[0088] Following the actual examples of the forward data query instruction and the second data query instruction above, the first reverse data insertion instruction can be generated based on the table name process_component, the query condition information (the value of the id column is 123) and the queried data (the value of the name column is "Li Si" and the value of the description column is "College Student"): INSERT INTOprocess_component (id, name, description) VALUES (123, 'Li Si', 'College Student'). This SQL statement can be used to indicate an insert operation to insert a row of data into the process_component table. The row of data contains three fields: id (value: 123), name (value: Li Si) and description (value: College Student).
[0089] Optionally, the service SQL instruction may include a data deletion instruction, and correspondingly, the reverse SQL instruction may include a data insertion instruction.
[0090] Specifically, the parsing of the operation object information in the business SQL instruction may include: parsing the forward data deletion instruction to determine the table name of the data table of the deleted data and the deletion condition information that the row to which the deleted data belongs should satisfy; accordingly, generating the query SQL instruction based on the operation object information may include: generating a third data query instruction corresponding to the forward data deletion instruction based on the table name and the deletion condition information; the third data query instruction is used to query the deleted data; accordingly, generating the reverse SQL instruction corresponding to the business SQL instruction based on the operation object information and the dependent data may include: generating a second reverse data insertion instruction corresponding to the forward data deletion instruction based on the table name, the deletion condition information and the deleted data; the second reverse data insertion instruction is used to insert the deleted data into the data table.
[0091] The forward data deletion instruction may specifically include a DELETE statement.
[0092] Here is a practical example of a forward data deletion instruction: DELETE FROM process_componentWHERE id=123. This SQL statement indicates that all rows in the process_component table whose id column value is equal to 123 will be deleted from the database.
[0093] In this actual example, the operation object information obtained by parsing the forward data deletion instruction may include the table name process_component and the deletion condition information id=123, which can be used to construct the third data query instruction and the second reverse data insertion instruction.
[0094] The third data query instruction may specifically include a SELECT statement.
[0095] Following the actual example of the forward data deletion instruction above, the third data query instruction can be generated based on the table name process_component and the deletion condition information id=123: SELECT * FROM process_component WHEREid=123. This SQL instruction indicates the execution of a query operation to retrieve data of all columns (indicated by *) from the process_component table, and specifically queries the data in the table that meets the condition "id=123", and more specifically, queries the data in the rows in the table where the value of the id column is equal to "123".
[0096] In actual application, if there are multiple columns in the table (such as name column, description column, etc.), and there is at least one row whose id column value is 123, then the query result will include all column data of this row (that is, the value of the name column, the value of the description column, etc. corresponding to the row whose id column value is 123). If there is no row in the table whose id column value is 123, then the query result will be empty. Assume that, according to id=123, the value of the name column is "Li Si" and the value of the description column is "College Student" in the process_component table, then the deleted data may include the value of the name column "Li Si" and the value of the description column "College Student".
[0097] The second reverse data insertion instruction may specifically include an INSERT INTO statement.
[0098] Following the actual examples of the forward data deletion instruction and the third data query instruction above, the second reverse data insertion instruction can be generated based on the table name process_component, the deletion condition information (the value of the id column is 123) and the deleted data (the value of the name column is "Li Si" and the value of the description column is "College Student"): INSERT INTOprocess_component (id, name, description) VALUES (123, 'Li Si', 'College Student'). This SQL statement can be used to indicate an insert operation to insert a row of data into the process_component table. The row of data contains three fields: id (value: 123), name (value: Li Si) and description (value: College Student).
[0099] In one or more embodiments of the present specification, in order to avoid risks in the data reverse processing process, the data reverse processing conditions can be verified during the analysis of the business SQL instructions, and a risk warning can be issued if the verification result indicates that there is a risk.
[0100] Specifically, in the process of analyzing the business SQL instruction, it can also include: determining whether the data table of the executed data has a unique key; if the data table of the reference data does not have a unique key, generating risk warning information, the risk warning information is used to prompt that the reverse SQL instruction generated for the executed data has the risk of execution error. The risk warning information can be used to provide business personnel together with the reverse SQL instruction.
[0101] In a data table, a unique key can be used to point to certain data in the data table. A unique key can contain one or more columns. When a unique key contains one column, it is also called a primary key, which is used to ensure the uniqueness of the data indicated. When a unique key contains multiple columns, the combined value of the multiple columns is unique, which is used to ensure the uniqueness of the data indicated by the unique key.
[0102] In one or more embodiments of the present specification, a technical solution is provided for executing a test based on the test data after the test data is prepared.
[0103] Specifically, after obtaining the test data, it may also include: in the simulation test environment, in response to the test business request of the target business type, using the second program to perform business operations based on the test data to obtain a first business execution result; then, the test result of the second program can be determined based on the first business execution result.
[0104] Specifically, it can be determined whether the first business execution result meets expectations. If the first business execution result meets expectations, the test result of the second program is test passed; if the first business execution result does not meet expectations, the test result of the second program is test failed.
[0105] More specifically, it can be determined whether the first business execution result is consistent with the second business execution result to obtain a judgment result, wherein the second business execution result is a business execution result obtained by using the first program to perform a business operation in response to an online business request of the target business type in a production environment; if the judgment result indicates that the first business execution result is consistent with the second business execution result, it is determined that the second program has passed the test; if the judgment result indicates that the first business execution result is inconsistent with the second business execution result, it is determined that the second program has failed the test.
[0106] In actual application, the test service request may include multiple service requests. As an example, determining whether they are consistent may be determining whether the consistent result meets a preset threshold. For example, meeting the preset threshold may indicate that the consistent ratio is greater than a preset ratio; for another example, meeting the preset threshold may indicate whether all are consistent, that is, there is no inconsistency.
[0107] The various technical features in the above embodiments can be combined arbitrarily as long as there is no conflict or contradiction between the combinations of features. However, due to space limitations, they are not described one by one. Therefore, any combination of the various technical features in the above embodiments also falls within the scope of this specification.
[0108] According to the above description, the overall flow diagram of the technical solution for determining data generation rules and preparing simulation test data using the data generation rules in an actual application scenario provided by the embodiment of this specification is as follows: Figure 3 shown.
[0109] In the first stage, data generation rules can be determined. For different business scenarios, data generation rules corresponding to each business scenario can be determined.
[0110] like Figure 3 As shown in , assuming a certain business scenario, when responding to a business request in the business scenario, service A and service B can be executed in sequence. For example, the interface for providing service A and the interface for providing service B can be called in sequence. Of course, the services provided in response to the business request given here are only examples. In actual application, when performing a business operation for a business request, one service, two services, or multiple services may be involved. In actual application, different business scenarios can be identified by different types of business requests. More specifically, different business types of requests can be identified by different key parameters carried in the business request to reflect different business scenarios.
[0111] like Figure 3 As shown in , the pre-change DB may refer to the baseline data before executing the program corresponding to service A or B, also known as the pre-request baseline DB; the post-change DB may refer to the data after executing the program corresponding to service A or B, also known as the post-request DB. DB is the abbreviation of Database. Figure 3 In the description, DB may specifically represent database data.
[0112] In the embodiments of the present specification, the scheme for determining data generation rules can be implemented in a simulation test environment. In the stage of determining data generation rules, the programs of service A and service B can be the same programs that have been tested and used in the production environment. In addition, in the stage of determining data generation rules, the data in the DB before the change can be synchronized from the online production environment to the simulation test environment, and can be the same data that the program relies on when executing service A and service B in the online production environment.
[0113] In practical applications, such as Figure 3As shown in . First, the pre-change DB of the target business scenario to be analyzed can be synchronized from the online production environment to the simulation test environment as the pre-request benchmark DB; then, a business request under the target business scenario can be initiated in the simulation test environment, and the database operation corresponding to the business request is executed based on the pre-request benchmark DB to generate the post-request DB; at this time, on the one hand, due to the use of DB virtualization technology, the post-request DB can be stored in a manner isolated from the pre-request benchmark DB; on the other hand, in the process of executing the database operation corresponding to the business request, the execution information of the database operation can be collected through the aspect data collection tool, for example, the SQL instructions corresponding to the database operations such as Create, Read, Update, and Delete can be collected; then, the dependent data required to execute the business request can be determined by analyzing the collected execution information.
[0114] Furthermore, in the process of determining dependent data based on execution information, the following processing can be performed for each business SQL instruction in the execution information. First, the business SQL instruction can be parsed to determine the operation object information of the business SQL instruction; then, the reverse SQL instruction corresponding to the business SQL instruction can be determined based on the operation object information. In actual application, by determining the corresponding reverse SQL instruction for each business SQL instruction in the business SQL instruction sequence used in the business execution process, a reverse SQL instruction sequence corresponding to the business SQL instruction sequence can be obtained. Finally, a data generation rule can be generated based on the reverse SQL instruction sequence, and the generated data generation rule can be marked as corresponding to the business scenario to be analyzed, so as to be used for subsequent test data preparation under the business scenario.
[0115] Optionally, the process of generating data generation rules based on the reverse SQL instruction sequence may specifically include, for a reverse SQL instruction sequence composed of at least one reverse SQL instruction executed on the DB after the online request, a reverse SQL instruction template corresponding to each reverse SQL instruction in the reverse SQL instruction sequence may be determined to obtain a reverse SQL instruction template sequence, wherein each reverse SQL instruction template in the reverse SQL instruction template sequence corresponds one-to-one with each reverse SQL instruction in the reverse SQL instruction sequence in a forward order. Compared with the reverse SQL instruction, the corresponding reverse SQL instruction template removes business parameters related to a single business request, such as user identification, order identification and other information, so that the reverse SQL instruction template can be applied to perform reverse operations on the DB after the request corresponding to different test requests.
[0116] In the second stage, simulation test data can be prepared while executing online services.
[0117] For the target business scenario to be analyzed, automated data preparation can be performed based on the data generation rules determined in the first stage, thereby achieving automated simulation testing of the program under the target business scenario.
[0118] In an embodiment of the present specification, the scheme for preparing simulation test data can be implemented in a simulation test environment. Among them, in the stage of preparing simulation test data, the programs of service A and service B can be programs to be tested, which are different versions of the programs used in the online production environment. Specifically, the first version of the target program, or the first program, can be used in the online production environment; the second version of the target program, or the second program, can be used in the simulation test environment. Moreover, in the stage of preparing simulation test data, the data in the changed DB can be synchronized from the online production environment to the simulation test environment, and can be the same as the DB data after the online request obtained after the first version of the program of service A and service B performs database operations online in response to business requests.
[0119] In practical applications, such as Figure 3 As shown in, when a real business request in a business scenario to be analyzed occurs online, on the one hand, the real business request information can be synchronized to the simulation test environment as test request information. Optionally, part of the business request information can be screened out from the real business request information and synchronized to the simulation test environment as test request information; on the other hand, the DB after the online request corresponding to the part of the real business request synchronized as the test request can be synchronized to the simulation test environment.
[0120] Then, the data generation rules corresponding to the business scenario determined in the first stage can be obtained, and the data generation rules can be applied to perform reverse database operations on the DB after the online request synchronized from the online production environment to obtain the reference DB before the online request. Specifically, the reverse SQL instruction template sequence can be spliced with the business parameters in the synchronized test request information to obtain a reverse SQL instruction sequence for performing reverse database operations; then, the reverse database operations indicated by the reverse SQL instruction sequence can be performed on the DB after the online request, thereby obtaining the reference DB before the online request as simulation test data.
[0121] In the third stage, simulation testing can be performed based on the test data generated in the second stage and the test request information synchronously obtained from the online production environment in the second stage.
[0122] Specifically, in the simulation test environment, the test request information synchronized from the online production environment to the simulation test environment in the second stage can be used to send a simulation test request to the second program to be tested. The second program can perform business operations based on the simulation test data obtained in the second stage (in fact, the same as the benchmark DB before the online request) to obtain the test execution result. In addition, the online execution result can be obtained, which is obtained by the first program performing business operations based on the benchmark DB before the online request in response to the real business request in the online production environment. Then, the test execution result can be compared with the online execution result to obtain a comparison result, and it can be determined whether the second program has passed the test based on the comparison result.
[0123] In actual application, if the first program is updated to the second program without affecting the normal execution of the original business function, then, based on the same benchmark DB before the online request and responding to the same test request information, the online execution result obtained should be consistent with the test execution result. Therefore, it is possible to determine whether the second program has passed the test by judging whether the comparison test execution result is consistent with the online execution result. If it is consistent, the test is passed, and if it is inconsistent, the test fails. The comparison test execution result is consistent with the online execution result, which may include that the test execution result may be the same as the corresponding online execution result, or may include that the test execution result may at least cover the corresponding online execution result. Among them, the test execution result covering the online execution result may indicate that the business result originally included in the online execution result also exists in the test execution result. Optionally, the test execution result may also include additional business content in addition to the business results included in the online execution result, and these additional business contents may be related to the newly added or improved functions of the second program compared to the first program. In this way, if the comparison test execution result is consistent with the online execution result, it can at least be explained that the target program will be updated from the first version of the first program to the second version of the second program, which will not affect the realization of the original business function of the first program.
[0124] Based on the same idea, the embodiments of this specification also provide a device corresponding to the above method.
[0125] Figure 4 The embodiments of this specification provide corresponding to Figure 2 A structural schematic diagram of a test data generating device.
[0126] like Figure 4 As shown, the device may include: An execution result data acquisition module 402 is used to acquire execution result data obtained by executing a first database operation; the first database operation is a database operation executed by a first program in response to an online business request of a target business type; the first program is a first version of a target program; A reverse SQL instruction determination module 404, configured to determine a reverse SQL instruction corresponding to the online service request of the target service type; The test data generation module 406 is used to perform the second database operation indicated by the reverse SQL instruction on the execution result data to obtain test data; the test data is used when a second program in a simulation test environment executes a test business request of the target business type; the second program is the second version of the target program.
[0127] based on Figure 4 The present specification also provides some specific implementation schemes of the method, which are described below.
[0128] Optionally, the test data generating device may also include: a business SQL instruction collection module, used to collect business SQL instructions corresponding to a third database operation; the third database operation is a database operation performed on the benchmark data in response to a virtual business request of the target business type; and a reverse SQL instruction generation module, used to determine a reverse SQL instruction corresponding to the business SQL instruction based on the business SQL instruction; the reverse SQL instruction is used to change the post-execution data generated by executing the third database operation to the benchmark data.
[0129] Optionally, the test data generating device may also include: a virtual business request acquisition module, used to obtain a virtual business request of the target business type in a simulation test environment; a virtual business execution module, used to perform a third database operation on the benchmark data in response to the virtual business request to obtain post-execution data; and a post-execution data storage module, used to store the post-execution data separately from the benchmark data.
[0130] Optionally, the reverse SQL instruction generation module may specifically include: a SQL instruction parsing unit, used to parse the operation object information in the business SQL instruction; and a reverse SQL instruction generation unit, used to generate a reverse SQL instruction corresponding to the business SQL instruction based on the operation object information.
[0131] Optionally, the SQL instruction parsing unit is specifically used to: parse the forward data insertion instruction to determine the table name of the data table into which the data is to be inserted, the primary key column name of the data table, and the primary key column value corresponding to the primary key column name; the reverse SQL instruction generating unit is specifically used to: generate a reverse data deletion instruction corresponding to the forward data insertion instruction based on the table name, the primary key column name, and the primary key column value; the reverse data deletion instruction is used to delete the data of the data row corresponding to the primary key column value.
[0132] Optionally, the reverse SQL instruction generation unit may specifically include: a query SQL instruction generation subunit, used to generate a query SQL instruction based on the operation object information; the query SQL instruction is used to query the dependent data on which the execution of the business SQL instruction depends; a dependent data query subunit, used to use the query SQL instruction to query the dependent data required to execute the business SQL instruction from the benchmark data; a reverse SQL instruction generation subunit, used to generate a reverse SQL instruction corresponding to the business SQL instruction based on the operation object information and the dependent data.
[0133] Optionally, the SQL instruction parsing unit can be specifically used to: parse the forward data update instruction to determine the table name of the data table of the updated data, the column name of the column to which the updated data belongs, and the update condition information that the row to which the updated data belongs should satisfy; accordingly, the query SQL instruction generating subunit can be specifically used to: generate a first data query instruction corresponding to the forward data update instruction based on the table name and the update condition information; the first data query instruction is used to query the pre-update value of the updated data; accordingly, the reverse SQL instruction generating subunit can be specifically used to: generate a reverse data update instruction corresponding to the forward data update instruction based on the table name, the column name of the column to which the updated data belongs, the pre-update value of the updated data, and the update condition information; the reverse data update instruction is used to update the updated data to the pre-update value.
[0134] Optionally, the SQL instruction parsing unit can be specifically used to: parse the forward data query instruction to determine the table name of the data table of the queried data and the query condition information that the row to which the queried data belongs should satisfy; accordingly, the query SQL instruction generating subunit can be specifically used to: generate a second data query instruction corresponding to the forward data query instruction based on the table name and the query condition information; the second data query instruction is used to query the queried data; accordingly, the reverse SQL instruction generating subunit can be specifically used to: generate a first reverse data insertion instruction corresponding to the forward data query instruction based on the table name, the query condition information and the queried data; the first reverse data insertion instruction is used to insert the queried data into the data table.
[0135] Optionally, the SQL instruction parsing unit can be specifically used to: parse the forward data deletion instruction to determine the table name of the data table of the deleted data and the deletion condition information that the row to which the deleted data belongs should satisfy; accordingly, the query SQL instruction generating subunit can be specifically used to: generate a third data query instruction corresponding to the forward data deletion instruction based on the table name and the deletion condition information; the third data query instruction is used to query the deleted data; accordingly, the reverse SQL instruction generating subunit can be specifically used to: generate a second reverse data insertion instruction corresponding to the forward data deletion instruction based on the table name, the deletion condition information and the deleted data; the second reverse data insertion instruction is used to insert the deleted data into the data table.
[0136] Optionally, the test data generating device can also be used to: determine whether the data table of the post-execution data has a unique key; if the data table of the benchmark data does not have a unique key, generate risk warning information; the risk warning information is used to prompt that the reverse SQL instructions generated for the post-execution data have the risk of execution errors.
[0137] Optionally, the test data generating device can also be used to: in the simulation test environment, in response to the test business request of the target business type, use the second program to perform a business operation based on the test data to obtain a first business execution result; determine whether the first business execution result is consistent with the second business execution result to obtain a judgment result; wherein the second business execution result is a business execution result obtained by using the first program to perform a business operation in response to an online business request of the target business type in a production environment; if the judgment result indicates that the first business execution result is consistent with the second business execution result, it is determined that the second program has passed the test; if the judgment result indicates that the first business execution result is inconsistent with the second business execution result, it is determined that the second program has failed the test.
[0138] It is understood that the above modules refer to computer programs or program segments for executing one or more specific functions. In addition, the distinction between the above modules does not mean that the actual program codes must also be separated.
[0139] The above is a schematic scheme of a test data generation device of this embodiment. It should be noted that the technical scheme of the test data generation device and the technical scheme of the test data generation method described above belong to the same concept, and the details not described in detail in the technical scheme of the test data generation device can be referred to the description of the technical scheme of the test data generation method described above.
[0140] Based on the same idea, the embodiments of this specification also provide a device corresponding to the above method.
[0141] Figure 5 The embodiments of this specification provide corresponding to Figure 2 A schematic diagram of the structure of a test data generating device. Figure 5 As shown, the device 500 may include: at least one processor 510; and, A memory 530 in communication with the at least one processor; wherein, The memory 530 stores instructions 520 executable by the at least one processor 510. The instructions are executed by the at least one processor 510 to enable the at least one processor 510 to: Acquire execution result data obtained by executing a first database operation; the first database operation is a database operation executed by a first program in response to an online business request of a target business type; the first program is a first version of a target program; Determine a reverse SQL instruction corresponding to the online service request of the target service type; The second database operation indicated by the reverse SQL instruction is performed on the execution result data to obtain test data; the test data is used when a second program in a simulation test environment executes a test business request of the target business type; the second program is a second version of the target program.
[0142] The above is a schematic scheme of a computing device of this embodiment. It should be noted that the technical scheme of the computing device and the technical scheme of the test data generation method described above are of the same concept, and the details not described in detail in the technical scheme of the computing device can be found in the description of the technical scheme of the test data generation method described above.
[0143] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other. Each embodiment focuses on the differences from other embodiments. In particular, for the device and equipment embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments. The devices, equipment and methods provided in the embodiments of this specification correspond to each other, so the devices and equipment also have beneficial technical effects similar to the corresponding methods. Since the beneficial technical effects of the methods have been described in detail above, the beneficial technical effects of the corresponding devices and equipment will not be repeated here.
[0144] The above describes specific embodiments of the present application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0145] In the 1990s, it was very clear whether the improvement of a technology was hardware improvement (for example, improvement of the circuit structure of diodes, transistors, switches, etc.) or software improvement (improvement of the method flow). However, with the development of technology, many improvements of the method flow today can be regarded as direct improvements of the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that the improvement of a method flow cannot be implemented with a hardware entity module. For example, a programmable logic device (PLD) (such as a field programmable gate array (FPGA)) is such an integrated circuit whose logical function is determined by the user's programming of the device. Designers can "integrate" a digital system on a PLD by programming themselves, without having to ask chip manufacturers to design and make dedicated integrated circuit chips. Moreover, nowadays, instead of manually making integrated circuit chips, this kind of programming is mostly implemented by "logic compiler" software, which is similar to the software compiler used when developing and writing programs, and the original code before compilation must also be written in a specific programming language, which is called hardware description language (HDL). There is not only one kind of HDL, but many kinds, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones are VHDL (Very-High-Speed Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also know that it is only necessary to program the method flow slightly in the above-mentioned hardware description languages and program it into the integrated circuit, and then it is easy to obtain the hardware circuit that implements the logic method flow.
[0146] The controller may be implemented in any suitable manner, for example, the controller may take the form of a microprocessor or processor and a computer-readable medium storing a computer-readable program code (e.g., software or firmware) executable by the (micro)processor, a logic gate, a switch, an application-specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller, examples of which include but are not limited to the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320, and the memory controller may also be implemented as part of the control logic of the memory. It is also known to those skilled in the art that, in addition to implementing the controller in a purely computer-readable program code manner, the controller may be implemented in the form of a logic gate, a switch, an application-specific integrated circuit, a programmable logic controller, and an embedded microcontroller by logically programming the method steps. Therefore, such a controller may be considered as a hardware component, and the devices for implementing various functions included therein may also be considered as structures within the hardware component. Or even, the devices for implementing various functions may be considered as both software modules for implementing the method and structures within the hardware component.
[0147] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
[0148] For the convenience of description, the above device is described in various units according to their functions. Of course, when implementing the present application, the functions of each unit can be implemented in the same or multiple software and / or hardware.
[0149] It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0150] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0151] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0152] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0153] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0154] Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.
[0155] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disc read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined in this article, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0156] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0157] The present application may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.
[0158] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.
Claims
1. A test data generation method, comprising: Obtaining execution result data obtained by executing the first database operation; The first database operation is a database operation performed by the first program in response to an online business request of a target business type; the first program is a first version of the target program; Determine a reverse SQL instruction corresponding to the online service request of the target service type; The second database operation indicated by the reverse SQL instruction is performed on the execution result data to obtain test data; the test data is used when a second program in a simulation test environment executes a test business request of the target business type; the second program is a second version of the target program.
2. The method of claim 1, further comprising: Collecting a business SQL instruction corresponding to a third database operation; the third database operation is a database operation performed on the benchmark data in response to a virtual business request of the target business type; Based on the business SQL instruction, a reverse SQL instruction corresponding to the business SQL instruction is determined; the reverse SQL instruction is used to change the post-execution data generated by executing the third database operation to the benchmark data.
3. The method of claim 2, further comprising: In a simulation test environment, obtaining a virtual service request of the target service type; In response to the virtual service request, executing a third database operation on the benchmark data to obtain executed data; The post-execution data is stored separately from the baseline data.
4. The method according to claim 2, wherein determining a reverse SQL instruction corresponding to the business SQL instruction based on the business SQL instruction specifically comprises: Parsing the operation object information in the business SQL instruction; Based on the operation object information, a reverse SQL instruction corresponding to the business SQL instruction is generated.
5. The method according to claim 4, wherein the parsing of the operation object information in the business SQL instruction specifically comprises: Parse the forward data insertion instruction to determine the table name of the data table into which the data is to be inserted, the primary key column name of the data table, and the primary key column value corresponding to the primary key column name; The generating, based on the operation object information, a reverse SQL instruction corresponding to the business SQL instruction specifically includes: Based on the table name, the primary key column name and the primary key column value, generating a reverse data deletion instruction corresponding to the forward data insertion instruction; The reverse data deletion instruction is used to delete the data of the data row corresponding to the primary key column value.
6. The method according to claim 4, wherein generating a reverse SQL instruction corresponding to the business SQL instruction based on the operation object information specifically comprises: Generate a query SQL instruction based on the operation object information; The query SQL instruction is used to query the dependent data on which the execution of the business SQL instruction depends; Using the query SQL instruction to query the dependent data required to execute the business SQL instruction from the benchmark data; Based on the operation object information and the dependent data, a reverse SQL instruction corresponding to the business SQL instruction is generated.
7. The method according to claim 6, wherein the parsing of the operation object information in the business SQL instruction specifically comprises: Parse the forward data update instruction to determine the table name of the data table of the updated data, the column name of the column to which the updated data belongs, and the update condition information that the row to which the updated data belongs should satisfy; The generating of the query SQL instruction based on the operation object information specifically includes: generating a first data query instruction corresponding to the forward data update instruction based on the table name and the update condition information; the first data query instruction is used to query the pre-update value of the updated data; The generating of a reverse SQL instruction corresponding to the business SQL instruction based on the operation object information and the dependent data specifically includes: generating a reverse data update instruction corresponding to the forward data update instruction based on the table name, the column name of the column to which the updated data belongs, the pre-update value of the updated data, and the update condition information; the reverse data update instruction is used to update the updated data to the pre-update value.
8. The method according to claim 6, wherein parsing the operation object information in the business SQL instruction specifically comprises: Parse the forward data query instruction to determine the table name of the data table of the queried data and the query condition information that the row of the queried data should satisfy; The generating of the query SQL instruction based on the operation object information specifically includes: generating a second data query instruction corresponding to the forward data query instruction based on the table name and the query condition information; the second data query instruction is used to query the queried data; The generating of a reverse SQL instruction corresponding to the business SQL instruction based on the operation object information and the dependent data specifically includes: generating a first reverse data insertion instruction corresponding to the forward data query instruction based on the table name, the query condition information and the queried data; the first reverse data insertion instruction is used to insert the queried data into the data table.
9. The method according to claim 6, wherein parsing the operation object information in the business SQL instruction specifically comprises: Parse the forward data deletion instruction to determine the table name of the data table of the deleted data and the deletion condition information that the row to which the deleted data belongs should satisfy; The generating of the query SQL instruction based on the operation object information specifically includes: generating a third data query instruction corresponding to the forward data deletion instruction based on the table name and the deletion condition information; the third data query instruction is used to query the deleted data; The generating of a reverse SQL instruction corresponding to the business SQL instruction based on the operation object information and the dependent data specifically includes: generating a second reverse data insertion instruction corresponding to the forward data deletion instruction based on the table name, the deletion condition information and the deleted data; the second reverse data insertion instruction is used to insert the deleted data into the data table.
10. The method of claim 2, further comprising: Determine whether the data table of the executed data has a unique key; If the data table of the benchmark data does not have a unique key, generating risk warning information; The risk warning information is used to prompt that there is a risk of execution error in the reverse SQL instruction generated for the post-execution data.
11. The method according to claim 1, after obtaining the test data, further comprising: In the simulation test environment, in response to the test service request of the target service type, using the second program to perform a service operation based on the test data to obtain a first service execution result; Determine whether the first business execution result is consistent with the second business execution result, and obtain a determination result; wherein the second business execution result is a business execution result obtained by using the first program to perform a business operation in response to an online business request of the target business type in a production environment; If the judgment result indicates that the first service execution result is consistent with the second service execution result, determining that the second program passes the test; If the judgment result indicates that the first service execution result is inconsistent with the second service execution result, it is determined that the second program fails the test.
12. A test data generating device, comprising: An execution result data acquisition module, used to acquire execution result data obtained by executing the first database operation; The first database operation is a database operation performed by the first program in response to an online business request of a target business type; the first program is a first version of the target program; A reverse SQL instruction determination module, used to determine a reverse SQL instruction corresponding to the online service request of the target service type; A test data generation module is used to perform the second database operation indicated by the reverse SQL instruction on the execution result data to obtain test data; the test data is used when a second program in a simulation test environment executes a test business request of the target business type; the second program is the second version of the target program.
13. A test data generating device, comprising: at least one processor; as well as, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to: Acquire execution result data obtained by executing a first database operation; the first database operation is a database operation executed by a first program in response to an online business request of a target business type; the first program is a first version of a target program; Determine a reverse SQL instruction corresponding to the online service request of the target service type; The second database operation indicated by the reverse SQL instruction is performed on the execution result data to obtain test data; the test data is used when a second program in a simulation test environment executes a test business request of the target business type; the second program is a second version of the target program.
