# US 11,307,948 B2 · Fault injection method and apparatus, electronic device and storage medium

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 11,307,948 B2
- Document ID: US11307948B2
- Status: Granted
- Kind: B2
- Application number: 17/124,086
- Filed: 2020-12-16
- Published: 2021-12-02
- Granted: 2022-04-19
- Earliest claimed: 2020-05-29
- Assignees: Beijing Baidu Netcom Science Technology Co., Ltd.
- Applicants: Beijing Baidu Netcom Science and Technology Co., Ltd.
- Inventors: Yu Guan
- Web page: https://patentgrep.com/patent/US11307948B2

## CPC

- G06F 11/263: Generation of test inputs, e.g. test vectors, patterns or sequences {; with adaptation of the tested hardware for testability with external testers}
- G06F 11/3684: {for test design, e.g. generating new test cases}
- G06F 11/0709: {in a distributed system consisting of a plurality of standalone computer nodes, e.g. clusters, client-server systems}
- G06F 11/076: {by exceeding a count or rate limit, e.g. word- or bit count limit}
- G06F 11/3688: {for test execution, e.g. scheduling of test suites}
- G06F 11/3692: {for test results analysis}
- G06F 11/3698: Environments for analysis, debugging or testing of software
- G06F 2201/81: Threshold
- G06F 2201/865: Monitoring of software
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A fault injection method and apparatus, an electronic device and a storage medium are provided, which are related to the technical fields of computers and cloud computing, in particular to the field of testing. The fault injection method includes: acquiring a fault injection task, which includes at least one target service identification and a fault scenario corresponding to the target service identification; determining a target service according to each target service identification, and acquiring a state of the target service; and injecting the fault scenario corresponding to the target service identification into the target service in a case that the state of the target service is a normal state. The application is beneficial to reduction of labor cost.

## Claims

### Claim 1

A fault injection method, comprising:
acquiring a fault injection task, which comprises at least one target service identification and a fault scenario corresponding to the target service identification;
determining a target service according to each target service identification, and acquiring a state of the target service; and
injecting the fault scenario corresponding to the target service identification into the target service in a case that the state of the target service is a normal state;
wherein the method further comprises:
collecting a target index of the target service; and
stopping injecting the fault scenario in a case of monitoring that the collected target index is beyond a preset index range;
wherein the collecting the target index of the target service comprises at least one of:
acquiring the target index of the target service from a designated index data push interface; and
collecting the target index from the target service.

### Claim 2 (depends on 1)

The method of claim 1, further comprising at least one of:
revoking the fault scenario injected into the target service; and
ending the fault injection task.

### Claim 3 (depends on 1)

The method of claim 1, wherein the determining the target service according to each target service identification, and acquiring the state of the target service, comprises: in a case that the fault injection task gets approved, determining the target service according to the target service identification, and acquiring the state of the target service,
wherein determining that the fault injection task gets approved comprises at least one of:
in a case that at least one of risks of a command and a code segment in the fault scenario in the fault injection task is lower than a preset risk level, determining that the fault injection task gets approved; and
in a case of receiving an approval instruction for the fault injection task, determining that the fault injection task gets approved.

### Claim 4 (depends on 1)

The method of claim 1, further comprising: configuring the fault injection task according to a received task configuration instruction,
wherein the configuring the fault injection task comprises at least one of:
adding the fault scenario into the fault injection task;
deleting, editing the fault scenario or performing an injection sequence adjustment on fault scenarios in the fault injection task; and
setting a triggering mode of the fault injection task.

### Claim 5 (depends on 4)

The method of claim 4, wherein the adding the fault scenario into the fault injection task comprises: selecting at least one fault scenario from a fault management module, to be added into the fault injection task, wherein the fault management module is prestored with a plurality of fault scenarios.

### Claim 6 (depends on 5)

The method of claim 5, wherein the fault scenario in the fault management module is managed by at least one of:
adding, deleting, modifying or checking the fault scenario in the fault management module;
generating a fault scenario according to a program content received from a fault programming interface, and uploading the generated fault scenario to the fault management module, wherein, before the generating the fault scenario, a high-risk command and a high-risk code segment in the received program content are identified, to prompt an injection risk of the fault scenario; and
binding the fault scenario in the fault management module with a corresponding target service.

### Claim 7

A fault injection apparatus, comprising:
at least one processor; and
a memory communicatively connected with the at least one processor, wherein
the memory stores instructions executable by the at least one processor, and the instructions, when executed by the at least one processor, enable the at least one processor to perform operations comprising:
acquiring a fault injection task, which comprises at least one target service identification and a fault scenario corresponding to the target service identification;
determining a target service according to each target service identification, and acquiring a state of the target service; and
injecting the fault scenario corresponding to the target service identification into the target service in a case that the state of the target service is a normal state;
wherein the operations further comprise:
collecting a target index of the target service; and
stopping injecting into the fault scenario in a case of monitoring that the collected target index is beyond a preset index range;
wherein the collecting the target index of the target service comprises at least one of:
acquiring the target index of the target service from a designated index data push interface; and
collecting the target index from the target service.

### Claim 8 (depends on 7)

The apparatus of claim 7, wherein the operations further comprise:
revoking the fault scenario injected into the target service; and
ending the fault injection task.

### Claim 9 (depends on 7)

The apparatus of claim 7, wherein the determining the target service according to each target service identification, and acquiring the state of the target service, comprises: in a case that the fault injection task gets approved, determining the target service according to the target service identification, and acquiring the state of the target service,
wherein determining that the fault injection task gets approved comprises at least one of:
in a case that at least one of risks of a command and a code segment in the fault scenario in the fault injection task is lower than a preset risk level, determining that the fault injection task gets approved; and
in a case of receiving an approval instruction for the fault injection task, determining that the fault injection task gets approved.

### Claim 10 (depends on 7)

The apparatus of claim 7, wherein the operations further comprises: configuring the fault injection task according to a received task configuration instruction,
wherein the configuring the fault injection task comprises at least one of:
adding the fault scenario into the fault injection task;
deleting, editing the fault scenario or performing an injection sequence adjustment on fault scenarios in the fault injection task; and
setting a triggering mode of the fault injection task.

### Claim 11 (depends on 10)

The apparatus of claim 10, wherein the adding the fault scenario into the fault injection task comprises: selecting at least one fault scenario from a fault management module, to be added into the fault injection task, wherein the fault management module is pre-stored with a plurality of fault scenarios.

### Claim 12 (depends on 11)

The apparatus of claim 11, wherein the fault scenario in the fault management module is managed by at least one of:
adding, deleting, modifying or checking the fault scenario in the fault management module;
generating a fault scenario according to a program content received from a fault programming interface, and uploading the generated fault scenario to the fault management module, wherein, before the fault scenario is generated, a high-risk command and a high-risk code segment in the received program content are identified, to prompt an injection risk of the fault scenario; and
binding the fault scenario in the fault management module with a corresponding target service.

### Claim 13

A non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions cause a computer to perform operations comprising:
acquiring a fault injection task, which comprises at least one target service identification and a fault scenario corresponding to the target service identification;
determining a target service according to each target service identification, and acquiring a state of the target service; and
injecting the fault scenario corresponding to the target service identification into the target service in a case that the state of the target service is a normal state;
wherein the operations further comprise:
collecting a target index of the target service; and
stopping injecting the fault scenario in a case of monitoring that the collected target index is beyond a preset index range;
wherein the collecting the target index of the target service comprises at least one of:
acquiring the target index of the target service from a designated index data push interface; and
collecting the target index from the target service.

### Claim 14 (depends on 13)

The storage medium of claim 13, wherein the operations further comprise at least one of:
revoking the fault scenario injected into the target service; and
ending the fault injection task.

### Claim 15 (depends on 13)

The storage medium of claim 13, wherein the determining the target service according to each target service identification, and acquiring the state of the target service, comprises: in a case that the fault injection task gets approved, determining the target service according to the target service identification, and acquiring the state of the target service,
wherein determining that the fault injection task gets approved comprises at least one of:
in a case that at least one of risks of a command and a code segment in the fault scenario in the fault injection task is lower than a preset risk level, determining that the fault injection task gets approved; and
in a case of receiving an approval instruction for the fault injection task, determining that the fault injection task gets approved.
