Traffic playback test method and device, electronic equipment, computer readable storage medium and computer program product

By automatically deploying the test environment on the Kubernetes platform and using network policies and hook technology to achieve environment isolation, the problem of unreliable isolation between the test environment and the production environment is solved, ensuring that the production environment is not affected during traffic replay testing and improving the reliability of test results.

CN121193633APending Publication Date: 2025-12-23TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410813345.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-21
Publication Date
2025-12-23

AI Technical Summary

Technical Problem

In existing technologies, the environmental isolation between the test environment and the production network environment is not reliable enough, which may affect the production network environment during traffic replay testing. Furthermore, the test environment is not close enough to the real production network environment and cannot effectively simulate the traffic replay of the production network environment.

Method used

The test environment is automatically deployed using the Kubernetes platform, and environment isolation is achieved through network policies such as iptables and hooking network-related system calls. This ensures that the test environment is independent of the production environment, and the recorded traffic cannot be identified in the production environment. Mock processing ensures that the production environment is not affected.

Benefits of technology

It enables effective simulation of traffic replay in the test environment, improving the reliability of environmental test results and preventing the test environment from affecting the live network environment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121193633A_ABST
    Figure CN121193633A_ABST
Patent Text Reader

Abstract

The invention provides a traffic playback test method and device, electronic equipment, a computer readable storage medium and a computer program product. The method comprises the following steps: in response to an environment test request for a target service in a test environment, obtaining recording traffic in a current network environment; wherein the test environment and the current network environment are in an environment isolation state; obtaining a service processing request of a target service; in response to the service processing request, performing traffic analysis on the recorded traffic to obtain request data of the service processing request; performing service logic processing on the target service based on the request data to obtain traffic playback response data of the target service; and determining an environment test result of the current network environment based on the traffic playback response data and the service response data of the target service in the recorded traffic. According to the method and the device, the traffic playback of the current network environment can be effectively simulated in the test environment, so that the reliability of an environment test result is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of artificial intelligence, and in particular to a traffic playback test method, apparatus, electronic device, computer-readable storage medium, and computer program product. Background Technology

[0002] As application systems grow in scale and complexity, ensuring the correctness of the original business logic becomes a major challenge when iterating, upgrading, or even refactoring the system. Simple business systems can be addressed with conventional automated testing tools and manual testing. However, complex systems require traffic replay testing to ensure testing efficiency during iteration. Traffic replay involves recording traffic in the production environment and then re-initiating the call to the iterated system in the test environment to verify the correctness of the system logic. A replay response is generated upon completion; by comparing the original recording with the replay response, the correctness of the tested system can be determined.

[0003] However, while the relevant technologies provide deployment solutions for test environments, the deployed test environments are not close enough to the real network environment, and the environmental isolation between the test environment and the network environment is not reliable enough. It cannot be guaranteed that the network environment will not be affected during traffic replay testing, thus making it impossible to effectively simulate the traffic replay of the network environment in the test environment. Summary of the Invention

[0004] This application provides a traffic replay testing method, apparatus, electronic device, computer-readable storage medium, and computer program product, which can effectively simulate traffic replay in a test environment, thereby improving the reliability of environmental test results.

[0005] The technical solution of this application embodiment is implemented as follows:

[0006] This application provides a traffic replay testing method, the method comprising: in response to an environment test request for a target service in a test environment, acquiring recorded traffic in a live network environment; wherein the test environment and the live network environment are in an environment isolation state; acquiring a service processing request for the target service; in response to the service processing request, parsing the recorded traffic to obtain request data of the service processing request; performing business logic processing on the target service based on the request data to obtain traffic replay response data of the target service; and determining the environment test result of the live network environment based on the traffic replay response data and the service response data of the target service in the recorded traffic.

[0007] This application provides a traffic playback testing device, comprising: a recording traffic acquisition module, configured to acquire recorded traffic in a live network environment in response to an environment test request for a target service in a test environment; wherein the test environment and the live network environment are in an environment isolation state; a request acquisition module, configured to acquire a service processing request for the target service; a parsing module, configured to parse the recorded traffic in response to the service processing request to obtain request data corresponding to the service processing request; a service logic processing module, configured to perform service logic processing on the target service based on the request data to obtain traffic playback response data of the target service; and a determination module, configured to determine the environment test result of the live network environment based on the traffic playback response data and the service response data of the target service in the recorded traffic.

[0008] In the above scheme, the recording traffic acquisition module is further configured to: respond to an environment test request for the target service in the test environment, acquire the traffic data of all processed services in the business module corresponding to the target service in the current network environment, and the protocol type supported by the current network environment; determine the preprocessing field corresponding to the protocol type; and perform data preprocessing on the traffic data based on the preprocessing field to obtain the recording traffic.

[0009] In the above scheme, the parsing module is further configured to: respond to the business processing request, determine at least one business processing sub-request when performing business logic processing on the target business; obtain the sub-request identifier and sub-request content identifier of each business processing sub-request; parse the recorded traffic based on the preprocessing field to obtain parsed data; obtain the sub-request response data corresponding to each business processing sub-request from the parsed data based on the sub-request identifier and the sub-request content identifier; and determine all the obtained sub-request response data as the request data of the business processing request.

[0010] In the above scheme, the business logic processing module is further configured to: determine the business processing logic of the target business; based on each sub-request response data in the request data and the sub-request content identifier of the sub-request response data, perform business logic processing on the target business according to the business processing logic to obtain the traffic replay response data of the target business.

[0011] In the above scheme, the test environment includes a test module, which is used to perform business logic processing on the target service based on the request data; the device also includes a loading module, which is used to: obtain the target image corresponding to the business module when processing the target service in the live network environment from the image repository of the live network environment; create a target container in the test environment for loading the target image; and load the target image in the target container to obtain the test module.

[0012] In the above scheme, the test environment further includes a replay module and a traffic parsing module; the test module is deployed in a first test node in the test environment; the replay module and the traffic parsing module are deployed in a second test node in the test environment; the first test node includes a first container group, and the target container is located in the first container group; the second test node includes a second container group and a third container group, the container deploying the replay module is located in the second container group, and the container deploying the traffic parsing module is located in the third container group; the address of the first test node is the first node address, the address of the second test node is the second node address; the address of the first container group is the first container group address, the address of the second container group is the second container group address, and the address of the third container group is the third container group address.

[0013] In the above scheme, the device further includes a network initialization module, which is used to: perform network initialization processing on the test environment to obtain traffic allowance conditions and traffic discard conditions in the test environment; wherein, when any current traffic request meets the traffic allowance conditions, the current traffic request is allowed to pass in the test environment, and when any current traffic request meets the traffic discard conditions, the current traffic request is discarded.

[0014] In the above scheme, the parsing module is further configured to: when the service processing request meets the traffic release condition, in response to the service processing request, perform traffic parsing on the recorded traffic; when the service processing request meets the traffic discard condition, prohibit responding to the service processing request.

[0015] In the above scheme, the traffic allowance condition includes at least one of the following: the destination address of the current traffic request is the same as any one of the first container group address, the second container group address, and the third container group address; the destination address of the current traffic request is the same as the first node address or the second node address; the source address of the current traffic request is the same as any one of the first container group address, the second container group address, and the third container group address, and the source port of the current traffic request is a first preset port; the destination address of the current traffic request is the same as any one of the first container group address, the second container group address, and the third container group address, and the destination port of the current traffic request is a second preset port; the traffic drop condition includes: the source address of the current traffic request is the same as any one of the first container group address, the second container group address, and the third container group address.

[0016] In the above scheme, the device further includes a construction module, which is used to: construct an independent dynamic library; call hook functions to hook all system networking processes in the playback module; and link the hooked system networking processes to the independent dynamic library.

[0017] In the above scheme, the parsing module is further configured to: upon receiving the business processing request, obtain the code corresponding to the business processing request from the independent dynamic library; and perform traffic parsing on the recorded traffic by executing the code obtained from the independent dynamic library.

[0018] In the above scheme, the determining module is further configured to: extract fields under different test dimensions from the traffic playback response data and the service response data of the target service in the recorded traffic, respectively, to obtain the first data field and the second data field under different test dimensions; and determine the environmental test result of the live network environment based on the first data field and the second data field for each test dimension.

[0019] This application provides an electronic device, including: a memory for storing computer-executable instructions; and a processor for executing the computer-executable instructions stored in the memory to implement the traffic playback test method provided in this application.

[0020] This application provides a computer-readable storage medium storing computer-executable instructions for implementing the traffic replay test method provided in this application when executed by a processor.

[0021] This application provides a computer program product, which includes computer-executable instructions stored in a computer-readable storage medium. When the processor of an electronic device reads the computer-executable instructions from the computer-readable storage medium and executes the computer-executable instructions, it implements the traffic playback test method provided in this application.

[0022] The embodiments of this application have the following beneficial effects:

[0023] First, in response to an environment test request for the target service in the test environment, recorded traffic from the live network environment is acquired; then, the business processing request of the target service is obtained. Next, in response to the business processing request, traffic parsing is performed on the recorded traffic to obtain the request data of the business processing request. Then, based on the request data, business logic processing is performed on the target service to obtain the traffic replay response data of the target service. Finally, based on the traffic replay response data and the business response data of the target service in the recorded traffic, the environment test result in the live network environment is determined. In this way, the test environment and the live network environment are isolated, and the recorded traffic cannot be identified in the live network environment. The request data of the business processing request can only be obtained through the traffic parsing step in the test environment, ensuring that the data in the test environment will not affect the live network environment during traffic replay testing. Furthermore, by accurately processing the request data with business logic, traffic replay in the test environment can be effectively simulated in the live network environment, thereby improving the reliability of the environment test results. Attached Figure Description

[0024] Figure 1 This is a schematic diagram of the architecture of the traffic replay test system provided in the embodiments of this application;

[0025] Figure 2 This is a schematic diagram of the flow playback test device provided in the embodiments of this application;

[0026] Figure 3 This is an optional flowchart illustrating the traffic replay testing method provided in the embodiments of this application;

[0027] Figure 4 This is another optional flowchart illustrating the traffic replay testing method provided in the embodiments of this application;

[0028] Figure 5 This is a schematic diagram of the architecture for traffic replay testing provided in an embodiment of this application;

[0029] Figure 6 This is a schematic diagram of the process for performing traffic replay testing provided in an embodiment of this application. Detailed Implementation

[0030] To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings. The described embodiments should not be regarded as limitations on this application. All other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0031] In the following description, references are made to “some embodiments,” which describe a subset of all possible embodiments, but it is understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.

[0032] If the application documents contain similar descriptions such as "first / second", the following explanation shall be added: In the following description, the terms "first / second / third" are used only to distinguish similar objects and do not represent a specific order of objects. It is understood that "first / second / third" may be interchanged in a specific order or sequence where permitted, so that the embodiments of this application described herein can be implemented in an order other than that illustrated or described herein.

[0033] In this application embodiment, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.

[0034] Unless otherwise defined, all technical and scientific terms used in the embodiments of this application have the same meaning as commonly understood by one of ordinary skill in the art. The terminology used in the embodiments of this application is for the purpose of describing the embodiments of this application only and is not intended to limit this application.

[0035] In the implementation of this application, the collection and processing of relevant data should strictly comply with the requirements of relevant national laws and regulations, obtain the informed consent or separate consent of the personal information subject, and carry out subsequent data use and processing within the scope of laws and regulations and the authorization of the personal information subject.

[0036] Before providing a further detailed description of the embodiments of this application, the nouns and terms involved in the embodiments of this application will be explained, and the nouns and terms involved in the embodiments of this application shall be interpreted as follows.

[0037] 1) Traffic recording: This involves recording the data packets of a specific request during network communication (i.e., the serialized results of the request's input parameters, output parameters, downstream remote procedure calls, databases, caches, etc.) in real time and saving them as raw data or in a parsed format. It is typically used for analyzing and auditing network communication, troubleshooting, and security monitoring. Traffic recording provides detailed information about network communication, allowing for in-depth analysis of the communication content.

[0038] 2) Traffic Replay: This involves restoring and replaying recorded network traffic data packets, retransmitting the packets in a virtual network environment, and simulating communication behavior in a live network environment. Traffic replay is typically used in scenarios such as network device performance testing, security vulnerability verification, and load balancing testing to simulate traffic in a live network environment and verify the performance and stability of network devices or systems.

[0039] 3) Production environment: The actual operating environment, which is the environment in which users actually use the system. In the production environment, the system's behavior directly affects users.

[0040] 4) Test environment: This is an environment that simulates the live network environment and is used to test the behavior of the system.

[0041] 5) Mock: A testing technique used to perform interface or unit tests by simulating code dependencies and setting expected values ​​when there are no actual dependencies.

[0042] 6) Mocking: Modify the traffic used for mocking so that the traffic cannot be used or identified in the live network environment.

[0043] 7) Hook: A programming technique used to insert or modify default system call behavior.

[0044] 8) Kubernetes (k8s): Kubernetes is a container orchestration platform used for scheduling and automatically deploying, managing, and scaling containerized applications. When deploying an application in a production environment, multiple instances of the application are typically deployed to load balance application requests. In Kubernetes, multiple containers can be created, each running an application instance. Built-in load balancing strategies enable the management, discovery, and access of this group of application instances, eliminating the need for complex manual configuration and handling by operations personnel.

[0045] Commonly used traffic replay tools in related technologies (such as tcpcopy and goreplay) all support sending recorded network traffic data to the service being tested. However, when using traffic replay tools like tcpcopy and goreplay to test system replay, they depend on the data and backend services of the test environment, making it difficult to set up the test environment and prone to failure or contaminating the real production network environment.

[0046] Furthermore, relatively mature traffic replay platforms in this field (such as MoonBox, Doom, Diffy, and ByteCopy) all implement traffic recording at the application layer and use mock mechanisms to perform regression verification through traffic replay in a specified test environment. However, while these traffic replay platforms provide deployment solutions for test environments, the deployment is not automated enough, and the test environment does not closely resemble the real-world production environment. Relying solely on intercepting request traffic through mocking to achieve environment isolation is also unreliable, as mock failures may impact the real-world production environment.

[0047] To address at least one of the aforementioned technical problems in related technologies, this application provides a traffic replay testing method based on the Kubernetes platform and traffic replay technology. This method, based on the Kubernetes platform, can automatically deploy test environments on demand, solving the problem of difficulty in setting up test environments. Furthermore, it achieves environmental isolation between the test environment and the production network environment through network policies such as iptables and hooking network-related system calls, solving the problem of unreliable environmental isolation. The traffic data in the production network environment is mocked to ensure that it cannot be identified by the production network environment, eliminating the possibility of polluting production network data.

[0048] The following describes an exemplary application of the traffic replay testing device (i.e., electronic device) provided in the embodiments of this application. The traffic replay testing device provided in the embodiments of this application can be implemented as a terminal or as a server. The following will describe an exemplary application when the traffic replay testing device is implemented as a server.

[0049] See Figure 1 , Figure 1 This is a schematic diagram of the architecture of the traffic replay test system 100 provided in this application embodiment. In order to support a traffic replay test application, the traffic replay test application runs on the terminal 400. The terminal 400 is connected to the server 200 through the network 300. The network 300 can be a wide area network or a local area network, or a combination of the two.

[0050] Terminal 400 sends an environment test request for a target service to server 200. Server 200 constitutes the traffic playback test device of this embodiment. Server 200 is used to respond to the environment test request for the target service in the test environment, obtain recorded traffic in the current network environment; wherein, the test environment and the current network environment are in an environmental isolation state; obtain the service processing request of the target service; respond to the service processing request, perform traffic parsing on the recorded traffic to obtain the request data of the service processing request; perform business logic processing on the target service based on the request data to obtain traffic playback response data of the target service; and determine the environment test result of the current network environment based on the traffic playback response data and the service response data of the target service in the recorded traffic. After obtaining the environment test result, server 200 returns the environment test result to terminal 400 so that the environment test result can be displayed on terminal 400 or the terminal 400 can continue to perform the next step of service processing based on the environment test result.

[0051] In some embodiments, server 200 may be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms. Terminal 400 may be a smartphone, tablet, laptop, desktop computer, smart TV, smart speaker, smartwatch, in-vehicle terminal, etc., but is not limited to these. Terminals and servers can be directly or indirectly connected via wired or wireless communication, which is not limited in this embodiment.

[0052] See Figure 2 , Figure 2 This is a schematic diagram of the structure of the electronic device 40 provided in the embodiment of this application. Figure 2 The illustrated electronic device 40 can be a traffic playback test device, which includes at least one processor 410, a memory 450, at least one network interface 420, and a user interface 430. The various components in the traffic playback test device are coupled together via a bus system 440. It is understood that the bus system 440 is used to implement communication between these components. In addition to a data bus, the bus system 440 also includes a power bus, a control bus, and a status signal bus. However, for clarity, in… Figure 2 The general labeled all buses as Bus System 440.

[0053] The processor 410 can be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor, etc.

[0054] User interface 430 includes one or more output devices 431 that enable the presentation of media content, including one or more speakers and / or one or more visual displays. User interface 430 also includes one or more input devices 432, including user interface components that facilitate user input, such as a keyboard, mouse, microphone, touch screen display, camera, other input buttons and controls.

[0055] The memory 450 may be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid-state storage, hard disk drives, optical disk drives, etc. The memory 450 may optionally include one or more storage devices physically located away from the processor 410.

[0056] The memory 450 may include volatile memory or non-volatile memory, or both. The non-volatile memory may be read-only memory (ROM), and the volatile memory may be random access memory (RAM). The memory 450 described in this application embodiment is intended to include any suitable type of memory.

[0057] In some embodiments, memory 450 is capable of storing data to support various operations, examples of which include programs, modules, and data structures or subsets or supersets thereof, as illustrated below.

[0058] Operating system 451 includes system programs for handling various basic system services and performing hardware-related tasks, such as the framework layer, core library layer, driver layer, etc., for implementing various basic business functions and handling hardware-based tasks;

[0059] The network communication module 452 is used to reach other electronic devices via one or more (wired or wireless) network interfaces 420, exemplary network interfaces 420 including: Bluetooth, WiFi, and Universal Serial Bus (USB), etc.

[0060] Presentation module 453 is configured to enable the presentation of information (e.g., a user interface for operating peripheral devices and displaying content and information) via one or more output devices 431 (e.g., a display screen, a speaker, etc.) associated with user interface 430;

[0061] The input processing module 454 is used to detect and translate one or more user inputs or interactions from one or more input devices 432.

[0062] In some embodiments, the apparatus provided in this application can be implemented in software. Figure 2 A traffic playback test device 455 stored in memory 450 is shown. This device can be software in the form of programs and plug-ins, and includes the following software modules: a traffic recording acquisition module 4551, a request acquisition module 4552, a parsing module 4553, a business logic processing module 4554, and a determination module 4555. These modules are logically related and can therefore be arbitrarily combined or further separated according to their implemented functions. The functions of each module will be described below.

[0063] In other embodiments, the apparatus provided in this application can be implemented in hardware. As an example, the apparatus provided in this application can be a processor in the form of a hardware decoding processor, which is programmed to execute the traffic playback test method provided in this application. For example, the processor in the form of a hardware decoding processor can be one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field-programmable gate arrays (FPGAs), or other electronic components.

[0064] In some embodiments, the terminal or server can implement the traffic replay testing method provided in this application by running various computer-executable instructions or computer programs. For example, computer-executable instructions can be microprogram-level commands, machine instructions, or software instructions. Computer programs can be native programs or software modules in an operating system; they can be native applications (APPs), i.e., programs that need to be installed in the operating system to run, or they can be applets that can be embedded in any APP, i.e., programs that only need to be downloaded to a browser environment to run. In summary, the aforementioned computer-executable instructions can be any form of instruction, and the aforementioned computer programs can be any form of application, module, or plugin.

[0065] The traffic replay testing methods provided in the embodiments of this application can be executed by an electronic device, which can be a server or a terminal. That is, the traffic replay testing methods in the embodiments of this application can be executed by a server, by a terminal, or by interaction between a server and a terminal.

[0066] See Figure 3 , Figure 3 This is an optional flowchart illustrating the traffic replay testing method provided in this application embodiment, which will be combined with... Figure 3 The steps shown will be explained, taking the traffic replay test method with the server as the execution subject as an example. The method includes the following steps S101 to S105:

[0067] Step S101: In response to an environment test request for the target service in the test environment, obtain the recorded traffic in the live network environment.

[0068] In this embodiment, the target business refers to the specific business domain, business process, or business function targeted in the test environment. For example, in software testing, the target business can be an application, a website, a mobile application, or other software system. It can also be the shopping process of an e-commerce website, the user registration and login function of a social media application, or the payment transaction process of a payment system. An environment test request refers to the test requirements for a specific target business in the test environment. Environment test requests include, but are not limited to, functional testing, performance testing, stability testing, and security testing. Recorded traffic refers to traffic data obtained in the current network environment through a traffic recording process, and the data after preprocessing according to preset data processing rules in the test environment. For example, data preprocessing can be mocking. Traffic data refers to a series of network requests and responses in the current network environment. Network requests and responses include requests initiated by users through terminals and response data returned by servers after responding to those requests, as well as interactions related to downstream system calls, database access, caching operations, etc. Based on these preset data processing rules, recorded traffic can be identified and processed in the test environment, but cannot be identified in the current network environment.

[0069] The production environment refers to the actual operational environment, while the test environment is an environment set up to test software applications or system behavior. The test environment simulates some or all of the characteristics of the production environment to execute test cases under conditions different from the production environment. In the traffic replay testing method provided in this application embodiment, the test environment and the production environment are in an isolated state, meaning they operate independently and do not affect each other. A preset environment isolation method can be used to maintain this isolation, preventing data in the test environment from contaminating the production environment, avoiding test operations in the test environment from affecting the stability and performance of the production environment, and ensuring that test operations do not threaten the security of the production environment or user privacy. The preset environment isolation method can be network isolation technology or modifying or replacing network-related system calls in the test environment.

[0070] In some embodiments, when a user sends an environment test request for a target service to a server via a terminal, the recorded traffic in the current network environment is encapsulated within the received environment test request. The server is deployed in the test environment. After receiving the environment test request for the target service in the test environment, the server can directly parse the request to obtain the recorded traffic in the current network environment. In other embodiments, the recorded traffic is pre-stored in a preset traffic database. After receiving the environment test request for the target service in the test environment, the server automatically retrieves the recorded traffic corresponding to the environment test request from the preset traffic database based on the request identifier of the environment test request.

[0071] Here, the test environment is isolated from the production environment, and the recorded traffic cannot be recognized by the production environment. This ensures that the production environment will not be affected during traffic playback tests in the test environment.

[0072] Step S102: Obtain the business processing request of the target business.

[0073] In this embodiment, the business processing request of the target business refers to a request initiated for a function or operation in a specific business domain. For example, the business processing request may be a user registration request or a user login request in a social media application. In a test environment, different user behaviors and service interactions can be simulated to generate the business processing request of the target business.

[0074] In some embodiments, the method for obtaining the business processing requests of the target business in a test environment can be to simulate user behavior or API calls using written automated test scripts to generate the business processing requests of the target business. Alternatively, it can be to use performance testing tools (e.g., JMeter, LoadRunner, etc.) to simulate concurrent access by multiple users, generating a large number of business processing requests, where the target business's business processing request can be one type of all business processing requests. It can also be to use UI automation testing tools (e.g., TestComplete, Sikuli, etc.) to simulate user interaction with the front-end interface to generate the business processing requests of the target business. Furthermore, it can be to use integrated automation testing frameworks for automated testing of web applications and mobile applications (e.g., Selenium, Appium, etc.) to simulate user interaction with the front-end interface to generate the business processing requests of the target business. Finally, it can be to use a mock service in the test environment to simulate real service behavior and generate the business processing requests of the target business. The specific methods for obtaining the business processing requests of the target business are not limited here.

[0075] Here, by obtaining the business processing request of the target business, the business logic processing can be accurately executed on the request data obtained through traffic parsing based on the business processing request.

[0076] Step S103: In response to the business processing request, perform traffic parsing on the recorded traffic to obtain the request data for the business processing request.

[0077] In this embodiment, traffic parsing refers to the process of extracting request data for business processing requests from recorded traffic according to preset data processing rules in a test environment. This process cannot be implemented in a live network environment. The business processing request includes a request header and a request body. The request header is metadata information included in the recorded traffic when a user sends a request via a terminal in a live network environment, such as the request method, target URL, hostname, and user agent. The request data is the request body, which is the actual data sent by the user via a terminal to the server in a live network environment. For example, when the business processing request is a user registration request for a social media application, the request data could be the username, password, verification code, etc., entered by the user for registration.

[0078] After receiving a business processing request, in response to that request, in the test environment, the recorded traffic is restored to the traffic data of the production network environment through a traffic parsing step. This traffic data includes all data related to the processing of the business request, namely the request data and the corresponding response data. Therefore, the request data of the business processing request can be directly extracted from this traffic data.

[0079] Here, in the test environment, the request data of the business processing request is accurately obtained through the traffic parsing step, so that the business logic processing of the target business can be accurately realized based on the request data.

[0080] Step S104: Perform business logic processing on the target business based on the request data to obtain the traffic replay response data of the target business.

[0081] In this embodiment, business logic processing refers to the process of analyzing and processing according to the actual needs of the target business. For example, when the actual need of the target business is to complete the user registration function of a social media application, the business logic processing may be the implementation of the underlying logic corresponding to the user registration function. The input data of the business logic processing process is the request data of the business processing request, and the output data is the traffic replay response data of the target business. The traffic replay response data refers to the simulated response result corresponding to the business processing request in the test environment. For example, the traffic replay response data may be the simulated user registration status, the simulated user registration result, the simulated user registration speed, and the simulated user registration response time, etc.

[0082] After obtaining the request data for the business processing request, the target business can be processed according to its business processing logic to obtain the traffic replay response data. The business processing logic can be obtained by extracting it from a pre-defined business processing logic library based on the target business's business identifier. Alternatively, the business processing logic can be pre-encapsulated within the business processing request; after obtaining the request, the corresponding business processing logic can be obtained through parsing the request.

[0083] Here, based on the request data obtained through traffic parsing in the test environment, the business logic processing can achieve accurate business logic processing of the target business on the basis of accurate input data, so as to improve the accuracy of environmental test results in the test environment.

[0084] Step S105: Based on the traffic playback response data and the service response data of the target service in the recorded traffic, determine the environmental test results of the live network environment.

[0085] In this embodiment, the business response data of the target service in the recorded traffic refers to the actual response results corresponding to the business processing requests under the target service in the live network environment. For example, the business response data could be the actual user registration status, actual user registration result, actual user registration speed, and actual user registration response time obtained after responding to a user registration request from a social media application in the live network environment. The environmental test results in the live network environment refer to the comparison results obtained by comparing the simulated response data obtained in the test environment with the actual response data obtained in the live network environment. The environmental test results are used to measure the system performance and stability of the tested system for the target service in the live network environment. If the environmental test results are consistent with expectations, it indicates that the tested system performs well for the target service. Conversely, if the environmental test results are inconsistent with expectations, it may be necessary to take corresponding improvement and optimization strategies to improve the performance and stability of the tested system for the target service. In summary, the environmental test results in the live network environment can help understand the overall performance of the tested system for the target service and determine whether to formulate corresponding improvement and optimization strategies.

[0086] In some embodiments, the service response data of the target service in the recorded traffic can be obtained by performing traffic parsing on the recorded traffic. The service response data obtained after traffic parsing corresponds to the request data of the service processing request. When the service processing request of the target service changes, the request data and service response data will change accordingly.

[0087] Here, the same fields in the traffic replay response data and the business response data can be compared to determine the performance gap between the tested system and the live network environment for the target business, and whether the gap matches the expectations, so that the environmental test results obtained in the live network environment are comprehensive and reliable.

[0088] The traffic replay testing method provided in this application first obtains recorded traffic in the live network environment in response to an environmental test request for a target service in the test environment; then, it obtains the service processing request of the target service; next, in response to the service processing request, it performs traffic parsing on the recorded traffic to obtain the request data of the service processing request; then, it performs business logic processing on the target service based on the request data to obtain the traffic replay response data of the target service; finally, it determines the environmental test result of the live network environment based on the traffic replay response data and the service response data of the target service in the recorded traffic. In this way, the test environment and the live network environment are in an environmental isolation state, and the recorded traffic cannot be identified in the live network environment. The request data of the service processing request can only be obtained through the traffic parsing step in the test environment, ensuring that the data in the test environment will not affect the live network environment during the traffic replay test. Furthermore, by accurately processing the request data with business logic, it effectively simulates the traffic replay of the live network environment in the test environment, thereby improving the reliability of the environmental test results.

[0089] The following will describe the traffic replay testing method in this application embodiment, focusing on the interaction between the terminal and the server in the traffic replay testing system. It should be noted that this traffic replay testing method is implemented through interaction between the terminal and the server, and is essentially the same as the traffic replay testing method executed by the server in the above embodiments. The only difference is that this application embodiment also describes the actions performed by the terminal during the execution of the traffic replay testing method. Furthermore, some steps can be executed by either the terminal or the server. Therefore, for steps in this embodiment that are the same as those in the above embodiments but have different execution subjects, this embodiment is merely illustrative. In the implementation process, any execution subject can perform these steps, and this application embodiment does not limit this.

[0090] Figure 4 This is another optional flowchart illustrating the traffic replay testing method provided in the embodiments of this application, such as... Figure 4 As shown, the method includes the following steps S201 to S218:

[0091] Step S201: The terminal receives user input of a traffic replay test operation for the target service in a test environment.

[0092] In this embodiment, the user can be either the developer or the user of the traffic replay test application. The user can input all traffic data of the business modules corresponding to the target service in the current network environment into the client of the traffic replay test application to generate a traffic replay test operation for the target service in the test environment. The traffic replay test application can provide a traffic replay test function. Users can input all traffic data of the business modules corresponding to the target service in the current network environment into this function page to generate a traffic replay test operation for the target service in the test environment, thereby triggering a traffic replay test request for the target service in the test environment.

[0093] In some embodiments, when a user performs a traffic replay test on a target service in the input test environment, they can also simultaneously input the protocol types supported by the current network environment. When the terminal receives the traffic data and the protocol types supported by the current network environment, a confirmation window for the traffic replay test will pop up on the traffic replay test function page. After the terminal detects that the user has clicked the confirmation button for the traffic replay test, further traffic replay testing will be performed based on the traffic data and the protocol types supported by the current network environment. Alternatively, in other embodiments, the user can directly input the traffic data and the protocol types supported by the current network environment on the traffic replay test function page. Upon receiving the traffic data and the protocol types supported by the current network environment, the terminal can directly trigger the traffic replay test function and then perform further traffic replay testing based on the traffic data and the protocol types supported by the current network environment.

[0094] In step S202, the terminal generates a traffic replay test request in response to the traffic replay test operation.

[0095] In this embodiment, user-input data can be encapsulated into a traffic replay test request. For example, the display interface of the traffic replay test application shows the traffic data of all processed services in the business module corresponding to the target service in the current network environment, as well as the protocol types supported by the current network environment. Users can select data according to their actual needs, and then the user-input traffic data and the protocol types supported by the current network environment are encapsulated into a traffic replay test request.

[0096] In step S203, the terminal sends a traffic replay test request for the target service in the test environment to the server.

[0097] Step S204: The server responds to the traffic replay test request for the target service in the test environment, obtains the traffic data of all processed services in the business module corresponding to the target service in the live network environment, and the protocol types supported by the live network environment.

[0098] In this embodiment of the application, in response to a traffic replay test request for a bullet screen to be published, if the traffic replay test request encapsulates the traffic data of all processed services in the business module corresponding to the target service in the current network environment, as well as the protocol types supported by the current network environment, then the traffic data of all processed services in the business module corresponding to the target service in the current network environment, as well as the protocol types supported by the current network environment, can be directly parsed to obtain.

[0099] The business module corresponding to the target business refers to the module capable of processing the target business in the current network environment. For example, this business module could be a user management module used to manage user information in the system. All business processes handled by the business module refer to all business logic and functions handled by that module. For example, when the business module is a user management module, all business processes include user registration, login, and information modification. The traffic data for all business processes handled by the business module refers to the actual network traffic data captured within the business module in the current network environment. This traffic data includes requests sent by the client and responses returned by the server for that business module. For example, receiving a user registration request submitted by a user through a client, verifying the user's input information (such as username, password, email, etc.), saving the user information to the database, and returning a successful registration response—the user registration request and the successful registration response together constitute the traffic data.

[0100] The protocol types supported in the live network environment refer to the communication protocols supported by various network devices and systems in actual network operation. These protocols are used for data transmission and communication to ensure the security, reliability, and efficiency of network communication. Protocol types supported in the live network environment include, but are not limited to, HTTP, HTTPS, FTP, SMTP, POP3, IMAP, DNS, SNMP, and SSH.

[0101] Step S205: The server determines the preprocessing fields corresponding to the protocol type.

[0102] In this embodiment, the preprocessing field corresponding to the protocol type refers to the field used when preprocessing traffic data in the current network environment. Different protocol types correspond to different preprocessing fields. For example, for the HTTP protocol, the preprocessing field can be "MOCK / builtin-bin / echo". Here, the preprocessing field is subsequently used to preprocess the traffic data so that the recorded traffic obtained after data preprocessing cannot be recognized in the current network environment.

[0103] In step S206, the server performs data preprocessing on the traffic data based on the preprocessing fields to obtain the recorded traffic.

[0104] In this embodiment, data preprocessing refers to making specific modifications to traffic data based on preprocessing fields. The main purpose of data preprocessing is to prevent traffic data from leaking into the live network environment and thus affecting it. Recorded traffic obtained through data preprocessing cannot be recognized in the live network environment. For example, data preprocessing can be mocking; when the protocol type is HTTP, a preprocessing field "MOCK / builtin-bin / echo" can be inserted into the first line of the traffic data, making the recorded traffic unrecognizable in the live network environment.

[0105] In some embodiments, data preprocessing may involve inserting preprocessed fields into the first or last line of the traffic data, inserting preprocessed fields into a specific position in the traffic data, or modifying the data format of the traffic data based on the preprocessed fields. The specific method of data preprocessing is not limited here.

[0106] Here, the recorded traffic is obtained through data preprocessing, which ensures that the live network environment will not be affected during subsequent traffic replay tests based on the recorded traffic.

[0107] Step S207: The server obtains the business processing request of the target business.

[0108] In this embodiment of the application, the specific meaning and implementation method of the step of obtaining the business processing request of the target business can be found in the description of step S102 above, and will not be repeated here.

[0109] In step S208, the server responds to the business processing request and determines at least one business processing sub-request when performing business logic processing on the target business.

[0110] In this embodiment, the business processing request includes at least one business processing sub-request, which can be viewed as different sub-steps or sub-tasks within the business processing request. These business processing sub-requests are part of the business logic processing flow and work together to complete the entire business logic processing flow. For example, assuming the business processing request is a user login request, the business processing sub-requests in the user login request could be a request to obtain the username and a request to obtain the user password.

[0111] Step S209: The server obtains the sub-request identifier and sub-request content identifier of each business processing sub-request.

[0112] In this embodiment, the sub-request identifier is an identifier used to distinguish different business processing sub-requests, and the sub-request content identifier is used to identify the specific content contained in each business processing sub-request or the request purpose of each business processing sub-request. For example, assuming that the business processing sub-requests are a request to obtain a username and a request to obtain a user password, the sub-request identifier for the request to obtain a username can be A1, and the sub-request content identifier can be name; the sub-request identifier for the request to obtain a user password can be A2, and the sub-request content identifier can be password.

[0113] In step S210, the server parses the recorded traffic based on the preprocessed fields to obtain parsed data.

[0114] In this embodiment, parsing the recorded traffic refers to parsing the recorded traffic into data that can be processed for business logic in a test environment by identifying preprocessing fields; that is, parsing the data. The parsed data includes all relevant data for processing business within the business module corresponding to the target business in the live network environment, such as the relevant request data for each business processing sub-request within a business processing sub-request.

[0115] In step S211, the server obtains the sub-request response data corresponding to each business processing sub-request from the parsed data based on the sub-request identifier and the sub-request content identifier.

[0116] In step S212, the server determines all the sub-request response data obtained as the request data for the business processing request.

[0117] In this embodiment, the parsed data includes sub-request response data corresponding to each business processing sub-request. The sub-request response data consists of the data or parameters contained in the business processing sub-request. For each business processing sub-request, the sub-request identifier and sub-request content identifier are fixed. Data can be searched in the parsed data using the sub-request identifier and sub-request content identifier to directly obtain the sub-request response data corresponding to each sub-request, i.e., the sub-request response data corresponding to each business processing sub-request. For example, when the business processing sub-request is a request to obtain a username, the sub-request response data corresponding to the username request can be obtained from the parsed data by obtaining the sub-request identifier A1 and the sub-request content identifier name, i.e., the username. The request data of the business processing request includes the sub-request response data corresponding to each business processing sub-request, i.e., all sub-request response data. For example, when the business processing request is a user login request, the request data of the business processing request can be the username corresponding to the request to obtain a username and the user password corresponding to the request to obtain a user password; that is, the username and user password together constitute the request data of the business processing request.

[0118] Here, by accurately obtaining the request data of the business processing request in the test environment, the target business can be accurately processed based on the request data.

[0119] Step S213: The server determines the business processing logic of the target business.

[0120] In step S214, the server performs business logic processing on the target business based on each sub-request response data and the sub-request content identifier in the request data, according to the business processing logic, to obtain the traffic replay response data of the target business.

[0121] In this embodiment, the business processing logic of the target service refers to the underlying logic for processing the target service requirements. During traffic replay testing, the business processing logic for the target service in the business module of the live network environment can be directly copied to the test environment, or the business processing logic of the target service can be extracted from a preset logic library that stores the business processing logic of the target service.

[0122] Each sub-request response data in the request data is used as input data for business logic processing. The sub-request content identifier in the sub-request response data is used to characterize the data role of the sub-request response data in business logic processing. Traffic replay response data refers to the simulated response results corresponding to the business processing request in the test environment. For example, traffic replay response data can be simulated user login status, simulated user login result, simulated user login speed, and simulated user login response time.

[0123] Here, based on the sub-request response data and the sub-request content identifier of each sub-request response data in the request data, accurate business logic processing of the target business can be achieved, so as to improve the accuracy of environmental test results in the test environment.

[0124] In step S215, the server extracts fields from the traffic replay response data and the target service response data in the recorded traffic under different test dimensions, and obtains the first data field and the second data field under different test dimensions.

[0125] In this embodiment, field extraction for different test dimensions refers to extracting different data fields from traffic replay response data and business response data based on the different data types involved in the testing process. Test dimensions can be set according to actual testing needs. The first data field is obtained by extracting fields from the traffic replay response data under different test dimensions, and the second data field is obtained by extracting fields from the business response data of the target business in the recorded traffic under different test dimensions. For each test dimension, the first data field and the second data field correspond to each other and belong to the same type of data field. Here, the field extraction process under different test dimensions is used to obtain accurate environmental test results by subsequently comparing the first and second data fields under each test dimension.

[0126] Step S216: For each test dimension, the server determines the environmental test results of the live network environment based on the first data field and the second data field.

[0127] In this embodiment, after obtaining the first data field and the second data field under different test dimensions, a field comparison can be performed on the first data field and the second data field under each test dimension to obtain the environmental test result of the live network environment. For example, when comparing fields under the test dimension of user login status, if the first data field represents a simulated user login status of login failure and the second data field represents a real user login status of login success, then the environmental test result of the live network environment is that the system performance of the tested system is unstable for user login.

[0128] Here, by comparing the same representation fields in the traffic replay response data and the service response data, the performance gap between the tested system for the target service in the test environment and the live network environment is determined, as well as whether the gap matches the expectations, so that the environmental test results in the live network environment are comprehensive and reliable.

[0129] In step S217, the server sends the environment test results to the terminal.

[0130] Step S218: The terminal displays the environmental test results.

[0131] In this embodiment, firstly, through a data preprocessing process, traffic data in the live network environment is transformed into recorded traffic that can only be recognized by the test environment. Then, in response to a business processing request, the sub-request identifier and sub-request content identifier of at least one business processing sub-request in the business processing request are determined. Based on these identifiers, the sub-request response data corresponding to each business processing sub-request is obtained from the parsed data. Next, based on all the sub-request response data, business logic processing is performed on the target business according to the business processing logic to obtain the traffic playback response data of the target business. Finally, by extracting and comparing fields under different test dimensions from the traffic playback response data and the business response data, accurate environmental test results are obtained. Thus, the test environment and the live network environment are in an isolated state, and the recorded traffic cannot be recognized in the live network environment. The request data of the business processing request can only be obtained through the traffic parsing step in the test environment, ensuring that the data in the test environment will not affect the live network environment during the traffic playback test. Furthermore, by accurately processing the requested data using business logic, the test environment can effectively simulate traffic replay in the production environment, thereby improving the reliability of the test results.

[0132] The traffic replay testing method provided in this application embodiment can be applied to a test environment, which includes a test module, a replay module, and a traffic parsing module. The replay module is used to respond to an environment test request for a target service in the test environment, acquire traffic data in the current network environment, preprocess the traffic data to obtain recorded traffic, and send the recorded traffic to the traffic parsing module; and receive traffic replay response data sent by the test module, and determine the environment test result of the current network environment based on the traffic replay response data and the service response data of the target service in the recorded traffic; wherein the test environment and the current network environment are in an environmental isolation state. The traffic parsing module is used to receive the recorded traffic sent by the replay module and the service processing request sent by the test module; and, in response to the service processing request, perform traffic parsing on the recorded traffic to obtain the request data corresponding to the service processing request, and send the request data to the test module. The test module is used to generate a service processing request corresponding to the target service and send the service processing request to the traffic parsing module; and receive the request data sent by the traffic parsing module; perform business logic processing on the target service based on the request data to obtain traffic replay response data of the target service, and send the traffic replay response data to the replay module.

[0133] The test module can be determined as follows: Obtain the target image corresponding to the business module handling the target service in the live network environment from the image repository; create a target container in the test environment to load the target image; load the target image into the target container to obtain the test module. In other words, the image repository is the place in the live network environment used to store container images, responsible for storing, managing, and distributing images. Each image in the image repository has a specific unique identifier; that is, different business modules handling different services have different image identifiers. For the business module handling the target service, the target image corresponding to the business module handling the target service in the live network environment can be directly obtained from the image repository based on the image identifier of that business module. Furthermore, in order to accurately test the system under test based on the business processing logic of this business module in the test environment, it is also necessary to create a target container in the test environment to load the target image. Loading the target image into this target container yields the test module in the test environment. This test module can implement the same business logic processing as the business module in the live network environment, so as to effectively simulate the traffic replay of the live network environment in the test environment.

[0134] The test module is deployed on the first test node in the test environment, while the replay module and traffic parsing module are deployed on the second test node. The first test node includes a first container group, with the target container located within it. The second test node includes a second container group and a third container group; the container deploying the replay module is located in the second container group, and the container deploying the traffic parsing module is located in the third container group. The address of the first test node is the first node address, and the address of the second test node is the second node address. The address of the first container group is the first container group address, the address of the second container group is the second container group address, and the address of the third container group is the third container group address.

[0135] In other words, the test modules, replay modules, and traffic parsing modules in the test environment can be containerized using a container orchestration platform (e.g., Kubernetes). The first test node and the second test node are different test nodes in the test environment. The test module is deployed in the target container of the first container group of the first test node in the test environment. The replay module is deployed in one of the containers of the second container group of the second test node in the test environment. The replay module is also deployed in one of the containers of the third container group of the second test node in the test environment.

[0136] All containers within the same container group share the same address. Containers in different container groups have different addresses, and different test nodes also have different addresses. The target container for the test module shares the same address as the first container group; that is, the target container's address is the address of the first container group. The container deploying the replay module shares the same address as the second container group; that is, the container deploying the replay module's address is the address of the second container group. The container deploying the traffic parsing module shares the same address as the third container group; that is, the container deploying the traffic parsing module's address is the address of the third container group.

[0137] Here, by determining the addresses of the target container, the container deploying the replay module, and the container deploying the traffic parsing module, network isolation technology can be set up to allow communication only between containers and between containers and test nodes in the test environment, effectively achieving environmental isolation between the test environment and the production network environment.

[0138] To prevent current traffic requests in the test environment from affecting the production environment and to ensure the accuracy of test results in the production environment, the test environment and the production environment need to be isolated from each other. The following two methods can be used to achieve this isolation.

[0139] Method 1: Before responding to an environment test request for the target service in the test environment and obtaining the recorded traffic in the live network environment, it is necessary to first perform network initialization processing on the test environment to obtain the traffic allowance and traffic drop conditions in the test environment; among them, when any current traffic request meets the traffic allowance condition, the current traffic request is allowed to pass in the test environment, and when any current traffic request meets the traffic drop condition, the current traffic request is dropped.

[0140] Network initialization refers to setting up and configuring the network in the test environment to ensure its stability and reliability during testing. Traffic allowance conditions refer to the conditions under which network traffic is allowed to pass through the test environment, while traffic drop conditions refer to the conditions under which network traffic is prohibited from passing through the test environment. This network traffic can be any current traffic request in the test environment, such as the service processing request at the current moment mentioned above. When any current traffic request meets the traffic allowance condition, it is allowed to pass through the test environment; when any current traffic request meets the traffic drop condition, it is dropped.

[0141] Secondly, when responding to a business processing request and parsing the recorded traffic, it is necessary to determine whether the business processing request meets the traffic release conditions. If the business processing request meets the traffic release conditions, traffic parsing is performed on the recorded traffic in response to the request; if the business processing request meets the traffic discard conditions, the response to the business processing request is prohibited. That is, when the business processing request meets the traffic release conditions, it is determined that the test environment and the production environment are in an isolated state at the current moment, allowing subsequent traffic parsing and business logic processing to obtain accurate traffic playback response data for the target business, effectively simulating traffic playback in the production environment within the test environment. When the business processing request meets the traffic discard conditions, it is determined that the test environment and the production environment are not isolated at the current moment, preventing subsequent traffic parsing and business logic processing, and thus failing to effectively simulate traffic playback in the production environment within the test environment.

[0142] The traffic allowance conditions include at least one of the following: the destination address of the current traffic request is the same as any one of the first container group address, the second container group address, and the third container group address; the destination address of the current traffic request is the same as the first node address or the second node address; the source address of the current traffic request is the same as any one of the first container group address, the second container group address, and the third container group address, and the source port of the current traffic request is a first preset port; the destination address of the current traffic request is the same as any one of the first container group address, the second container group address, and the third container group address, and the destination port of the current traffic request is a second preset port.

[0143] In other words, one of the conditions for allowing network traffic to pass through the test environment is that the destination address of the current traffic request must be any one of the following: the address of the target container deploying the test module, the address of the container deploying the replay module, or the address of the container deploying the traffic parsing module. Otherwise, the current traffic request will not be responded to. The first preset port is a port preset in the test environment that is allowed to send network traffic. Another condition for allowing network traffic to pass through the test environment is that the source address of the current traffic request must be any one of the following: the address of the target container deploying the test module, the address of the container deploying the replay module, or the address of the container deploying the traffic parsing module, and the source port sending the current traffic request must be the first preset port. The second preset port is a port preset in the test environment that is allowed to receive network traffic. Another condition for allowing network traffic to pass through the test environment is that the destination address of the current traffic request must be any one of the following: the address of the target container deploying the test module, the address of the container deploying the replay module, or the address of the container deploying the traffic parsing module, and the destination port receiving the current traffic request must be the second preset port.

[0144] Traffic dropping conditions include: the source address of the current traffic request is the same as any one of the addresses of the first container group, the second container group, and the third container group. Network traffic is not allowed to pass through in the test environment if the source address of the current traffic request is any one of the addresses of the target container deploying the test module, the container deploying the replay module, or the container deploying the traffic parsing module in the test environment. If the source port sending the current traffic request is not specified as a pre-defined port allowed to send network traffic in the test environment, then network communication for this current traffic request is not allowed in the test environment; that is, responding to this current traffic request is not permitted.

[0145] Here, by setting traffic allowance and drop conditions in the test environment, network communication in the test environment can be strictly controlled, so that the test environment and the live network environment are isolated from each other. This ensures that the data in the test environment will not affect the live network environment during the traffic replay test, and effectively simulates the traffic replay of the live network environment in the test environment.

[0146] Method 2: Before responding to environmental test requests for the target business in the test environment and obtaining the recorded traffic in the live network environment, it is necessary to first build an independent dynamic library; call the hook function to hook all system network processes in the playback module; and link the hooked system network processes to the independent dynamic library.

[0147] Secondly, when responding to a business processing request and performing traffic parsing on the recorded traffic, it is necessary to obtain the code corresponding to the business processing request from an independent dynamic library upon receiving the business processing request; and to perform traffic parsing on the recorded traffic by executing the code obtained from the independent dynamic library.

[0148] In other words, an independent dynamic library (DLL) refers to a dynamic link library that can be shared by multiple modules in a test environment. DLLs are loaded at system runtime and contain callable functions and data without needing to be embedded into the code of each module. Hook functions are special functions used to intercept and handle calls to other functions. System networking processes are processes responsible for network communication in the system. They are responsible for receiving and sending network data packets, establishing and managing network connections, and handling network-related system calls and user requests. When responding to a business processing request and parsing the recorded traffic, since all system networking processes in the playback module are linked to the independent DLLs, upon receiving a business processing request, the code corresponding to the business processing request can be directly obtained from the independent DLLs, and the recorded traffic can be parsed by executing the code obtained from the independent DLLs.

[0149] Here, all system networking processes in the replay module are linked to an independent dynamic library. This allows the code in the independent dynamic library to be directly called to perform traffic replay tests when traffic replay tests for business processing requests are started in the test environment. This keeps the test environment isolated from the production environment, ensuring that the data in the test environment will not affect the production environment during the traffic replay test. This effectively simulates the traffic replay of the production environment in the test environment.

[0150] The following will describe an exemplary application of the embodiments of this application in a real-world application scenario.

[0151] This application provides a traffic replay testing method, which relates to a traffic replay method in an isolated environment based on the Kubernetes platform. This method utilizes Kubernetes container orchestration technology to flexibly create an isolated test environment to simulate a real-world network environment, and uses traffic replay technology to copy traffic from the live network environment to the isolated test environment for testing and verification. This method can effectively perform traffic replay testing to evaluate the system's performance, correctness, and reliability.

[0152] This solution is based on the Kubernetes platform and deploys a separate Kubernetes cluster to conduct traffic replay tests in test environment 10. The architecture diagram for the traffic replay test is shown below. Figure 5 As shown, there are three different types of container sets (Pods) in this test environment: test module 501, replay module 502, and Mock module 503 (i.e., the traffic parsing module mentioned above).

[0153] The test module 501, upon startup, loads the required image file (containing service binaries, configuration files, etc.) from the image repository 506, and initializes a network isolation environment, allowing only network communication between the test module 501 and Node A, the playback module 502, and the mock module 503. The playback module 502 is responsible for mocking the traffic data recorded by the traffic recording module 505, then sending the mocked recorded traffic to the test module 501; and generating a playback report by analyzing the response data. The mock module 503 receives the recorded traffic from the test module, finds matching response data by searching the recorded traffic, and then returns it to the test module 501.

[0154] See Figure 6 , Figure 6This is a flowchart illustrating the execution of a traffic replay test according to an embodiment of this application. A new Pod is started in the test environment, and the image of business module 504 is loaded from image repository 506 into business container B of test module 501. Before starting business container B, the network environment is initialized, and network isolation is achieved through iptables, allowing only processes in the Pod to access the Node where the Pod resides (the Node needs to manage the Pod through the network), replay module 502, and Mock module 503. The LD_PRELOAD environment variable is set to hook the dynamic library, hooking network and time-related system calls such as connect and time, before starting the container process. After mocking the traffic data, replay module 502 sends the recorded traffic to business container B. Business container B executes business logic. When business container B needs to initiate a downstream system call, because connect has been hooked, the data (i.e., the Mock request) is sent to Mock module 503. Mock module 503 retrieves the recorded traffic, finds the matching response data (i.e., the aforementioned request data), and returns it to business container B. Business container B continues to execute the business request and sends the final playback response packet (i.e., the traffic playback response data mentioned above) to the playback module 502. Upon receiving the playback response packet from business container B, the playback module analyzes its success, compares the packet fields with the recorded traffic, assesses the time consumption, and finally generates a playback report, which is then sent to the webpage 507.

[0155] To prevent requests from the test environment from affecting the production environment, environmental isolation between the test and production environments is necessary. This solution proposes two environmental isolation methods, and using both methods simultaneously can better guarantee the effectiveness of environmental isolation.

[0156] One method of environment isolation involves rewriting all connection system calls in the playback module's binary using hooks, ensuring that all recording traffic is sent to the Mock module. This can be implemented using a separate dynamic library, configured with LD_PRETOWD at process startup for priority linking.

[0157] gcc–shared–fPIC–o libconnhook.so connhook.cpp–ldl;

[0158] LD_PRELOAD=libconnhook.so svr.

[0159] The first command line compiles a shared library named libconnhook.so, which contains the content defined in connhook.cpp, and links the dl library. The second command line sets the LD_PRELOAD environment variable, instructing the operating system to load the libconnhook.so shared library first when running the svr program. This way, the code in the shared library will be executed first during program execution to achieve hooking or modify program behavior.

[0160] Another method of environment isolation is to restrict outbound network traffic in the test environment using iptables, which is executed when the pod starts:

[0161] iptables -A OUTPUT -p tcp -s<POD_IP> -d<POD_IP> -j ACCEPT;

[0162] iptables –A OUTPUT -p tcp -s<POD_IP> -d<NODE_IP> -j ACCEPT;

[0163] iptables–A OUTPUT–p tcp–s<POD_IP> -m multiport–s ports<MOCK_PORT> -jACC EPT;

[0164] iptables–A OUTPUT–p tcp–s<POD_IP> -m multiport–d ports<MOCK_PORT> -jACC EPT;

[0165] iptables -A OUTPUT -p tcp -s<POD_IP> -j DROP.

[0166] These rules allow<POD_IP> and<POD_IP> and<NODE_IP> TCP traffic between them, and specific ports<MOCK_PORT> The inbound and outbound traffic, while blocking<POD_IP> All other TCP traffic initiated. These rules are typically used to allow communication between containers, or between containers and nodes, while limiting unnecessary network traffic to improve network security and performance.

[0167] Furthermore, recorded traffic is obtained through mocked traffic data. Mocking is a strategy that modifies traffic data to prevent it from leaking into the production environment and impacting it. This strategy specifically modifies the traffic data to make it unrecognizable in the production environment, thus avoiding any impact. There are many ways to implement mocking, and the specific implementation depends on the protocol used in the production environment. For example, for the HTTP protocol, a specific field "MOCK / builtin-bin / echo" can be inserted into the first line of the traffic data, making it unrecognizable in the production environment. However, in a test environment, the framework can be modified to recognize this specific field, and then the mocked traffic data (i.e., recorded traffic) can be filtered before being passed to the business logic for processing.

[0168] Furthermore, in the test environment, to more accurately simulate the production network environment, the system time can be modified by hooking time functions. Recorded traffic will include the recording time under the production network environment at that time. When performing traffic playback, setting this recording time to the system time allows for the simulation of the production network's time state during traffic playback. This method not only helps to more accurately simulate the production network environment but also helps to better understand the behavior of business traffic.

[0169] Besides hooking time functions, you can also directly use libfaketime to modify the system time. libfaketime is an open-source library that provides a simple and effective way to modify the system time. It can be used directly to simulate the time state of the production environment, thereby more accurately replaying business traffic.

[0170] This application combines the Kubernetes platform with traffic replay technology, and utilizes network isolation, traffic mocking, and system call hooking techniques to achieve accurate simulation of live network traffic replay testing in an isolated environment (i.e., a test environment). Compared to traditional traffic replay testing methods, this invention has the following advantages and effects: Flexibility: Through Kubernetes container orchestration technology, isolated environments can be flexibly created and managed, supporting traffic replay for any single module and adapting to different testing needs. Non-intrusiveness: Images of live network modules can be reused without modification, recompilation, or configuration changes. Correctness: By simulating live network traffic in an isolated environment, the true performance of the system can be evaluated more accurately. Reliability: Using the isolated environment of the Kubernetes platform ensures that the testing process will not affect the live network environment, improving the reliability of the test.

[0171] It is understood that in the embodiments of this application, if the content involving user information, such as target business, recorded traffic and environmental test results, involves data related to user information or enterprise information, when the embodiments of this application are applied to specific products or technologies, it is necessary to obtain user permission or consent, or to obfuscate this information to eliminate the correspondence between this information and the user; and the collection and processing of related data should strictly comply with the requirements of relevant laws and regulations when applied in the instance, obtain the informed consent or separate consent of the personal information subject, and carry out subsequent data use and processing within the scope of laws and regulations and the authorization of the personal information subject.

[0172] The following description continues to illustrate the exemplary structure of the traffic playback testing device 455 provided in the embodiments of this application as a software module. In some embodiments, such as Figure 2 As shown, the software modules stored in the traffic playback testing device 455 in the memory 450 may include: a recording traffic acquisition module 4551, used to acquire recording traffic in the current network environment in response to an environment test request for a target service in the test environment; wherein the test environment and the current network environment are in an environment isolation state; a request acquisition module 4552, used to acquire the service processing request of the target service; a parsing module 4553, used to parse the recording traffic in response to the service processing request to obtain the request data corresponding to the service processing request; a service logic processing module 4554, used to perform service logic processing on the target service based on the request data to obtain the traffic playback response data of the target service; and a determination module 4555, used to determine the environment test result of the current network environment based on the traffic playback response data and the service response data of the target service in the recording traffic.

[0173] In some embodiments, the recording traffic acquisition module 4551 is further configured to: respond to an environment test request for a target service in a test environment, acquire traffic data of all processed services in the service module corresponding to the target service in the current network environment, and the protocol type supported by the current network environment; determine the preprocessing field corresponding to the protocol type; and perform data preprocessing on the traffic data based on the preprocessing field to obtain the recording traffic.

[0174] In some embodiments, the parsing module 4553 is further configured to: in response to the business processing request, determine at least one business processing sub-request when performing business logic processing on the target business; obtain a sub-request identifier and a sub-request content identifier for each business processing sub-request; parse the recorded traffic based on the preprocessing field to obtain parsed data; obtain sub-request response data corresponding to each business processing sub-request from the parsed data based on the sub-request identifier and the sub-request content identifier; and determine all obtained sub-request response data as the request data for the business processing request.

[0175] In some embodiments, the business logic processing module 4554 is further configured to: determine the business processing logic of the target business; and perform business logic processing on the target business according to the business processing logic based on each sub-request response data in the request data and the sub-request content identifier of the sub-request response data, to obtain the traffic replay response data of the target business.

[0176] In some embodiments, the test environment includes a test module, which is used to perform business logic processing on the target service based on the request data; the device 455 further includes a loading module, which is used to: obtain a target image corresponding to the business module when processing the target service in the live network environment from the image repository of the live network environment; create a target container for loading the target image in the test environment; and load the target image in the target container to obtain the test module.

[0177] In some embodiments, the test environment further includes a replay module and a traffic parsing module; the test module is deployed in a first test node in the test environment; the replay module and the traffic parsing module are deployed in a second test node in the test environment; the first test node includes a first container group, and the target container is located in the first container group; the second test node includes a second container group and a third container group, the container deploying the replay module is located in the second container group, and the container deploying the traffic parsing module is located in the third container group; the address of the first test node is the first node address, the address of the second test node is the second node address; the address of the first container group is the first container group address, the address of the second container group is the second container group address, and the address of the third container group is the third container group address.

[0178] In some embodiments, the apparatus 455 further includes a network initialization module, which is configured to: perform network initialization processing on the test environment to obtain traffic allowance conditions and traffic discard conditions in the test environment; wherein, when any current traffic request meets the traffic allowance conditions, the current traffic request is allowed to pass through the test environment, and when any current traffic request meets the traffic discard conditions, the current traffic request is discarded.

[0179] In some embodiments, the parsing module 4553 is further configured to: when the service processing request meets the traffic release condition, in response to the service processing request, perform traffic parsing on the recorded traffic; when the service processing request meets the traffic discard condition, prohibit responding to the service processing request.

[0180] In some embodiments, the traffic allowance condition includes at least one of the following: the destination address of the current traffic request is the same as any one of the first container group address, the second container group address, and the third container group address; the destination address of the current traffic request is the same as the first node address or the second node address; the source address of the current traffic request is the same as any one of the first container group address, the second container group address, and the third container group address, and the source port of the current traffic request is a first preset port; the destination address of the current traffic request is the same as any one of the first container group address, the second container group address, and the third container group address, and the destination port of the current traffic request is a second preset port; the traffic drop condition includes: the source address of the current traffic request is the same as any one of the first container group address, the second container group address, and the third container group address.

[0181] In some embodiments, the device 455 further includes a construction module, which is configured to: construct an independent dynamic library; call a hook function to hook all system networking processes in the playback module; and link the hooked system networking processes to the independent dynamic library.

[0182] In some embodiments, the parsing module 4553 is further configured to: upon receiving the service processing request, obtain code corresponding to the service processing request from the independent dynamic library; and perform traffic parsing on the recorded traffic by executing the code obtained from the independent dynamic library.

[0183] In some embodiments, the determining module 4555 is further configured to: extract fields from the traffic playback response data and the service response data of the target service in the recorded traffic under different test dimensions, respectively, to obtain a first data field and a second data field under different test dimensions; and determine the environmental test result of the live network environment based on the first data field and the second data field for each test dimension.

[0184] It should be noted that the description of the apparatus in this application embodiment is similar to the description of the method embodiment described above, and has similar beneficial effects as the method embodiment; therefore, it will not be repeated. For technical details not disclosed in this apparatus embodiment, please refer to the description of the method embodiment of this application for understanding.

[0185] This application provides a computer-readable storage medium storing computer-executable instructions. When these instructions are executed by a processor, they cause the processor to execute the traffic playback test method provided in this application. For example, ... Figure 3 The traffic replay test method is shown.

[0186] This application provides a computer program product including computer-executable instructions stored in a computer-readable storage medium. A processor of an electronic device reads the computer-executable instructions from the computer-readable storage medium and executes the instructions, causing the electronic device to perform the traffic playback test method described above in this application.

[0187] In some embodiments, the computer-readable storage medium may be a memory such as RAM, ROM, flash memory, magnetic surface memory, optical disk, or CD-ROM; or it may be a variety of devices including one or any combination of the above-mentioned memories.

[0188] In some embodiments, computer-executable instructions may take the form of programs, software, software modules, scripts, or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as stand-alone programs or as modules, components, subroutines, or other units suitable for use in a computing environment.

[0189] As an example, computer-executable instructions may, but do not necessarily, correspond to files in a file system. They may be stored as part of a file that holds other programs or data, for example, in one or more scripts in a Hyper Text Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple co-located files (e.g., files that store one or more modules, subroutines, or code sections).

[0190] As an example, computer-executable instructions can be deployed to execute on a single electronic device, or on multiple electronic devices located at one location, or on multiple electronic devices distributed across multiple locations and interconnected via a communication network.

[0191] The above description is merely an embodiment of this application and is not intended to limit the scope of protection of this application. Any modifications, equivalent substitutions, and improvements made within the spirit and scope of this application are included within the scope of protection of this application.

Claims

1. A flow playback test method, characterized by, The method includes: In response to an environment test request for a target service in a test environment, the recorded traffic in the live network environment is obtained; wherein the test environment and the live network environment are in an environment isolation state; Obtain the business processing request of the target service; In response to the business processing request, the recorded traffic is parsed to obtain the request data of the business processing request; Based on the requested data, the target service is processed using business logic to obtain the traffic replay response data of the target service; Based on the traffic playback response data and the service response data of the target service in the recorded traffic, the environmental test results of the live network environment are determined.

2. The method of claim 1, wherein, The process of responding to an environment test request for the target service in a test environment and obtaining recorded traffic in the live network environment includes: In response to an environment test request for the target service in the test environment, obtain the traffic data of all processed services in the business module corresponding to the target service in the live network environment, as well as the protocol types supported by the live network environment; Determine the preprocessing fields corresponding to the protocol type; Based on the preprocessing fields, the traffic data is preprocessed to obtain the recorded traffic.

3. The method of claim 2, wherein, In response to the service processing request, the recorded traffic is parsed to obtain the request data for the service processing request, including: In response to the business processing request, at least one business processing sub-request is determined when performing business logic processing on the target business; Obtain the sub-request identifier and sub-request content identifier for each of the aforementioned business processing sub-requests; Based on the preprocessed fields, the recorded traffic is parsed to obtain parsed data; Based on the sub-request identifier and the sub-request content identifier, obtain the sub-request response data corresponding to each business processing sub-request from the parsed data; All the sub-request response data obtained are determined as the request data for the business processing request.

4. The method of claim 3, wherein, The step of performing business logic processing on the target service based on the request data to obtain traffic replay response data for the target service includes: Determine the business processing logic of the target service; Based on each sub-request response data and the sub-request content identifier in the request data, the target service is processed according to the business processing logic to obtain the traffic replay response data of the target service.

5. The method of claim 1, wherein, The testing environment includes a testing module, which is used to perform business logic processing on the target business based on the request data. Before obtaining recorded traffic in the live network environment in response to an environment test request for the target service in the test environment, the method further includes: Obtain the target image corresponding to the business module used to process the target business in the current network environment from the image repository of the current network environment; Create a target container in the test environment to load the target image; The target image is loaded into the target container to obtain the test module.

6. The method of claim 5, wherein, The test environment also includes a replay module and a traffic parsing module; the test module is deployed in a first test node of the test environment; the replay module and the traffic parsing module are deployed in a second test node of the test environment; The first test node includes a first container group, and the target container is located in the first container group; the second test node includes a second container group and a third container group, the container where the replay module is deployed is located in the second container group, and the container where the traffic parsing module is deployed is located in the third container group; The address of the first test node is the first node address, the address of the second test node is the second node address; the address of the first container group is the first container group address, the address of the second container group is the second container group address, and the address of the third container group is the third container group address.

7. The method of claim 6, wherein, Before obtaining recorded traffic in the live network environment in response to an environment test request for the target service in the test environment, the method further includes: The test environment is initialized to obtain the traffic allowance and traffic discard conditions under the test environment; wherein, when any current traffic request meets the traffic allowance condition, the current traffic request is allowed to pass through the test environment, and when any current traffic request meets the traffic discard condition, the current traffic request is discarded. The step of responding to the service processing request by performing traffic parsing on the recorded traffic includes: When the business processing request meets the traffic release condition, in response to the business processing request, the recorded traffic is parsed. When the service processing request meets the traffic dropping condition, the service processing request shall not be responded to.

8. The method of claim 7, wherein, The traffic release conditions include at least one of the following: The target address of the current traffic request is the same as any one of the first container group address, the second container group address, and the third container group address; The target address of the current traffic request is the same as the address of the first node or the address of the second node; The source address of the current traffic request is the same as any one of the first container group address, the second container group address, and the third container group address, and the source port of the current traffic request is the first preset port; The target address of the current traffic request is the same as any one of the first container group address, the second container group address, and the third container group address, and the target port of the current traffic request is the second preset port; The traffic dropping conditions include: the source address of the current traffic request is the same as any one of the first container group address, the second container group address, and the third container group address.

9. The method of claim 6, wherein, Before obtaining recorded traffic in the live network environment in response to an environment test request for the target service in the test environment, the method further includes: Build independent dynamic libraries; The hook function is invoked to hook all system networking processes in the playback module; Link the system networking process after hooking to the independent dynamic library; The step of responding to the service processing request by performing traffic parsing on the recorded traffic includes: Upon receiving the business processing request, the code corresponding to the business processing request is retrieved from the independent dynamic library; The recorded traffic is parsed by executing the code obtained from the independent dynamic library.

10. The method according to any one of claims 1 to 9, characterized in that, The determination of the environmental test results for the live network environment based on the traffic playback response data and the service response data of the target service in the recorded traffic includes: For the traffic playback response data and the business response data of the target service in the recorded traffic, fields are extracted under different test dimensions to obtain the first data field and the second data field under different test dimensions. For each test dimension, the environmental test results of the live network environment are determined based on the first data field and the second data field.

11. A flow playback test apparatus, characterized by, include: The recording traffic acquisition module is used to respond to environment test requests for the target service in the test environment and acquire the recording traffic in the live network environment; wherein the test environment and the live network environment are in an environmental isolation state. The request acquisition module is used to acquire the business processing request of the target business. The parsing module is used to respond to the business processing request by parsing the recorded traffic to obtain the request data corresponding to the business processing request; The business logic processing module is used to perform business logic processing on the target business based on the request data to obtain the traffic replay response data of the target business; The determination module is used to determine the environmental test results of the live network environment based on the traffic playback response data and the service response data of the target service in the recorded traffic.

12. An electronic device, characterized in that, include: Memory is used to store executable instructions for a computer; The processor, when executing computer-executable instructions stored in the memory, implements the traffic playback test method according to any one of claims 1 to 10.

13. A computer-readable storage medium, characterized in that, The device stores computer-executable instructions, which, when executed by a processor, implement the traffic replay test method according to any one of claims 1 to 10.

14. A computer program product, characterized in that, The computer program product includes computer-executable instructions, which are stored in a computer-readable storage medium. When the processor of the electronic device reads the computer-executable instructions from the computer-readable storage medium and executes the computer-executable instructions, it implements the traffic playback test method according to any one of claims 1 to 10.