Pre-data construction method, device, storage medium and program product

By analyzing the log data of the application services and database, determining the correspondence between the business logic and the data table and generating reverse restore statements, the problems of low efficiency and poor comprehensiveness of the pre-data construction in the prior art are solved, and an efficient and reliable pre-data construction is achieved.

CN119357161BActive Publication Date: 2025-03-21HUNDSUN TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411896852.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-23
Publication Date
2025-03-21
Estimated Expiration
2044-12-23

AI Technical Summary

Technical Problem

In the prior art, the pre-data construction method depends on the experience and ability of the tester, resulting in low construction efficiency, poor comprehensiveness, and easy to miss or errors.

Method used

By determining the log data of the application service and database, determining the correspondence between the business logic and the data table, and generating a reverse restore statement, thereby constructing the pre-data corresponding to the business logic.

Benefits of technology

The construction process of pre-data is simplified, the construction efficiency is improved, the maintainability of test cases is enhanced, manual intervention is reduced, and the reliability and accuracy of pre-data is ensured.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119357161B_ABST
    Figure CN119357161B_ABST
Patent Text Reader

Abstract

The present application provides a method, device, storage medium and program product for constructing pre-data, wherein the method includes: determining multiple first log data of an application service and multiple second log data of a database; determining the correspondence between business logic and a data table according to the multiple first log data and the multiple second log data; generating a reverse restore statement corresponding to each second log data according to each second log data; constructing the pre-data corresponding to the business logic according to the reverse restore statement corresponding to each second log data and the correspondence between the business logic and the data table. The present application only needs to construct the pre-data through the log data of the application service and the log data of the database during the runtime of the business logic, which simplifies the construction process of the pre-data, improves the construction efficiency of the pre-data, enhances the maintainability of the test case, and also ensures the reliability of the obtained pre-data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of automated testing technology, and in particular to a method, device, storage medium and program product for constructing pre-data. Background Art

[0002] In software automation testing technology, in order for automated test cases to be run repeatedly, a lot of test data needs to be constructed for the software interface under test before it is called. This process is generally called pre-data construction.

[0003] The prior art method for constructing pre-data usually constructs data by manually writing a structured query language (SQL) script. Specifically, testers extract persistence-related data tables in the software interface implementation logic based on their own business experience and understanding of software codes, write SQL scripts, and execute SQL scripts to insert, update, or delete records in the data table to construct pre-data.

[0004] However, this method of constructing pre-data relies on the experience and ability of testers, and has very high requirements on the business understanding and SQL writing skills of testers. It is also very likely to be missed or make mistakes. At the same time, it needs to be improved through repeated debugging, which results in a large workload, low writing efficiency, low construction efficiency and poor comprehensiveness. Summary of the invention

[0005] The purpose of this application is to provide a method, device, storage medium and program product for constructing pre-data in order to address the deficiencies in the above-mentioned prior art, so as to solve the problems of low construction efficiency and poor comprehensiveness in the process of constructing pre-data in the prior art.

[0006] To achieve the above purpose, the technical solution adopted in the embodiment of the present application is as follows:

[0007] In a first aspect, an embodiment of the present application provides a method for constructing preamble data, the method comprising:

[0008] Determine a plurality of first log data of the application service and a plurality of second log data of the database, each of the first log data includes: first time information, an identifier of the business logic, and an identifier of the operation interface, and each of the second log data includes: second time information, an identifier of an operation object, and operation information, and the operation object includes: an operated data table and an operated field in the data table;

[0009] Determining a correspondence between the business logic and the data table according to the plurality of first log data and the plurality of second log data;

[0010] Generate a reverse restore statement corresponding to each piece of second log data according to each piece of second log data;

[0011] According to the reverse restoration statements corresponding to each piece of second log data and the corresponding relationship between the business logic and the data table, the pre-data corresponding to the business logic are constructed.

[0012] In a second aspect, another embodiment of the present application provides a pre-data construction device, the device comprising:

[0013] A log data determination module, used to determine a plurality of first log data of the application service and a plurality of second log data of the database, each of the first log data includes: first time information, an identifier of the business logic, and an identifier of the operation interface, and each of the second log data includes: second time information, an identifier of an operation object, and operation information, and the operation object includes: an operated data table and an operated field in the data table;

[0014] A corresponding relationship determination module, used to determine the corresponding relationship between the business logic and the data table according to the plurality of first log data and the plurality of second log data;

[0015] A generating module, used for generating a reverse restoration statement corresponding to each piece of second log data according to each piece of second log data;

[0016] The construction module is used to construct the pre-data corresponding to the business logic according to the reverse restoration statement corresponding to each second log data and the corresponding relationship between the business logic and the data table.

[0017] In the third aspect, another embodiment of the present application provides an electronic device, comprising: a processor, a storage medium and a bus, wherein the storage medium stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor communicates with the storage medium through the bus, and the processor executes the machine-readable instructions to perform the steps of any method described in the first aspect above.

[0018] In a fourth aspect, another embodiment of the present application provides a storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of any method described in the first aspect are executed.

[0019] In the fifth aspect, another embodiment of the present application provides a computer program product, which includes a computer program code. When the computer program code is executed by a computing device, the computing device performs the steps of any method described in the first aspect above.

[0020] The beneficial effect of the present application is as follows: by determining multiple first log data of the application service and multiple second log data of the database when the business logic is executed, the corresponding relationship between the business logic and the data table is determined, and at the same time, according to each second log data, a reverse restoration statement corresponding to each second log data is generated, so that according to the corresponding relationship between the business logic and the data table and the reverse restoration statement corresponding to each second log data, the pre-data corresponding to the business logic can be constructed, so that the construction process of the pre-data only depends on the operation process of the business logic, that is, the pre-data can be constructed only through the log data of the application service and the log data of the database during the operation of the business logic, which simplifies the construction process of the pre-data, improves the construction efficiency of the pre-data, enhances the maintainability of the test case, and also reduces the manual intervention in the construction process of the pre-data, ensuring the reliability of the obtained pre-data.

[0021] At the same time, since the pre-data is constructed through the log data of the application service at the runtime of the business logic and the log data of the database, the obtained pre-data is more in line with the actual operation status of the business logic, and can also accurately determine all the pre-data related to the business logic, ensuring the accuracy and comprehensiveness of the obtained pre-data.

[0022] In addition, since the process of constructing the pre-data in the present application is not affected by the business logic executable by the object under test or the system under test, the pre-data construction method provided by the present application can also be applied to any scenario where pre-data needs to be constructed.

[0023] In addition, by executing the front-end data construction method provided by this application, the tester's business familiarity requirements for the object or system under test and the threshold for code reading skills are greatly reduced. Testers can deepen their understanding of the business through the correspondence between the business logic and the data table and the reverse restoration statements generated by the front-end data construction method provided by this application, thereby improving the testing effect. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0025] Figure 1 A schematic diagram of an application scenario of the method for constructing pre-data provided in an embodiment of the present application;

[0026] Figure 2A schematic diagram of a flow chart of a method for constructing pre-data provided in an embodiment of the present application;

[0027] Figure 3 Another schematic diagram of a flow chart of a method for constructing pre-data provided in an embodiment of the present application;

[0028] Figure 4 A timing diagram of a method for constructing pre-data provided in an embodiment of the present application;

[0029] Figure 5 A schematic diagram of another flow chart of the method for constructing pre-data provided in the embodiment of the present application;

[0030] Figure 6 A schematic diagram of a process flow when generating reverse restoration statements corresponding to each second log data in the front data construction method provided in an embodiment of the present application;

[0031] Figure 7 Another flow chart of generating reverse restore statements corresponding to each second log data in the front data construction method provided in the embodiment of the present application;

[0032] Figure 8 A schematic diagram of a flow chart for generating a reverse restore statement corresponding to second log data in the front-end data construction method provided in an embodiment of the present application;

[0033] Fig. 9 A schematic diagram of a pre-data construction device provided in an embodiment of the present application;

[0034] Fig.10 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0035] To make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. It should be understood that the drawings in the present application only serve the purpose of explanation and description and are not used to limit the scope of protection of the present application. In addition, it should be understood that the schematic drawings are not drawn in real proportion. The flowchart used in this application shows the operations implemented according to some embodiments of the present application. It should be understood that the operations of the flowchart can be implemented out of sequence, and the steps without logical context can be reversed in order or implemented simultaneously. In addition, those skilled in the art can add one or more other operations to the flowchart under the guidance of the content of the present application, or remove one or more operations from the flowchart.

[0036] In addition, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.

[0037] It should be noted that the term "comprising" will be used in the embodiments of the present application to indicate the existence of the features declared thereafter, but does not exclude the addition of other features.

[0038] The prior art method for constructing pre-data usually constructs data by manually writing a structured query language (SQL) script. Specifically, testers extract persistence-related data tables in the software interface implementation logic based on their own business experience and understanding of software codes, write SQL scripts, and execute SQL scripts to insert, update, or delete records in the data table to construct pre-data.

[0039] However, this method of constructing pre-data relies on the experience and ability of testers, and has very high requirements on the business understanding and SQL writing skills of testers. It is also very likely to be missed or make mistakes. At the same time, it needs to be improved through repeated debugging, which results in a large workload, low writing efficiency, low construction efficiency and poor comprehensiveness.

[0040] The prior art method for constructing pre-data can also construct pre-data by collecting, processing and converting data from other similar products. Specifically, the original data is collected from the database of the actual production environment of other similar products, and redundancy is eliminated through a series of collection, cleaning, conversion and clustering to finally generate the pre-data.

[0041] However, it is difficult to guarantee whether the source of the original data of this front-end data construction method is a real data source, which affects the accuracy and security of the original data. Moreover, if the data structure of similar products is very different from the software under test, there will be a problem of high conversion costs. In addition, the data granularity of the front-end data constructed in this way is difficult to meet the actual application requirements, difficult to split into the granularity of a single test case, and not easy to modify and maintain. It can only be used as an intermediate product in the process of obtaining the front-end data.

[0042] In summary, the prior art method for constructing pre-data has the problems of low construction efficiency and poor comprehensiveness.

[0043] Based on the above-mentioned problems, an embodiment of the present application proposes a method for constructing front-end data, which determines the correspondence between business logic and data table through multiple first log data of application services and multiple second log data of database when business logic is executed. At the same time, according to each second log data, a reverse restore statement corresponding to each second log data is generated, so that the front-end data corresponding to the business logic can be constructed according to the correspondence between business logic and data table and the reverse restore statement corresponding to each second log data, so that the construction process of the front-end data only depends on the operation process of the business logic, that is, the front-end data can be constructed only through the log data of the application service at the operation time of the business logic and the log data of the database, thereby improving the construction efficiency. At the same time, because the front-end data is constructed through the log data of the application service at the operation time of the business logic and the log data of the database, the accuracy and comprehensiveness of the obtained front-end data are also guaranteed.

[0044] First, the relevant usage scenarios and concepts involved in the front-end data construction method provided in the embodiment of the present application are explained.

[0045] It should be understood that before automated testing, it is necessary to generate test cases for the object under test or the system under test, so that the object under test or the system under test can be tested through the test cases. In the process of generating test cases, the pre-data construction method provided by the embodiment of the present application can be executed to construct the pre-data, so that after obtaining the pre-data, the pre-data is added to the test case, and the test case is executed to test the object under test or the system under test.

[0046] Specifically, when executing the premise data construction method of the embodiment of the present application, the logs of the application services of the object under test or the system under test and the logs of the database can be used as inputs of the premise data construction method of the embodiment of the present application, thereby realizing the construction of the premise data by executing the steps of the premise data construction method of the embodiment of the present application, and after obtaining the premise data, filling the premise data into the test case, and testing the object under test or the system under test through the test case.

[0047] Among them, the application service can be an application service layer, which is responsible for receiving requests from the user interface and calling the business logic for processing. The business logic can be a business logic layer, which is responsible for implementing specific business rules and operations after being called by the application service. Among them, the specific business rules and operations can include storing, retrieving and updating data in the database. The database is used to store the data required for executing specific business rules and operations.

[0048] As an example, in the specific implementation process, the technical solution provided by the embodiment of the present application can be deployed in an electronic device in the form of a plug-in to realize the construction of pre-data, and after obtaining the pre-data, the pre-data can be pushed to the test case to test the object under test or the system under test through the test case.

[0049] Optionally, Figure 1 A schematic diagram of an application scenario of the method for constructing pre-data provided in the embodiment of the present application, referring to Figure 1 As shown, the user inputs the corresponding request through the user interface. After the application service obtains the request input by the user, it calls one or more business logics corresponding to the request for processing. At the same time, the running process of the business logic after being called is tracked, and the tracking information is stored in the log of the application service. When a certain business logic is called, one or more interfaces related to the business logic are called to implement operations such as storage, retrieval or update of one or more data tables in the database. At the same time, the database system can track information such as database operations, transaction processing, errors and warnings, and store them in the database log.

[0050] For example, taking an online retail system as an example, a user can browse, search, and purchase products in the online retail system. When a user requests to purchase a specific product in the interface of the online retail system, the application service can obtain the request to purchase the specific product input by the user and call the purchase business logic related to the purchase. After the purchase business logic is called, the purchase business logic queries the inventory of the specific product in the database through a first interface, modifies the inventory information of the specific product through a second interface, and stores the order information of the user's purchase through a third interface.

[0051] For example, when the user completes the purchase, the application service log adds request information when the application service calls the purchase business logic, as well as related information that the purchase business logic calls the first interface, the second interface, and the third interface, and the database log adds related information that the inventory of the specific product in the database has been modified.

[0052] The following is a detailed description of the pre-data construction method provided in the embodiments of the present application in combination with multiple embodiments.

[0053] Figure 2 A schematic diagram of a flow chart of a method for constructing pre-data provided in an embodiment of the present application, referring to Figure 2 As shown, the execution subject of the method can be any electronic device with processing capability, and the method includes:

[0054] S201: Determine a plurality of first log data of an application service and a plurality of second log data of a database.

[0055] It can be understood that the embodiment of the present application takes the application service calling a business logic as an example. At this time, the multiple first log data of the application service can be understood as the multiple log data related to one or more interfaces called by the business logic after the application service calls the business logic and the business logic is executed, that is, the multiple first log data of the application service is used to indicate the one or more interfaces called after the application service calls the business logic. The multiple second log data of the database can be understood as the multiple log data generated by each data table in the database when the business logic is executed. The multiple second log data of the database are used to indicate which fields in which tables in the database were executed at what time and what operations were performed.

[0056] Optionally, the electronic device may obtain multiple pieces of first log data of the application service from the log of the application service according to different business logics, and obtain multiple pieces of second log data of the database from the log of the database.

[0057] Exemplarily, the electronic device may run the specified business logic, and after the specified business logic is run, obtain multiple first log data of the application service from the log of the application service, and obtain multiple second log data of the database from the log of the database.

[0058] Exemplarily, the electronic device may also directly obtain multiple first log data of the application service from the log of the application service according to the identification of the business logic, and obtain multiple second log data of the database from the log of the database according to the time period corresponding to the multiple first log data.

[0059] For example, let's continue to take the above user's request to purchase a specific product in the interface of the online retail system as an example. When the purchase is completed, at this time, the first first log data of the application service can indicate that the query interface is called through the purchase business logic at the first moment, and the second first log data can indicate that the update interface is called through the purchase business logic at the second moment. The first second log data of the database can indicate that the inventory of a specific product in the inventory table of the database is updated at the third moment, and the inventory before the update is 10, and the inventory after the update is 9. Among them, the first moment and the third moment can be the same moment, or they can be moments with errors due to delays.

[0060] Each first log data includes: first time information, an identifier of the business logic, and an identifier of the operation interface. Specifically, the identifier of the operation interface is used to indicate one or more operation interfaces called by the business logic.

[0061] Each second log data includes: second time information, an identifier of an operation object, and operation information, and the operation object includes: an operated data table and an operated field in the data table. Specifically, the operation information is used to indicate what type of operation is performed on the operated field in the operated data table, and change information of the field before and after the operation.

[0062] S202: Determine a correspondence between business logic and a data table according to the plurality of first log data and the plurality of second log data.

[0063] It can be understood that, taking the application service calling a business logic as an example, multiple first log data can indicate the correspondence between the business logic and each interface under the business logic, and multiple second log data can indicate the relevant information of each data table being operated. Since the second log data will only be generated after the data table is operated by the interface, therefore, it is possible to determine which data tables are operated by each interface under the business logic through multiple first log data and multiple second log data, that is, the correspondence between the business logic and the data table.

[0064] Optionally, the correspondence between the business logic and the data table can be obtained by matching the calling time of each interface in multiple first log data, i.e., the first time information, and the change time of each field in each data table in multiple second log data, i.e., the second time information.

[0065] For example, continuing to take the above example of a user requesting to purchase a specific commodity in the interface of the online retail system, the corresponding relationship between the business logic and the data table may be that under the purchase business logic, an operation is performed on the inventory table of the database.

[0066] S203: Generate a reverse restore statement corresponding to each piece of second log data according to each piece of second log data.

[0067] It can be understood that, taking the test of a specific business logic as an example, the data preparation link in the test case containing the pre-data is usually executed first, and then the business logic of the system or object under test is executed to obtain the execution result. The test for this specific business logic is completed by checking whether the execution result meets expectations. According to the specific business logic of the object or system under test, reverse restoration is performed to realize the pre-data construction, so that the test for this specific business logic can be repeatedly executed, so that the specific business logic can be repeatedly verified to obtain the same execution result, which helps to enhance the robustness of the test case.

[0068] Optionally, the database operations under the business logic corresponding to each piece of second log data can be determined based on each piece of second log data, and each database operation can be reverse restored to generate a reverse restore statement corresponding to each piece of second log data, so that the obtained reverse restore statement can be applied to the scenario of testing the business logic.

[0069] The reverse restore statement corresponding to the second log data is used to indicate the database operation that should be performed when testing the business logic.

[0070] For example, continuing with the example of the user requesting to purchase a specific product in the interface of the online retail system, when the first second log data of the database indicates that the inventory of a specific product in the inventory table of the database was updated at a third time, the reverse restore statement corresponding to the obtained second log data can be used to indicate a new addition operation to the inventory of the specific product in the inventory table of the database.

[0071] Optionally, the execution order of the above S202 and the above S203 is not unique, and the electronic device can adjust it according to actual application conditions.

[0072] S204: constructing the pre-data corresponding to the business logic according to the reverse restore statements corresponding to each piece of second log data and the corresponding relationship between the business logic and the data table.

[0073] Optionally, after obtaining the reverse restore statements corresponding to each piece of the second log data, a match can be performed based on the correspondence between the business logic and the data table obtained in S202, and the reverse restore statements corresponding to each piece of the second log data, to determine the reverse restore statements corresponding to each data table under the business logic, thereby constructing the pre-data corresponding to the business logic.

[0074] Exemplarily, continuing with the example of the user requesting to purchase a specific product in the interface of the online retail system, the correspondence between the business logic and the data table is that under the purchase business logic, an operation is performed on the inventory table of the database, and the reverse restore statement corresponding to the second log data is used to indicate that a new operation is performed on the inventory of the specific product in the inventory table of the database. Then, the corresponding pre-data under the purchase business logic can be constructed, and the pre-data is used to indicate that a new operation is performed on the inventory of the specific product in the inventory table.

[0075] In this embodiment, the correspondence between the business logic and the data table is determined by determining multiple first log data of the application service and multiple second log data of the database when the business logic is executed. At the same time, according to each second log data, a reverse restore statement corresponding to each second log data is generated, so that according to the correspondence between the business logic and the data table and the reverse restore statement corresponding to each second log data, the pre-data corresponding to the business logic can be constructed, so that the construction process of the pre-data only depends on the operation process of the business logic, that is, the pre-data can be constructed only through the log data of the application service and the log data of the database during the operation of the business logic, which simplifies the construction process of the pre-data, improves the construction efficiency of the pre-data, enhances the maintainability of the test case, and also reduces the manual intervention in the construction process of the pre-data, ensuring the reliability of the obtained pre-data.

[0076] At the same time, since the pre-data is constructed through the log data of the application service at the runtime of the business logic and the log data of the database, the obtained pre-data is more in line with the actual operation status of the business logic, and can also accurately determine all the pre-data related to the business logic, ensuring the accuracy and comprehensiveness of the obtained pre-data.

[0077] In addition, since the process of constructing the pre-data in the present application is not affected by the business logic executable by the object under test or the system under test, the pre-data construction method provided by the present application can also be applied to any scenario where pre-data needs to be constructed.

[0078] In addition, by executing the front-end data construction method provided by this application, the tester's business familiarity requirements for the object or system under test and the threshold for code reading skills are greatly reduced. Testers can deepen their understanding of the business through the correspondence between the business logic and the data table and the reverse restoration statements generated by the front-end data construction method provided by this application, thereby improving the testing effect.

[0079] In a possible implementation, a process of determining a plurality of first log data of an application service and a plurality of second log data of a database is exemplarily described. Figure 3 Another flowchart of the method for constructing pre-data provided in the embodiment of the present application is shown in FIG. Figure 3 As shown, the above S201 can be performed according to the following steps, which specifically include:

[0080] S301, executing business logic, generating multiple first log data when the business logic is running, and calling an operation interface to operate a database so that the database records original database log data.

[0081] Optionally, Figure 4A timing diagram of the method for constructing pre-data provided in the embodiment of the present application, referring to Figure 4 As shown, continuing with a business logic as an example, the electronic device can provide a user interface to the user, and the user inputs a corresponding request through the user interface. After the application service of the object under test or the system under test obtains the request input by the user, it executes the business logic and generates multiple first log data.

[0082] Optionally, continue to refer to Figure 4 As shown, the application service of the object under test or the system under test calls the operation interface to operate the database of the object under test or the system under test, and the operated database records the original database log data.

[0083] Optionally, after the business logic is executed, the application service of the object under test or the system under test returns the business logic execution result to the user interface, and the electronic device obtains multiple first log data.

[0084] S302: Screen the original database log data according to the preset whitelist information to obtain a plurality of second log data.

[0085] Optionally, continue to refer to Figure 4 As shown, the electronic device filters the original database log data according to the preset whitelist information to obtain multiple second log data. After obtaining multiple first log data and multiple second log data, the electronic device executes the steps of the front data construction method provided in the embodiment of the present application to construct the front data and push the front data to the test case.

[0086] Among them, the preset whitelist information can be used to indicate the database user name, the connection session identifier of the application service and the information related to the operation interface. The electronic device can eliminate the data in the original database log data that is not related to the previous data according to the whitelist information, thereby obtaining multiple second log data.

[0087] Exemplarily, continuing with the example of the user requesting to purchase a specific product in the interface of the online retail system, the original database log data of the database may include database operation status information, query execution information, resource usage information, and data modification operation information, etc. The second log data may indicate that the inventory of a specific product in the inventory table of the database was updated at a third moment.

[0088] By executing business logic, when the business logic is running, multiple first log data are generated, and the operation interface is called to operate the database, so that the database records the original database log data, and the original database log data is filtered according to the preset whitelist information to obtain multiple second log data. It is possible to quickly obtain multiple first log data and multiple second log data, thereby improving the construction efficiency of the front data.

[0089] In a possible implementation, a process of determining a correspondence between a business logic and a data table according to a plurality of first log data and a plurality of second log data is exemplarily described. Figure 5 Another flowchart of the method for constructing pre-data provided in the embodiment of the present application is shown in FIG. Figure 5 As shown, the above S202 includes:

[0090] S501, traverse multiple first log data, and for the traversed current first log data, search from multiple second log data for at least one target second log data that matches the current first log data in time according to the first time information of the current first log data and the second time information of each second log data.

[0091] Optionally, before traversing the plurality of first log data, the plurality of first log data and the plurality of second log data may be timestamp aligned according to the first time information of the plurality of first log data and the second time information of the plurality of second log data, and sorted in the order of the timestamps.

[0092] Optionally, multiple first log data may be traversed, and for the current first log data traversed, at least one target second log data that matches the current first log data in time may be searched from the multiple second log data according to the first time information of the current first log data and the second time information of each second log data. Matching in time may be understood as the error between the first time information and the second time information not exceeding a preset time error threshold.

[0093] For example, continue to take the above user requesting to purchase a specific product in the interface of the online retail system as an example, assuming that the current first log data traversed is the update interface called through the purchase business logic at the second moment, then according to the second moment, it is possible to find from multiple second log data that the inventory of a specific product in the inventory table of the database was updated at the third moment as the target second log data. Among them, the second moment and the third moment have the same or similar timestamps.

[0094] S502: Obtain the identifier of the operated data table in each target second log data.

[0095] Optionally, after finding at least one target second log data that matches the current first log data in time, an identifier of the operated data table in each target second log data is obtained.

[0096] Exemplarily, continuing with the example of the user requesting to purchase a specific commodity in the interface of the online retail system, when the target second log data is that the inventory of a specific commodity in the inventory table of the database is updated at the third moment, the identifier of the operated data table in the obtained target second log data is used to indicate the inventory table.

[0097] S503: Use the data table indicated by the identifier of the data table in each target second log data as the data table corresponding to the business logic.

[0098] Optionally, the data table indicated by the identifier of the data table in each target second log data obtained is used as the data table corresponding to the business logic.

[0099] For example, continuing with the example of the user requesting to purchase a specific commodity in the interface of the online retail system, the inventory table in the database is used as the corresponding data table under the purchase business logic.

[0100] The above is an exemplary description of the process of determining the correspondence between the business logic and the data table. While obtaining the correspondence between the business logic and the data table, a reverse restore statement corresponding to each second log data can be generated according to each second log data. The following is an exemplary description.

[0101] In one possible implementation, Figure 6 A schematic diagram of a flow chart for generating reverse restore statements corresponding to each second log data in the front data construction method provided in the embodiment of the present application, referring to Figure 6 As shown, the above S203 includes:

[0102] S601: parse the second log data to obtain second time information, an identifier of an operation object, and operation information in the second log data.

[0103] Optionally, when there are multiple pieces of second log data, the multiple pieces of second log data are processed respectively to generate reverse restoration statements corresponding to each piece of second log data. Any second log data is taken as an example for description.

[0104] Optionally, the second log data can be parsed by a string processing function, a regular expression or a log parsing library to extract the second time information, the identifier of the operation object and the operation information in the second log data. The operation information includes: the operation type, the data value before the operation and the data value after the operation. The operation type is used to indicate what type of operation is performed on the operation object, such as: add, delete, update and other types of operations.

[0105] For example, continue to take the above user requesting to purchase a specific commodity in the interface of the online retail system as an example, assuming that the second log data indicates that the inventory of a specific commodity in the inventory table of the database is updated at the third moment, and the inventory before the update is 10, and the inventory after the update is 9. Then at this time, the second time information obtained is: at the third moment, the data table operated is: inventory table, the field operated in the data table is: inventory of a specific commodity, the operation type is: update, the data value before the operation is 10, and the data value after the operation is 9.

[0106] S602: Generate a reverse restore statement corresponding to the second log data according to the identifier of the operation object and the operation information in the second log data.

[0107] Optionally, the database operation under the business logic corresponding to the second log data can be determined based on the identifier of the operation object and the operation information in the second log data, and reverse restoration processing can be performed based on the database operation to obtain the reverse database operation corresponding to the database operation under the business logic, thereby generating the corresponding reverse restoration statement of the second log data.

[0108] Optionally, reverse restoration processing may be performed according to the identifier of the operation object and the operation information in the second log data in combination with preset reverse deduction and reorganization rules, thereby generating a corresponding reverse restoration statement for the second log data.

[0109] Optionally, while generating the reverse restore statement corresponding to the second log data, explanation information of the reverse restore statement corresponding to the second log data can also be generated based on the identifier of the operation object and the operation information in the second log data, wherein the explanation information is used to explain the semantics of the reverse restore statement corresponding to the second log data, thereby improving the readability of the reverse restore statement corresponding to the second log data. The generation process of the explanation information of the reverse restore statement corresponding to the second log data can refer to the generation process of the reverse restore statement corresponding to the second log data, and this application does not elaborate on this.

[0110] Exemplarily, continuing with the example of the user requesting to purchase a specific product in the interface of the online retail system, it can be determined that the database operation under the purchase business logic corresponding to the second log data is to update the inventory of a specific product. Then, based on the database operation of updating the inventory of a specific product, reverse restore processing can be performed to obtain that the reverse database operation corresponding to the database operation under the business logic is to reversely update the inventory of a specific product, and a corresponding reverse restore statement for the second log data is generated, wherein the corresponding reverse restore statement for the second log data is used to execute the operation of reversely updating the inventory of a specific product.

[0111] Exemplarily, continuing with the example of the user requesting to purchase a specific product in the interface of the online retail system, it can be determined that the database operation under the purchase business logic corresponding to the second log data is to update the inventory of a specific product. The identifier of the operation object and the operation information in the second log data can also be read, and combined with the preset reverse deduction and reconstruction rules, the operation type and the operation information are replaced and spliced, thereby generating the corresponding reverse restoration statement of the second log data.

[0112] By parsing the second log data, the second time information, the identifier of the operation object and the operation information in the second log data are obtained, and according to the identifier of the operation object and the operation information in the second log data, the reverse restoration statement corresponding to the second log data is generated, so that the reverse restoration statement corresponding to each second log data can be quickly obtained, thereby improving the construction efficiency of the preceding data and ensuring the reliability and comprehensiveness of the obtained preceding data.

[0113] As a possible implementation manner, a process of generating a reverse restore statement corresponding to the second log data according to the identifier of the operation object and the operation information in the second log data is exemplarily described. Figure 7 Another flow chart of generating reverse restore statements corresponding to each second log data in the front data construction method provided in the embodiment of the present application, referring to Figure 7 As shown, the above S602 includes:

[0114] S701: Generate structured data corresponding to the second log data according to an identifier of an operation object and operation information in the second log data and a preset data structure template.

[0115] Optionally, the identifier of the operation object and the operation information in the second log data may be formatted according to the format in a preset data structure template and mapped to the preset data structure template, thereby generating structured data corresponding to the second log data.

[0116] Optionally, after generating structured data corresponding to the second log data, the generated structured data may be verified according to a preset data structure template to ensure that it complies with the format and content requirements of the data structure template, and correct it if it does not comply.

[0117] Among them, the preset data structure template can be a predefined structure template, which is used to indicate the format, type and structure of the structured data corresponding to the second log data, including at least: the identifier of the field operated in the data table (abbreviated as ID), the table name of the data table operated, the time of executing the operation, the operation type, the data value before the operation and the data value after the operation.

[0118] S702: Generate a reverse restore statement corresponding to the second log data according to the structured data corresponding to the second log data.

[0119] Optionally, the identification of the operation object and the operation information in the structured data corresponding to the second log data can be read, and the database operation corresponding to the identification of the operation object and the operation information can be determined, and based on the database operation, reverse restoration processing can be performed to obtain the reverse database operation corresponding to the database operation, thereby generating the corresponding reverse restoration statement of the second log data.

[0120] Optionally, the identifier of the operation object and the operation information in the structured data corresponding to the second log data may be read, and reverse restoration processing may be performed in combination with preset reverse deduction and reconstruction rules, thereby generating a reverse restoration statement corresponding to the second log data.

[0121] By using the identification of the operation object and the operation information in the second log data and a preset data structure template, structured data corresponding to the second log data is generated, making the second log data more standardized and easy to process, thereby ensuring the readability of the structured data. This makes it possible to generate a reverse restoration statement corresponding to the second log data based on the structured data corresponding to the second log data more accurate and in-depth, thereby improving the efficiency of generating reverse restoration statements.

[0122] Optionally, a process of generating structured data corresponding to the second log data according to the identifier of the operation object and the operation information in the second log data and a preset data structure template is exemplarily described, and the above S702 includes:

[0123] The second time information in the second log data, the identifier of the operated data table, the identifier of the operated field, the operation type, the data value before the operation and the data value after the operation are filled into the corresponding positions in the data structure template to obtain structured data corresponding to the second log data.

[0124] Exemplarily, continuing to take the above user requesting to purchase a specific product in the interface of the online retail system as an example, assuming that the second time information is: the third moment, the data table being operated is: the inventory table, the field being operated in the data table is: the inventory of a specific product, the operation type is: update, the data value before the operation is 10, and the data value after the operation is 9, the second time information in the second log data, the identifier of the operated data table, the identifier of the operated field, the operation type, the data value before the operation, and the data value after the operation can be filled into the corresponding positions in the data structure template, and the structured data corresponding to the second log data is obtained as follows:

[0125] {

[0126] "SCN": 5978261328954,---------------------------Object id

[0127] "SEG_OWNER": "User 1",-----------------------Database user

[0128] "TABLE_NAME": "Inventory Table",-----------------------Operation object table name

[0129] "TIMESTAMP": the third moment,------------------operation time

[0130] "OPERATION": "Update",------------------------Operation type

[0131] "data": {--------------------------------------------Value after operation

[0132] "PRODUCT_QUANTITY": "9",

[0133] "PRODUCT_NAME": "A specific product",

[0134] },

[0135] "before": {-----------------------------------------Value content before operation

[0136] "SYS_STATUS": "10",

[0137] "PRODUCT_NAME": "A specific product",

[0138] }

[0139] The above is an exemplary description of the process of generating structured data corresponding to the second log data. It can be understood that after obtaining the structured data corresponding to the second log data, the front data construction method provided in the embodiment of the present application can generate a reverse restoration statement corresponding to the second log data. The following is an exemplary description of the process.

[0140] In a possible implementation, generating a reverse restore statement corresponding to the second log data according to the structured data corresponding to the second log data in S702 includes:

[0141] Generate a reverse restore statement corresponding to the second log data according to the operation type in the structured data.

[0142] Optionally, the operation type in the structured data can be read, and based on the operation type in the structured data, the database operation corresponding to the operation type can be determined, and based on the database operation, reverse restoration processing can be performed to obtain the reverse database operation corresponding to the database operation, and based on the operation type corresponding to the reverse database operation, a reverse restoration statement corresponding to the second log data can be generated.

[0143] Optionally, the operation type in the structured data may be read, and reverse restoration processing may be performed based on the operation type in the structured data in combination with preset reverse deduction and reorganization rules, thereby generating a corresponding reverse restoration statement for the second log data.

[0144] It can be understood that, according to different operation types in the structured data, different operations can be performed to generate reverse restore statements corresponding to the second log data, which are exemplarily described below.

[0145] In a possible implementation, when the operation type in the structured data is insert, the above steps may generate a reverse restore statement corresponding to the second log data according to the operation type in the structured data, and may be performed according to the following steps, including:

[0146] If the operation type in the structured data is insert, the operation type is replaced with the first target type, and a reverse restore statement corresponding to the second log data is generated based on the first target type, the identifier of the operated data table in the structured data, the identifier of the operated field, and the data value after the operation.

[0147] Optionally, when the operation type in the structured data is insert, the operation type may be replaced with a first target type, wherein the first target type is delete.

[0148] Optionally, after the operation type is replaced, a reverse restore statement corresponding to the second log data is generated based on a combination of the first target type, the identifier of the operated data table in the structured data, the identifier of the operated field, and the data value after the operation.

[0149] In a possible implementation, when the operation type in the structured data is insert, the above steps generate a reverse restore statement corresponding to the second log data according to the first target type, the identifier of the operated data table in the structured data, the identifier of the operated field, and the data value after the operation, and can be performed according to the following steps, including:

[0150] The first target type, the preset first target field, the identifier of the operated data table in the structured data, the identifier of the operated field, and the data value after the operation are sequentially spliced ​​to generate a reverse restoration statement corresponding to the second log data.

[0151] The first target field is the Where field in the SQL statement.

[0152] For example, taking the business logic as triggering the "new environment system status information" interface, the database operation performed is: adding test environment 3 and setting the system status to 0 as an example, the structured data corresponding to the second log data is:

[0153] {

[0154] "OPERATION":insert,

[0155] "TABLE_NAME":hs_user.sysarg,

[0156] "data":{

[0157] "INIT_DATE": 20241021,

[0158] "SYS_STATUS": "0",

[0159] "SYSTEM_NAME":"Test Environment 3",

[0160] },

[0161] "before":{},

[0162] } as an example, at this time, the reverse restore statement corresponding to the generated second log data can be:

[0163] Delete hs_user.sysarg where SYSTEM_NAME=”Test Environment 3” and SYS_STATUS=”0” and INIT_DATE=20241021.

[0164] Exemplarily, the explanation information of the reverse restore statement corresponding to the second log data generated at this time may be: assuming that there is a record of system_name="test environment 2" in the previous table sysarg, then the record is deleted to meet the requirement of repeated execution of the automated use case.

[0165] The above is an exemplary description of the processing procedure when the operation type in the structured data is inserting. The following is an exemplary description of the processing procedure when the operation type in the structured data is deleting.

[0166] In a possible implementation, when the operation type in the structured data is deletion, the above steps may generate a reverse restore statement corresponding to the second log data according to the operation type in the structured data, and may be performed according to the following steps, including:

[0167] If the operation type in the structured data is deletion, the operation type is replaced with the second target type, and a reverse restore statement corresponding to the second log data is generated based on the second target type, the identifier of the operated data table in the structured data, the identifier of the operated field, and the data value before the operation.

[0168] Optionally, when the operation type in the structured data is delete, the operation type may be replaced with a second target type, wherein the second target type is insert.

[0169] Optionally, after the operation type is replaced, a reverse restore statement corresponding to the second log data is generated based on a combination of the second target type, the identifier of the operated data table in the structured data, the identifier of the operated field, and the data value before the operation.

[0170] In a possible implementation, when the operation type in the structured data is deletion, the above steps generate a reverse restore statement corresponding to the second log data according to the second target type, the identifier of the operated data table in the structured data, the identifier of the operated field, and the data value before the operation, including:

[0171] The second target type, the preset second target field, the identifier of the operated data table in the structured data, the identifier of the operated field, and the data value before the operation are sequentially spliced ​​to generate a reverse restore statement corresponding to the second log data.

[0172] The second target field is the Value field in the SQL statement.

[0173] For example, the business logic is used to trigger the "delete environment system status information" interface, and the database operation performed is: delete test environment 2 as an example, and the structured data corresponding to the second log data is:

[0174] {

[0175] "OPERATION":delete,

[0176] "TABLE_NAME":hs_user.sysarg,

[0177] "data":{},

[0178] "before":{

[0179] "INIT_DATE": 20241021,

[0180] "SYS_STATUS": "0",

[0181] "SYSTEM_NAME": "Test Environment 2"

[0182] },} as an example, at this time, the reverse restore statement corresponding to the generated second log data can be:

[0183] Insert hs_user.sysarg (SYSTEM_NAME,SYS_STATUS,INIT_DATE) values("Test Environment 2","0",20241021).

[0184] Exemplarily, the explanation information of the reverse restore statement corresponding to the second log data generated at this time may be: prepare a record of system_name="test environment 2" in the table sysarg in advance to meet the requirement of repeated execution of the automated use case.

[0185] The above is an exemplary description of the processing procedure when the operation type in the structured data is insertion and deletion. The following is an exemplary description of the processing procedure when the operation type in the structured data is update.

[0186] In a possible implementation, when the operation type in the structured data is update, the above steps may generate a reverse restore statement corresponding to the second log data according to the operation type in the structured data, and may be performed according to the following steps, including:

[0187] If the operation type in the structured data is update, a reverse restore statement corresponding to the second log data is generated based on the first target type, the second target type, the identifier of the operated data table in the structured data, the identifier of the operated field, the data value before the operation, and the data value after the operation.

[0188] Optionally, when the operation type in the structured data is update (UPDATE), a reverse restore statement corresponding to the second log data can be generated based on the first target type (delete), the second target type (Insert), the identifier of the operated data table in the structured data, the identifier of the operated field, and the data value before the operation and the data value after the operation.

[0189] In one possible implementation, Figure 8 A schematic diagram of a flow chart for generating a reverse restore statement corresponding to the second log data in the front data construction method provided in an embodiment of the present application, referring to Figure 8 As shown, when the operation type in the structured data is update, the above steps generate a reverse restore statement corresponding to the second log data according to the first target type, the second target type, the identifier of the operated data table in the structured data, the identifier of the operated field, the data value before the operation, and the data value after the operation, including:

[0190] S801. Concatenate the first target type, the preset first target field, the identifier of the operated data table in the structured data, the identifier of the operated field, and the data value after the operation in sequence to generate a first sub-reverse restore statement corresponding to the second log data.

[0191] For example, taking the business logic as triggering the "modify system status" interface, the database operation performed is: changing the system status of the test environment 1 to 1, and the structured data corresponding to the second log data is:

[0192] {

[0193] "SCN": 5978261328954,---------------------------Object id

[0194] "SEG_OWNER": "HS_USER",-----------------------Database user

[0195] "TABLE_NAME": "SYSARG",-----------------------Operation object table name

[0196] "TIMESTAMP": 1729492371000,------------------Operation time

[0197] "OPERATION": "UPDATE",------------------------Operation type

[0198] "data": {--------------------------------------------Value after operation

[0199] "INIT_DATE": 20241021,

[0200] "SYS_STATUS": "1",

[0201] "SYSTEM_NAME": "Test Environment 1",

[0202] },

[0203] "before": {-----------------------------------------Value content before operation

[0204] "INIT_DATE": 20241021,

[0205] "SYS_STATUS": "0",

[0206] "SYSTEM_NAME": "Test Environment 1",

[0207] }

[0208] Exemplarily, the first target type (delete), the preset first target field Where, the identifier of the operated data table in the structured data, the identifier of the operated field, and the data value after the operation may be sequentially concatenated to generate the first sub-reverse restoration statement corresponding to the second log data as shown below:

[0209] Delete hs_user.sysarg where SYSTEM_NAME="Test Environment 1"and SYS_STATUS="1"and INIT_DATE=20241021.

[0210] S802. Concatenate the second target type, the preset second target field, the identifier of the operated data table in the structured data, the identifier of the operated field, and the data value before the operation in sequence to generate a second sub-reverse restore statement corresponding to the second log data.

[0211] For example, the business logic is used to trigger the "Modify System Status" interface, and the database operation performed is: changing the system status of the test environment 1 to 1. For example, the second target type (Insert), the preset second target field Value, the identifier of the operated data table in the structured data, the identifier of the operated field, and the data value before the operation are sequentially spliced ​​to generate the second sub-reverse restore statement corresponding to the second log data as shown below:

[0212] Insert hs_user.sysarg (SYSTEM_NAME,SYS_STATUS,INIT_DATE) Values("Test Environment 1","0",20241021).

[0213] S803: Concatenate the first sub-reverse restore statement with the second sub-reverse restore statement to generate a reverse restore statement corresponding to the second log data.

[0214] Exemplarily, the first sub-reverse restore statement is concatenated with the second sub-reverse restore statement to generate a reverse restore statement corresponding to the second log data as follows:

[0215] Delete hs_user.sysarg where SYSTEM_NAME="Test Environment 1"and SYS_STATUS="1"and INIT_DATE=20241021;Insert hs_user.sysarg (SYSTEM_NAME,SYS_STATUS,INIT_DATE)Values("Test Environment 1","0",20241021).

[0216] Exemplarily, the explanation information of the reverse restore statement corresponding to the second log data can be: first clear the records with SYSTEM_NAME="Test Environment 1" and SYS_STATUS="1" in the table sysarg, and then insert 1 record with SYSTEM_NAME="Test Environment 1" and SYS_STATUS="0" to meet the repeated execution requirements of the automated use case.

[0217] Based on the same inventive concept, a pre-data construction device corresponding to the pre-data construction method is also provided in the embodiment of the present application. Since the principle of solving the problem by the device in the embodiment of the present application is similar to the above-mentioned pre-data construction method in the embodiment of the present application, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.

[0218] Fig. 9 A schematic diagram of a pre-data construction device provided in an embodiment of the present application, referring to Fig. 9 As shown, the device includes: a log data determination module 901, a corresponding relationship determination module 902, a generation module 903 and a construction module 904;

[0219] The log data determination module 901 is used to determine a plurality of first log data of the application service and a plurality of second log data of the database, each of the first log data includes: first time information, an identifier of the business logic, and an identifier of the operation interface; each of the second log data includes: second time information, an identifier of an operation object, and operation information; the operation object includes: an operated data table and an operated field in the data table;

[0220] A correspondence determination module 902, configured to determine a correspondence between a business logic and a data table according to a plurality of first log data and a plurality of second log data;

[0221] A generating module 903, configured to generate, according to each piece of second log data, a reverse restore statement corresponding to each piece of second log data;

[0222] The construction module 904 is used to construct the pre-data corresponding to the business logic according to the reverse restoration statement corresponding to each second log data and the corresponding relationship between the business logic and the data table.

[0223] Optionally, the log data determination module 901 is specifically configured to:

[0224] Execute the business logic, generate a plurality of first log data when the business logic is running, and call the operation interface to operate the database so that the database records the original database log data;

[0225] According to the preset whitelist information, the original database log data is screened to obtain a plurality of second log data.

[0226] Optionally, the corresponding relationship determination module 902 is specifically configured to:

[0227] Traversing the plurality of first log data, for the traversed current first log data, searching, according to the first time information of the current first log data and the second time information of each second log data, for at least one target second log data that matches the current first log data in time from the plurality of second log data;

[0228] Obtaining the identifier of the operated data table in the second log data of each target;

[0229] The data table indicated by the identifier of the data table in each target second log data is used as the data table corresponding to the business logic.

[0230] Optionally, the generating module 903 is specifically configured to:

[0231] Parsing the second log data to obtain second time information, an identifier of an operation object, and operation information in the second log data, where the operation information includes: an operation type, a data value before the operation, and a data value after the operation;

[0232] A reverse restore statement corresponding to the second log data is generated according to the identifier of the operation object and the operation information in the second log data.

[0233] Optionally, the generating module 903 is specifically configured to:

[0234] Generate structured data corresponding to the second log data according to the identifier of the operation object and the operation information in the second log data and a preset data structure template;

[0235] According to the structured data corresponding to the second log data, a reverse restore statement corresponding to the second log data is generated.

[0236] Optionally, the generating module 903 is specifically configured to:

[0237] The second time information in the second log data, the identifier of the operated data table, the identifier of the operated field, the operation type, the data value before the operation and the data value after the operation are filled into the corresponding positions in the data structure template to obtain structured data corresponding to the second log data.

[0238] Optionally, the generating module 903 is specifically configured to:

[0239] According to the operation type in the structured data, a reverse restore statement corresponding to the second log data is generated.

[0240] Optionally, the generating module 903 is specifically configured to:

[0241] If the operation type in the structured data is insert, the operation type is replaced with the first target type, and a reverse restore statement corresponding to the second log data is generated based on the first target type, the identifier of the operated data table in the structured data, the identifier of the operated field, and the data value after the operation.

[0242] Optionally, the generating module 903 is specifically configured to:

[0243] The first target type, the preset first target field, the identifier of the operated data table in the structured data, the identifier of the operated field, and the data value after the operation are sequentially spliced ​​to generate a reverse restoration statement corresponding to the second log data.

[0244] Optionally, the generating module 903 is specifically configured to:

[0245] If the operation type in the structured data is deletion, the operation type is replaced with the second target type, and a reverse restore statement corresponding to the second log data is generated based on the second target type, the identifier of the operated data table in the structured data, the identifier of the operated field, and the data value before the operation.

[0246] Optionally, the generating module 903 is specifically configured to:

[0247] The second target type, the preset second target field, the identifier of the operated data table in the structured data, the identifier of the operated field, and the data value before the operation are sequentially spliced ​​to generate a reverse restore statement corresponding to the second log data.

[0248] Optionally, the generating module 903 is specifically configured to:

[0249] If the operation type in the structured data is update, a reverse restore statement corresponding to the second log data is generated based on the first target type, the second target type, the identifier of the operated data table in the structured data, the identifier of the operated field, the data value before the operation, and the data value after the operation.

[0250] Optionally, the generating module 903 is specifically configured to:

[0251] The first target type, the preset first target field, the identifier of the operated data table in the structured data, the identifier of the operated field, and the data value after the operation are sequentially spliced ​​to generate a first sub-reverse restoration statement corresponding to the second log data;

[0252] The second target type, the preset second target field, the identifier of the operated data table in the structured data, the identifier of the operated field, and the data value before the operation are sequentially concatenated to generate a second sub-reverse restoration statement corresponding to the second log data;

[0253] The first sub-reverse restore statement is concatenated with the second sub-reverse restore statement to generate a reverse restore statement corresponding to the second log data.

[0254] For descriptions of the processing flow of each module in the device and the interaction flow between each module, reference may be made to the relevant descriptions in the above method embodiment, which will not be described in detail here.

[0255] The embodiment of the present application also provides an electronic device, Fig.10 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application, such as Fig.10 As shown, it includes: a processor 1001, a memory 1002, and optionally, a bus 1003. The memory 1002 stores machine-readable instructions executable by the processor 1001 (for example, Fig. 9The device includes the log data determination module 901, the corresponding relationship determination module 902, the generation module 903 and the execution instructions corresponding to the construction module 904, etc.), when the electronic device is running, the processor 1001 communicates with the memory 1002 through the bus 1003, and when the machine-readable instructions are executed by the processor 1001, the steps of the above-mentioned pre-data construction method are executed.

[0256] An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned method for constructing the pre-data are executed.

[0257] An embodiment of the present application also provides a computer program product, which includes a computer program code. When the computer program code is executed by a computing device, the computing device executes the steps of the above-mentioned pre-data construction method.

[0258] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the system and device described above can refer to the corresponding process in the method embodiment, and will not be repeated in this application. In the several embodiments provided in this application, it should be understood that the disclosed system, device and method can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the modules is only a logical function division. There may be other division methods in actual implementation. For example, multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, indirect coupling or communication connection of devices or modules, which can be electrical, mechanical or other forms.

[0259] In addition, each functional unit in each embodiment of the present application can be integrated into a processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention is essentially or part of the technical solution that contributes to the prior art or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, RandomAccess Memory), disk or optical disk and other media that can store program code.

[0260] The above are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be covered by the protection scope of the present application.

Claims

1. A method for constructing pre-data, characterized in that: include: Determine a plurality of first log data of the application service and a plurality of second log data of the database, each of the first log data includes: first time information, an identifier of the business logic, and an identifier of the operation interface, and each of the second log data includes: second time information, an identifier of an operation object, and operation information, the operation object includes: an operated data table and an operated field in the data table, and the operation information is used to indicate a type of operation performed on the operated field in the operated data table, and change information of the field before and after the operation; Determining a correspondence between the business logic and the data table according to the plurality of first log data and the plurality of second log data; Generate a reverse restore statement corresponding to each piece of second log data according to each piece of second log data; According to the reverse restoration statements corresponding to each piece of second log data and the corresponding relationship between the business logic and the data table, the pre-data corresponding to the business logic are constructed.

2. The method for constructing preamble data according to claim 1, characterized in that: The determining of the plurality of first log data of the application service and the plurality of second log data of the database includes: Executing the business logic, generating the plurality of first log data when the business logic is running, and calling the operation interface to operate the database so that the database records the original database log data; The original database log data is screened according to the preset whitelist information to obtain the plurality of second log data.

3. The method for constructing preamble data according to claim 1, characterized in that: The determining, according to the plurality of first log data and the plurality of second log data, the correspondence between the business logic and the data table includes: Traversing the plurality of first log data, for the traversed current first log data, searching, from the plurality of second log data, at least one target second log data that matches the current first log data in time according to the first time information of the current first log data and the second time information of each second log data; Obtaining an identifier of an operated data table in each of the target second log data; The data table indicated by the identifier of the operated data table in each of the target second log data is used as the data table corresponding to the business logic.

4. The method for constructing preamble data according to claim 1, characterized in that: The generating, according to each piece of second log data, a reverse restore statement corresponding to each piece of second log data includes: Parsing the second log data to obtain second time information, an identifier of an operation object, and operation information in the second log data, wherein the operation information includes: an operation type, a data value before the operation, and a data value after the operation; A reverse restore statement corresponding to the second log data is generated according to the identifier of the operation object and the operation information in the second log data.

5. The method for constructing preamble data according to claim 4, characterized in that: The generating, according to the identifier of the operation object and the operation information in the second log data, a reverse restore statement corresponding to the second log data includes: Generate structured data corresponding to the second log data according to the identifier of the operation object and the operation information in the second log data and a preset data structure template; A reverse restore statement corresponding to the second log data is generated according to the structured data corresponding to the second log data.

6. The method for constructing preamble data according to claim 5, characterized in that: The generating structured data corresponding to the second log data according to the identifier of the operation object and the operation information in the second log data and a preset data structure template includes: The second time information, the identifier of the operated data table, the identifier of the operated field, the operation type, the data value before the operation and the data value after the operation in the second log data are filled into the corresponding positions in the data structure template to obtain the structured data corresponding to the second log data.

7. The method for constructing preamble data according to claim 5, characterized in that: The generating, according to the structured data corresponding to the second log data, a reverse restore statement corresponding to the second log data includes: Generate a reverse restore statement corresponding to the second log data according to the operation type in the structured data.

8. The method for constructing preamble data according to claim 7, characterized in that: The generating, according to the operation type in the structured data, a reverse restore statement corresponding to the second log data includes: If the operation type in the structured data is insert, the operation type is replaced with the first target type, and a reverse restore statement corresponding to the second log data is generated based on the first target type, the identifier of the operated data table in the structured data, the identifier of the operated field, and the data value after the operation.

9. The method for constructing preamble data according to claim 8, characterized in that: The generating, according to the first target type, the identifier of the operated data table in the structured data, the identifier of the operated field, and the data value after the operation, a reverse restore statement corresponding to the second log data includes: The first target type, the preset first target field, the identifier of the operated data table in the structured data, the identifier of the operated field, and the data value after the operation are sequentially spliced ​​to generate a reverse restore statement corresponding to the second log data.

10. The method for constructing preamble data according to claim 7, characterized in that: The generating, according to the operation type in the structured data, a reverse restore statement corresponding to the second log data includes: If the operation type in the structured data is deletion, the operation type is replaced with a second target type, and a reverse restore statement corresponding to the second log data is generated based on the second target type, the identifier of the operated data table in the structured data, the identifier of the operated field, and the data value before the operation.

11. The method for constructing preamble data according to claim 10, characterized in that: The generating, according to the second target type, the identifier of the operated data table in the structured data, the identifier of the operated field, and the data value before the operation, a reverse restore statement corresponding to the second log data includes: The second target type, the preset second target field, the identifier of the operated data table in the structured data, the identifier of the operated field, and the data value before the operation are sequentially spliced ​​to generate a reverse restore statement corresponding to the second log data.

12. The method for constructing preamble data according to claim 7, characterized in that: The generating, according to the operation type in the structured data, a reverse restore statement corresponding to the second log data includes: If the operation type in the structured data is update, a reverse restore statement corresponding to the second log data is generated based on the first target type, the second target type, the identifier of the operated data table in the structured data, the identifier of the operated field, and the data value before the operation and the data value after the operation.

13. The method for constructing preamble data according to claim 12, characterized in that: The generating a reverse restore statement corresponding to the second log data according to the first target type, the second target type, the identifier of the operated data table in the structured data, the identifier of the operated field, and the data value before the operation and the data value after the operation includes: The first target type, the preset first target field, the identifier of the operated data table in the structured data, the identifier of the operated field, and the data value after the operation are sequentially spliced ​​to generate a first sub-reverse restoration statement corresponding to the second log data; The second target type, the preset second target field, the identifier of the operated data table in the structured data, the identifier of the operated field, and the data value before the operation are sequentially concatenated to generate a second sub-reverse restoration statement corresponding to the second log data; The first sub-reverse restore statement and the second sub-reverse restore statement are concatenated to generate a reverse restore statement corresponding to the second log data.

14. An electronic device, characterized in that: include: A processor and a memory, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor executes the machine-readable instructions to perform the steps of the pre-data construction method as described in any one of claims 1 to 13.

15. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the pre-data construction method as described in any one of claims 1 to 13 are executed.

16. A computer program product, characterized in that The computer program product includes computer program code. When the computer program code is executed by a computing device, the computing device executes the steps of the preceding data construction method according to any one of claims 1 to 13.

Citation Information

Patent Citations

  • Expected data generation method and device for testing and electronic equipment

    CN110046086A

  • Data preparation method and device, equipment and storage medium

    CN113760734A