Skip to content

Instantly share code, notes, and snippets.

@jstaffans
Last active April 4, 2018 18:47
Show Gist options
  • Save jstaffans/7711c1f5ebcc6fef6ef71c8e338a466b to your computer and use it in GitHub Desktop.
Save jstaffans/7711c1f5ebcc6fef6ef71c8e338a466b to your computer and use it in GitHub Desktop.
Jepsen notes

Setup, development

  • can start a cluster of Docker containers locally for development/testing
    • see up.sh in jepsen/docker
  • use these from Leiningen running locally on same machine as Docker host: https://stackoverflow.com/a/45071285/1479173
    • ie resolve Docker containers from host
    • add node host names to a file (e.g. nodes.txt) with a trailing dot and do lein run test --nodes-file ./nodes.txt
n1.
n2.
n3.
n4.
n5.

Writing tests

  • Jepsen does everything including installing the software under test
  • Source of installation package is usually an archive on the internet: can share a local volume to give nodes access to files directly
volumes: 
  - ./db:/opt/jepsen_db:ro
(c/su
  (let [url (str "file:///opt/jepsen_db/etcd-" version "-linux-amd64.tar.gz")]
    (cu/install-archive! url dir))
  • the system under test is called the "DB"
  • DB installation happens in parallel

Checking

What to check?

  • you need to decide which part of the system under test to model and check
  • usually no need to model the entire API
  • focus on parts that are easily verifiable, e.g. sets (should never contain duplicates)

Misc

  • the etcd test is probably the simplest one to copy for a new use case!

REPL

Construct a new test from the last one:

jepsen.etcdemo> (require '[jepsen.core :as jepsen]
                         '[jepsen.repl :as repl])
jepsen.etcdemo> (jepsen/run! (-> (repl/last-test "etcd") etcd-test))
                         
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment