Abnormal scenario testing method and system based on middleman message hijacking
Through the man-in-the-middle message hijacking technology, complex abnormal scenarios can be efficiently constructed and tested under a distributed microservice architecture, solving the problem of low efficiency in existing technologies and providing flexible abnormal scenario simulation and verification capabilities.
Patent Information
- Application Number
- CN202211329334.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-27
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2042-10-27
AI Technical Summary
The existing technology is inefficient when simulating complex abnormal scenario testing under a distributed microservice architecture. It requires a lot of manpower and material resources to modify codes and deployment files, and it is difficult to fully cover various abnormal scenarios.
Adopt an abnormal scenario testing method based on man-in-the-middle message hijacking, and simulate business abnormal situations through proxy forwarding and message matching and filtering processing, including behaviors such as timeout, discarding, field modification, and repeated sending, to realize the construction of abnormal scenarios for distributed microservice architecture and testing.
Without invading application code and service deployment, it can efficiently and flexibly construct and test complex abnormal scenarios, support diversified network and business abnormal scenario simulations, and ensure parallel testing and comparative verification of normal and abnormal scenarios.
Smart Images

Figure CN115801335B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of software system testing of a microservice architecture, and in particular to an abnormal scenario testing method and system based on middleman message hijacking. Background Art
[0002] With the rapid development of the Internet, traditional monolithic applications can no longer adapt well to the ever-changing business needs, and monolithic applications are gradually migrating to distributed microservice architecture. The change of distributed microservice architecture has brought great challenges to system testing, and the complexity of application systems has also shifted from within the system to between systems. In addition to having a good understanding of the business functions of the system, testers also need to pay attention to the abnormal calls across systems and services under the microservice architecture and whether the processing logic of the corresponding abnormal scenarios is correct.
[0003] Patent document CN111782519A discloses a testing method, device and electronic device, which preferentially call the test version of a microservice from a test environment; if the test version of the microservice does not exist in the test environment, the public version of the microservice is called from a public environment to avoid isolation between the public environment and the test environment, and avoid deploying all microservices in the test environment.
[0004] However, for software system testing based on a complex microservice architecture, patent document CN111782519A needs to spend a lot of manpower and material resources to simulate the failure of a service node or network node, as well as business and data anomalies between services. It requires modifying the code, modifying the deployment file, or configuring baffles to construct the abnormal scenarios that the testers want, which is inefficient and difficult to cover comprehensively. Summary of the invention
[0005] In view of the defects in the prior art, the purpose of the present invention is to provide an abnormal scenario testing method and system based on middleman message hijacking.
[0006] According to the present invention, a method for testing abnormal scenarios based on middleman message hijacking is provided, comprising:
[0007] Proxy forwarding step: transparently forward the request message in the process of cross-service remote call of the application system to the middleman message hijacking node;
[0008] Message matching and filtering processing steps: In the middleman message hijacking node, the request message that matches the filtering rules is processed according to the processing rules to simulate business abnormalities.
[0009] Preferably, it also includes:
[0010] Exception processing logic verification step: verify whether the processing logic of the application service of the application system in the tested system meets the expected business results when the business exception occurs in the tested system, as the test verification result.
[0011] Wherein, the system under test is a system under a distributed microservice architecture.
[0012] Preferably, the request message that does not match the filtering rule in the message matching and filtering processing step is not processed in any way, and continues to be transparently forwarded to the target node through the proxy forwarding step, and the normal scenario is tested concurrently with the abnormal scenario.
[0013] Preferably, the message matching and filtering processing step includes:
[0014] Message timeout processing steps: According to the configured timeout time, hijack the relevant request message to the specified timeout time, and then transparently forward it to the target application system in the target node to simulate the abnormal scenario of the timeout of the system under test;
[0015] Message discard processing steps: directly discard the hijacked request message, do not transparently forward it to the target node, and simulate the abnormal situation that the target application system in the target node does not receive the request message;
[0016] Message field modification processing steps: According to the configured field replacement information or adding or deleting field content, the request message is replaced and assembled, and then forwarded to the target application system in the target node to simulate the abnormal scenario of the business layer message abnormality;
[0017] Message repeated sending processing steps: according to the configured number of repeated sending times, the request message is sent to the target application system in the target node for multiple times in succession to simulate the retransmission abnormal scenario of the system under test.
[0018] Preferably, in the proxy forwarding step, for remote service calls between application systems through domain names, by configuring DNS domain name resolution or local domain name resolution, the request messages between application systems are transparently forwarded to the middleman message hijacking node, so that the middleman message hijacking node can capture all cross-service business request messages in real time; the method adopted is:
[0019] Method A: By configuring the local Hosts file domain name resolution in the application system, add a mapping from the remote call service domain name to the middleman message hijacking node IP, and forward the application system request message proxy to the middleman message hijacking node; or
[0020] Method B: When using a public configuration file to manage the call address between services, modify the service call address in the configuration file to the middleman message hijacking node address; or, when managing the call address between services for the configuration center service, modify the service call address in the configuration service to the middleman message hijacking node address.
[0021] According to the present invention, an abnormal scenario testing system based on middleman message hijacking is provided, comprising:
[0022] Proxy forwarding module: transparently forwards the request message in the process of cross-service remote call of the application system to the middleman message hijacking node;
[0023] Message matching and filtering processing module: In the middleman message hijacking node, the request message that matches the filtering rules is processed according to the processing rules to simulate business abnormalities.
[0024] Preferably, it also includes:
[0025] Exception processing logic verification module: Verify whether the processing logic of the application service of the application system in the tested system meets the expected business results when the business exception occurs in the tested system, as the test verification result.
[0026] Wherein, the system under test is a system under a distributed microservice architecture.
[0027] Preferably, the request message that does not match the filtering rule in the message matching and filtering processing module is not processed in any way, and continues to be transparently forwarded to the target node through the proxy forwarding module, and the normal scenario is tested concurrently with the abnormal scenario.
[0028] Preferably, the message matching filtering processing module includes:
[0029] Message timeout processing module: hijacks the relevant request message to the specified timeout time according to the configured timeout time, and transparently forwards it to the target application system in the target node to simulate the abnormal scenario of the timeout of the system under test;
[0030] Message discard processing module: directly discards the hijacked request message and does not transparently forward it to the target node, simulating the abnormal situation that the target application system in the target node does not receive the request message;
[0031] Message field modification processing module: replaces and assembles the request message according to the configured field replacement information or adds or deletes field content, and then forwards it to the target application system in the target node to simulate the abnormal scenario of abnormal messages at the business level;
[0032] Message retransmission processing module: according to the configured number of retransmissions, the request message is sent to the target application system in the target node for multiple times in succession to simulate the retransmission exception scenario of the system under test.
[0033] Preferably, in the proxy forwarding module, for remote service calls between application systems through domain names, by configuring DNS domain name resolution or local domain name resolution, the request messages between application systems are transparently forwarded to the middleman message hijacking node, so that the middleman message hijacking node can capture all cross-service business request messages in real time; the method adopted is:
[0034] Method A: By configuring the local Hosts file domain name resolution in the application system, add a mapping from the remote call service domain name to the middleman message hijacking node IP, and forward the application system request message proxy to the middleman message hijacking node; or
[0035] Method B: When using a public configuration file to manage the call address between services, modify the service call address in the configuration file to the middleman message hijacking node address; or, when managing the call address between services for the configuration center service, modify the service call address in the configuration service to the middleman message hijacking node address.
[0036] Compared with the prior art, the present invention has the following beneficial effects:
[0037] 1. The present invention realizes the construction and testing of various complex abnormal scenarios without intrusion into application code and without special deployment of application services.
[0038] 2. The present invention adopts the middleman message hijacking technology to transparently forward the application messages between each service node to the middleman message hijacking node through domain name mapping, accurately filters and matches the specified request messages through rule configuration, and efficiently and flexibly performs transparent forwarding, delayed forwarding, discarding and message content replacement on the application messages. Through a variety of configuration methods, it realizes the simulation construction of scenarios such as network, service anomalies and business anomalies between each service node.
[0039] 3. The middleman message hijacking node of the present invention supports message protocol data matching and message business data field level matching to achieve precise test isolation, ensuring that the anomaly constructed for a specific message will not affect the normal forwarding of other messages, thereby achieving parallel testing of normal scenarios and abnormal scenarios. At the same time, the comparison and verification of normal scenarios and abnormal scenarios can also be achieved by whether the configuration of the abnormal scenario is turned on. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Other features, objects and advantages of the present invention will become more apparent from the detailed description of non-limiting embodiments made with reference to the following drawings:
[0041] Figure 1 It is a schematic diagram of the module principle of the present invention.
[0042] Figure 2 It is a timing diagram of the method of the present invention. DETAILED DESCRIPTION
[0043] The present invention is described in detail below in conjunction with specific embodiments. The following embodiments will help those skilled in the art to further understand the present invention, but are not intended to limit the present invention in any form. It should be noted that, for those of ordinary skill in the art, several changes and improvements can also be made without departing from the concept of the present invention. These all belong to the protection scope of the present invention.
[0044] The present invention belongs to an abnormal scenario testing system based on middleman message hijacking, which is used to construct various complex abnormal test scenarios in the process of system testing and business verification. During the cross-service remote call process of the application server, the message proxy originally forwarded to the target service node is forwarded to the middleman message hijacking node by domain name mapping. After the middleman message hijacking node hijacks the request message, it can flexibly perform transparent forwarding, delayed forwarding, discarding, message content replacement, repeated sending and other behaviors on the application message according to the configured processing rules, realizing the simulation of application service failures and the construction of complex abnormal scenarios in the test process without intrusion into the application service code.
[0045] Basic Example
[0046] According to an abnormal scenario testing system based on middleman message hijacking provided by the present invention, the overall architecture diagram of the system is as follows: Figure 1 As shown, including:
[0047] Proxy forwarding module: transparently forwarding the request message in the process of cross-service remote call of the application system to the middleman message hijacking node; in the proxy forwarding module, for the remote service call between application systems through the domain name, by configuring the DNS domain name resolution or the local domain name resolution, the request message between the application systems is transparently forwarded to the middleman message hijacking node, so that the middleman message hijacking node can capture all cross-service business request messages in real time; the adopted methods are: Method A: by configuring the local Hosts file domain name resolution in the application system, a mapping of the remote call service domain name to the middleman message hijacking node IP is added, and the application system request message proxy is forwarded to the middleman message hijacking node; or Method B: in the case of using a public configuration file to manage the call address between services, the service call address in the configuration file is modified to the middleman message hijacking node address; or, in the case of managing the call address between services for the configuration center service, the service call address in the configuration service is modified to the middleman message hijacking node address.
[0048] Message matching and filtering processing module: In the middleman message hijacking node, the request message that matches the filtering rules is processed according to the processing rules to simulate business abnormalities; in the message matching and filtering processing module, the request message that does not match the filtering rules is not processed at all, and continues to be transparently forwarded to the target node through the proxy forwarding module, and the normal scenario and the abnormal scenario are tested concurrently. The message matching and filtering processing module includes: a message timeout processing module: according to the configured timeout time, after hijacking the relevant request message to the specified timeout time, transparently forwarding it to the target application system in the target node, simulating the abnormal scenario of the timeout of the tested system; a message discarding processing module: directly discarding the hijacked request message, not transparently forwarding it to the target node, simulating the abnormal situation that the target application system in the target node does not receive the request message; a message field modification processing module: according to the configured field replacement information or adding and deleting field content, after replacing and assembling the request message, forwarding it to the target application system in the target node, simulating the abnormal scenario of the business level message abnormality; a message repeated sending processing module: according to the configured number of repeated sending times, sending the request message to the target application system in the target node for multiple times in succession, simulating the retransmission abnormal scenario of the tested system.
[0049] Exception processing logic verification module: Verify whether the processing logic of the application service of the application system in the tested system meets the expected business results when the business exception occurs in the tested system, as the test verification result. The tested system is a system under the distributed microservice architecture.
[0050] Those skilled in the art know that, in addition to implementing the system, device and its various modules provided by the present invention in a purely computer-readable program code, it is entirely possible to implement the same program in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers and embedded microcontrollers by logically programming the method steps. Therefore, the system, device and its various modules provided by the present invention can be considered as a hardware component, and the modules included therein for implementing various programs can also be considered as structures within the hardware component; the modules for implementing various functions can also be considered as both software programs for implementing the method and structures within the hardware component.
[0051] Preferred Examples and Modifications
[0052] The present invention also provides an abnormal scenario testing method based on middleman message hijacking. A person skilled in the art can implement the abnormal scenario testing system based on middleman message hijacking by executing the step flow of the abnormal scenario testing method based on middleman message hijacking, that is, the abnormal scenario testing method based on middleman message hijacking can be understood as a preferred implementation of the abnormal scenario testing system based on middleman message hijacking. Specifically, the abnormal scenario testing method based on middleman message hijacking includes:
[0053] Step S1: During the process of cross-service remote calls on the application server, the application systems make remote service calls through domain names; by configuring DNS domain name resolution or local domain name resolution, the request messages between application systems are transparently forwarded to the middleman message hijacking node, thereby realizing the real-time capture of all cross-service business request messages by the middleman message hijacking node.
[0054] The step S1 includes the following two situations:
[0055] Step S1.1A: By configuring the local Hosts file domain name resolution in the application system, a mapping of the remote call service domain name to the middleman message hijacking node IP is added to implement the application system request message proxy forwarding to the middleman message hijacking node; or
[0056] Step S1.1B: If a public configuration file (property file, etc.) or configuration center service (Apollo configuration, etc.) is used to manage the call address between services, the service call address in the configuration file or configuration service can be modified to the middleman message hijacking node address to implement the application system request message proxy forwarding to the middleman message hijacking node.
[0057] Step S2: Relevant personnel can log in to the middleman message hijacking node and simulate various abnormal scenarios of request messages by configuring the filtering rules and processing rules of the request messages. The step S2 includes:
[0058] Step S2.1: The middleman message hijacking node supports multi-condition filtering rule configuration. For each request message, a single or multiple filtering conditions can be configured according to the message fields of the request message. Multiple filtering conditions are configured through the And, Or, and Not keywords for AND, OR, and NOT combination. The request messages to be processed can be accurately filtered without affecting the normal business processing of the interface that does not hit the filtering conditions.
[0059] Step S2.2: For the request messages that have been filtered out, different processing rules can be configured according to the business abnormality scenarios, mainly including request message timeout (Delay), request message discard (Drop), request message field replacement (Replace), message field addition (Add), message field deletion (Delete), request message repeated sending (Repeat) and other different processing methods, to achieve real-time simulation of abnormal scenarios of request messages.
[0060] Step S2.3: For abnormal simulation of complex business scenarios, the middleman message hijacking node supports multiple interface message combination linkage configurations, and can expand other processing logics in addition to the processing rules supported above by increasing the logic of the processing rules.
[0061] Step S2.4: After completing the configuration of filtering rules and processing rules, the node is hijacked through the middleman message to load the relevant configuration, which takes effect immediately without restarting the relevant services.
[0062] Step S2.5: For the configured rules, the configuration of the abnormal scenario can be set to valid or invalid by turning on or off the buttons at the middleman message hijacking node, so as to quickly implement the comparison test between the normal scenario and the abnormal scenario.
[0063] Step S3: After completing the deployment and configuration of step S1 and step S2, the user initiates a test through the front-end or interface message tool, and requests the traffic to be transparently forwarded to the middleman message hijacking node. The middleman message hijacking node hijacks the messages that match the rules according to the filtering rules and processing rules in step S2, and performs corresponding business exception processing. The messages that do not match the rules continue to be transparently forwarded without any processing, to ensure that normal scenarios can execute test verification concurrently.
[0064] Step S4: The request message that needs to be processed abnormally in step S3 is processed according to the configured processing rules, and the dynamic expansion of the abnormal scenario processing logic is supported; step S4 includes the following test design scenarios:
[0065] Step S4.1: For the message timeout processing rules, according to the configured timeout time, hijack the relevant message to the specified timeout time, and then transparently forward it to the target application service system to simulate whether the processing logic of the tested system after timeout is correct.
[0066] Step S4.2: According to the message discarding processing rules, the hijacked message is directly discarded without transparently forwarding it backwards, simulating the abnormality that the target application system does not receive the request message, and verifying whether the processing logic after the message is discarded is correct.
[0067] Step S4.3: Modify the processing rules for the message fields, replace the configured field information or add or delete field content, replace and assemble the request message, and then forward it to the target application service system to create business-level message anomalies, such as exception code modification, error code modification, amount modification, etc., to simulate whether the processing flow after the business logic exception of the system under test is correct.
[0068] Step S4.4: For the message repeated sending processing rule, according to the configured repeated sending times, the request message is sent to the target application system for multiple times to simulate whether the system's anti-retransmission, idempotence and other exception processing is normal and effective.
[0069] Step S4.5: In addition to the above supported exception handling rules, the middleman message hijacking node also supports the expansion of other related cross-service exception scenarios by adding new processing rule logic.
[0070] Step S5: Based on the simulation of various abnormal scenarios, verify whether the processing logic of the application service of the tested system meets the expected business results when various abnormal situations occur. According to the test verification results, optimize and improve the relevant exception handling logic to enhance the service exception handling capability under the distributed microservice architecture and ensure the availability and reliability of the system.
[0071] The above describes the specific embodiments of the present invention. It should be understood that the present invention is not limited to the above specific embodiments, and those skilled in the art can make various changes or modifications within the scope of the claims, which does not affect the essence of the present invention. In the absence of conflict, the embodiments of the present application and the features in the embodiments can be combined with each other arbitrarily.
Claims
1. An abnormal scenario testing method based on middleman message hijacking, characterized in that: include: Proxy forwarding step: transparently forward the request message in the process of cross-service remote call of the application system to the middleman message hijacking node; Message matching and filtering processing steps: In the middleman message hijacking node, the request message that matches the filtering rule is processed according to the processing rules to simulate business abnormalities; The request message that does not match the filtering rule in the message matching and filtering processing step is not processed in any way, and continues to be transparently forwarded to the target node through the proxy forwarding step, and the normal scenario is tested concurrently with the abnormal scenario; Message discard processing steps: directly discard the hijacked request message, do not transparently forward it to the target node, and simulate the abnormal situation that the target application system in the target node does not receive the request message; Message repeated sending processing steps: according to the configured number of repeated sending times, the request message is sent to the target application system in the target node for multiple times in succession to simulate the retransmission abnormal scenario of the system under test.
2. The abnormal scenario testing method based on middleman message hijacking according to claim 1 is characterized in that: Also includes: Exception processing logic verification step: verify whether the processing logic of the application service of the application system in the tested system meets the expected business results when the business exception occurs in the tested system, as the test verification result; Wherein, the system under test is a system under a distributed microservice architecture.
3. The abnormal scenario testing method based on middleman message hijacking according to claim 1 is characterized in that: The message matching and filtering processing step includes: Message timeout processing steps: According to the configured timeout time, hijack the relevant request message to the specified timeout time, and then transparently forward it to the target application system in the target node to simulate the abnormal scenario of the timeout of the system under test; Message field modification processing steps: According to the configured field replacement information or adding or deleting field content, the request message is replaced and assembled, and then forwarded to the target application system in the target node to simulate the abnormal scenario of business-level message abnormality.
4. The abnormal scenario testing method based on middleman message hijacking according to claim 1 is characterized in that: In the proxy forwarding step, for remote service calls between application systems through domain names, by configuring DNS domain name resolution or local domain name resolution, the request messages between application systems are transparently forwarded to the middleman message hijacking node, so that the middleman message hijacking node can capture all cross-service business request messages in real time; the method adopted is: Method A: By configuring the local Hosts file domain name resolution in the application system, a mapping of the remote call service domain name to the middleman message hijacking node IP is added, and the application system request message proxy is forwarded to the middleman message hijacking node; or Method B: When using a public configuration file to manage the call address between services, modify the service call address in the configuration file to the middleman message hijacking node address; or, when managing the call address between services for the configuration center service, modify the service call address in the configuration service to the middleman message hijacking node address.
5. An abnormal scenario testing system based on middleman message hijacking, characterized in that: include: Proxy forwarding module: transparently forwards the request message in the process of cross-service remote call of the application system to the middleman message hijacking node; Message matching and filtering processing module: In the middleman message hijacking node, the request message that matches the filtering rules is processed according to the processing rules to simulate business abnormalities; The request message that does not match the filtering rule in the message matching and filtering processing module is not processed in any way, and is transparently forwarded to the target node through the proxy forwarding module, and the normal scenario is tested concurrently with the abnormal scenario; Message discard processing module: directly discards the hijacked request message and does not transparently forward it to the target node, simulating the abnormal situation that the target application system in the target node does not receive the request message; Message repeated sending processing module: according to the configured number of repeated sending times, the request message is sent to the target application system in the target node for multiple times in succession to simulate the retransmission abnormal scenario of the system under test.
6. The abnormal scenario testing system based on middleman message hijacking according to claim 5 is characterized in that: Also includes: Exception processing logic verification module: Verify whether the processing logic of the application service of the application system in the tested system meets the expected business results when the business exception occurs in the tested system, as the test verification result; Wherein, the system under test is a system under a distributed microservice architecture.
7. The abnormal scenario testing system based on middleman message hijacking according to claim 5 is characterized in that: The message matching filtering processing module includes: Message timeout processing module: hijacks the relevant request message to the specified timeout time according to the configured timeout time, and transparently forwards it to the target application system in the target node to simulate the abnormal scenario of the timeout of the system under test; Message field modification processing module: replaces and assembles the request message according to the configured field replacement information or adds or deletes field content, and then forwards it to the target application system in the target node to simulate the abnormal scenario of business-level message abnormality.
8. The abnormal scenario testing system based on middleman message hijacking according to claim 5 is characterized in that: In the proxy forwarding module, for remote service calls between application systems through domain names, by configuring DNS domain name resolution or local domain name resolution, the request messages between application systems are transparently forwarded to the middleman message hijacking node, so that the middleman message hijacking node can capture all cross-service business request messages in real time; the method adopted is: Method A: By configuring the local Hosts file domain name resolution in the application system, a mapping of the remote call service domain name to the middleman message hijacking node IP is added, and the application system request message proxy is forwarded to the middleman message hijacking node; or Method B: When using a public configuration file to manage the call address between services, modify the service call address in the configuration file to the middleman message hijacking node address; or, when managing the call address between services for the configuration center service, modify the service call address in the configuration service to the middleman message hijacking node address.
