jepsen.role

Supports tests where each node has a single, distinct role. For instance, one node might run ZooKeeper, and the remaining nodes might run Kafka.

Using this namespace requires the test to have a :roles map, whose keys are arbitrary roles, and whose corresponding values are vectors of nodes in the test, like so:

{:mongod “n1” “n2” :mongos “n3”}

db

(db dbs)

Takes a map of role -> DB and creates a composite DB which implements the full suite of DB protocols. Setup! on this DB calls the setup! for that particular role’s DB for that node, with a restricted test, and so on.

db-helper*

macro

(db-helper* & body)

We have to figure out the role, db, and restricted test for every single fn. This anaphoric macro binds these variables to strip out boilerplate. Only for use in DB below, or when writing your own DB and you use exactly the form below.

nodes

(nodes test role)

Returns a vector of nodes associated with a given role, in test order. Right now this returns nil when given a role not in the roles map. I’m not sure if that’s more or less useful than throwing. This may change.

restrict-client

(restrict-client role client)

Your test has nodes with different roles, but only one role is client-facing.

Wraps a jepsen Client c in a new Client specific to the given role. This client responds only to (client/open! wrapper test node). Instead of connecting to the given node, calls `(client/open! c test node’), where node’ is a node with the given role.

Note that this wrapper evaporates after open!; the inner client takes over thereafter. Calls to invoke! etc go directly to the inner client and will receive the full test map, rather than a restricted one. This may come back to bite us later, in which case we’ll change.

restrict-nemesis

(restrict-nemesis role nemesis)

Wraps a Nemesis in a new one restricted to a specific role. Calls to the underlying nemesis receive a restricted test map.

restrict-nemesis-package

(restrict-nemesis-package role package)

Restricts a jepsen.nemesis.combined package to act purely on a single role. Right now we just restrict the nemesis, not the generators; maybe later we’ll need to do the generators too. Operations in this package have their operation :fs lifted to :f [role f]. Also adds a :role key to the package, for your use later.

restrict-test

(restrict-test role test)

Takes a test map and a role. Returns a version of the test map where the :nodes are only those for this specific role, and the :barrier is replaced by a fresh CyclicBarrier for the appropriate number of nodes.

role

(role test node)

Takes a test and node. Returns the role for that particular node. Throws if the test does not define a role for that node.