|
12 | 12 | [control :as c]
|
13 | 13 | [independent :as independent]
|
14 | 14 | [generator :as gen]
|
15 |
| - [nemesis :as nemesis] |
16 | 15 | [tests :as tests]
|
17 | 16 | [util :refer [timeout meh]]]
|
18 | 17 | [jepsen.checker.timeline :as timeline]
|
19 | 18 | ;[knossos.model :as model]
|
20 | 19 | [jepsen.os.ubuntu :as ubuntu]
|
21 | 20 | [tarantool [db :as db]
|
| 21 | + [nemesis :as nemesis] |
22 | 22 | [register :as register]
|
23 | 23 | [sets :as sets]
|
24 | 24 | [counter :as counter]]))
|
|
68 | 68 | ;:pages {:serialized-indices [true false]}
|
69 | 69 | :register {}})
|
70 | 70 |
|
| 71 | +(def nemeses |
| 72 | + "Types of faults a nemesis can create." |
| 73 | + #{:pause :kill :partition :clock}) |
| 74 | + |
| 75 | +(def standard-nemeses |
| 76 | + "Combinations of nemeses for tests" |
| 77 | + [[] |
| 78 | + [:pause] |
| 79 | + [:kill] |
| 80 | + [:partition] |
| 81 | + [:pause :kill :partition :clock]]) |
| 82 | + |
| 83 | +(def special-nemeses |
| 84 | + "A map of special nemesis names to collections of faults" |
| 85 | + {:none [] |
| 86 | + :standard [:pause :kill :partition :clock :member] |
| 87 | + :all [:pause :kill :partition :clock :member]}) |
| 88 | + |
| 89 | +(defn parse-nemesis-spec |
| 90 | + "Takes a comma-separated nemesis string and returns a collection of keyword |
| 91 | + faults." |
| 92 | + [spec] |
| 93 | + (->> (str/split spec #",") |
| 94 | + (map keyword) |
| 95 | + (mapcat #(get special-nemeses % [%])))) |
| 96 | + |
71 | 97 | (def cli-opts
|
72 | 98 | "Options for test runners."
|
73 | 99 | [["-v" "--version VERSION"
|
|
80 | 106 | :parse-fn keyword
|
81 | 107 | :missing (str "--workload " (cli/one-of workloads))
|
82 | 108 | :validate [workloads (cli/one-of workloads)]]
|
| 109 | + [nil "--nemesis FAULTS" "A comma-separated list of nemesis faults to enable" |
| 110 | + :parse-fn parse-nemesis-spec |
| 111 | + :validate [(partial every? (into nemeses (keys special-nemeses))) |
| 112 | + (str "Faults must be one of " nemeses " or " |
| 113 | + (cli/one-of special-nemeses))]] |
| 114 | + [nil "--nemesis-interval SECONDS" "How long to wait between nemesis faults" |
| 115 | + :default 3 |
| 116 | + :parse-fn read-string |
| 117 | + :validate [#(and (number? %) (pos? %)) "must be a positive number"]] |
83 | 118 | ["-e" "--engine NAME"
|
84 | 119 | "What Tarantool data engine should we use?"
|
85 | 120 | :default "memtx"]])
|
86 | 121 |
|
87 | 122 | (def crash-pattern
|
88 | 123 | "An egrep pattern we use to find crashes in the Tarantool logs."
|
89 |
| - "Segmentation fault|too long WAL write|F>") |
| 124 | + "Segmentation fault|too long WAL write|F>|ER_TUPLE_FOUND") |
90 | 125 |
|
91 | 126 | (defn logged-crashes
|
92 | 127 | "Takes a test, and returns a map of nodes to strings from their Tarantool logs
|
|
119 | 154 | (defn tarantool-test
|
120 | 155 | [opts]
|
121 | 156 | (let [workload ((get workloads (:workload opts)) opts)
|
122 |
| - nemesis nemesis/noop |
| 157 | + nemesis (nemesis/nemesis-package |
| 158 | + {:db db/db |
| 159 | + :nodes (:nodes opts) |
| 160 | + :faults (:nemesis opts) |
| 161 | + :partition {:targets [:primaries]} |
| 162 | + :pause {:targets [nil :one :primaries :majority :all]} |
| 163 | + :kill {:targets [nil :one :primaries :majority :all]} |
| 164 | + :interval (:nemesis-interval opts)}) |
| 165 | + _ (info (pr-str nemesis)) |
123 | 166 | gen (->> (:generator workload)
|
124 | 167 | (gen/nemesis (:generator nemesis))
|
125 | 168 | (gen/time-limit (:time-limit opts)))
|
|
133 | 176 | (merge tests/noop-test
|
134 | 177 | opts
|
135 | 178 | {:client (:client workload)
|
136 |
| - :nemesis nemesis |
| 179 | + :nemesis (:nemesis nemesis) |
137 | 180 | :name (str "tarantool-" (:version opts))
|
138 | 181 | :os ubuntu/os
|
139 | 182 | :db (db/db (:version opts))
|
140 | 183 | :engine (:engine opts)
|
141 | 184 | :mvcc (:mvcc opts)
|
142 | 185 | :pure-generators true
|
143 | 186 | :generator gen
|
144 |
| - :checker (checker/compose {:perf (checker/perf) |
| 187 | + :checker (checker/compose {:perf (checker/perf {:nemeses (:perf nemesis)}) |
145 | 188 | :clock-skew (checker/clock-plot)
|
146 | 189 | :crash (crash-checker)
|
147 | 190 | :timeline (timeline/html)
|
|
0 commit comments