jepsen.store

Persistent storage for test runs and later analysis.

all-tests

(all-tests)

A plain old vector of test delays, sorted in chronological order. Unlike tests, attempts to load tests with no .fressian or .jepsen file will return nil here, instead of throwing. Helpful when you want to slice and dice all tests at the REPL.

base-dir

class-name->ns-str

(class-name->ns-str class-name)

Turns a class string into a namespace string (by translating _ to -)

close!

(close! test)

Takes a test map and closes its store handle, if one exists. Returns test without store handle.

console-appender

default-edn-reader

(default-edn-reader tag value)

We use defrecords heavily and it’s nice to be able to deserialize them.

default-logging-overrides

Logging overrides that we apply by default

default-nonserializable-keys

What keys in a test can’t be serialized to disk, by default?

delete!

(delete!)(delete! test-name)(delete! test-name test-time)

Deletes all tests, or all tests under a given name, or, if given a date as well, a specific test.

delete-file-recursively!

(delete-file-recursively! f)

dir?

(dir? f)

Is this a directory?

edn-tag->constructor

(edn-tag->constructor tag)

Takes an edn tag and returns a constructor fn taking that tag’s value and building an object from it.

file-name

(file-name f)

Maps a File to a string name.

fressian-file

(fressian-file test)

Gives the path to a fressian file encoding all the results from a test.

fressian-file!

(fressian-file! test)

Gives the path to a fressian file encoding all the results from a test, ensuring its containing directory exists.

jepsen-file

(jepsen-file test)

Gives the path to a .jepsen file encoding all the results from a test.

jepsen-file!

(jepsen-file! test)

Gives the path to a .jepsen file, ensuring its directory exists.

latest

(latest)

Loads the latest test

load

(load test)(load test-name test-time)

Loads a specific test, either given a map with {:name … :start-time …}, or by name and time as separate arguments. Prefers to load a .jepsen file, falls back to .fressian.

load-fressian-file

(load-fressian-file file)

Loads an arbitrary Fressian file.

load-jepsen-file

(load-jepsen-file file)

Loads a test from an arbitrary Jepsen file. This is lazy, and retains a filehandle which will remain open until all references to this test are gone and the GC kicks in.

load-results

(load-results test-name test-time)

Loads the results map for a test by name and time. Prefers a lazy map from test.fressian; falls back to parsing results.edn.

load-results-edn

(load-results-edn test)

Loads the results map for a test by parsing the result.edn file, instead of test.jepsen.

memoized-edn-tag->constructor

memoized-load-results

migrate-to-jepsen-format!

(migrate-to-jepsen-format!)

Loads every test and copies their Fressian files to the new on-disk format.

nonserializable-keys

(nonserializable-keys test)

What keys in a test can’t be serialized to disk? The union of default nonserializable keys, plus any in :nonserializable-keys.

path

(path test)(path test & args)

With one arg, a test, returns the directory for that test’s results. Given additional arguments, returns a file with that name in the test directory. Nested paths are flattened: (path t [:a :b :c :d) expands to …/a/b/c/d. Nil path components are ignored: (path t :a nil :b) expands to …/a/b.

Test must have only two keys: :name, and :start-time. :start-time may be a string, or a DateTime.

path!

(path! & args)

Like path, but ensures the path’s containing directories exist.

read-handlers

save-0!

(save-0! test)

Writes a test at the start of a test run. Updates symlinks. Returns a new version of test which should be used for subsequent writes.

save-1!

(save-1! test)

Phase 1: after completing the history, writes test.jepsen and history files to disk and updates latest symlinks. Returns test with metadata which should be preserved for calls to save-2!

save-2!

(save-2! test)

Phase 2: after computing results, we update the .jepsen file and write results as EDN. Returns test with metadata that should be preserved for future save calls.

serializable-test

(serializable-test test)

Takes a test and returns it without its serializable keys.

start-logging!

(start-logging! test)

Starts logging to a file in the test’s directory. Also updates current symlink. Test may include a :logging key, which should be a map with the following optional options:

{:overrides   A map of packages to log level keywords}

Test may also include a :logging-json? flag, which produces JSON structured Jepsen logs.

stop-logging!

(stop-logging!)

Resets logging to console only.

symlink?

(symlink? f)

Is this a symlink?

test

(test which)

Like load, loads a specific test. Frequently you don’t care about individual test names; you just want “the last test”, or “the third most recent”. This function can take:

  • A Long. (test 0) returns the first test ever run; (test 2) loads the third. (test -1) loads the most recent test; -2 the next-to-most-recent.

  • A String. Can be a directory name, in which case we look for a test.jepsen in that directory.

test-names

(test-names)

Returns a seq of all known test names.

tests

(tests)(tests test-name)

If given a test name, returns a map of test runs to deref-able tests. With no test name, returns a map of test names to maps of runs to deref-able tests.

update-current-symlink!

(update-current-symlink! test)

Creates a current symlink to the currently running test, if a store directory exists.

update-symlink!

(update-symlink! test dest)

Takes a test and a symlink path. Creates a symlink from that path to the test directory, if it exists.

update-symlinks!

(update-symlinks! test)

Creates latest and current symlinks to the given test, if a store directory exists.

virtual-dir?

(virtual-dir? f)

Is this a . or .. directory entry?

with-handle

macro

(with-handle [test-sym test-expr] & body)

Takes a binding symbol and a test expression. Opens a store.format handle for writing and reading test data, and evaluates body with that handle open, closing it automatically at the end of the block. Within block, test-sym is bound to test-expr, but with a special key :store :handle being the writer handle. Returns the value of the body.

The generator interpreter, save-0, save-1, etc. use this handle to write and read test data as the test is run.

with-out-file

macro

(with-out-file test filename & body)

Binds stdout to a file for the duration of body.

write-fressian!

(write-fressian! test)

Write the entire test as a .fressian file.

write-fressian-file!

(write-fressian-file! data file)

Writes a data structure to the given file, as Fressian. For instance:

(write-fressian-file! {:foo 2} (path! test “foo.fressian”)).

write-handlers

write-history!

(write-history! test)

Writes out history.txt and history.edn files.

write-jepsen!

(write-jepsen! test)

Takes a test and saves it as a .jepsen binary file.

write-results!

(write-results! test)

Writes out a results.edn file.