-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
src: add a checker for comments test
Closes #32
- Loading branch information
Showing
6 changed files
with
136 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{:index 1, :type :invoke :f :read :value nil} | ||
{:index 2, :type :invoke :f :write :value 425} | ||
{:index 3, :type :ok :f :write :value 425} | ||
{:index 4, :type :invoke :f :write :value 430} | ||
{:index 5, :type :ok :f :write :value 430} | ||
{:index 6, :type :ok :f :read :value #{2 10 15 20 34 35 38 42 43 47 51 53 59 61 71 72 82 88 89 | ||
113 119 123 129 132 145 146 163 167 176 206 216 224 230 | ||
238 243 244 255 260 292 294 299 312 316 324 325 327 330 | ||
350 356 359 360 361 363 366 367 371 376 403 410 419 422 | ||
430}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
(ns elle-cli.comments | ||
"Checks for a strict serializability anomaly in which T1 < T2, but T2 is | ||
visible without T1. | ||
We perform concurrent blind inserts across n tables, and meanwhile, perform | ||
reads of both tables in a transaction. To verify, we replay the history, | ||
tracking the writes which were known to have completed before the invocation | ||
of any write w_i. If w_i is visible, and some w_j < w_i is *not* visible, | ||
we've found a violation of strict serializability. | ||
Splits keys up onto different tables to make sure they fall in different | ||
shard ranges" | ||
(:require [jepsen.checker :as checker] | ||
[knossos.model :as model] | ||
[knossos.op :as op])) | ||
|
||
(defprotocol Checker | ||
(check [checker test history opts] | ||
"Verify the history is correct. Returns a map like | ||
{:valid? true} | ||
or | ||
{:valid? false | ||
:some-details ... | ||
:failed-at [details of specific operations]} | ||
Opts is a map of options controlling checker execution. Keys include: | ||
:subdirectory - A directory within this test's store directory where | ||
output files should be written. Defaults to nil.")) | ||
|
||
(defn checker | ||
"An empty checker that only returns nil." | ||
[] | ||
(reify Checker | ||
(check [_ _ _ _]))) | ||
|
||
(comment | ||
; Source: https://github.com/jepsen-io/jepsen/blob/main/cockroachdb/src/jepsen/cockroach/comments.clj | ||
(defn checker | ||
[] | ||
(reify Checker | ||
(check [this test model history opts] | ||
; Determine first-order write precedence graph | ||
(let [expected (loop [completed (sorted-set) | ||
expected {} | ||
[op & more :as history] history] | ||
(cond | ||
; Done | ||
(not (seq history)) | ||
expected | ||
|
||
; We know this value is definitely written | ||
(= :write (:f op)) | ||
(cond ; Write is beginning; record precedence | ||
(op/invoke? op) | ||
(recur completed | ||
(assoc expected (:value op) completed) | ||
more) | ||
|
||
; Write is completing; we can now expect to see | ||
; it | ||
(op/ok? op) | ||
(recur (conj completed (:value op)) | ||
expected more) | ||
|
||
true | ||
(recur completed expected more)) | ||
|
||
true | ||
(recur completed expected more))) | ||
errors (->> history | ||
(r/filter op/ok?) | ||
(r/filter #(= :read (:f %))) | ||
(reduce (fn [errors op] | ||
(let [seen (:value op) | ||
our-expected (->> seen | ||
(map expected) | ||
(reduce set/union)) | ||
missing (set/difference our-expected | ||
seen)] | ||
(if (empty? missing) | ||
errors | ||
(conj errors | ||
(-> op | ||
(dissoc :value) | ||
(assoc :missing missing) | ||
(assoc :expected-count | ||
(count our-expected))))))) | ||
[]))] | ||
{:valid? (empty? errors) | ||
:errors errors})))) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters