Skip to main content

Module fault_proxy

Module fault_proxy 

Source
Expand description

Byte-level TCP fault-injection proxy for testing Redis client resilience.

FaultProxy sits between a test client and an upstream Redis node, forwarding bytes over TCP while allowing tests to inject faults: per- direction delay, mid-frame connection drops, chunked writes, and a black-hole mode. Unlike crate::chaos, which operates on the server process, this module operates purely on the wire and needs no Docker or root privileges.

§Example

use redis_server_wrapper::{Direction, FaultProxy, RedisServer};
use std::time::Duration;

let server = RedisServer::new().port(6400).start().await.unwrap();
let proxy = FaultProxy::spawn(server.addr()).await.unwrap();

// Route a client through `proxy.addr()` instead of `server.addr()`.

// Drop the connection after 8 bytes of the server's response.
proxy.close_after(Direction::UpstreamToClient, 8);

// ... assert the client sees a clean mid-frame connection error ...

// Back to clean passthrough for the next connection.
proxy.reset();

Structs§

FaultProxy
A TCP proxy that forwards bytes between test clients and an upstream Redis node while injecting configurable network faults.

Enums§

Delay
A delay applied before forwarding data in one direction.
Direction
A direction of byte flow through a FaultProxy.