builtin:fault#

Adds network faults to containers: delay, jitter, packet loss, corruption, duplication, reordering, and a bandwidth limit. Use it to test how your application handles a slow or unreliable dependency. The faults apply to all traffic of the container, including traffic that does not go through the kevin proxy.

The step applies faults to the containers of the steps in its needs:

backend: {uses: "builtin:container", with: {image: "myapp/backend"}}

backend_fault: {
    uses:  "builtin:fault"
    needs: ["backend"]
    with: {
        delay_ms:     200
        loss_percent: 10
    }
}

A builtin:kubernetes step has one container for each node. Use containers with the keys of workers to select nodes:

cluster: {uses: "builtin:kubernetes", with: {driver: "kind", workers: {worker_a: {}, worker_b: {}}}}

worker_fault: {
    uses:  "builtin:fault"
    needs: ["cluster"]
    with: {
        containers:   ["worker_a", "worker_b"]
        loss_percent: 25
    }
}

For a step in needs that has one container, such as backend above, containers accepts the step name. This also works for a setup.<step> entry.

FieldTypeDefaultDescription
containers[...string]-Limits the fault to these containers. Unset, the fault applies to every container of every step in needs. A name is the container name that its step reports, a key of a builtin:kubernetes step’s workers, or the name of a step in needs that has one container.
interfacestring-The network interface in the container to impair. Unset means "eth0".
delay_msint & >0-The fixed one-way delay added to every packet, in milliseconds.
jitter_msint & >=0-The random variation around delay_ms, in milliseconds. Has an effect only with delay_ms.
loss_percentfloat & >0 & <=100-The percentage of packets dropped.
corrupt_percentfloat & >0 & <=100-The percentage of packets corrupted (a single bit flipped).
duplicate_percentfloat & >0 & <=100-The percentage of packets duplicated.
reorder_percentfloat & >0 & <=100-The percentage of packets sent without delay_ms, ahead of delayed packets. Has an effect only with delay_ms.
rate_kbitint & >0-The maximum throughput of the interface, in kilobits per second.

Behavior#

  • At least one fault field is required.
  • The step fails if a containers entry matches no container, or if no step in needs has a container.
  • kevin removes the faults on teardown.
  • Running the step again with changed values replaces the faults.