Liking cljdoc? Tell your friends :D

urd.consensus.schedule

Schedules as DATA, so a failing run shrinks to a minimal counterexample.

The problem this solves

Every property test in this project generated a seed and handed it to the simulator. test.check then dutifully shrank the seed -- and a numerically smaller seed produces a completely unrelated schedule, not a simpler one. So a failure reported "seed 47283 fails" and nothing more: no minimal case, no reduction, no way to see which fault mattered. Shrinking was structurally useless, which is most of the value of property testing.

A schedule is instead an ordered vector of steps:

[[:tick 3]
 [:crash :b]
 [:tick 5]
 [:partition [#{:a :b} #{:c :d}]]
 [:tick 10]
 [:heal]
 [:tick 20]]

test.check shrinks a vector by dropping elements and simplifying each one, so it will remove the partition, then the crash, then shorten the ticks, and hand back the smallest schedule that still fails. That is a counterexample you can read.

What is still drawn from the seed

Message delays and duplication remain RNG-driven, because enumerating them as data would make schedules enormous without making counterexamples clearer. The faults that a human reasons about -- who crashed, who was partitioned from whom, when -- are data. Both are reproducible; only the second shrinks.

A schedule with no fault steps is just "run for n ticks", so this subsumes the plain case rather than replacing it.

Schedules as DATA, so a failing run shrinks to a minimal counterexample.

## The problem this solves

Every property test in this project generated a *seed* and handed it to the
simulator. test.check then dutifully shrank the seed -- and a numerically
smaller seed produces a completely unrelated schedule, not a simpler one. So a
failure reported "seed 47283 fails" and nothing more: no minimal case, no
reduction, no way to see which fault mattered. Shrinking was structurally
useless, which is most of the value of property testing.

A schedule is instead an ordered vector of steps:

    [[:tick 3]
     [:crash :b]
     [:tick 5]
     [:partition [#{:a :b} #{:c :d}]]
     [:tick 10]
     [:heal]
     [:tick 20]]

test.check shrinks a vector by dropping elements and simplifying each one, so
it will remove the partition, then the crash, then shorten the ticks, and hand
back the smallest schedule that still fails. That is a counterexample you can
read.

## What is still drawn from the seed

Message delays and duplication remain RNG-driven, because enumerating them as
data would make schedules enormous without making counterexamples clearer. The
faults that a human reasons about -- who crashed, who was partitioned from
whom, when -- are data. Both are reproducible; only the second shrinks.

A schedule with no fault steps is just "run for n ticks", so this subsumes
the plain case rather than replacing it.
raw docstring

describeclj/s

(describe schedule)

Render a schedule as something a human can read in a failure report.

Render a schedule as something a human can read in a failure report.
sourceraw docstring

runclj/s

(run s schedule)

Apply a whole schedule.

Apply a whole schedule.
sourceraw docstring

run-withclj/s

(run-with sim-opts schedule)

Build a simulator and run schedule against it.

sim-opts is passed to sim/make; the seed still governs delays and duplication, while the schedule governs the faults.

Build a simulator and run `schedule` against it.

`sim-opts` is passed to `sim/make`; the seed still governs delays and
duplication, while the schedule governs the faults.
sourceraw docstring

stepclj/s

(step s [op & args])

Apply one schedule step to a simulator.

Apply one schedule step to a simulator.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close