Production data testing method and device, electronic device and storage medium

By collecting and mapping the log data of the production environment, automated testing in the test environment is realized, solving the problem of automated testing in the isolation of the production environment and the test environment, and improving testing efficiency and troubleshooting efficiency.

CN118689778AInactive Publication Date: 2024-09-24E SURFING VISION TECHNOLOGY CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202411172328.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-26
Publication Date
2024-09-24
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

In an architecture where the production environment and the test environment are isolated, it is difficult to implement automated testing of online production data, resulting in low efficiency and high cost of troubleshooting.

Method used

By collecting online log data from the production environment, the data source address is obtained, initial test cases are exported, and converted to the test environment based on the preset address mapping relationship, automated test processing is performed, and production data test results are generated.

Benefits of technology

It realizes the reproduction of production environment problems in the test environment, improves the efficiency of problem troubleshooting, reduces the burden of manual analysis of logs by R&D personnel, and improves testing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118689778A
    Figure CN118689778A
Patent Text Reader

Abstract

The invention relates to a production data testing method and device, an electronic device and a storage medium, and the production data testing method comprises the steps: collecting online log data in a production environment, and obtaining a first data source address in the production environment; exporting the online log data as an initial test case; based on a preset address mapping relationship, mapping the first data source address to a second data source address in a test environment, and converting the initial test case to the second data source address to obtain a target test case; and performing automatic test processing based on the target test case to generate a production data test result. According to the invention, the problem of low measurement efficiency due to the fact that a large amount of production data cannot be obtained for testing because the production environment is isolated from the testing environment is solved, and automatic testing of the production data is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a production data testing method, device, electronic device and storage medium. Background Art

[0002] With the continuous expansion of online business and the improvement of project functions, it is particularly important to ensure the stable operation and efficient troubleshooting of online business. Traditional testing methods often fail to fully cover the complex situations in the production environment, especially before making code changes or launching new functions, there is a lack of effective means to simulate and verify the specific impact of these changes on production business.

[0003] In existing technical solutions, there is strict business isolation between the production environment and the test environment, data cannot be directly interoperable, and the test environment lacks sufficient and comprehensive data for testing. This makes it difficult to reproduce problems in the production environment in the test environment, increasing the difficulty and cost of troubleshooting. In addition, troubleshooting production environment problems usually relies on R&D personnel to manually fill in and analyze logs, which is not only inefficient but also prone to missing key information.

[0004] Currently, no effective solution has been proposed for how to achieve automated testing of online production data and improve testing efficiency under the architecture of isolating the production environment and the test environment in related technologies. Summary of the invention

[0005] The embodiments of the present application provide a production data testing method and device, an electronic device and a storage medium to at least solve the problem in the related art of how to achieve automated testing of online production data and improve testing efficiency under an architecture in which the production environment and the test environment are isolated.

[0006] In a first aspect, an embodiment of the present application provides a production data testing method, comprising: Collect online log data in a production environment, and obtain a first data source address in the production environment; Exporting the online log data as an initial test case; Based on a preset address mapping relationship, the first data source address is mapped to a second data source address under the test environment, and the initial test case is converted to the second data source address to obtain a target test case; Automated test processing is performed based on the target test case to generate production data test results.

[0007] In some embodiments, collecting online log data in a production environment includes: Collecting interface log data in the production environment according to the obtained request identifier; The middleware log data in the production environment is collected, and the online log data includes the interface log data and the middleware log data.

[0008] In some embodiments, collecting interface log data in a production environment according to the request identifier includes: According to the request identifier, request log data in a production environment is collected, log cleaning is performed on the request log data, and the interface log data is obtained, where the request log data includes the request identifier.

[0009] In some embodiments, mapping the first data source address to the second data source address under the test environment based on a preset address mapping relationship includes: Based on a preset address mapping relationship, the access key of the production environment is modified to the access key of the test environment, and the first data source address is mapped to the second data source address in the test environment.

[0010] In some embodiments, the automated test processing based on the target test case to generate production data test results includes: Based on the target test case, obtaining request parameter information and data operation request; Acquire test middleware data, modify the data according to the data operation request, and store the modified data in the target test database; According to the request parameter information and the target test database, the test interface is requested to perform automated testing to generate production data test results.

[0011] In some embodiments, the acquiring of the test middleware data, modifying the data according to the data operation request, and storing the modified data in the target test database includes: Based on the test environment, obtaining test middleware data; If the data operation request is a query request, querying the target test case in response to the query request, and storing the data queried from the target test case in the target test database; If the data operation request is an insert request or a delete request, storing the data of the target test case in the target test database; If the data operation request is an update request, the target test case overwrites the test middleware data, and the overwritten test middleware data is stored in the target test database. In some embodiments, the requesting test interface to perform automated testing based on the request parameter information and the target test database to generate production data test results includes: According to the request parameter information and the target test database, simulating the storage space of the production environment in the test environment, and storing the target test case in the storage space; The test case in the storage space is called, and based on the test case, the test interface is requested to perform a test to generate the production data test result.

[0012] In a second aspect, an embodiment of the present application provides a production data testing device, including: A log collection module, used to collect online log data in a production environment and obtain a first data source address in the production environment; An export module, used to export the online log data as an initial test case; A data address mapping module, used to map the first data source address to a second data source address under a test environment based on a preset address mapping relationship, and convert the initial test case to the second data source address to obtain a target test case; The automated testing module is used to perform automated testing based on the target test cases and generate production data test results.

[0013] In a third aspect, an embodiment of the present application provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the production data testing method as described in the first aspect above.

[0014] In a fourth aspect, an embodiment of the present application provides a storage medium, in which a computer program is stored, wherein the computer program is configured to execute the production data testing method as described in the first aspect above when running.

[0015] Compared with the related technologies, the log collection service, data source address mapping and automated testing service provided by the embodiments of the present application import production environment data into the test environment through data source address mapping, thereby solving the problem of how to achieve automated testing of online production data and improve testing efficiency under the architecture in which the production environment and the test environment are isolated, and reproducing the problems occurring in the production environment in the test environment, thereby improving the efficiency of troubleshooting.

[0016] Details of one or more embodiments of the present application are set forth in the following drawings and description to make other features, objects, and advantages of the present application more readily apparent. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings: Figure 1 is a hardware structure block diagram of a terminal of a production data testing method according to an embodiment of the present invention; Figure 2 is an operation flow chart of a production data testing method according to an embodiment of the present application; Figure 3 is a flow chart of a production data testing method according to a preferred embodiment of the present application; Figure 4 is a relationship diagram between a production environment and a test environment according to an embodiment of the present application; Figure 5 It is a structural block diagram of a production data testing device according to an embodiment of the present application. DETAILED DESCRIPTION

[0018] In order to make the purpose, technical solutions and advantages of the present application clearer, the present application is described and illustrated below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application. Based on the embodiments provided in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application. In addition, it can also be understood that although the efforts made in this development process may be complex and lengthy, for ordinary technicians in the field related to the contents disclosed in the present application, some changes such as design, manufacturing or production based on the technical contents disclosed in the present application are only conventional technical means, and should not be understood as insufficient contents disclosed in the present application.

[0019] Reference to "embodiments" in this application means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those of ordinary skill in the art that the embodiments described in this application may be combined with other embodiments without conflict.

[0020] Unless otherwise defined, the technical terms or scientific terms involved in this application should be understood by people with ordinary skills in the technical field to which this application belongs. The words "one", "a", "a", "the" and the like involved in this application do not indicate a quantity limitation, and may indicate the singular or plural. The terms "include", "comprise", "have" and any of their variations involved in this application are intended to cover non-exclusive inclusions; for example, a process, method, system, product or device that includes a series of steps or modules (units) is not limited to the listed steps or units, but may also include steps or units that are not listed, or may also include other steps or units inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The "multiple" involved in this application means greater than or equal to two. "And / or" describes the association relationship of associated objects, indicating that there can be three relationships. For example, "A and / or B" can mean: A exists alone, A and B exist at the same time, and B exists alone. The terms "first", "second", "third" and the like involved in the present application are merely used to distinguish similar objects and do not represent a specific ordering of the objects.

[0021] The method embodiment provided in this embodiment can be executed in a terminal, a computer or a similar computing device. Taking running on a terminal as an example, Figure 1 1 is a hardware structure diagram of a terminal of the production data testing method according to an embodiment of the present invention. Figure 1 As shown, the terminal 10 may include one or more ( Figure 1 Only one is shown in the figure) a processor 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data. Optionally, the terminal may also include a transmission device 106 and an input / output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.

[0022] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the production data testing method in the embodiment of the present invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the terminal 10 via a network. Examples of the above network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0023] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by the communication provider of the terminal 10. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0024] This embodiment provides a production data testing method. Figure 2 is a flowchart of a production data testing method according to an embodiment of the present application, such as Figure 2 As shown, the process includes the following steps: Step S21, collecting online log data in the production environment, and obtaining the first data source address in the production environment.

[0025] Among them, the production environment refers to the environment in which the software or system actually runs. It is oriented to end users or customers and processes real business data and traffic. Log data collection refers to the process of collecting the operation logs of the system, application or service from the production environment. The log data records various events and status information during the operation of the software or system, including user operations, system errors, performance data, etc. The first data source address refers to the location or identifier of the data source that stores or provides key business data in the production environment. This address can be the IP address and port number of the database server, the path of the file system, the URL (Uniform Resource Locator) of the API (Application Programming Interface), etc., depending on the storage and access method of the data. The first data source address is the key information for accessing and obtaining production data, which is crucial for tasks such as testing, analysis, and monitoring. The first data source address can be obtained by clarifying the type of the first data source, whether it is a database, file system, API or other type of data source, and then consulting the system or application documents and configuration files. Usually, these files contain the configuration information of the data source, including address, port, user name, password, etc.

[0026] Step S22: export the online log data as an initial test case.

[0027] Step S23, based on a preset address mapping relationship, mapping the first data source address to a second data source address under the test environment, and converting the initial test case to the second data source address to obtain a target test case.

[0028] Among them, the test environment is an environment specially used for software or system testing. The test environment allows R&D personnel to execute test cases under safe and controllable conditions to verify whether the functions, performance, stability and security of the software or system meet the expected requirements. It simulates certain aspects of the production environment, but is usually not directly connected to the production environment to ensure that the test activities will not have any impact on the production environment. The present invention accesses data from different data source addresses through the test environment and the production environment respectively, ensuring the isolation of the production environment from the test environment, so as to protect the production environment from potential risks that may be caused by the test activities; Address Mapping A data source address relationship is a corresponding relationship between a production environment and a test environment. This mapping relationship allows a system or application to automatically convert a data source address from an original environment (such as a production environment) to a corresponding address in a target environment (such as a test environment) when migrating from one environment to another. The preset address mapping relationship can be defined by the developer and then stored in a mapping table or configuration file, such as JSON, XML, CSV, or a database table. The address conversion process can be accomplished by obtaining the first data source address and the second data source address, and then replacing the first data source address with the found second data source address in a test case or other place that needs to be modified based on the preset address mapping relationship. This process can be implemented through automated tools or scripts to ensure that all relevant references are correctly updated and that the initial test case is converted to the target test case after the data source address is converted.

[0029] Step S24, performing automated test processing based on the target test case to generate production data test results.

[0030] The automated testing part of the present invention uses a pre-written test framework and test scripts to execute target test cases, such as Figure 3 , generate multiple test instances in response to the data in the target test case, compare the actual results with the expected results, and check whether any failures or abnormalities occur, that is, the production data test results.

[0031] Through the above steps, the present invention collects representative online log data from the production environment, and obtains the first data source address in the production environment; processes the online log data to derive it as an initial test case; based on a preset address mapping relationship, maps the first data source address to the second data source address in the test environment, and converts the initial test case to the second data source address to obtain a target test case, so that under the isolation architecture of the production and test environments, the production data is automatically converted to the test environment based on the data source address mapping, thereby opening up data intercommunication between the production environment and the test environment, and realizing an automated testing method for online production data under the environment isolation architecture, effectively improving the testing efficiency, and avoiding the problem of missing information that may be caused by R&D personnel manually filling in and analyzing logs; performing automated testing on the target test case, simulating the database and various operations of the production environment, and finally generating production data test results, realizing the reproduction of production environment problems and automated testing interfaces without affecting online business, so that the cause of production failures can be analyzed, and the impact of functional changes on production business can be tested before the function is changed.

[0032] In some embodiments, the step S21 of collecting online log data in the production environment further includes: S211, according to the obtained request identifier, collect online log data in the production environment. Among them, the interface log data is a log with unified tracking link information and consistent format printed by implanting multiple services in the online production environment, recording the interface request information in a specific format and rules, that is, setting the following data structure to send a request to the server and obtain the corresponding data results.

[0033] The data structure of the interface request is as follows, which mainly includes the request id, business flow id, request parameter information, and return parameter information.

[0034] 2024-05-30 10:13:30.895 15830524212d4ae3af7453ec24f929b7 123.182.194.105 POST Headers:xxx / xxx / xxx xxx.com [{"SEQID":"28714","METHOD":"xxx","BODY":{"xxx":"xxx","xxx":"xxxx"}] {"code":0,"method":"xxx","seqId":"xxx"} x-request-id:8fc663425d4c3b42fcf8ef5a230f1d07; S212, collect the middleware log data in the production environment, the online log data includes interface log data and middleware log data. The middleware log data refers to the log information of various operations, events and states automatically recorded by the middleware system or application program during the operation of the middleware program, which can record the user's access to data resources such as databases and file systems, and help monitor the use and changes of data. In this embodiment, the middleware log data mainly records the changes of the database; in the production environment, the middleware can be deployed on one or more servers or in a virtual machine or container (such as Docker, Kubernetes). In addition, the middleware system can be implemented through Web server middleware, application server middleware, message middleware, database middleware, etc.

[0035] The above-mentioned embodiment is used to collect online log data in the production environment, and centrally stores log information by collecting interface log data and middleware log data, so that the production environment and the test environment can conveniently access and analyze log data, without searching across multiple systems or servers, reducing the tediousness and errors of manual log processing, and effectively improving the test efficiency. In the conventional production environment log, usually only http request logs are provided, and R&D personnel are not allowed to push data and reproduce requests in production services, rarely print detailed business logs, and cannot set breakpoints to debug error information, which means that R&D personnel often need to infer the cause of the error based on request parameters and a small amount of service exception logs in practice, and it is difficult to intuitively and quickly locate the problem. The log collection service of the present invention automates the processing of log data, so that detailed business logs can be printed, and the processed business logs are imported into the test environment to push data and reproduce requests, thereby meeting the test troubleshooting requirements.

[0036] In some embodiments, step S211 further includes: According to the request identifier, the request log data in the production environment is collected, the request log data is cleaned, and the interface log data is obtained. The request log data includes the request identifier.

[0037] The request identifier is used to uniquely identify a request so that it can be tracked, identified and processed during the communication process. For example, the request line, request header and session identifier in the session between the client and the server can be combined to uniquely identify an HTTP request. Collect all request information in the production environment according to the request identifier, that is, collect request log data; Perform log cleaning on the request log data. Log cleaning can include operations such as responding to special parameters and error requests, removing duplicate logs, and uniformly formatting logs. Log cleaning can improve the quality and value of log data and provide strong support for subsequent automated testing. Through log cleaning, formatted interface log data is obtained, which is used to obtain request-related data in subsequent test environments. The log collection service automatically processes log data and provides collection, query, and cleaning functions. These functions are not only used for subsequent automated testing, but can also be used by R&D personnel to directly analyze full-link business logs.

[0038] In some embodiments, step S23 maps the first data source address to the second data source address under the test environment based on a preset address mapping relationship, and converts the initial test case to the second data source address, and the step of obtaining the target test case further includes: Based on a preset address mapping relationship, the access key of the production environment is modified to the access key of the test environment, and the first data source address is mapped to the second data source address in the test environment.

[0039] Among them, the access key of the production environment is used to access various types of data in the production environment. Since the production environment and the test environment are isolated from each other, and the data and keys of the production environment usually contain sensitive information, the access key of the production environment cannot be used directly in the test environment. It is necessary to map the data source address and key of the production environment to the test environment to ensure the effectiveness and security of the test. By modifying the access key of the production environment to the access key of the test environment, and mapping the first data source address to the second data source address in the test environment, it is possible to convert a large amount of data in the production environment to the test environment for testing under the architecture where the production environment and the test environment are isolated, that is, convert the initial test case in the production environment to the target test case in the test environment, avoiding the omission problem caused by the R&D personnel writing log data by themselves in the traditional technology.

[0040] In some embodiments, step S24 performs automated test processing based on the target test case, and the step of generating production data test results also includes: S241, based on the target test case, obtain request parameter information and data operation request.

[0041] Among them, the target test case is the data in the test environment, which can be obtained through the newly added test environment access key. The target test case is converted from the initial test case, including the cleaned interface log data. The cleaned interface log data can obtain parameter information and database data operation requests. The data operation request is the log data left by the operation of the database in the production environment. The request parameter information is the mapping of various request parameters of the production environment to the test environment, which is used to simulate the sending of various parameter information in the test environment to request the interface under test, so as to simulate the interaction between actual users or systems, detect whether the test interface can correctly process and return the expected results, and realize the detection of the interface.

[0042] S242, acquiring the test middleware data, modifying the data according to the data operation request, and storing the modified data in the target test database.

[0043] Among them, the operation of the database will leave two logs. The tracking link information of the command / result log of the database operation will be left in the interface log data, and a middleware change log will be left in the middleware log data to print the original data and operation commands. The data of the middleware changes can be obtained by tracking the link information, so the test middleware data can be obtained from the target test case. The test middleware data is the middleware data of the test environment, which records the changes of the database. The test case structure for the database is as follows, which mainly includes new data, original data, operation type, database information, and data table information.

[0044] {"data":{"xxx_type":"2","update_time":"2023-05-23 19:17:54","create_time":"2023-05-23 19:10:19","xxx_id":"10004","xxxx_id":"45","id":"16","zzz":"90086","status":"3"},"database":"xxx","t raceId":"15830524212d4ae3af7453ec24f929b7","old":{"xxx_id":"80086"},"table":"t_xxx","type":"UPDATE"} In the test environment, by dynamically modifying or overwriting the data in the database according to the requirements of the test case, different modification operations are performed for different data operation requests to achieve the conversion of the test environment middleware data and obtain the test environment database, which reproduces the database data in the production environment. After the modification operation, the target test data after the middleware data conversion is obtained, and the target test data is stored in the test environment database.

[0045] S243, requesting the test interface to perform automated testing according to the request parameter information and the target test database, and generating production data test results.

[0046] In order to simulate the interaction between actual users or systems, various parameter information is sent in the test environment to request the interface under test. You can use the automated test framework (such as JUnit, pytest, etc.) to write automated test scripts, execute the test scripts in the test environment, and verify whether the functions and performance of the interface meet expectations. Finally, the production data test results are generated, including successful and failed use cases, so that R&D personnel can troubleshoot and fix the code based on the feedback.

[0047] In some embodiments, S242, the step of obtaining test middleware data, modifying the data according to the data operation request, and storing the modified data in the target test database further includes: If the data operation request is a query request, querying a target test case in response to the query request, and storing the data queried from the target test case in a target test database; The operation of the database will leave two logs, one is the tracking link information of the command to operate the database in the interface log data, and the other is the middleware change log that prints the original data and operation commands in the middleware log data. The data operation request for the production environment middleware change is obtained by tracking the link information. When the data operation request is a query request, the target test case can be queried according to the sql query log printed in the log data, and the data results obtained by the query can be written into the test environment database.

[0048] If the data operation request is an insert request or a delete request, the data of the target test case is stored in the target test database; Among them, when the data operation request is an insert request, the corresponding data original in the target test case can be written into the target test database; when the data operation request is a delete request, the delete request can remove the corresponding data original in the target test case and then write it into the target test database.

[0049] If the data operation request is an update request, the target test case will overwrite the test middleware data, and the overwritten test middleware data will be stored in the target test database.

[0050] Among them, in the update command of the production environment database, the log records the updated data and the updated field data, so the update operation in the test environment needs to record both the data before the modification and the modified data for verification. When the data operation request is an update request, the target test case overwrites the test middleware data and stores it in the target test database, and the overwritten test middleware data is stored in the target test database.

[0051] In some embodiments, S242, the step of obtaining test middleware data, requesting a test interface to perform automated testing according to request parameter information and a target test database, and generating production data test results further includes: Based on the request parameter information and the target test database, the storage space of the production environment is simulated in the test environment, and the target test case is stored in the storage space; Call the test cases in the storage space, and perform tests based on the test cases requesting the test interface to generate production data test results.

[0052] Among them, according to the request parameter information and the data in the target test database, the storage space of the production environment can be simulated. The storage space includes cache services, message queues and databases. The cache service of the test environment is used to store and quickly retrieve data to reduce direct access to slower databases or other storage systems. The cache service can include a series of middleware with similar functions, such as the domestic TongRDS of Oriental Communications. The message queue is an asynchronous communication mechanism for transmitting information between different applications or different parts of the same application. Through the message queue, different parts of the system can run independently. When the system load is at its peak, the message queue can temporarily store messages that cannot be processed immediately to avoid system overload. The database provides a structured data storage method that allows users to query, update and manage data in an efficient manner. The cache service is used to store some frequently modified data, while the database is used to persist data that needs to be maintained for a long time. The following example illustrates: A user purchases a product on a shopping website. The user and product information is stored in the database, the user's current online status is stored in the cache, and the order placed by the user is pushed to the message queue. Figure 4At this time, the production environment is reproduced, the database is imported, the cache service and message queue are configured, and the test interface is requested for testing. The prepared test request can be sent to the test interface, and the sending and receiving process of the request can be monitored to ensure that there are no network or communication problems. Then, the response data of the interface is captured and recorded, and the response data is analyzed to verify whether it meets the expected results, identify any differences or inconsistencies, and evaluate their impact on the production environment. Test management tools (such as Jira, TestRail, etc.) can be used to record test results, and multiple reproduction of the cause of the error is supported, making troubleshooting more convenient.

[0053] In a preferred embodiment, Figure 3 , the production service accesses the formatted log plug-in, and generates formatted interface log data and formatted middleware log data (including operation type and operation result) during the business process. The log collection unit monitors log changes, and automatically collects interface log data and middleware log data (log collection service), cleans the call log, finds requests with changes in request and response parameter formats, and exports them as offline use case files. Offline use case files can be downloaded locally and local traffic can be reproduced through automated testing tools. Figure 4 , Figure 4 The process of log collection service to the automated test system is to map the middleware address of the production environment (the first data source address) to the test environment address (the second data source address), and roll back the test middleware data according to the middleware operation results of the target test case to store the data before modification in the middleware, and reproduce the production environment database, cache service and message queue. Finally, the test interface is called by simulating online request parameters for R&D personnel to perform automated testing or business troubleshooting.

[0054] This embodiment also provides a production data testing device, which is used to implement the above-mentioned embodiments and preferred implementation modes, and will not be repeated hereafter. As used below, the terms "module", "unit", "subunit", etc. can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.

[0055] Figure 5 is a structural block diagram of a production data testing device according to an embodiment of the present application, such as Figure 5 As shown, the device comprises: The log collection module 51 is used to collect online log data in the production environment and obtain the first data source address in the production environment; An export module 52, used to export online log data as initial test cases; The data address mapping module 53 is used to map the first data source address to the second data source address under the test environment based on a preset address mapping relationship, and convert the initial test case to the second data source address to obtain a target test case; The automated testing module 54 is used to perform automated testing based on target test cases and generate production data test results.

[0056] The log collection module 51 is also used to collect interface log data in the production environment according to the obtained request identifier; collect middleware log data in the production environment, and the online log data includes interface log data and middleware log data.

[0057] The log collection module 51 is also used to collect request log data in the production environment according to the request identifier, perform log cleaning on the request log data, and obtain interface log data. The request log data includes the request identifier.

[0058] The data address mapping module 53 is also used to modify the access key of the production environment to the access key of the test environment based on a preset address mapping relationship, and map the first data source address to the second data source address in the test environment.

[0059] The above-mentioned automated testing module 54 is also used to obtain request parameter information and data operation requests based on target test cases; Obtain test middleware data, modify the data according to the data operation request, and store the modified data in the target test database; According to the request parameter information and the target test database, the test interface is requested to perform automated testing and generate production data test results.

[0060] The above-mentioned automated testing module 54 is also used to obtain test middleware data based on the test environment; If the data operation request is a query request, querying a target test case in response to the query request, and storing the data queried from the target test case in a target test database; If the data operation request is an insert request or a delete request, the data of the target test case is stored in the target test database; If the data operation request is an update request, the target test case will overwrite the test middleware data, and the overwritten test middleware data will be stored in the target test database.

[0061] The automated testing module 54 is also used to simulate the storage space of the production environment in the test environment according to the request parameter information and the target test database, and store the target test cases to the storage space; Call the test cases in the storage space, and perform tests based on the test cases requesting the test interface to generate production data test results.

[0062] It should be noted that the above modules can be functional modules or program modules, and can be implemented by software or hardware. For modules implemented by hardware, the above modules can be located in the same processor; or the above modules can be located in different processors in any combination.

[0063] This embodiment further provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.

[0064] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.

[0065] Optionally, in this embodiment, the processor may be configured to perform the following steps through a computer program: S1, collect online log data in the production environment, and obtain the first data source address in the production environment.

[0066] S2, export online log data as initial test cases.

[0067] S3, based on a preset address mapping relationship, mapping the first data source address to the second data source address under the test environment, and converting the initial test case to the second data source address to obtain a target test case.

[0068] S4, performs automated test processing based on target test cases and generates production data test results.

[0069] It should be noted that the specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementation modes, and this embodiment will not be described in detail here.

[0070] In addition, in combination with the production data testing method in the above embodiment, the embodiment of the present application can provide a storage medium for implementation. The storage medium stores a computer program; when the computer program is executed by a processor, any one of the production data testing methods in the above embodiment is implemented.

[0071] Those skilled in the art should understand that the technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0072] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.

Claims

1. A production data testing method, characterized in that: include: Collect online log data in a production environment, and obtain a first data source address in the production environment; Exporting the online log data as an initial test case; Based on a preset address mapping relationship, the first data source address is mapped to a second data source address under the test environment, and the initial test case is converted to the second data source address to obtain a target test case; Automated test processing is performed based on the target test case to generate production data test results.

2. The production data testing method according to claim 1, characterized in that: The online log data collected in the production environment includes: Collecting interface log data in the production environment according to the obtained request identifier; The middleware log data in the production environment is collected, and the online log data includes the interface log data and the middleware log data.

3. The production data testing method according to claim 2, characterized in that: The collecting of interface log data in the production environment according to the request identifier includes: According to the request identifier, request log data in a production environment is collected, log cleaning is performed on the request log data, and the interface log data is obtained, where the request log data includes the request identifier.

4. The production data testing method according to claim 1, characterized in that: The mapping of the first data source address to the second data source address under the test environment based on a preset address mapping relationship includes: Based on a preset address mapping relationship, the access key of the production environment is modified to the access key of the test environment, and the first data source address is mapped to the second data source address in the test environment.

5. The production data testing method according to any one of claims 1 to 4, characterized in that: The step of performing automated test processing based on the target test case to generate production data test results includes: Based on the target test case, obtaining request parameter information and data operation request; Acquire test middleware data, modify the data according to the data operation request, and store the modified data in the target test database; According to the request parameter information and the target test database, the test interface is requested to perform automated testing to generate production data test results.

6. The production data testing method according to claim 5, characterized in that: The acquiring of the test middleware data, modifying the data according to the data operation request, and storing the modified data in the target test database includes: Based on the test environment, obtaining test middleware data; If the data operation request is a query request, querying the target test case in response to the query request, and storing the data queried from the target test case in the target test database; If the data operation request is an insert request or a delete request, storing the data of the target test case in the target test database; If the data operation request is an update request, the target test case overwrites the test middleware data, and the overwritten test middleware data is stored in the target test database.

7. The production data testing method according to claim 5, characterized in that: The step of requesting the test interface to perform automated testing and generating production data test results according to the request parameter information and the target test database includes: According to the request parameter information and the target test database, simulating the storage space of the production environment in the test environment, and storing the target test case in the storage space; The test case in the storage space is called, and based on the test case, the test interface is requested to perform a test to generate the production data test result.

8. A production data testing device, characterized in that: include: A log collection module, used to collect online log data in a production environment and obtain a first data source address in the production environment; An export module, used to export the online log data as an initial test case; A data address mapping module, used to map the first data source address to a second data source address under a test environment based on a preset address mapping relationship, and convert the initial test case to the second data source address to obtain a target test case; The automated testing module is used to perform automated testing based on the target test cases and generate production data test results.

9. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to run the computer program to execute the production data testing method according to any one of claims 1 to 7.

10. A storage medium, characterized in that: The storage medium stores a computer program, wherein the computer program is configured to execute the production data testing method according to any one of claims 1 to 7 when running.

Citation Information

Patent Citations

  • Network software online testing method and system

    CN103580943A

  • Beta testing method and device

    CN106484610A

  • Online analog data acquisition method, device and equipment

    CN111881035A

  • Interface testing method, device and equipment based on traffic playback and storage medium

    CN116881145A

  • Test data processing method and device, equipment, storage medium and program product

    CN117033172A