Fault injection method and device, storage medium and terminal equipment

CN115481010BActive Publication Date: 2026-10-20TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202110661462.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-06-15
Publication Date
2026-10-20
Estimated Expiration
2041-06-15

AI Technical Summary

Technical Problem

现有的故障注入方法会受到应用程序本身的限制

Benefits of technology

[0020]本申请实施例另一方面还提供一种终端设备,包括处理器和存储器;

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115481010B_ABST
    Figure CN115481010B_ABST
Patent Text Reader

Abstract

The embodiment of the application discloses a fault injection method and device, a storage medium and a terminal device, and is applied to the technical field of application services. A fault injection device is used to obtain a fault injection command of a fault type, and a fault injection parameter contained in the fault injection command is transmitted to a fault injection plug-in of a target application program. The fault injection plug-in generates corresponding executable fault information according to the fault injection parameter. When a transmission message of the target application program is intercepted, executable fault information corresponding to the transmission message is determined, and then the executable fault information is injected into the target application program. In this way, the fault injection plug-in only needs to be loaded in the target application program to flexibly generate executable fault information of various fault types and inject the executable fault information into the target program, so that the target application program is not limited by the body code, and the expansibility of fault injection is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of application service technology, and in particular to fault injection methods, apparatus, storage media and terminal equipment. Background Technology

[0002] Fault injection mechanism refers to injecting fault codes into an application. The fault codes run during the application's operation, which can simulate anomalies in any function of the application, thereby managing faults in any function of the application.

[0003] Existing fault injection methods are primarily non-intrusive. When it's necessary to simulate application faults, this can be done through the application's configuration interface, allowing fault simulation to occur during the application's execution. However, existing fault injection methods are limited by the application itself. Summary of the Invention

[0004] This application provides a fault injection method, apparatus, storage medium, and terminal device, which realizes fault injection through a fault injection plugin in a target application.

[0005] One embodiment of this application provides a fault injection method, including:

[0006] Obtain a fault injection command of a fault type, the fault injection command being used to instruct the injection of a type of executable fault information into a target application, the fault injection command containing fault injection parameters;

[0007] The fault injection parameters are transmitted to the fault injection plugin of the target application;

[0008] The fault injection plugin is used for:

[0009] Generate corresponding executable fault information based on the fault injection parameters;

[0010] When a transmission message of the target application is intercepted, executable fault information corresponding to the transmission message is determined;

[0011] The executable fault information corresponding to the transmission message is injected into the target application so that the target application runs the executable fault information when it performs corresponding operations according to the transmission message.

[0012] Another aspect of this application provides a fault injection device, including:

[0013] The command acquisition unit is used to acquire a fault injection command of a fault type. The fault injection command is used to instruct the injection of a type of executable fault information into the target application. The fault injection command contains fault injection parameters.

[0014] A parameter transmission unit is used to transmit the fault injection parameters to the fault injection plugin of the target application.

[0015] The fault injection plugin is used for:

[0016] Generate corresponding executable fault information based on the fault injection parameters;

[0017] When a transmission message of the target application is intercepted, executable fault information corresponding to the transmission message is determined;

[0018] The fault atom corresponding to the transmission message is injected into the target application so that the target application runs the executable fault information when it performs the corresponding operation according to the transmission message.

[0019] Another aspect of this application provides a computer-readable storage medium storing a plurality of computer programs adapted for loading by a processor and executing the fault injection method as described in one aspect of this application.

[0020] Another aspect of this application embodiment provides a terminal device, including a processor and a memory;

[0021] The memory is used to store multiple computer programs, which are loaded by a processor and executed as the fault injection method described in one aspect of an embodiment of this application; the processor is used to implement each of the multiple computer programs.

[0022] As can be seen, in the method of this application embodiment, a fault injection command of a fault type is obtained through a fault injection device, and the fault injection parameters contained in the fault injection command are transmitted to the fault injection plugin of the target application. The fault injection plugin generates corresponding executable fault information according to the fault injection parameters. When a transmission message of the target application is intercepted, the executable fault information corresponding to the transmission message is determined, and then the executable fault information is injected into the target application. In this way, only the fault injection plugin needs to be loaded in the target application to flexibly generate executable fault information of various fault types for injection into the target program, without being limited by the ontology code of the target application, thus improving the scalability of fault injection. Attached Figure Description

[0023] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0024] Figure 1 This is a schematic diagram of a fault injection method provided in an embodiment of this application;

[0025] Figure 2 This is a flowchart of a fault injection method provided in one embodiment of this application;

[0026] Figure 3 This is a schematic diagram of the fault injection device in one application embodiment of this application;

[0027] Figure 4a This is a schematic diagram of the user settings interface provided by the chaos engineering agent in one embodiment of this application;

[0028] Figure 4b This is a schematic diagram of a parameter setting interface displayed by a chaos engineering agent in one embodiment of this application;

[0029] Figure 4c This is a schematic diagram of a user settings interface for another parameter setting interface displayed by the chaos engineering agent in one embodiment of this application;

[0030] Figure 5 This is a flowchart of a fault injection method in one application embodiment of this application;

[0031] Figure 6 This is a schematic diagram of a distributed system to which the fault injection method is applied in another application embodiment of this application;

[0032] Figure 7 This is a schematic diagram of the block structure in another application embodiment of this application;

[0033] Figure 8 This is a schematic diagram of the structure of a fault injection device provided in an embodiment of this application;

[0034] Figure 9 This is a schematic diagram of the structure of a terminal device provided in an embodiment of this application. Detailed Implementation

[0035] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.

[0036] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a particular order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented, for example, in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0037] This application provides a fault injection method, which mainly injects executable fault information into any application (such as a target application), so that when the target application malfunctions during operation, specifically, such as... Figure 1 As shown, fault injection is achieved by the fault injection device in the following manner:

[0038] A fault injection command of a fault type is obtained, the fault injection command being used to instruct the injection of a type of executable fault information into a target application, the fault injection command containing fault injection parameters; the fault injection parameters are transmitted to a fault injection plugin of the target application; wherein, the fault injection plugin is used to: generate corresponding executable fault information based on the fault injection parameters; when a transmission message of the target application is intercepted, determine the executable fault information corresponding to the transmission message, and inject the executable fault information corresponding to the transmission message into the target application, so that the target application runs the executable fault information when performing corresponding operations based on the transmission message.

[0039] In this way, simply loading the fault injection plugin in the target application allows for the flexible generation of executable fault information of various fault types to be injected into the target program, without being limited by the ontology code of the target application, thus improving the scalability of fault injection.

[0040] One embodiment of this application provides a fault injection method, mainly a method executed by a fault injection device, as shown in the flowchart below. Figure 2 As shown, it includes:

[0041] Step 101: Obtain a fault injection command of a certain type. The fault injection command is used to instruct the injection of a type of executable fault information into the target application. The fault injection command contains fault injection parameters.

[0042] It is understood that the fault injection method in this embodiment can be mainly initiated through a fault injection device. In one case, the user can operate the fault injection device, causing the device to display a user settings interface based on the user's operation. This user settings interface is used to initiate the fault injection process in this embodiment. The user settings interface includes at least one setting interface corresponding to each fault type. When the user operates the setting interface for a certain fault type, the fault injection device responds to the operation on that interface by displaying a parameter setting interface for that fault type. This parameter setting interface may include a fault parameter input interface. Thus, when the user inputs the corresponding fault injection parameters through each setting interface, the fault injection device responds to the operation on the fault parameter input interface by acquiring the fault injection parameters input by the user through the input interface. Finally, the fault injection device generates a fault injection command for the aforementioned fault type, and includes the fault injection parameters input through the fault parameter input interface in the command.

[0043] The fault type refers to the type of fault that occurs during the execution of the target application, which can include request delay, request timeout, abnormal request message, abnormal response message, and abnormal processing of request messages. Fault injection parameters refer to the parameters used during the fault injection process and during fault execution. Different fault types correspond to different fault injection parameters. For example, when the fault type is request delay, the fault injection parameters may include parameters such as the delay duration; when the fault type is abnormal request message, the fault injection parameters may include parameters such as the request format used to replace the request message received by the target application.

[0044] Step 102: Transmit the fault injection parameters to the fault injection plugin of the target application.

[0045] The target application here can be any application loaded in the aforementioned fault injection device, or it can be an application independent of the aforementioned fault injection device; no limitation is made here.

[0046] The fault injection plugin is used to perform the following steps:

[0047] Step 103: Generate corresponding executable fault information based on the fault injection parameters. Specifically, the executable fault information can be a piece of fault code. In some examples, this executable fault information can also be called a fault atom.

[0048] Specifically, the executable fault information generated by the fault injection device based on the fault injection parameters varies depending on the fault type. That is, it generates executable fault information corresponding to the fault type based on the fault type specified in the fault injection parameters. For example:

[0049] If the fault type is request delay, then the executable fault information corresponding to the request delay is generated according to the fault injection parameters. This executable fault information is used to transmit the request message to the target application for processing after a preset time period when the request message of the target application is intercepted.

[0050] If the fault type is request timeout, then executable fault information corresponding to the request timeout is generated according to the fault injection parameters. This executable fault information is used to transmit the request message to the target application for processing after the timeout period when the request message of the target application is intercepted and the request message includes a timeout period.

[0051] If the fault type is request message exception, then executable fault information corresponding to the request message exception is generated according to the fault injection parameters. This executable fault information is used to replace the request message with a preset request when the request message of the target application is intercepted, and then transmit the replaced request message to the target application for processing, that is, to simulate the fault atom of the request.

[0052] If the fault type is response message exception, then the executable fault information corresponding to the response message exception is generated according to the fault injection parameters. This executable fault information is used to replace the response message of the target application with a preset response when the response message is intercepted, and then return the replaced response message, which is used to simulate the fault atom of the response.

[0053] If the fault type is an exception to the processing of the request message, then an executable fault information for the exception to the processing of the request message is generated according to the fault injection parameters. This executable fault information is used to return preset exception handling information when the request message of the target application is intercepted, that is, to simulate the fault atom of the exception.

[0054] Step 104: When a transmission message of the target application is intercepted, determine the executable fault information corresponding to the transmission message.

[0055] Step 105: Inject the executable fault information corresponding to the transmission message into the target application so that the target application runs the executable fault information when performing corresponding operations according to the transmission message.

[0056] The transmission messages of the target application here mainly refer to the request messages received by the target application and the response messages to be sent by the target application. Furthermore, these transmission messages can be those transmitted when the target application is running a specific function, where the function can correspond to a service of the target application.

[0057] In this embodiment, after intercepting a transmission message from the target application, the fault injection plugin does not immediately pass the transmission message to the target application for processing. Instead, it determines whether any executable fault information corresponding to the transmission message has been generated previously. If so, it injects the corresponding executable fault information into the target application and runs the executable fault information; otherwise, it passes the transmission message to the target application for processing. It should be noted that the fault injection plugin continuously generates executable fault information based on fault injection commands and stores each executable fault information as a fault atom in the executable atom library. Thus, when a transmission message from the target application is intercepted, it searches the executable atom library for the executable fault information, i.e., the fault atom, corresponding to the transmission message.

[0058] Furthermore, after injecting executable fault information into the target application, the target application will run the executable fault information when performing corresponding operations based on the transmitted messages. Specifically, when the target application receives a request message, it can call the executable fault information corresponding to the following fault types: request delay and request timeout; when the target application is performing corresponding operations based on the request message, it can call the executable fault information of the following fault types: request message exception and request message processing exception; when the target application needs to send a response message, it can call the executable fault information of the following fault type: response message exception.

[0059] Specifically, when an executable fault message corresponding to a delayed execution request is encountered, if the target application's request message is intercepted, the request message is transmitted to the target application for processing after a preset time period. When an executable fault message corresponding to a timeout execution request is encountered, if the target application's request message is intercepted and includes a timeout period, the request message is transmitted to the target application for processing after the timeout period. When an executable fault message corresponding to an abnormal execution request message is encountered, if the target application's request message is intercepted, the request message is replaced with a preset request, and the replaced request message is transmitted to the target application for processing. When an executable fault message corresponding to an abnormal execution response message is encountered, if the target application's response message is intercepted, the response message is replaced with a preset response, and the replaced response message is returned. When an executable fault message corresponding to an abnormal execution of the processing of a request message is encountered, if the target application's request message is intercepted, preset exception handling information is returned.

[0060] Additionally, it should be noted that steps 101 to 105 above describe the process by which the fault injection plugin in the target application generates executable fault information and injects it when the fault injection device initiates a fault injection command. In other embodiments, the user can initiate an injection stop command through the user interface displayed by the fault injection device. This injection stop command is used to stop injecting a fault of a certain type into the target application. In this way, the fault injection device will obtain the injection stop command and transmit it to the fault injection plugin of the target application. The fault injection plugin will then delete the executable fault information, i.e., the fault atom, corresponding to the injection stop command in the executable atom library according to the injection stop command.

[0061] In a specific application, the executable atom library maintains two sets of executable fault information: a first fault atom group and a second fault atom group. Each fault atom group can include multiple sets of executable fault information, i.e., multiple fault atoms. The executable fault information in the first fault atom group is used to match intercepted transmission messages, while the second fault atom group is used to maintain the state of the executable fault information. Specifically, the fault injection plugin searches for the executable fault information corresponding to the aforementioned transmission message in the first fault atom group; it continuously updates the executable fault information in the second fault atom group to obtain the updated executable fault information, and stores the updated executable fault information in the second fault atom group into the first fault atom group to update the first fault atom group. The updating of the executable fault information in the second fault atom group mainly includes:

[0062] When new executable fault information is detected, the new executable fault information is added to the second fault atom group to update the second fault atom group. For example, when the fault injection plugin generates new executable fault information based on the fault injection parameters, the new executable fault information will be detected. When executable fault information with a duration exceeding the preset duration is detected, or when the fault injection plugin receives an injection stop command, the corresponding executable fault information is removed from the second fault atom group to update the second fault atom group.

[0063] When a request message is intercepted by the fault injection plugin and the corresponding executable fault information is searched from the executable atomic library, a race condition will occur if expired executable fault information in the executable atomic library needs to be cleaned up. That is, the executable fault information needs to be locked. In order to prevent the locking from causing long-term blocking and affecting the fault injection process, two fault atomic groups are maintained in the executable atomic library. In this way, no locking is required when searching for the corresponding executable fault information from the first fault atomic group, thus avoiding blocking.

[0064] Specifically, if a transport message corresponds to multiple executable fault messages, the fault injection plugin, when injecting the executable fault messages, specifically injects the executable fault messages corresponding to the transport message into the target application according to the order in which the target application processes the transport message. Thus, when running these multiple executable fault messages, the corresponding executable fault messages are also invoked in the order in which the transport message is processed, i.e., these executable fault messages are invoked recursively.

[0065] For example, the target application processes request messages in the following order: after receiving the request message, it generates a response message based on the request message and returns the generated response message. If the identified multiple executable fault information includes executable fault information corresponding to request delay and executable fault information corresponding to request message exception, then according to the target application's processing order of request messages, the executable fault information corresponding to request delay is injected first, followed by the executable fault information corresponding to request message exception. When running these multiple executable fault information, upon receiving a request message, the executable fault information corresponding to request delay is called first, meaning that after waiting for a period of time, the request message needs to be processed. At this point, the executable fault information corresponding to request message exception is called again, meaning that the exception handling information corresponding to the request message is directly obtained and returned.

[0066] As can be seen, in the method of this embodiment, a fault injection command of a fault type is obtained through a fault injection device, and the fault injection parameters contained in the fault injection command are transmitted to the fault injection plugin of the target application. The fault injection plugin generates corresponding executable fault information based on the fault injection parameters. When a transmission message of the target application is intercepted, the executable fault information corresponding to the transmission message is determined, and the executable fault information is injected into the target application. In this way, only the fault injection plugin needs to be loaded in the target application to flexibly generate executable fault information of various fault types for injection into the target program, without being limited by the ontology code of the target application, thus improving the scalability of fault injection.

[0067] The following example illustrates the fault injection method of this application, which can perform fault injection on the transmission messages of a service in the target application, such as... Figure 3 As shown, the fault injection device 10 in this embodiment may include: a chaos engineering agent 11, a fault injection tool 12, and a parameter distribution channel component 13, wherein:

[0068] (1) Chaos Engineering Agent 11 is used to obtain fault injection commands for various fault types, and to call fault injection tool 12 according to the fault injection parameters in the fault injection command, and to pass the fault injection parameters in the fault injection command to fault injection tool 12. The call can be a local call or a remote call.

[0069] Here, chaos engineering is a discipline that experiments on distributed systems to improve the resilience of technical architectures. By observing the behavioral changes of distributed systems in controlled fault injection tests, it uncovers system weaknesses and makes targeted improvements, thereby enhancing system reliability and establishing the system's ability and information to withstand runaway conditions.

[0070] In this embodiment, the chaos engineering agent 11 can specifically display, for example... Figure 4a The user settings interface shown includes at least one setting interface corresponding to each fault type, namely, the "Request Delay" button, the "Simulate Request" button, the "Simulate Response" button, the "Simulate Abnormality" button, and the "Request Timeout" button.

[0071] When the user clicks the "Request Delay" button, the Chaos Engineering Agent will display the following: Figure 4b and Figure 4c The parameter setting interface shown provides input interfaces for two types of fault parameters: "Fault Configuration" and "Experiment Target". For the "Fault Configuration" type parameter, the parameter setting interface can include input interfaces for two parameters, namely "Delay Duration (Request Delay)" and "Duration (Atomic Execution Duration)", i.e., input boxes. For the "Fault Configuration" type parameter, the parameter setting interface can include input interfaces for parameters such as "Business Module", "Deployment Platform", "Experiment Target", "Service" and "Interface".

[0072] When a user inputs fault injection parameters through the input interface of the parameter settings interface, a fault injection command can be generated.

[0073] (2) Fault injection tool 12 is used to encapsulate and distribute fault injection parameters, such as by using inter-process communication protocol or by using Unix domain socket to distribute fault injection parameters, so as to facilitate the transmission of fault injection parameters.

[0074] (3) Parameter delivery channel component 13 is used to listen to and obtain the encapsulated fault injection parameters and transmit the fault injection parameters to the fault injection plugin 14 of the target application.

[0075] In this embodiment, the target application is carried in the fault injection device 10. The fault injection plugin 14 of the target application is used to generate executable fault information based on the fault injection parameters in the fault injection command of any fault type after obtaining the fault injection parameters. In this embodiment, it is simply referred to as fault atom. The fault atom is put into the executable atom library. When the fault injection plugin 14 intercepts the request message and response message of the target application, it finds the corresponding fault atom from the executable atom library and injects the found fault atom into the target application.

[0076] Among them, the fault injection plugin 14 can utilize the interceptor of the Remote Procedure Call Protocol (RPC) framework (such as the frameworks of languages ​​such as Java, Golang, C++, Python, Rust, etc.) to intercept the transmitted messages. The interceptor will intercept all request and response messages of a certain service in the target application. It can obtain the caller and callee information from the request message header and match it with the target information of each fault atom in the executable atomic library. If they match, the fault atom is injected.

[0077] Furthermore, the fault injection device 10 may also include: an injection management tool 15, which is used to uniformly manage the status of the fault injection process initiated by the fault injection device 10. When the fault injection process ends, a stop injection command will be issued to the fault injection plugin 14 to delete the corresponding fault atom in the executable atom library.

[0078] In practical applications, the hardware environment of the fault injection device 10 may include: an operating system of CentOS 7 x86_64, a CPU of AMD EPYC 7K62 with a clock speed of 2595.124MHz. The performance overhead of the fault injection device 10 can be mainly divided into two parts:

[0079] The first part is the overhead of the Chaos Engineering Agent 11, which generally runs within the business container and does not consume much memory or CPU resources. When performing fault injection, the Resident Set Size (RSS) memory usage is less than 100K, the CPU utilization is 3%, and two ports are required to listen for remote calls. The second part is the overhead of the fault injection plugin 14. The executable atomic library will store two copies of fault atoms in memory. The memory usage of a single fault atom is about 70 bytes, and the total memory usage of the executable atomic library is about 70 * the number of surviving fault atoms * 2 bytes. Since communication with the parameter distribution channel component 13 can be achieved through Unix domain sockets, no additional ports are required. In addition, the fault injection plugin 14 itself will start two processes to ensure all functions.

[0080] Specifically, refer to Figure 5 As shown, the fault injection device 10 in this embodiment can implement fault injection through the following steps:

[0081] Step 201: The chaos engineering agent 11 in the fault injection device 10 obtains a fault injection command of a certain fault type, parses the fault injection parameters in the fault injection command, and calls the corresponding fault injection tool 12 to pass the fault injection parameters through the fault injection tool 12.

[0082] Step 202: The fault injection tool 12 encapsulates and distributes the fault injection parameters.

[0083] Step 203: The parameter distribution channel component 13 listens to the encapsulated fault injection parameters and transmits the fault injection parameters to the fault injection plugin 14 of the target application.

[0084] Step 204: The fault injection plugin 14 generates fault atoms, i.e., the above-mentioned executable fault information, according to the fault injection parameters, and adds the fault atoms to the executable atom library.

[0085] Step 205: The fault injection plugin 14 intercepts the request and response messages of a certain service (i.e. function) in the target application, searches for the corresponding fault atom in the executable atomic library, and injects the found fault atom into the target application; if no corresponding fault atom is found, the request message is transmitted to the target application for processing, or the response message is returned.

[0086] During steps 201 to 205 above, the injection management tool 15 in the fault injection device 10 manages the fault injection process. When the fault injection process ends, it issues a stop injection command to the fault injection plugin 14, and the fault injection plugin 14 deletes the corresponding fault atom in the executable atom library.

[0087] As can be seen, the fault injection method in this embodiment can achieve the following technical effects:

[0088] (1) Precise fault injection: It can perform precise fault injection on upstream and downstream services or interfaces of a specific target application in proportion to minimize the explosion radius. It supports fault injection on specific fields in the request message, such as the request message of a specific user, and can simulate faults in various fine combination scenarios.

[0089] (2) Low-cost fault simulation: There is no need to inject faults at the dependent end for external dependencies such as middleware, and fault injection for the entire cluster or data center can also be simulated.

[0090] (3) In a cloud-native environment, it can simulate fault injection scenarios that cannot be simulated by external fault injection, thus enriching the underlying injection capabilities of Chaos Engineering.

[0091] The following uses another specific application example to illustrate the fault injection method in this application. The fault injection device in this embodiment is mainly a distributed system 100. The distributed system may include a client 300 and multiple nodes 200 (any form of computing device in the network, such as a server or user terminal). The client 300 and the nodes 200 are connected through network communication.

[0092] Taking a distributed system as an example, see blockchain system. Figure 6 This is an optional structural diagram of the distributed system 100 provided in this application embodiment applied to a blockchain system. It consists of multiple nodes 200 (any form of computing device connected to the network, such as servers or user terminals) and clients 300. The nodes form a peer-to-peer (P2P) network. The P2P protocol is an application layer protocol running on top of the Transmission Control Protocol (TCP). In the distributed system, any machine, such as a server or terminal, can join and become a node. A node includes a hardware layer, a middleware layer, an operating system layer, and an application layer.

[0093] See Figure 6 The functions of each node in the blockchain system shown include:

[0094] 1) Routing: A basic function of nodes used to support communication between nodes.

[0095] In addition to routing capabilities, nodes can also have the following functions:

[0096] 2) Applications are deployed in the blockchain to implement specific business needs. They record data related to the implementation of functions to form record data, carry digital signatures in the record data to indicate the source of the task data, and send the record data to other nodes in the blockchain system. When other nodes successfully verify the source and integrity of the record data, they add the record data to the temporary block.

[0097] For example, in this embodiment, the application in the node also includes code that implements fault injection functionality, which mainly includes:

[0098] A fault injection command of a fault type is obtained, the fault injection command being used to instruct the injection of executable fault information of a certain type into a target application, the fault injection command containing fault injection parameters; the fault injection parameters are transmitted to a fault injection plugin of the target application; wherein, the fault injection plugin is used to: generate corresponding executable fault information based on the fault injection parameters; when a transmission message of the target application is intercepted, determine the executable fault information corresponding to the transmission message, and inject the fault atom corresponding to the transmission message into the target application, so that the target application runs the executable fault information when performing corresponding operations according to the transmission message.

[0099] 3) A blockchain consists of a series of blocks that are sequentially generated. Once a new block is added to the blockchain, it will not be removed. The blocks contain the data submitted by the nodes in the blockchain system.

[0100] See Figure 7 This is an optional schematic diagram of the block structure provided in this application embodiment. Each block includes the hash value of the transaction records stored in this block (the hash value of this block) and the hash value of the previous block. The blocks are connected through their hash values ​​to form a blockchain. Additionally, the block may include information such as a timestamp when it was generated. A blockchain is essentially a decentralized database, a chain of data blocks linked together using cryptographic methods. Each data block contains relevant information used to verify the validity of the information (anti-counterfeiting) and to generate the next block.

[0101] This application also provides a fault injection device 20, the structural schematic diagram of which is shown below. Figure 8 As shown, it can specifically include:

[0102] Command acquisition unit 21 is used to acquire a fault injection command of a fault type. The fault injection command is used to instruct the injection of a certain type of executable fault information into the target application. The fault injection command contains fault injection parameters.

[0103] The parameter transmission unit 22 is used to transmit the fault injection parameters obtained by the command acquisition unit 21 to the fault injection plugin 23 of the target application.

[0104] The fault injection plugin 23 is used for:

[0105] Generate corresponding executable fault information based on the fault injection parameters;

[0106] When a transmission message of the target application is intercepted, executable fault information corresponding to the transmission message is determined, and the fault atom corresponding to the transmission message is injected into the target application so that the target application runs the executable fault information when performing corresponding operations according to the transmission message.

[0107] It should be noted that the target application can be an application installed in the fault injection device 20 of this embodiment, or it can be an application installed independently of the fault injection device 20. In this embodiment, the latter will be used as an example.

[0108] Furthermore, the fault injection device 20 in this embodiment may further include:

[0109] The interface initiation unit 24 is used to display a user settings interface, which includes: setting interfaces corresponding to at least one fault type; in response to an operation on the setting interface of a fault type, it displays a fault injection parameter setting interface for the fault type, which includes: a fault parameter input interface; in response to an operation on the fault parameter input interface, it obtains the fault injection parameters input by the user through the fault parameter input interface; and generates a fault injection command for the fault type, wherein the fault injection command includes the fault injection parameters input through the fault parameter input interface. The command acquisition unit 21 is the fault injection command generated by the interface initiation unit 24. The at least one fault type includes at least one of the following types: request delay, request timeout, request message exception, response message exception, and request message processing exception.

[0110] Furthermore, when generating executable fault information, the aforementioned fault injection plugin 23 generates executable fault information corresponding to the fault type based on the fault type of the fault injection parameters. Thus, when running the corresponding executable fault information:

[0111] When the executable fault information corresponding to the running request delay is received, specifically if the request message of the target application is intercepted, the request message will be transmitted to the target application for processing after a preset time period.

[0112] When the executable failure information corresponding to the timeout of the request is received, specifically if the request message of the target application is intercepted and the request message includes a timeout period, the request message is transmitted to the target application for processing after the timeout period.

[0113] When the executable fault information corresponding to the abnormal running request message is obtained, specifically if the request message of the target application is intercepted, the request message is replaced with a preset request, and the replaced request message is transmitted to the target application for processing.

[0114] When the executable fault information corresponding to the abnormal response message is executed, specifically if the response message of the target application is intercepted, the received response message is replaced with a preset response and the replaced response message is returned.

[0115] When the execution of the executable fault information corresponding to the exception in the processing of the request message is interrupted, specifically if the request message of the target application is intercepted, the preset exception handling information is returned.

[0116] Furthermore, when the transmission message corresponds to multiple executable fault information, the fault injection plugin 23, when injecting the executable fault information into the target application, specifically injects the executable fault information corresponding to the transmission message into the target application according to the order in which the target application processes the transmission message.

[0117] Furthermore, after generating the corresponding executable fault information based on the fault injection parameters, the fault injection plugin 23 is also used to: store the executable fault information in the executable atomic library; and when the transmission message of the target application is intercepted, the fault injection plugin 23 is used to search for the executable fault information corresponding to the transmission message from the executable atomic library.

[0118] Further, if the executable atom library includes a first fault atom group and a second fault atom group, then the step of searching for executable fault information corresponding to the transmission message in the executable atom library, specifically the fault injection plugin 23, is used to search for executable fault information corresponding to the transmission message in the first fault atom group; the fault injection plugin 23 is also used to: when executable fault information with a duration exceeding a preset duration is detected, remove executable fault information with a duration exceeding the preset duration from the second fault atom group to update the second fault atom group; when new executable fault information is detected, add the new executable fault information to the second fault atom group to update the second fault atom group; and store the updated executable fault information in the second fault atom group into the first fault atom group to update the first fault atom group.

[0119] In this way, simply loading the fault injection plugin 23 in the target application allows for the flexible generation of executable fault information of various fault types to be injected into the target program, without being limited by the ontology code of the target application, thus improving the scalability of fault injection.

[0120] This application embodiment also provides a terminal device 30, the structural schematic diagram of which is shown below. Figure 9 As shown, the terminal device can vary significantly due to differences in configuration or performance. It may include one or more central processing units (CPUs) 31 (e.g., one or more processors) and memory 32, and one or more storage media 33 (e.g., one or more mass storage devices) for storing application programs 331 or data 332. The memory 32 and storage media 33 can be temporary or persistent storage. The program stored in the storage media 33 may include one or more modules (not shown in the figure), each module including a series of instruction operations on the terminal device. Furthermore, the CPU 31 may be configured to communicate with the storage media 33 and execute the series of instruction operations stored in the storage media 33 on the terminal device.

[0121] Specifically, the application program 331 stored in the storage medium 33 includes a fault-injection application program, which may include the command acquisition unit 21, parameter transmission unit 22, and interface initiation unit 24 of the fault injection device 20, which will not be described in detail here. Furthermore, the central processing unit 31 may be configured to communicate with the storage medium 33 and execute a series of operations corresponding to the fault-injection application program stored in the storage medium 33 on the terminal device.

[0122] The terminal device may also include one or more power supplies 34, one or more wired or wireless network interfaces 35, one or more input / output interfaces 36, and / or one or more operating systems 333, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, etc.

[0123] The steps performed by the fault injection device in the above method embodiments can be based on this. Figure 9 The structure of the terminal device shown is illustrated.

[0124] In another aspect, embodiments of this application also provide a computer-readable storage medium storing a plurality of computer programs adapted for loading by a processor and executing a fault injection method performed by the fault injection apparatus described above.

[0125] Another aspect of this application embodiment provides a terminal device, including a processor and a memory;

[0126] The memory is used to store multiple computer programs, which are loaded by a processor and executed as described above by the fault injection device; the processor is used to implement each of the multiple computer programs.

[0127] Additionally, according to one aspect of this application, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the fault injection method provided in the various optional implementations of the above embodiments.

[0128] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, which may include: read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.

[0129] The fault injection method, apparatus, storage medium, and terminal device provided in the embodiments of this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.

Claims

1. A fault injection method, characterized in that, include: Obtain a fault injection command of a fault type, the fault injection command being used to instruct the injection of a type of executable fault information into a target application, the fault injection command containing fault injection parameters; The fault injection parameters are transmitted to the fault injection plugin of the target application; The fault injection plugin is used for: Generate corresponding executable fault information based on the fault injection parameters; The executable fault information is stored in the executable atomic library through the fault injection plugin. When the transmission message of the target application is intercepted, the caller and the callee information is obtained from the header of the transmission message. The caller and the callee information is matched with the target information of each executable fault information in the executable atomic library. When the match is successful, the executable fault information corresponding to the transmission message is searched in the executable atomic library. The executable fault information corresponding to the transmission message is injected into the target application so that the target application runs the executable fault information when it performs corresponding operations according to the transmission message.

2. The method as described in claim 1, characterized in that, Before obtaining the fault injection command for a fault type, the method further includes: Display the user settings interface, which includes at least one setting interface corresponding to each fault type; In response to an operation on the setting interface of a fault type, a fault injection parameter setting interface of the fault type is displayed, the parameter setting interface including: an input interface for fault parameters; In response to an operation on the input interface of the fault parameters, obtain the fault injection parameters input by the user through the input interface of the fault parameters; Generate a fault injection command for the fault type, wherein the fault injection command includes the fault injection parameters input through the fault parameter input interface.

3. The method as described in claim 2, characterized in that, The at least one fault type includes at least one of the following types: request delay, request timeout, request message error, response message error, and processing error of request message.

4. The method as described in claim 3, characterized in that, The step of generating corresponding executable fault information based on the fault injection parameters includes: Based on the fault type of the fault injection parameters, generate executable fault information corresponding to the fault type; When the executable fault information corresponding to the request delay is executed, if the request message of the target application is intercepted, the request message is transmitted to the target application for processing after a preset time period; or, When the executable failure information corresponding to the timeout of the request is received, if the request message of the target application is intercepted and the request message includes a timeout period, then the request message is transmitted to the target application for processing after the timeout period; or, When the executable fault information corresponding to the abnormal request message is executed, if the request message of the target application is intercepted, the request message is replaced with a preset request, and the replaced request message is transmitted to the target application for processing; or, When executing the executable fault information corresponding to the abnormal response message, if the response message of the target application is intercepted, the response message is replaced with a preset response, and the replaced response message is returned; or, When the executable fault information corresponding to the exception handling of the request message is executed, if the request message of the target application is intercepted, the preset exception handling information is returned.

5. The method according to any one of claims 1 to 4, characterized in that, When the transmission message corresponds to multiple executable fault information, the step of injecting the executable fault information corresponding to the transmission message into the target application specifically includes: According to the order in which the target application processes the transmitted messages, the executable fault information corresponding to the transmitted message from the plurality of executable fault information is injected into the target application.

6. The method as described in claim 1, characterized in that, If the executable atom library includes a first fault atom group and a second fault atom group, then searching for executable fault information corresponding to the transmission message from the executable atom library includes: searching for executable fault information corresponding to the transmission message from the first fault atom group; The fault injection plugin is also used for: When an executable fault message with a duration exceeding a preset duration is detected, the executable fault message with a duration exceeding the preset duration in the second fault atom group is removed to update the second fault atom group; When new executable fault information is detected, the new executable fault information is added to the second fault atom group to update the second fault atom group; The executable fault information in the updated second fault atom group is stored in the first fault atom group to update the first fault atom group.

7. A fault injection device, characterized in that, include: The command acquisition unit is used to acquire a fault injection command of a fault type. The fault injection command is used to instruct the injection of a type of executable fault information into the target application. The fault injection command contains fault injection parameters. A parameter transmission unit is used to transmit the fault injection parameters to the fault injection plugin of the target application. The fault injection plugin is used for: Generate corresponding executable fault information based on the fault injection parameters; The executable fault information is stored in the executable atomic library through the fault injection plugin. When the transmission message of the target application is intercepted, the caller and the callee information is obtained from the header of the transmission message. The caller and the callee information is matched with the target information of each executable fault information in the executable atomic library. When the match is successful, the executable fault information corresponding to the transmission message is searched in the executable atomic library. The executable fault information corresponding to the transmission message is injected into the target application so that the target application runs the executable fault information when it performs corresponding operations according to the transmission message.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a plurality of computer programs adapted to be loaded by a processor and executed by the fault injection method as described in any one of claims 1 to 6.

9. A terminal device, characterized in that, Including processor and memory; The memory is used to store a plurality of computer programs, which are loaded by a processor and executed as the fault injection method as described in any one of claims 1 to 6; The processor is used to implement each of the plurality of computer programs.

Citation Information

Patent Citations

  • Fault injection method and device and business service system

    CN110674028A