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.
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.
err-badness
(err-badness test err)
Takes a bank error and returns a number, depending on its type. Bigger numbers mean more egregious errors.
ok-reads
(ok-reads history)
Filters a history to just OK reads. Returns nil if there are none.
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.