jepsen.tests.bank

Helper functions for doing bank tests, where you simulate transfers between accounts, and verify that reads always show the same balance. The test map should have these additional options:

:accounts A collection of account identifiers. :total-amount Total amount to allocate. :max-transfer The largest transfer we’ll try to execute.

by-node

(by-node test history)

Groups operations by node.

check-op

(check-op accts total negative-balances? op)

Takes a single op and returns errors in its balance

checker

(checker checker-opts)

Verifies that all reads must sum to (:total test), and, unless :negative-balances? is true, checks that all balances are non-negative.

diff-transfer

Transfers only between different accounts.

err-badness

(err-badness test err)

Takes a bank error and returns a number, depending on its type. Bigger numbers mean more egregious errors.

generator

(generator)

A mixture of reads and transfers for clients.

ok-reads

(ok-reads history)

Filters a history to just OK reads. Returns nil if there are none.

plotter

(plotter)

Renders a graph of balances over time

points

(points history)

Turns a history into a seqeunce of time total-of-accounts points.

read

(read _ _)

A generator of read operations.

test

(test)(test opts)

A partial test; bundles together some default choices for keys and amounts with a generator and checker. Options:

:negative-balances? if true, doesn’t verify that balances remain positive

transfer

(transfer test _)

Generator of a transfer: a random amount between two randomly selected accounts.