jepsen.generator.test
This namespace contains functions for testing generators. See the jepsen.generator-test
namespace in the test/
directory for a concrete example of how these functions can be used.
NOTE: While the simulate
function is considered stable at this point, the others might still be subject to change – use with care and expect possible breakage in future releases.
default-context
A default initial context for running these tests. Two worker threads, one nemesis.
imperfect
(imperfect gen)
(imperfect ctx gen)
Simulates the series of ops obtained from a generator where threads alternately fail, info, then ok, and repeat, taking 10 ns each. Returns invocations and completions.
n+nemesis-context
(n+nemesis-context n)
A context with n numeric worker threads and one nemesis.
perfect
(perfect gen)
(perfect ctx gen)
Simulates the series of ops obtained from a generator where the system executes every operation successfully in 10 nanoseconds. Returns only invocations.
perfect*
(perfect* gen)
(perfect* ctx gen)
Simulates the series of ops obtained from a generator where the system executes every operation successfully in 10 nanoseconds. Returns full history.
perfect-info
(perfect-info gen)
(perfect-info ctx gen)
Simulates the series of ops obtained from a generator where every operation crashes with :info in 10 nanoseconds. Returns only invocations.
quick-ops
(quick-ops gen)
(quick-ops ctx gen)
Simulates the series of ops obtained from a generator where the system executes every operation perfectly, immediately, and with zero latency.
rand-seed
We need tests to be deterministic for reproducibility, but also pseudorandom. Changing this seed will force rewriting some tests, but it might be necessary for discovering edge cases.
simulate
(simulate gen complete-fn)
(simulate ctx gen complete-fn)
Simulates the series of operations obtained from a generator, given a function that takes a context and op and returns the completion for that op.
Strips out op :index fields–it’s generally not as useful for testing.
with-fixed-rands
macro
(with-fixed-rands seed & body)
Rebinds rand, rand-int, and rand-nth to yield a deterministic series of random values. Definitely not threadsafe, but fine for tests I think.