Skip to main content

Module chaos

Module chaos 

Source
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.

§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));

Functions§

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.
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 FAILOVER on a replica node.
trigger_save
Trigger a background RDB save.