jepsen.cli

Command line interface. Provides a default main method for common Jepsen functions (like the web interface), and utility functions for Jepsen tests to create their own test runners.

-main

(-main & args)

default-nodes

help-opt

merge-opt-specs

(merge-opt-specs a b)

Takes two option specifications and merges them together. Where both offer the same option name, prefers the latter.

one-of

(one-of coll)

Takes a collection and returns a string like “Must be one of …” and a list of names. For maps, uses keys.

package-opt

(package-opt default)(package-opt option-name default)

parse-concurrency

(parse-concurrency parsed)(parse-concurrency parsed k)

Takes a parsed map. Parses :concurrency; if it is a string ending with n, e.g 3n, sets it to 3 * the number of :nodes. Otherwise, parses as a plain integer. With an optional keyword k, parses that key in the parsed map–by default, the key is :concurrency.

parse-nodes

(parse-nodes parsed)

Takes a parsed map and merges all the various node specifications together. In particular:

  • If :nodes-file and :nodes are blank, and :node is the default node list, uses the default node list.
  • Otherwise, merges together :nodes-file, :nodes, and :node into a single list.

The new parsed map will have a merged nodes list in :nodes, and lose :nodes-file and :node options.

rename-keys

(rename-keys m replacements)

Given a map m, and a map of keys to replacement keys, yields m with keys renamed.

rename-options

(rename-options parsed replacements)

Like rename-keys, but takes a parsed map and updates keys in :options.

rename-ssh-options

(rename-ssh-options parsed)

Takes a parsed map and moves SSH options to a map under :ssh.

repeated-opt

(repeated-opt short-opt long-opt docstring default)(repeated-opt short-opt long-opt docstring default parse-map)

Helper for vector options where we want to replace the default vector (checking via identical?) if any options are passed, building a vector for multiple args. If parse-map is provided (a map of string cmdline options to parsed values), the special word “all” can be used to specify every value in the map.

run!

(run! subcommands [command & arguments :as argv])

Parses arguments and runs tests, etc. Takes a map of subcommand names to subcommand-specs, and a list of arguments. Each subcommand-spec is a map with the following keys:

:opt-spec - The option parsing spec to use. :opt-fn - A function to transform the tools.cli options map, e.g. {:options …, :arguments …, :summary …}. Default: identity :usage - A usage string (default: “Usage:”) :run - Function to execute with the transformed options (default: pprint)

If an unrecognized (or no command) is given, prints out a general usage guide and exits.

For a subcommand, if help or –help is given, prints out a help string with usage for the given subcommand and exits with status 0.

If invalid arguments are given, prints those errors to the console, and exits with status 254.

Finally, if everything looks good, calls the given subcommand’s run function with parsed options, and exits with status 0.

Catches exceptions, logs them to the console, and exits with status 255.

serve-cmd

(serve-cmd)

A web server command.

single-test-cmd

(single-test-cmd opts)

A command which runs a single test with standard built-ins. Options:

{:opt-spec A vector of additional options for tools.cli. Merge into test-opt-spec. Optional. :opt-fn A function which transforms parsed options. Composed after test-opt-fn. Optional. :opt-fn* Replaces test-opt-fn, in case you want to override it altogether. :tarball If present, adds a –tarball option to this command, defaulting to whatever URL is given here. :usage Defaults to jc/test-usage. Optional. :test-fn A function that receives the option map and constructs a test.}

This comes with two commands: test, which runs a test and analyzes it, and analyze, which constructs a test map using the same arguments as run, but analyzes a history from disk instead.

tarball-opt

(tarball-opt default)

test-all-cmd

(test-all-cmd opts)

A command that runs a whole suite of tests in one go. Options:

:opt-spec A vector of additional options for tools.cli. Appended to test-opt-spec. Optional. :opt-fn A function which transforms parsed options. Composed after test-opt-fn. Optional. :opt-fn* Replaces test-opt-fn, instead of composing with it. :usage Defaults to test-usage. Optional. :tests-fn A function that receives the transformed option map and constructs a sequence of tests to run.

test-all-exit!

(test-all-exit! results)

Takes a map of statuses and exits with an appropriate error code: 255 if any crashed, 2 if any were unknown, 1 if any were invalid, 0 if all passed.

test-all-print-summary!

(test-all-print-summary! results)

Prints a summary of test outcomes. Takes a map of statuses (e.g. :crashed, true, false, :unknown), to test files. Returns results.

test-all-run-tests!

(test-all-run-tests! tests)

Runs a sequence of tests and returns a map of outcomes (e.g. true, :unknown, :crashed, false) to collections of test folders with that outcome.

test-opt-fn

(test-opt-fn parsed)

An opt fn for running simple tests. Remaps ssh keys, remaps :node to :nodes, reads :nodes-file into :nodes, and parses :concurrency.

test-opt-spec

Command line options for testing.

test-usage

(test-usage)

validate-tarball

(validate-tarball parsed)

Takes a parsed map and ensures a tarball is present.