Expand description
Fault injection primitives for testing Redis client resilience.
This module provides operations for simulating failures in Redis topologies: killing nodes, freezing processes (SIGSTOP/SIGCONT), triggering failovers, and more. All operations work with the handle types returned by the server, cluster, and sentinel builders.
Unix-only: the node-kill and freeze/resume operations send POSIX signals
via kill. See the crate-level “Platform Support” docs for details.
§Example
use redis_server_wrapper::{RedisCluster, chaos};
use std::time::Duration;
let cluster = RedisCluster::builder()
.masters(3)
.replicas_per_master(1)
.base_port(7100)
.start()
.await
.unwrap();
// Freeze a node (SIGSTOP) -- it stops processing but stays in memory.
chaos::freeze_node(cluster.node(0));
// ... test client behavior with a frozen node ...
// Resume the node (SIGCONT).
chaos::resume_node(cluster.node(0));Structs§
- Reshard
Guard - Holds a hash slot in the
MIGRATING/IMPORTINGstate so tests can deterministically observe-ASKredirects, then finishes or reverts the migration.
Functions§
- fill_
memory - Fill a node with
countkeys holding fixed-size values. - flushall
- Flush all data from a node.
- freeze_
master_ by_ slot - Freeze the master node that owns a given hash slot.
- freeze_
node - Freeze a node by sending SIGSTOP.
- kill_
master_ by_ key - Kill the master node that owns the hash slot for a given key.
- kill_
master_ by_ slot - Kill the master node that owns a given hash slot.
- kill_
node - Kill a node immediately with SIGKILL.
- migrate_
slot - Migrate a single hash slot from one master to another.
- migrate_
slots - Migrate a range of hash slots from one master to another.
- partition
- Simulate a network partition by freezing every node not in
reachable. - pause_
node - Freeze a node for a fixed duration, then resume it automatically.
- recover
- Resume all nodes in a cluster by sending SIGCONT.
- resume_
node - Resume a frozen node by sending SIGCONT.
- slow_
down - Pause client connections for a duration using
CLIENT PAUSE. - trigger_
failover - Trigger a
CLUSTER FAILOVERon a replica node. - trigger_
save - Trigger a background RDB save.