raftSimTest
Build a MultiNodeRaftSim of n voters and run body under runTest(StandardTestDispatcher(), timeout = RAFT_SIM_WEDGE_BACKSTOP), wrapped in dumpOnWedge — the canonical harness for multi-node Raft tests. See MultiNodeRaftSim for the full determinism contract.
@Test
fun leaderElected() = raftSimTest(n = 3) { sim ->
val leader = sim.awaitLeader()
assertNotNull(leader)
}
@Test
fun partitionAndRecover() = raftSimTest(n = 3) { sim ->
sim.awaitLeader()
val leaderId = sim.leader()!!.let { l ->
sim.nodes.entries.first { it.value === l }.key
}
sim.partitionOff(leaderId)
val survivors = sim.nodeIds.filter { it != leaderId }.toSet()
sim.awaitLeader(among = survivors)
sim.heal()
// The old leader rejoins as a follower
sim.awaitRole(leaderId, RaftRole.Follower)
}Parameters
Number of voters (default 3 — minimum for fault tolerance with one crash).
Timing config forwarded to MultiNodeRaftSim. Defaults to MULTI_NODE_SIM_BASE_CONFIG.
Seed for per-node Random derivation. Defaults to MULTI_NODE_SIM_SEED.
Wall-clock wedge backstop, not a performance budget — read RAFT_SIM_WEDGE_BACKSTOP before changing it, and in particular before tightening it. Fast failure is the job of the bounded await* helpers' virtual within bounds and the election-churn bound, both of which are load-independent and dump state.