CN-121996445-A - Remote procedure call fault injection test method, device, equipment and medium
Abstract
The application discloses a remote procedure call fault injection test method, a device, equipment and a medium, relating to the technical field of software test, wherein the method comprises the following steps: and searching the precondition of the RPC of the current round of iteration, under the condition that the precondition of the RPC of the current round of iteration is null, performing fault injection test on the RPC of the current round of iteration, finding the RPC triggered by error processing logic during the fault injection test on the RPC of the current round of iteration, taking the RPC of the current round of iteration as the precondition of the RPC triggered by error processing logic, taking the RPC triggered by error processing logic as the RPC of the next round of iteration, and performing the fault injection test on the found RPC triggered by error processing logic through multiple rounds of iteration.
Inventors
- ZHENG NAIQIAN
- JIN XIN
- Liu Zhuzhe
- Qiao Tianshuo
Assignees
- 北京大学
Dates
- Publication Date
- 20260508
- Application Date
- 20260410
Claims (10)
- 1. A method for remote procedure call fault injection testing, the method comprising: Retrieving the precondition of the RPC of the current round of iteration, wherein the precondition of the RPC of the current round of iteration is the fault of the RPC which is injected into other RPCs previously and is used for triggering the current round of iteration; under the condition that the precondition of the RPC of the current round iteration is null, performing fault injection on the RPC of the current round iteration, and performing fault injection test, wherein the precondition is that the null indicates that the RPC of the current round iteration can be triggered in normal processing logic without any precondition; During fault injection testing of the RPC of the current round iteration, discovering the RPC triggered by error processing logic, wherein the RPC triggered by the error processing logic is triggered by the error processing logic of the RPC of the current round iteration injected with faults; Taking the RPC of the current round of iteration as a precondition of the RPC triggered by the error processing logic, taking the RPC triggered by the error processing logic as the RPC of the next round of iteration and executing the fault injection test of the next round of iteration so as to find the RPC triggered by the error processing logic through multiple rounds of iteration and execute the fault injection test on the found RPC triggered by the error processing logic.
- 2. The remote procedure call fault injection test method according to claim 1, further comprising determining, as the RPC of the current round iteration, a test state to be the RPC to be tested according to a plurality of fault entries contained in a pre-constructed fault library, wherein the fault library contains a plurality of fault entries, and one fault entry characterizes the test state of one RPC under one fault; After finding the RPC triggered by the error processing logic, creating a plurality of fault entries in the fault library based on a plurality of faults for the RPC triggered by the error processing logic, and setting the test state of the fault entry corresponding to the RPC triggered by the error processing logic to be tested; After taking the RPC of the current round of iteration as the precondition of the RPC triggered by the error processing logic, taking the RPC triggered by the error processing logic as the RPC of the next round of iteration and executing the fault injection test of the next round of iteration, setting the test state of the fault entry corresponding to the fault injection test of the next round of iteration in the plurality of fault entries corresponding to the RPC triggered by the error processing logic to be completed.
- 3. The remote procedure call fault injection test method of claim 2, wherein retrieving the preconditions of the RPC of the current round of iterations comprises determining the preconditions of the RPC of the current round of iterations from a plurality of precondition entries in a pre-constructed precondition library, the precondition library comprising a plurality of precondition entries, each precondition entry characterizing an RPC that is triggerable under one precondition; after finding the RPC triggered by the error processing logic, creating a precondition entry corresponding to the RPC triggered by the error processing logic in the precondition library according to the precondition of the RPC of the current round iteration and the fault injected into the RPC of the current round iteration.
- 4. A remote procedure call fault injection test method according to claim 3, characterised in that the method further comprises: Determining the error level of each RPC triggered by the error processing logic according to the triggering times of the error processing logic in the precondition; setting a preset error level threshold; creating a plurality of fault entries in the fault library based on a plurality of faults for the RPCs triggered by the error handling logic, including creating a plurality of fault entries in the fault library based on a plurality of faults for RPCs triggered by the error handling logic having an error level less than the preset error level threshold; The method comprises the steps of creating a precondition entry corresponding to the RPC triggered by error processing logic in the precondition library according to the precondition of the RPC of the current round iteration and the fault injected into the RPC of the current round iteration, wherein the precondition entry is created for the RPC triggered by the error processing logic, and comprises creating the precondition entry in the precondition library according to the precondition of the RPC of the current round iteration and the fault injected into the RPC of the current round iteration, wherein the precondition entry is triggered by the error processing logic and the error level is smaller than the preset error level threshold.
- 5. A remote procedure call fault injection test method according to claim 3, characterised in that the method further comprises: Determining the number of RPCs to be tested corresponding to each precondition item according to the precondition library and the fault library, wherein the RPCs to be tested represent RPCs which can be triggered simultaneously under one precondition and have test states which are to be tested and are triggered by error processing logic; the method comprises the steps of taking the RPC triggered by the error processing logic as the RPC of the next iteration and executing the fault injection test of the next iteration, wherein the RPC triggered by the error processing logic is used as the RPC of the next iteration and the fault injection test of the next iteration is executed, and the RPC with the largest number of pre-condition entries to be tested is used as the RPC of the next iteration.
- 6. The remote procedure call fault injection test method of claim 5, further comprising, after taking a plurality of RPCs triggered by the error handling logic corresponding to the precondition entry with the largest number of RPCs to be tested as the RPCs of the next iteration and performing the fault injection test of the next iteration: Judging whether abnormal RPCs exist in a plurality of RPCs triggered by error processing logic corresponding to the precondition entries with the largest number of RPCs to be tested, wherein the abnormal RPCs represent the RPCs triggered by the error processing logic which do not occur after the fault is injected; In the case of an abnormal RPC, maintaining the testing state of a corresponding fault item of the abnormal RPC in the fault library to be tested, and creating a new precondition item in the precondition library aiming at the abnormal RPC, wherein the new precondition item represents that the abnormal RPC is independently triggered under the original precondition; And re-executing fault injection test on the abnormal RPC according to the new pre-condition entry.
- 7. The remote procedure call fault injection test method of claim 6, further comprising, after re-performing a fault injection test on the abnormal RPC according to the new precondition entry: judging whether the abnormal RPC occurs after re-executing the fault injection test; Updating the new precondition entry in the precondition library for the abnormal RPC under the condition that the abnormal RPC does not occur after the fault injection test is re-executed, so as to obtain an updated precondition entry, wherein the updated precondition entry represents that the abnormal RPC is independently triggered under other preconditions; and re-executing fault injection test on the abnormal RPC according to the updated pre-condition entry.
- 8. A remote procedure call fault injection testing device, the device comprising: The pre-condition searching module is used for searching the pre-condition of the RPC of the current round of iteration, wherein the pre-condition of the RPC of the current round of iteration is a fault which is injected into other RPCs previously and is used for triggering the RPC of the current round of iteration; The first fault injection test module is used for injecting faults into the RPC of the current round iteration and carrying out fault injection test under the condition that the precondition of the RPC of the current round iteration is empty, wherein the precondition is that the RPC of the current round iteration can be triggered in normal processing logic without any precondition; The RPC detection module is used for finding the RPC triggered by the error processing logic during the fault injection test of the RPC of the current round iteration, wherein the RPC triggered by the error processing logic is triggered by the error processing logic of the RPC of the current round iteration injected with the fault; And the iteration fault injection test module is used for taking the RPC of the current round of iteration as a precondition of the RPC triggered by the error processing logic, taking the RPC triggered by the error processing logic as the RPC of the next round of iteration and executing the fault injection test of the next round of iteration so as to find the RPC triggered by the error processing logic through multiple rounds of iteration and execute the fault injection test on the found RPC triggered by the error processing logic.
- 9. An electronic device comprising a processor, a memory and a program or instruction stored on the memory and executable on the processor, which when executed by the processor, implements the steps of the method of any of claims 1 to 7.
- 10. A readable storage medium, characterized in that it stores thereon a program or instructions, which when executed by a processor, realizes the steps in the method according to any of claims 1 to 7.
Description
Remote procedure call fault injection test method, device, equipment and medium Technical Field The application belongs to the field of software testing, and particularly relates to a remote procedure call fault injection testing method, device, equipment and medium. Background In recent years, the scale of distributed systems is becoming larger, the number of components is larger, and interactions are more complex. They need to communicate frequently over the network to coordinate tasks and share data. Remote Procedure Calls (RPCs) facilitate this process by allowing components to call methods on remote servers with the semantics of local function calls. RPCs have become ubiquitous in modern distributed systems, such as micro-services, distributed file systems, distributed databases, and distributed computing frameworks. gRPC, APACHE THRIFT and the RPC framework such as RESTful API provide a transparent communication interface that masks the complexity of the underlying network connections and data transfer. Despite these advantages, RPCs can also introduce vulnerabilities and malfunctions into the system. Remote Procedure Calls (RPCs) may fail due to transient errors such as network jitter and server overload. These errors may disrupt the communication workflow, propagate exceptions to the application logic, or cause system stalls. Such errors are unavoidable in distributed systems and it is not easy to handle them correctly. One reason is that distributed systems have a large number of RPCs, and each RPC has its own error handling requirements. It is not easy to ensure that all RPCs have sufficient error handling logic for all possible errors. Another reason is that error handling is very sensitive to system logic and error type. For example, retry strategies are common practice for handling unusable errors. However, retry strategies are not suitable for non-idempotent RPCs because retrying non-idempotent requests may cause unexpected side effects such as data duplication or loss, and therefore it is critical to systematically test the error handling mechanisms of a distributed system under various transient RPC errors. Current unit testing is a common reliability assurance technique. It has been widely used in distributed systems to test the correctness of individual modules. However, it is not very desirable in testing RPC (remote procedure call) error handling for two main reasons. First, it is very difficult to simulate the RPC peer in unit testing. Simulating the RPC peers requires simulating complex responses and interactions between distributed components, which is not only challenging, but also error-prone. Second, in large-scale systems, the effort required to manually identify and write test cases for each RPC is enormous, which necessarily results in coverage holes. Thus, a more practical approach is fault injection testing. The method injects transient RPC errors into the terminal in the running process of the system, checks whether the system is correctly represented, and is not easy to realize effective RPC fault injection in the distributed system due to gaps in coverage, efficiency bottlenecks and complexity of fault identification. First, the RPC calls are distributed across various parts of the system, including both normal execution logic and error handling logic. The existing test suite is difficult to trigger error processing logic, so that RPC initiated from the error processing logic cannot be covered, and then after a single test is finished, the fault RPC which causes test failure cannot be identified to further test and search for a new RPC, and further the RPC fault injection test efficiency under the distributed system is difficult to improve. Disclosure of Invention The embodiment of the application aims to provide a remote procedure call fault injection test method, a device, equipment and a medium, which can solve the problems. In order to solve the technical problems, the application is realized as follows: In a first aspect, an embodiment of the present application provides a remote procedure call fault injection test method, where the method includes: Retrieving the precondition of the RPC of the current round of iteration, wherein the precondition of the RPC of the current round of iteration is the fault of the RPC which is injected into other RPCs previously and is used for triggering the current round of iteration; under the condition that the precondition of the RPC of the current round iteration is null, performing fault injection on the RPC of the current round iteration, and performing fault injection test, wherein the precondition is that the null indicates that the RPC of the current round iteration can be triggered in normal processing logic without any precondition; During fault injection testing of the RPC of the current round iteration, discovering the RPC triggered by error processing logic, wherein the RPC triggered by the error processing logic is trigger