Fault injection method and device, medium and computer equipment
Through the plug-in design of fault injection, the problems of complex fault injection operations and insufficient scenario satisfaction in the existing technology are solved, and fault injection with high flexibility and precision are achieved, and stability and fault tolerance testing of financial technology systems are supported.
Patent Information
- Application Number
- CN202411712450.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-26
- Publication Date
- 2025-03-25
- Estimated Expiration
- 2044-11-26
AI Technical Summary
The existing fault injection technology has complex operational processes and difficult execution, which is difficult for beginners to master quickly, and the fault scenarios and data components simulated by existing tools are difficult to meet the diversified needs of financial technology systems.
Through the fault injection plug-in design, multiple fault injection plug-ins are built. Each plug-in corresponds to a preset database, including multiple fault injection targets and corresponding fault injection logic, realizing dynamic loading and monitoring of microservice programs and executing fault injection logic in real time.
It significantly improves the flexibility and scalability of fault injection, ensures the comprehensiveness and accuracy of tests, improves the real-timeness of fault injection, and provides technical support for the system's stability and fault tolerance testing under real fault conditions.
Smart Images

Figure CN119690535A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of fault injection technology and the field of financial technology, and in particular, to a fault injection method, apparatus, medium and computer equipment. Background Art
[0002] In the field of financial technology, the stability and reliability of the system are the basis for ensuring transaction security, smooth capital flow and user trust. As an effective testing method, fault injection technology plays an important role in this field. This technology artificially introduces various preset faults to simulate various abnormal situations that may be encountered in the actual production environment, thereby helping system developers and operation and maintenance teams to comprehensively identify and repair potential system weaknesses. With the rapid development of the financial technology industry, the complexity of the system continues to increase, and the demand for fault injection technology is becoming increasingly urgent. In particular, in key scenarios such as high-frequency trading and real-time risk control, the system's recovery mechanism is particularly important. Fault injection technology can not only verify the response speed and effect of these mechanisms when a fault occurs, but also strengthen the emergency response coordination and problem troubleshooting capabilities between teams by simulating real fault scenarios, further improve the efficiency and speed of fault handling, and ensure the overall robustness of the financial technology system.
[0003] However, in the relevant technologies, the current implementation schemes in the industry still have several significant defects: First, the operational process of fault injection is complicated and difficult to execute, which not only increases the cost and time of testing, but also may cause unnecessary system risks due to operational errors; second, since this technology requires in-depth technical knowledge and rich practical experience, beginners often find it difficult to quickly master the relevant tools and methods, which affects the overall efficiency and testing quality of the technical team. In addition, with the continuous upgrading and complexity of financial technology systems, the fault injection scenarios and data components simulated by existing tools can no longer meet the diverse needs in actual production environments. Summary of the invention
[0004] The embodiments of the present disclosure at least provide a fault injection method, apparatus, medium and computer equipment. Through the fault injection plug-in design, the flexibility and scalability of fault injection are significantly improved, the comprehensiveness of the test is ensured, and the accuracy and real-time performance of fault injection are greatly improved. Technical support is provided for the stability and fault tolerance testing of the system under real fault conditions, so that the robustness and reliability of the system in the face of various faults can be better evaluated.
[0005] According to one aspect of the present application, a fault injection method is provided, comprising:
[0006] Construct a fault injection code package, and mount the fault injection code package on a preset microservice program; wherein the fault injection code package includes a plurality of fault injection plug-ins, each of which corresponds to a preset database, and each of which includes a plurality of fault injection targets corresponding to the preset database; the preset microservice program implements functions by accessing the preset database;
[0007] In response to the preset microservice program startup instruction, multiple fault injection plug-ins related to the preset microservice program are loaded based on the fault injection code package, and fault injection targets in the preset microservice program are determined based on the multiple fault injection plug-ins;
[0008] The preset microservice program is monitored using the multiple fault injection plug-ins. When the calling behavior of the preset microservice program to any of the preset databases is monitored, a fault injection target corresponding to the calling behavior is determined, and the fault injection logic corresponding to the fault injection target is executed.
[0009] According to another aspect of the present application, a fault injection device is provided, the device comprising:
[0010] A fault injection code package construction module is used to construct a fault injection code package and mount the fault injection code package on a preset microservice program; wherein the fault injection code package includes a plurality of fault injection plug-ins, each of which corresponds to a preset database, and each of which includes a plurality of fault injection targets corresponding to the preset database; the preset microservice program implements functions by accessing the preset database;
[0011] a fault injection logic determination module, configured to respond to the preset microservice program startup instruction, load multiple fault injection plug-ins related to the preset microservice program based on the fault injection code package, and determine a fault injection target in the preset microservice program based on the multiple fault injection plug-ins;
[0012] The fault injection logic execution module is used to use the multiple fault injection plug-ins to monitor the preset microservice program, and when monitoring the calling behavior of the preset microservice program to any of the preset databases, determine the fault injection target corresponding to the calling behavior, and execute the fault injection logic corresponding to the fault injection target.
[0013] According to another aspect of the present application, an embodiment of the present disclosure provides a computer device, including: a processor, a memory and a bus, the memory storing machine-readable instructions executable by the processor, when the computer device is running, the processor and the memory communicate through the bus, and when the machine-readable instructions are executed by the processor, the fault injection method described in any possible implementation manner described above is performed.
[0014] According to another aspect of the present application, an embodiment of the present disclosure provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the fault injection method as described in any possible implementation manner described above is implemented.
[0015] By means of the above technical solution, the fault injection method, device, medium and computer equipment provided in the embodiments of the present disclosure construct a code package containing multiple fault injection plug-ins for a specific preset database, and mount it on the microservice program. When the program starts, the relevant plug-in is loaded to determine the fault injection target, and the corresponding fault injection logic is executed once triggered by monitoring the microservice program's call behavior to the database. In this way, through the fault injection plug-in design, the flexibility and scalability of fault injection are significantly improved, the comprehensiveness of the test is ensured, and the accuracy and real-time performance of fault injection are greatly improved, which provides technical support for the stability and fault tolerance test of the system under real fault conditions, so that the robustness and reliability of the system in the face of various faults can be better evaluated.
[0016] In order to make the above-mentioned objectives, features and advantages of the present disclosure more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the following briefly introduces the drawings required to be cited in the embodiments. The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present disclosure and are used together with the specification to illustrate the technical solutions of the present disclosure. It should be understood that the following drawings only illustrate certain embodiments of the present disclosure and should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without creative work.
[0018] Figure 1 A schematic diagram of an application environment of a fault injection method provided by an embodiment of the present disclosure is shown;
[0019] Figure 2 A flow chart of a fault injection method provided by an embodiment of the present disclosure is shown;
[0020] Figure 3 A flowchart of a method for constructing a fault injection code package in a fault injection method provided in an embodiment of the present disclosure is shown;
[0021] Figure 4 A schematic diagram of the structure of a fault injection device provided by an embodiment of the present disclosure is shown;
[0022] Figure 5 A schematic diagram of the structure of a computer device provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0023] In order to make the purpose, technical scheme and advantages of the embodiments of the present disclosure clearer, the technical scheme in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, rather than all of the embodiments. The components of the embodiments of the present disclosure generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present disclosure provided in the drawings is not intended to limit the scope of the present disclosure for protection, but merely represents the selected embodiments of the present disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present disclosure.
[0024] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0025] The term "and / or" herein only describes an association relationship, indicating that three relationships may exist. For example, A and / or B may represent the following three situations: A exists alone, A and B exist at the same time, and B exists alone. In addition, the term "at least one" herein represents any combination of at least two of any one or more of a plurality of. For example, including at least one of A, B, and C may represent including any one or more elements selected from the set consisting of A, B, and C.
[0026] To facilitate understanding of this embodiment, the execution subject of the fault injection method provided by the embodiment of the present disclosure is first introduced in detail. The fault injection method provided by the embodiment of the present invention can be applied to Figure 1In an application environment, the client communicates with the server through a network. The client can be a mobile device, a user terminal, a terminal, a handheld device, a computing device, etc. The server can be an independent physical server, a server cluster or a distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud storage, big data and artificial intelligence platforms.
[0027] The fault injection method provided by the embodiment of the present application is described in detail below in conjunction with the accompanying drawings. Figure 2 FIG. 2 is a flow chart of a fault injection method provided by an embodiment of the present disclosure, and the method includes the following S201 to S203:
[0028] S201, construct a fault injection code package, and mount the fault injection code package on a preset microservice program.
[0029] It is understandable that the preset microservice program is an application designed with a microservice architecture, in which the functions are divided into multiple services (each service implements a specific function), and each service can be deployed and expanded independently. Here, the preset microservice program implements the function by accessing the preset database. The fault injection code package includes multiple fault injection plug-ins, each fault injection plug-in corresponds to a preset database, and each fault injection plug-in includes multiple fault injection targets corresponding to the preset database.
[0030] Specifically, refer to Figure 3 As shown, the method for constructing a fault injection code package includes the following S301 to S304:
[0031] S301, obtaining database information of multiple preset databases.
[0032] Here, the preset database refers to some key data storage resources in the system, such as relational databases (MySQL, PostgreSQL, etc.) or non-relational databases (Redis, MongoDB, etc.). Database information can include database name, type, connection parameters, table structure, data storage method, etc. This information is the basis for building a fault injection plug-in to ensure that the fault can be correctly mapped to the corresponding database. By extracting this information, the characteristics and potential failure modes of different databases can be identified to prepare for subsequent fault injection.
[0033] S302, for any preset database, determine a fault matching rule corresponding to any preset database based on the database information of any preset database; and determine multiple fault injection targets corresponding to any preset database and a fault injection logic corresponding to each of the fault injection targets based on the fault matching rule corresponding to any preset database; and, determine a plug-in name and a plug-in description of the fault injection plug-in of any preset database based on the database information of any preset database.
[0034] It is understandable that, since the database information of various preset databases is different, different preset databases include different fault matching rules. Here, the fault matching rule refers to the situation that may cause failures defined by the system based on the characteristics of the database (such as the database architecture, operation characteristics (such as addition, deletion, modification, query, etc.), connection method, etc.). These rules determine which types of failures should be simulated and matched with specific database objects. According to the fault matching failure of the preset database, multiple fault injection targets existing in the database can be identified. Here, the fault injection target refers to the specific point or path where failures may occur in the database operation, such as database connection pool, query execution, data storage, index operation, etc. Each target corresponds to one or more fault injection logics. The fault injection logic is a specific implementation of the fault behavior (such as delay, exception, etc.) for a specific target, and defines the specific fault injection behavior that should be taken when simulating a fault.
[0035] Exemplarily, taking the construction of fault injection targets and injection logic in the fault injection plug-in for the database MongoDB as an example, the fault matching rules of MongoDB are mainly based on the database characteristics of MongoDB (such as document storage, support for ACID transactions, distributed architecture, etc.) and operation characteristics (such as add, delete, modify, check, etc.) to define situations that may cause failures. These rules help determine which types of failures should be simulated and match them with specific objects of MongoDB (such as collections, documents, etc.). The fault injection target of MongoDB can refer to the specific point or path where failures may occur in database operations. For example, the methods in the MongoCollectionImpl client class of MongoDB (such as find, executeDrop, insertOne, deleteOne, etc.), as well as key links such as database connection pool, query execution, data storage, index operation, etc., can all be used as targets for fault injection. The fault injection logic of MongoDB is a specific implementation of the fault behavior (such as delay, exception, etc.) for specific targets. For example, it can simulate MongoDB to return a delay when performing a find operation, or simulate fault scenarios such as connection failure caused by exhaustion of database connection pool resources.
[0036] Specifically, fault injection behaviors can include network delay failure, request exception failure, and connection pool full failure. Network delay failure refers to simulating the network delay between the database and the microservice, and testing the performance of the system under unstable network conditions; request exception failure refers to simulating database request errors (such as timeout, no response, or error response), and observing how the microservice handles abnormal requests; connection pool full failure refers to simulating the exhaustion of database connection pool resources, and testing how the system handles requests when the connection pool is insufficient.
[0037] For example, since the database information of each preset database includes the name, type, and connection parameters of the database, the plug-in name and plug-in description of the fault injection plug-in of any preset database can be determined according to the database information of each preset database. The plug-in name is a unique identifier of the plug-in, which is used to distinguish different plug-ins, and the plug-in description is a brief description of the plug-in function to help developers understand the role of the plug-in.
[0038] S303, for any preset database, determine the fault injection plug-in of any preset database according to the multiple fault injection targets corresponding to the any preset database, the fault injection logic corresponding to each of the fault injection targets, and the plug-in name and plug-in description of the fault injection plug-in of any preset database.
[0039] It is understandable that after determining multiple fault injection targets corresponding to each preset database, the fault injection logic corresponding to each fault injection target, and the plug-in name and plug-in description of the fault injection plug-in, the fault injection plug-in for the preset database can be determined.
[0040] S304: construct the fault injection code package based on the fault injection plug-ins of any of the preset databases.
[0041] Specifically, after the construction of the fault injection plug-ins corresponding to the plurality of preset databases is completed, the plug-ins are combined together to form a fault injection code package. Here, the fault injection code package contains the fault injection plug-ins of all preset databases and can be deployed to the preset microservice program by mounting.
[0042] In the present disclosure, by obtaining database information of multiple preset databases and constructing fault injection plug-ins corresponding to different databases accordingly, by integrating the fault injection plug-ins of multiple preset databases into a fault injection code package and allowing it to be deployed in a microservice program in a mounting manner, the flexibility and ease of use of the fault injection test are improved, providing strong support for the reliability assurance of the microservice architecture test.
[0043] S202, in response to the preset microservice program startup instruction, multiple fault injection plug-ins related to the preset microservice program are loaded based on the fault injection code package, and fault injection targets in the preset microservice program are determined based on the multiple fault injection plug-ins.
[0044] It is understandable that after the preset microservice program is started, the fault injection code package will automatically load multiple fault injection plug-ins related to the preset microservice program according to the configuration. These plug-ins will be dynamically applied to the microservice program, intervene in the process of microservice program startup, identify the part of the program that interacts with the database, and prepare the corresponding fault injection logic. This dynamic injection method not only ensures the flexibility of fault injection testing, but also minimizes interference with the normal operation of the microservice program. After each fault injection plug-in is determined, the fault injection target in the preset microservice program can be determined according to the fault injection rules in each fault injection plug-in.
[0045] Here, after determining the fault injection target in the preset microservice program according to the multiple fault injection plug-ins, the following steps (1) to (3) may also be included:
[0046] (1) in response to a fault configuration instruction of a fault configuration interface for any of the fault injection plug-ins, determining fault injection information corresponding to the fault configuration instruction; wherein the fault configuration interface is used to set the fault injection information, and the fault injection information includes a fault injection behavior, a fault matching rule, and a fault injection time;
[0047] (2) generating a fault injection logic corresponding to the fault injection target indicated by the fault matching rule based on the fault injection code package according to the fault injection behavior corresponding to the fault configuration instruction and the fault injection time;
[0048] (3) According to the fault injection logic, update any one of the fault injection plug-ins in the fault injection code package.
[0049] It is understandable that the fault configuration interface is a user interaction interface, and the user can flexibly configure various parameters and conditions of fault injection, such as fault type, occurrence time, etc., according to actual needs. For example, injecting exceptions into the query operation of a specific table makes the test more in line with the actual application scenario. Among them, each fault injection plug-in can receive fault configuration instructions through this interface, and the fault configuration instructions contain detailed information about fault behavior, matching rules, and fault injection time. Among them, the fault injection time defines the timing of the fault occurrence, which can usually be set to a specific time point or triggered according to a specific cycle. In some other embodiments, the fault configuration interface can also be used for the configuration of fault injection instructions.
[0050] Specifically, after obtaining the fault injection information, the fault injection logic corresponding to the fault injection target indicated by the fault matching rule can be generated based on this information to determine when, where, and how to inject the fault. For example, if a fault injection target in a plug-in is set by the user to inject a delay behavior, then according to the configured fault injection logic, it can be realized that when the service call is made on this fault injection target, the response is returned according to the configured time delay. Finally, after the fault injection logic is generated according to the fault configuration instructions in the fault configuration decryption, the fault injection plug-in in the fault injection code package can be updated according to the generated fault injection logic.
[0051] In the present disclosure, fault parameters are flexibly set through a fault configuration interface, and injection logic corresponding to fault matching rules is generated through a fault injection code package. At the same time, a fault injection plug-in is updated without modifying the microservice program itself, thereby improving the flexibility and efficiency of fault testing.
[0052] S203, using the multiple fault injection plug-ins to monitor the preset microservice program, when monitoring the calling behavior of the preset microservice program to any of the preset databases, determining the fault injection target corresponding to the calling behavior, and executing the fault injection logic corresponding to the fault injection target.
[0053] Specifically, during the running of the microservice program, the fault injection plug-in monitors the running status and behavior of the program in real time. In particular, it focuses on the interaction between the microservice program and the database. When the microservice program issues a database call, the fault injection plug-in can detect these call behaviors in time and determine the fault injection targets related to them based on the characteristics of the call behavior (such as the database table called, the type of operation, the timing of the call, etc.). Each database call may trigger one or more fault injection targets, depending on the type of fault injected.
[0054] It is understandable that after the fault injection target is determined, the fault injection plug-in will execute the fault injection logic related to the target. For example, inject network delays, database errors, data loss, etc. These fault logics can be divided into several different types, such as letting the database connection time out, simulating database query return errors, etc. In this way, the microservice program will face these man-made faults, thereby verifying the fault tolerance of the system. In this way, the present disclosure can flexibly inject various types of faults when the microservice program is running through the above-mentioned fault injection method, thereby simulating real fault scenarios to achieve the fault tolerance and stability of the evaluation system. Not only does it simplify the process of fault injection, but it also significantly expands the coverage and application scenarios of fault injection, making fault injection technology more practical and efficient.
[0055] Specifically, after executing the fault injection logic, it is necessary to determine whether the execution result corresponding to the fault injection logic meets the execution condition corresponding to the call behavior. If the execution result meets the preset call behavior condition, it means that in the current fault scenario, the microservice program can continue to execute its database call normally and return the correct call content. On the contrary, if the execution result fails to meet the condition, it means that the microservice program has encountered an obstacle when dealing with this specific fault. At this time, it is necessary to troubleshoot the fault introduced by the fault injection logic. Here, the troubleshooting process may include reconfiguring services, correcting data errors, restoring network connections, etc., in order to eliminate the impact of the fault and enable the microservice program to return to a stable state. After the processing is completed, the microservice program will try to execute the previously failed database call again and successfully return the call content to ensure service continuity.
[0056] For example, a microservice program in the financial field may be responsible for processing customer account information, including operations such as deposits, withdrawals, and transfers, all of which require interaction with the database. Taking the transfer operation as an example, after the fault injection logic is executed, it is necessary to determine whether the execution result of this logic meets the execution conditions corresponding to the transfer operation. Assume that the fault injection logic simulates a network delay failure, resulting in a delay in the transfer request when it is sent to the database. If in this fault scenario, the microservice program can correctly handle network delays, such as continuously retrying requests before timeout, or rolling back transactions after request failures, and can eventually successfully complete the transfer operation and return the correct call content (such as confirmation information of successful transfer), then this means that the microservice program can still continue to execute its database call normally in the current network delay failure scenario.
[0057] However, if the execution result fails to meet the conditions, such as the microservice program directly throws an exception due to network delay and does not take any recovery measures, resulting in the failure of the transfer operation, then this indicates that the microservice program encountered obstacles in dealing with the specific failure of network delay. At this time, it is necessary to troubleshoot the network delay failure introduced by the fault injection logic. After the processing is completed, the microservice program will try to execute the previously failed transfer operation again. This time, since troubleshooting has been performed, the microservice program should be able to successfully complete the transfer and return the correct call content, such as confirmation of successful transfer and update of account balance.
[0058] It is understandable that in order to determine whether the microservice program has sufficient troubleshooting capabilities, the present disclosure proposes that after troubleshooting is completed, the matching information between the call content and the target call content can also be evaluated. By comparing the degree of matching between the actual call content and the target call content, it can be determined whether the microservice program can effectively handle the fault and return to normal. If the matching degree meets the preset standard, it means that the program has sufficient troubleshooting capabilities and can run stably in the face of various faults. On the contrary, if the matching degree does not meet the preset standard, it means that the fault tolerance of the microservice program is weak and may not be able to effectively deal with faults, and optimization and adjustment are required.
[0059] The fault injection method, apparatus, medium and computer equipment provided in the embodiments of the present disclosure significantly improve the flexibility and scalability of fault injection through the fault injection plug-in design, ensure the comprehensiveness of the test, and greatly improve the accuracy and real-time performance of fault injection, providing technical support for the stability and fault tolerance testing of the system under real fault conditions, so that the robustness and reliability of the system in the face of various faults can be better evaluated.
[0060] Those skilled in the art will appreciate that, in the above method of specific implementation, the order in which the steps are written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of the steps should be determined by their functions and possible internal logic.
[0061] Based on the same inventive concept, a fault injection device corresponding to the fault injection method is also provided in the embodiment of the present disclosure. Since the principle of solving the problem by the device in the embodiment of the present disclosure is similar to the above-mentioned fault injection method in the embodiment of the present disclosure, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.
[0062] Reference Figure 4 FIG. 4 is a schematic diagram of a fault injection device 400 provided in an embodiment of the present disclosure, wherein the device includes:
[0063] A fault injection code package construction module 401 is used to construct a fault injection code package and mount the fault injection code package on a preset microservice program; wherein the fault injection code package includes a plurality of fault injection plug-ins, each of which corresponds to a preset database, and each of which includes a plurality of fault injection targets corresponding to the preset database; the preset microservice program implements functions by accessing the preset database;
[0064] A fault injection logic determination module 402 is used to respond to the preset microservice program startup instruction, load multiple fault injection plug-ins related to the preset microservice program based on the fault injection code package, and determine the fault injection target in the preset microservice program based on the multiple fault injection plug-ins;
[0065] The fault injection logic execution module 403 is used to use the multiple fault injection plug-ins to monitor the preset microservice program, and when monitoring the calling behavior of the preset microservice program to any of the preset databases, determine the fault injection target corresponding to the calling behavior, and execute the fault injection logic corresponding to the fault injection target.
[0066] In some possible embodiments, the fault injection code package construction module 401 is specifically used to:
[0067] Get database information of multiple preset databases;
[0068] For any preset database, a fault matching rule corresponding to any preset database is determined based on the database information of any preset database; and multiple fault injection targets corresponding to any preset database and a fault injection logic corresponding to each of the fault injection targets are determined based on the fault matching rule corresponding to any preset database; and a plug-in name and a plug-in description of a fault injection plug-in of any preset database are respectively determined based on the database information of any preset database; wherein the fault injection logic corresponding to each of the fault injection targets is determined based on the fault injection behavior corresponding to the fault injection target, and the fault injection behavior includes a network delay fault, a request abnormality fault, and a connection pool full fault;
[0069] For any preset database, determine the fault injection plug-in of any preset database according to the multiple fault injection targets corresponding to the any preset database, the fault injection logic corresponding to each of the fault injection targets, and the plug-in name and plug-in description of the fault injection plug-in of any preset database;
[0070] The fault injection code package is constructed based on a plurality of fault injection plug-ins of any of the preset databases.
[0071] In some possible embodiments, the fault injection logic determination module 402 is further configured to:
[0072] In response to a fault configuration instruction of the fault configuration interface for any of the fault injection plug-ins, determining fault injection information corresponding to the fault configuration instruction; wherein the fault configuration interface is used to set the fault injection information, and the fault injection information includes a fault injection behavior, a fault matching rule, and a fault injection time;
[0073] Generate a fault injection logic corresponding to the fault injection target indicated by the fault matching rule based on the fault injection code package according to the fault injection behavior corresponding to the fault configuration instruction and the fault injection time;
[0074] According to the fault injection logic, any one of the fault injection plug-ins in the fault injection code package is updated.
[0075] In some possible embodiments, the fault injection logic execution module 403 is further used to:
[0076] Based on the preset microservice program, it is determined whether the execution result corresponding to the fault injection logic meets the execution condition corresponding to the calling behavior.
[0077] In some possible embodiments, the fault injection logic execution module 403 is further used to:
[0078] When the execution result corresponding to the fault injection logic satisfies the execution condition corresponding to the calling behavior, the calling behavior is executed and the calling content is returned.
[0079] In some possible embodiments, the fault injection logic execution module 403 is further used to:
[0080] When the execution result corresponding to the fault injection logic does not satisfy the execution condition corresponding to the calling behavior, troubleshooting the fault injection behavior corresponding to the fault injection logic;
[0081] After completing the troubleshooting process of the fault injection behavior, the calling behavior is executed and the calling content is returned.
[0082] In some possible embodiments, the fault injection logic execution module 403 is further used to:
[0083] Determine matching information between the call content and the target call content, and determine whether the preset microservice program has fault resolution capability based on the matching information;
[0084] If the matching information between the call content and the target call content meets the preset standard, the preset microservice program has the fault resolution capability;
[0085] If the matching information between the call content and the target call content does not meet the preset standard, the preset microservice program does not have the fault resolution capability.
[0086] Based on the same technical concept, the embodiment of the present disclosure also provides a computer device. Figure 5, which is a schematic diagram of the structure of a computer device 500 provided in an embodiment of the present disclosure, including a processor 501, a memory 502, and a bus 503. The memory 502 is used to store execution instructions, including a memory 5021 and an external memory 5022; the memory 5021 is also called an internal memory, which is used to temporarily store the operation data in the processor 501 and the data exchanged with the external memory 5022 such as a hard disk. The processor 501 exchanges data with the external memory 5022 through the memory 5021.
[0087] In the embodiment of the present application, the memory 502 is specifically used to store the application code for executing the solution of the present application, and the execution is controlled by the processor 501. That is, when the computer device 500 is running, the processor 501 communicates with the memory 502 through the bus 503, so that the processor 501 executes the application code stored in the memory 502, and then executes the method described in any of the above embodiments.
[0088] Among them, the memory 502 can be, but is not limited to, random access memory (Random Access Memory, RAM), read only memory (Read Only Memory, ROM), programmable read-only memory (Programmable Read-Only Memory, PROM), erasable programmable read-only memory (Erasable Programmable Read-Only Memory, EPROM), electrically erasable read-only memory (Electric Erasable Programmable Read-Only Memory, EEPROM), etc.
[0089] Processor 501 may be an integrated circuit chip with signal processing capabilities. The above-mentioned processor may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The disclosed methods, steps and logic block diagrams in the embodiments of the present invention may be implemented or executed. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0090] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the computer device 500. In other embodiments of the present application, the computer device 500 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0091] The embodiment of the present disclosure also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the fault injection method described in the above method embodiment are executed. The storage medium can be a volatile or non-volatile computer-readable storage medium.
[0092] The embodiments of the present disclosure also provide a computer program product, which carries a program code. The instructions included in the program code can be used to execute the steps of the fault injection method described in the above method embodiment. For details, please refer to the above method embodiment, which will not be repeated here.
[0093] The computer program product may be implemented in hardware, software or a combination thereof. In one optional embodiment, the computer program product is implemented as a computer storage medium. In another optional embodiment, the computer program product is implemented as a software product, such as a software development kit (SDK).
[0094] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the system and device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. In the several embodiments provided in the present disclosure, it should be understood that the disclosed system and method can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0095] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0096] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0097] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present disclosure, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present disclosure. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0098] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present disclosure, which are used to illustrate the technical solutions of the present disclosure, rather than to limit them. The protection scope of the present disclosure is not limited thereto. Although the present disclosure is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed in the present disclosure, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.
Claims
1. A fault injection method, characterized in that: include: Construct a fault injection code package, and mount the fault injection code package on a preset microservice program; wherein the fault injection code package includes a plurality of fault injection plug-ins, each of which corresponds to a preset database, and each of which includes a plurality of fault injection targets corresponding to the preset database; the preset microservice program implements functions by accessing the preset database; In response to the preset microservice program startup instruction, multiple fault injection plug-ins related to the preset microservice program are loaded based on the fault injection code package, and fault injection targets in the preset microservice program are determined based on the multiple fault injection plug-ins; The preset microservice program is monitored using the multiple fault injection plug-ins. When the calling behavior of the preset microservice program to any of the preset databases is monitored, a fault injection target corresponding to the calling behavior is determined, and the fault injection logic corresponding to the fault injection target is executed.
2. The method according to claim 1, characterized in that The construction of the fault injection code package includes: Get database information of multiple preset databases; For any preset database, a fault matching rule corresponding to any preset database is determined based on the database information of any preset database; and multiple fault injection targets corresponding to any preset database and a fault injection logic corresponding to each of the fault injection targets are determined based on the fault matching rule corresponding to any preset database; and a plug-in name and a plug-in description of a fault injection plug-in of any preset database are respectively determined based on the database information of any preset database; wherein the fault injection logic corresponding to each of the fault injection targets is determined based on the fault injection behavior corresponding to the fault injection target, and the fault injection behavior includes a network delay fault, a request abnormality fault, and a connection pool full fault; For any preset database, determine the fault injection plug-in of any preset database according to the multiple fault injection targets corresponding to the any preset database, the fault injection logic corresponding to each of the fault injection targets, and the plug-in name and plug-in description of the fault injection plug-in of any preset database; The fault injection code package is constructed based on a plurality of fault injection plug-ins of any of the preset databases.
3. The method according to claim 2, characterized in that After determining the fault injection target in the preset microservice program based on the multiple fault injection plug-ins, the method further includes: In response to a fault configuration instruction of the fault configuration interface for any of the fault injection plug-ins, determining fault injection information corresponding to the fault configuration instruction; wherein the fault configuration interface is used to set the fault injection information, and the fault injection information includes a fault injection behavior, a fault matching rule, and a fault injection time; Generate a fault injection logic corresponding to the fault injection target indicated by the fault matching rule based on the fault injection code package according to the fault injection behavior corresponding to the fault configuration instruction and the fault injection time; According to the fault injection logic, any one of the fault injection plug-ins in the fault injection code package is updated.
4. The method according to claim 3, characterized in that After executing the fault injection logic corresponding to the fault injection target, the method further comprises: Based on the preset microservice program, it is determined whether the execution result corresponding to the fault injection logic meets the execution condition corresponding to the calling behavior.
5. The method according to claim 4, characterized in that After judging whether the execution result corresponding to the fault injection logic satisfies the execution condition corresponding to the calling behavior based on the preset microservice program, the method includes: When the execution result corresponding to the fault injection logic satisfies the execution condition corresponding to the calling behavior, the calling behavior is executed and the calling content is returned.
6. The method according to claim 4, characterized in that After judging whether the execution result corresponding to the fault injection logic meets the execution condition corresponding to the calling behavior based on the preset microservice program, the method further includes: When the execution result corresponding to the fault injection logic does not satisfy the execution condition corresponding to the calling behavior, troubleshooting the fault injection behavior corresponding to the fault injection logic; After completing the troubleshooting process of the fault injection behavior, the calling behavior is executed and the calling content is returned.
7. The method according to claim 6, characterized in that After completing the troubleshooting process of the fault injection behavior, executing the calling behavior and returning the calling content, the method further includes: Determine matching information between the call content and the target call content, and determine whether the preset microservice program has fault resolution capability based on the matching information; If the matching information between the call content and the target call content meets the preset standard, the preset microservice program has the fault resolution capability; If the matching information between the call content and the target call content does not meet the preset standard, the preset microservice program does not have the fault resolution capability.
8. A fault injection device, characterized in that: include: A fault injection code package construction module is used to construct a fault injection code package and mount the fault injection code package on a preset microservice program; wherein the fault injection code package includes a plurality of fault injection plug-ins, each of which corresponds to a preset database, and each of which includes a plurality of fault injection targets corresponding to the preset database; the preset microservice program implements functions by accessing the preset database; a fault injection logic determination module, configured to respond to the preset microservice program startup instruction, load multiple fault injection plug-ins related to the preset microservice program based on the fault injection code package, and determine a fault injection target in the preset microservice program based on the multiple fault injection plug-ins; The fault injection logic execution module is used to use the multiple fault injection plug-ins to monitor the preset microservice program, and when monitoring the calling behavior of the preset microservice program to any of the preset databases, determine the fault injection target corresponding to the calling behavior, and execute the fault injection logic corresponding to the fault injection target.
9. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
10. A computer device comprising a storage medium, a processor, and a computer program stored in the storage medium and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Fault injection method and device and apparatus
CN109032825A
Fault injection system and method
CN118069492A
Testing method based on fault injection and computing equipment
CN118445202A
System and method for isolating faults in a resilient system
US20190205489A1