|
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]
|
22 | 21 | [errcode :as err]
|
| 22 | + [nemesis :as nemesis] |
23 | 23 | [register :as register]
|
24 | 24 | [sets :as sets]
|
25 | 25 | [counter :as counter]]))
|
|
76 | 76 | ;:pages {:serialized-indices [true false]}
|
77 | 77 | :register {}})
|
78 | 78 |
|
| 79 | +(def nemeses |
| 80 | + "Types of faults a nemesis can create." |
| 81 | + #{:pause :kill :partition :clock}) |
| 82 | + |
| 83 | +(def standard-nemeses |
| 84 | + "Combinations of nemeses for tests." |
| 85 | + [[] |
| 86 | + [:pause] |
| 87 | + [:kill] |
| 88 | + [:partition] |
| 89 | + [:pause :kill :partition :clock]]) |
| 90 | + |
| 91 | +(def special-nemeses |
| 92 | + "A map of special nemesis names to collections of faults." |
| 93 | + {:none [] |
| 94 | + :standard [:pause :kill :partition :clock] |
| 95 | + :all [:pause :kill :partition :clock]}) |
| 96 | + |
| 97 | +(defn parse-nemesis-spec |
| 98 | + "Takes a comma-separated nemesis string and |
| 99 | + returns a collection of keyword faults." |
| 100 | + [spec] |
| 101 | + (->> (str/split spec #",") |
| 102 | + (map keyword) |
| 103 | + (mapcat #(get special-nemeses % [%])))) |
| 104 | + |
79 | 105 | (def cli-opts
|
80 | 106 | "Options for test runners."
|
81 | 107 | [["-v" "--version VERSION"
|
|
84 | 110 | [nil "--mvcc"
|
85 | 111 | "Enable MVCC engine"
|
86 | 112 | :default false]
|
| 113 | + [nil "--nemesis FAULTS" "A comma-separated list of nemesis faults to enable" |
| 114 | + :parse-fn parse-nemesis-spec |
| 115 | + :validate [(partial every? (into nemeses (keys special-nemeses))) |
| 116 | + (str "Faults must be one of " nemeses " or " |
| 117 | + (cli/one-of special-nemeses))]] |
| 118 | + [nil "--nemesis-interval SECONDS" "How long to wait between nemesis faults" |
| 119 | + :default 3 |
| 120 | + :parse-fn read-string |
| 121 | + :validate [#(and (number? %) (pos? %)) "must be a positive number"]] |
87 | 122 | ["-e" "--engine NAME"
|
88 | 123 | "What Tarantool data engine should we use?"
|
89 | 124 | :default "memtx"]])
|
|
142 | 177 | (defn tarantool-test
|
143 | 178 | [opts]
|
144 | 179 | (let [workload ((get workloads (:workload opts)) opts)
|
145 |
| - nemesis nemesis/noop |
| 180 | + nemesis (nemesis/nemesis-package |
| 181 | + {:db db/db |
| 182 | + :nodes (:nodes opts) |
| 183 | + :faults (:nemesis opts) |
| 184 | + :partition {:targets [:one :majority :majorities-ring]} |
| 185 | + :pause {:targets [:one :majority :all]} |
| 186 | + :kill {:targets [:one :majority :all]} |
| 187 | + :interval (:nemesis-interval opts)}) |
| 188 | + _ (info (pr-str nemesis)) |
146 | 189 | gen (->> (:generator workload)
|
147 | 190 | (gen/nemesis (:generator nemesis))
|
148 | 191 | (gen/time-limit (:time-limit opts)))
|
|
156 | 199 | (merge tests/noop-test
|
157 | 200 | opts
|
158 | 201 | {:client (:client workload)
|
159 |
| - :nemesis nemesis |
| 202 | + :nemesis (:nemesis nemesis) |
160 | 203 | :name (str "tarantool-" (:version opts))
|
161 | 204 | :os ubuntu/os
|
162 | 205 | :db (db/db (:version opts))
|
|
168 | 211 | 10
|
169 | 212 | (:concurrency opts))
|
170 | 213 | :generator gen
|
171 |
| - :checker (checker/compose {:perf (checker/perf) |
| 214 | + :checker (checker/compose {:perf (checker/perf {:nemeses (:perf nemesis)}) |
172 | 215 | :clock-skew (checker/clock-plot)
|
173 | 216 | :crash (crash-checker)
|
174 | 217 | :timeline (timeline/html)
|
|
177 | 220 | :workload (:checker workload)})})))
|
178 | 221 |
|
179 | 222 | (defn all-test-options
|
180 |
| - "Takes base cli options, a collection of workloads, and a test count, |
| 223 | + "Takes base cli options, a collection of nemeses, workloads, and a test count, |
181 | 224 | and constructs a sequence of test options."
|
182 |
| - [cli workloads] |
183 |
| - (for [w workloads, i (range (:test-count cli))] |
| 225 | + [cli nemeses workloads] |
| 226 | + (for [n nemeses, w workloads, i (range (:test-count cli))] |
184 | 227 | (assoc cli
|
| 228 | + :nemesis n |
185 | 229 | :workload w)))
|
186 | 230 |
|
187 | 231 | (defn all-tests
|
188 | 232 | "Takes parsed CLI options and constructs a sequence of test options, by
|
189 |
| - combining all workloads." |
190 |
| - [test-fn opts] |
191 |
| - (let [workloads (if-let [w (:workload opts)] [w] |
192 |
| - (if (:only-workloads-expected-to-pass opts) |
| 233 | + combining all workloads and nemeses." |
| 234 | + [test-fn cli] |
| 235 | + (let [nemeses (if-let [n (:nemesis cli)] [n] standard-nemeses) |
| 236 | + workloads (if-let [w (:workload cli)] [w] |
| 237 | + (if (:only-workloads-expected-to-pass cli) |
193 | 238 | workloads-expected-to-pass
|
194 | 239 | standard-workloads))]
|
195 |
| - (->> (all-test-options opts workloads) |
| 240 | + (->> (all-test-options cli nemeses workloads) |
196 | 241 | (map test-fn))))
|
197 | 242 |
|
198 | 243 | (defn -main
|
|
0 commit comments