Fault injection method, device, medium and computer equipment
By building a fault injection code package and plug-in design, the problems of fault injection complexity and insufficient adaptability in existing technologies are solved, efficient and flexible fault injection testing is achieved, and the robustness and reliability of the financial technology system are improved.
Patent Information
- Application Number
- CN202411712450.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-26
- Publication Date
- 2025-09-26
- Estimated Expiration
- 2044-11-26
AI Technical Summary
Existing fault injection technology is complex and difficult to operate, making it difficult for beginners to master. The fault injection scenarios and data components simulated by existing tools cannot meet the diverse needs of financial technology systems, affecting testing efficiency and quality.
By building a fault injection code package, which includes multiple fault injection plug-ins, each plug-in corresponds to a preset database. The plug-in is loaded and monitors the database call behavior when the microservice program starts, and executes the corresponding fault injection logic.
It improves the flexibility and scalability of fault injection, improves the accuracy and real-time performance of the test, and enhances the stability and fault tolerance evaluation of the system under real fault conditions.
Smart Images

Figure CN119690535B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the fields of fault injection technology and financial technology, and in particular to a fault injection method, apparatus, medium, and computer equipment. Background Art
[0002] In the fintech sector, system stability and reliability are fundamental to ensuring transaction security, smooth capital flow, and user trust. Fault injection technology, as an effective testing method, plays a crucial role in this area. By artificially introducing various preset faults, this technology simulates the various anomalies that may be encountered in actual production environments, helping system developers and operations teams comprehensively identify and remediate potential system weaknesses. With the rapid development of the fintech industry and the increasing complexity of systems, the demand for fault injection technology is becoming increasingly urgent. This is especially true in critical scenarios such as high-frequency trading and real-time risk control, where system recovery mechanisms are particularly important. Fault injection technology not only verifies the response speed and effectiveness of these mechanisms in the event of a failure, but also, by simulating real-world failure scenarios, strengthens emergency response coordination and troubleshooting capabilities across teams, further improving the efficiency and speed of troubleshooting and ensuring the overall robustness of fintech systems.
[0003] However, current industry implementations of these technologies still suffer from several significant flaws. First, the complex operational process and execution difficulty of fault injection not only increase testing costs and time but can also lead to unnecessary systemic risks due to operational errors. Second, because the technology requires in-depth technical knowledge and extensive practical experience, beginners often struggle to quickly master the relevant tools and methods, impacting the overall efficiency and testing quality of technical teams. Furthermore, as fintech systems continue to evolve and become increasingly complex, the fault injection scenarios and data components simulated by existing tools are no longer able to meet the diverse needs of actual production environments. Summary of the Invention
[0004] The embodiments of the present disclosure provide at least one fault injection method, apparatus, medium, and computer equipment. Through the plug-in design of fault injection, the flexibility and scalability of fault injection are significantly improved, ensuring the comprehensiveness of the test while greatly improving the accuracy and real-time performance of fault injection. This provides technical support for testing the stability and fault tolerance of the system under real fault conditions, enabling better evaluation of the robustness and reliability of the system in the face of various types of faults.
[0005] According to one aspect of the present application, a fault injection method is provided, comprising:
[0006] Constructing a fault injection code package and mounting the fault injection code package on a preset microservice program; wherein the fault injection code package includes multiple fault injection plug-ins, each of which corresponds to a preset database, and each of which includes multiple fault injection targets corresponding to the preset database; the preset microservice program implements its function 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 a call behavior of the preset microservice program to any of the preset databases is monitored, a fault injection target corresponding to the call 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, comprising:
[0010] A fault injection code package construction module is configured 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 multiple fault injection plug-ins, each of which corresponds to a preset database and includes multiple fault injection targets corresponding to the preset database; the preset microservice program implements its functions by accessing the preset database;
[0011] a fault injection logic determination module, configured to, in response 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 configured to monitor the preset microservice program using the multiple fault injection plug-ins, and upon monitoring a call behavior of the preset microservice program to any of the preset databases, determine a fault injection target corresponding to the call 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, wherein the memory stores machine-readable instructions executable by the processor. When the computer device is running, the processor and the memory communicate via the bus, and when the machine-readable instructions are executed by the processor, a fault injection method as described in any possible implementation method 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 having a computer program stored thereon. When the computer program is executed by a processor, the fault injection method as described in any of the possible implementations described above is implemented.
[0015] By means of the above technical solution, the fault injection method, apparatus, medium, and computer equipment provided in the embodiments of the present disclosure construct a code package containing multiple fault injection plug-ins for specific preset databases, which are mounted on the microservice program. When the program starts, the relevant plug-ins are loaded to determine the fault injection target. By monitoring the microservice program's call behavior to the database, the corresponding fault injection logic is executed once triggered. In this way, the fault injection plug-in design significantly improves the flexibility and scalability of fault injection, ensures the comprehensiveness of the test, and greatly improves the accuracy and real-time performance of fault injection. It provides technical support for the stability and fault tolerance testing of the system under real fault conditions, making it possible to better evaluate the robustness and reliability of the system in the face of various faults.
[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 given below and described in detail with reference to the accompanying 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 that need to be cited in the embodiments. The drawings herein are incorporated into and constitute a part of the specification. These drawings illustrate embodiments consistent with the present disclosure and, together with the specification, are used 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 those of ordinary skill in the art, other relevant drawings can be obtained based on these drawings without inventive effort.
[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 the fault injection method provided by an embodiment of the present disclosure is shown;
[0021] Figure 4 A schematic structural diagram of a fault injection device provided by an embodiment of the present disclosure is shown;
[0022] Figure 5 A schematic structural diagram of a computer device provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0023] In order to make the purpose, technical solutions and advantages of the embodiments of the present disclosure clearer, the technical solutions 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, not all of the embodiments. The components of the embodiments of the present disclosure generally described and shown in the drawings herein 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 disclosure for which protection is sought, but merely represents 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 are within 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, it does not require further definition or explanation in subsequent drawings.
[0025] The term "and / or" herein simply describes an association relationship, indicating that three relationships can exist. For example, A and / or B can represent the existence of A alone, the simultaneous existence of A and B, and the existence of B alone. In addition, the term "at least one" herein refers to any combination of at least two of any one or more of a plurality of items. For example, "at least one of A, B, and C" can represent 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, a client communicates with a server via a network. The client can be a mobile device, user terminal, terminal, handheld device, computing device, etc. The server can be a standalone physical server, a server cluster or distributed system consisting 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 with reference to the accompanying drawings. Figure 2 FIG. 2 is a flow chart of a fault injection method provided by an embodiment of the present disclosure, the method comprising the following steps 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 understood that the preset microservice program is an application designed with a microservice architecture, in which functions are split into multiple services (each service implements a specific function), and each service can be independently deployed and scaled. Here, the preset microservice program implements its functions by accessing a preset database. The fault injection code package includes multiple fault injection plug-ins, each of which corresponds to a preset database and 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: Obtain database information of multiple preset databases.
[0032] Here, the pre-set 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 may include the database name, type, connection parameters, table structure, data storage method, etc. This information is the foundation for building a fault injection plugin, ensuring that faults are correctly mapped to the corresponding database. By extracting this information, we can identify the characteristics and potential failure modes of different databases and prepare for subsequent fault injection.
[0033] S302. For any preset database, determine a fault matching rule corresponding to the preset database based on the database information of the preset database; and determine multiple fault injection targets corresponding to the preset database and fault injection logic corresponding to each fault injection target based on the fault matching rule corresponding to the preset database; and, determine a plug-in name and a plug-in description of the fault injection plug-in of the preset database based on the database information of the 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 rules refer to the situations 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 failures of the preset database, multiple fault injection targets that exist in the database can be identified. Here, the fault injection target refers to the specific point or path where a failure may occur in the database operation, such as the 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 failure.
[0035] For example, taking the construction of fault injection targets and injection logic in a fault injection plug-in for the MongoDB database as an example, MongoDB's fault matching rules mainly define situations that may cause failures based on MongoDB's database characteristics (such as document-based storage, support for ACID transactions, distributed architecture, etc.) and operation characteristics (such as add, delete, modify, query, etc.). These rules help determine which fault types should be simulated and match them with specific MongoDB objects (such as collections, documents, etc.). MongoDB's fault injection targets can refer to specific points or paths in database operations where failures may occur. For example, methods in MongoDB's client class MongoCollectionImpl (such as find, executeDrop, insertOne, deleteOne, etc.), as well as key links such as database connection pools, query execution, data storage, and index operations can all serve as fault injection targets. MongoDB's fault injection logic is a specific implementation of the fault behavior (such as delays, exceptions, etc.) for specific targets. For example, it can simulate MongoDB returning a delay when performing a find operation, or simulate failure scenarios such as connection failures 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 to test 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) to observe how the microservice handles abnormal requests; connection pool full failure refers to simulating the exhaustion of database connection pool resources to test how the system handles requests when the connection pool is insufficient.
[0037] For example, since the database information for each pre-defined database includes the database name, type, and connection parameters, the plugin name and plugin description for each pre-defined database fault injection plugin can be determined based on the database information for each pre-defined database. The plugin name is a unique identifier for the plugin, used to distinguish different plugins, and the plugin description is a brief description of the plugin's functionality, helping developers understand the plugin's purpose.
[0038] S303: For any preset database, determine the fault injection plug-in for any preset database based on 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 for the any preset database.
[0039] It is understandable that after determining the 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 one of the preset databases.
[0041] Specifically, after completing the construction of fault injection plug-ins corresponding to multiple preset databases, these plug-ins are combined 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 based on this, by integrating the fault injection plug-ins of multiple preset databases into a fault injection code package and allowing it to be deployed to the microservice program in a mounting manner, the flexibility and ease of fault injection testing are improved, providing strong support for the reliability assurance of microservice architecture testing.
[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 understood that after the preset microservice program starts, 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 and will intervene during the microservice program startup process to identify the portion 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 based on 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, the fault injection information including a fault injection behavior, a fault matching rule, and a fault injection time;
[0047] (2) generating, based on the fault injection code package and the fault injection behavior corresponding to the fault configuration instruction and the fault injection time, a fault injection logic corresponding to the fault injection target indicated by the fault matching rule;
[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 users 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 query operations on specific tables makes the test more suitable for actual application scenarios. Among them, each fault injection plug-in can receive fault configuration instructions through this interface. The fault configuration instructions contain detailed information about fault behavior, matching rules, and fault injection time. Among them, the fault injection time defines the time when the fault occurs, which can usually be set to a specific time point or triggered according to a specific period. In some other embodiments, the fault configuration interface can also be used to configure fault injection instructions.
[0050] Specifically, after obtaining fault injection information, 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 plugin is configured by the user to inject a delay, the configured fault injection logic can ensure that when a service call is made to this fault injection target, a response is returned according to the configured time delay. Finally, after generating fault injection logic based on the fault configuration instructions in the fault configuration decryption, the fault injection plugin in the fault injection code package can be updated based on the generated fault injection logic.
[0051] In this disclosure, fault parameters are flexibly set through the fault configuration interface, and injection logic corresponding to the fault matching rules is generated through the fault injection code package. At the same time, the fault injection plug-in is updated without modifying the microservice program itself, which improves the flexibility and efficiency of fault testing.
[0052] S203: Monitor the preset microservice program using the multiple fault injection plug-ins. When a call behavior of the preset microservice program to any of the preset databases is monitored, determine a fault injection target corresponding to the call behavior, and execute fault injection logic corresponding to the fault injection target.
[0053] Specifically, as the microservice program runs, the fault injection plugin monitors the program's running status and behavior in real time. In particular, it focuses on the interaction between the microservice program and the database. When the microservice program makes a database call, the fault injection plugin promptly detects these calls and, based on their characteristics (such as the database table being called, the type of operation, and the timing of the call), identifies the relevant fault injection targets. Each database call may trigger one or more fault injection targets, depending on the type of fault being 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, injecting network delays, database errors, data loss, etc. These fault logics can be divided into several different types, such as causing database connection timeouts, 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 evaluation of the system's fault tolerance and stability. It not only simplifies the fault injection process, but 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 conditions corresponding to the call behavior. If the execution result meets the preset call behavior conditions, it means that under the current fault scenario, the microservice program can continue to execute its database call normally and return the correct call content. Conversely, if the execution result fails to meet the conditions, it means that the microservice program 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, troubleshooting may include reconfiguring services, correcting data errors, restoring network connections, etc., with the aim of eliminating the impact of the fault and enabling 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 sector 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 executing the fault injection logic, it is necessary to determine whether the execution result of this logic meets the execution conditions corresponding to the transfer operation. Suppose the fault injection logic simulates a network delay failure, resulting in a delay when the transfer request is sent to the database. If the microservice program can correctly handle the network delay in this failure scenario, such as continuously retrying the request before the timeout, or rolling back the transaction after the request fails, and is ultimately able to successfully complete the transfer operation and return the correct call content (such as a confirmation message that the transfer was successful), then this indicates that the microservice program can still continue to execute its database call normally under the current network delay failure scenario.
[0057] However, if the execution result fails to meet the conditions, for example, the microservice program directly throws an exception due to network latency and does not take any recovery measures, resulting in the transfer operation failing, then this indicates that the microservice program encountered an obstacle when dealing with the specific failure of network latency. In this case, it is necessary to troubleshoot the network latency 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, because the 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 the successful transfer and an updated account balance.
[0058] It is understandable that in order to determine whether the microservice program has sufficient fault-solving 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 fault-solving 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 it may not be able to effectively deal with faults, and needs to be optimized and adjusted.
[0059] The fault injection method, apparatus, medium, and computer equipment provided in the embodiments of the present disclosure significantly enhance the flexibility and scalability of fault injection through a fault injection plug-in design, thereby ensuring the comprehensiveness of the test and greatly improving the accuracy and real-time performance of fault injection. This provides technical support for testing the stability and fault tolerance of the system under real fault conditions, enabling better evaluation of the robustness and reliability of the system in the face of various types of faults.
[0060] Those skilled in the art will understand that in the above-mentioned method of the specific implementation method, the writing order of each step does not mean a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of each step should be determined by its function and possible internal logic.
[0061] Based on the same inventive concept, the embodiments of the present disclosure also provide a fault injection device corresponding to the fault injection method. Since the principle of solving the problem by the device in the embodiments of the present disclosure is similar to that of the above-mentioned fault injection method in the embodiments 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 configured 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 multiple fault injection plug-ins, each of which corresponds to a preset database and includes multiple fault injection targets corresponding to the preset database; the preset microservice program implements its functions by accessing the preset database;
[0064] a fault injection logic determination module 402 configured to, in response 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;
[0065] The fault injection logic execution module 403 is used to use 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, it determines the fault injection target corresponding to the calling behavior and executes 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 the preset database is determined based on the database information of the preset database; and multiple fault injection targets corresponding to the 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 the preset database; and a plug-in name and a plug-in description of the fault injection plug-in of the preset database are respectively determined based on the database information of the 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 for any preset database based on the multiple fault injection targets corresponding to the any 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 for the any preset database;
[0070] The fault injection code package is constructed based on a plurality of fault injection plug-ins of any one 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 any of the fault injection plug-ins on the fault configuration interface, determining fault injection information corresponding to the fault configuration instruction; wherein the fault configuration interface is used to set the fault injection information, the fault injection information including fault injection behavior, fault matching rules, and fault injection time;
[0073] Generating, based on the fault injection code package and the fault injection behavior corresponding to the fault configuration instruction and the fault injection time, a fault injection logic corresponding to the fault injection target indicated by the fault matching rule;
[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 configured 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 configured to:
[0078] When the execution result corresponding to the fault injection logic meets 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 configured to:
[0080] If the execution result corresponding to the fault injection logic does not satisfy the execution condition corresponding to the calling behavior, performing troubleshooting on 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 configured to:
[0083] Determining matching information between the call content and the target call content, and judging 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 criteria, then the preset microservice program has the ability to resolve the fault;
[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, includes a processor 501, a memory 502, and a bus 503. The memory 502 is used to store execution instructions and includes a memory 5021 and an external memory 5022. The memory 5021 is also referred to as internal memory and is used to temporarily store operation data in the processor 501 and data exchanged with an 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 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 via the bus 503, so that the processor 501 executes the application code stored in the memory 502, thereby performing the method described in any of the aforementioned embodiments.
[0088] Among them, the memory 502 can be, but is not limited to, random access memory (RAM), read only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), etc.
[0089] The 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 gate or transistor logic devices, discrete hardware components. The various methods, steps and logic block diagrams disclosed in the embodiments of the present invention can be implemented or executed. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0090] It should be understood that the structure illustrated in the embodiments 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, or may combine or separate certain components, or arrange the components differently. The components shown in the illustrations may be implemented in hardware, software, or a combination of software and hardware.
[0091] The present disclosure also provides a computer-readable storage medium having a computer program stored thereon. When executed by a processor, the computer program executes the steps of the fault injection method described in the above method embodiment. The storage medium may be a volatile or non-volatile computer-readable storage medium.
[0092] The present disclosure also provides a computer program product that carries program code. The program code includes instructions that 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 and will not be repeated here.
[0093] The computer program product may be implemented in hardware, software, or a combination thereof. In one embodiment, the computer program product is implemented as a computer storage medium. In another 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 brevity 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 separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[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 enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute 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 scope of protection of the present disclosure is not limited thereto. Although the present disclosure has been described in detail with reference to the above-described embodiments, those skilled in the art should understand that any person skilled in the art can modify or easily conceive of changes to the technical solutions described in the above-described embodiments within the technical scope disclosed in the present disclosure, or replace some of the technical features therein with equivalents. Such modifications, changes, or replacements do not deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be included in the scope of protection of the present disclosure. Therefore, the scope of protection of the present disclosure shall be subject to the scope of protection of the claims.
Claims
1. A fault injection method, characterized in that: include: Get database information of multiple preset databases; For any preset database, determine a fault matching rule corresponding to the preset database based on database information of the preset database; and determine multiple fault injection targets corresponding to the preset database and fault injection logic corresponding to each fault injection target based on the fault matching rule corresponding to the preset database; and, based on the database information of any of the preset databases, respectively determining the plug-in name and plug-in description of the fault injection plug-in of any of the preset databases; 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 for any preset database based on the multiple fault injection targets corresponding to the any 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 for the any preset database; Based on the fault injection plug-ins of any of the plurality of preset databases, a fault injection code package is constructed; and the fault injection code package is mounted 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; and the preset microservice program implements its function 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 a call behavior of the preset microservice program to any of the preset databases is monitored, a fault injection target corresponding to the call 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 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 any of the fault injection plug-ins on the fault configuration interface, determining fault injection information corresponding to the fault configuration instruction; wherein the fault configuration interface is used to set the fault injection information, the fault injection information including fault injection behavior, fault matching rules, and fault injection time; Generating, based on the fault injection code package and the fault injection behavior corresponding to the fault configuration instruction and the fault injection time, a fault injection logic corresponding to the fault injection target indicated by the fault matching rule; According to the fault injection logic, any one of the fault injection plug-ins in the fault injection code package is updated.
3. The method according to claim 2, characterized in that After executing the fault injection logic corresponding to the fault injection target, the method includes: 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.
4. The method according to claim 3, characterized in that After determining 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 includes: When the execution result corresponding to the fault injection logic meets the execution condition corresponding to the calling behavior, the calling behavior is executed and the calling content is returned.
5. The method according to claim 3, characterized in that After determining 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: If the execution result corresponding to the fault injection logic does not satisfy the execution condition corresponding to the calling behavior, performing troubleshooting on 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.
6. The method according to claim 5, 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: Determining matching information between the call content and the target call content, and judging 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 criteria, then the preset microservice program has the ability to resolve the fault; 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.
7. A fault injection device, characterized in that: include: A fault injection code package building module is used to obtain database information of multiple preset databases; And, for any preset database, determining a fault matching rule corresponding to the any preset database based on database information of the any preset database; and determining a plurality of fault injection targets corresponding to the any preset database and a fault injection logic corresponding to each of the fault injection targets based on the fault matching rule corresponding to the any preset database; and, based on the database information of any preset database, respectively determining the plug-in name and plug-in description of the fault injection plug-in of any preset database; wherein the fault injection logic corresponding to each fault injection target is determined based on the fault injection behavior corresponding to the fault injection target, and the fault injection behavior includes network delay fault, request exception fault and connection pool full fault; and, for any preset database, determining 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 fault injection target, and the plug-in name and plug-in description of the fault injection plug-in of the any preset database; and, constructing a fault injection code package based on the multiple fault injection plug-ins of any preset database; and mounting the fault injection code package on a preset microservice program; wherein the fault injection code package includes multiple fault injection plug-ins, each of which corresponds to a preset database, and each of which includes multiple fault injection targets corresponding to the preset database; the preset microservice program implements its function by accessing the preset database; a fault injection logic determination module, configured to, in response 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 configured to monitor the preset microservice program using the multiple fault injection plug-ins, and upon monitoring a call behavior of the preset microservice program to any of the preset databases, determine a fault injection target corresponding to the call behavior, and execute the fault injection logic corresponding to the fault injection target.
8. 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 6 is implemented.
9. A computer device comprising a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, wherein: When the processor executes the computer program, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Fault injection method and device and apparatus
CN109032825A
Testing method based on fault injection and computing equipment
CN118445202A