|
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]]))
|
|
69 | 69 | ;:pages {:serialized-indices [true false]}
|
70 | 70 | :register {}})
|
71 | 71 |
|
| 72 | +(def nemeses |
| 73 | + "Types of faults a nemesis can create." |
| 74 | + #{:pause :kill :partition :clock}) |
| 75 | + |
| 76 | +(def standard-nemeses |
| 77 | + "Combinations of nemeses for tests" |
| 78 | + [[] |
| 79 | + [:pause] |
| 80 | + [:kill] |
| 81 | + [:partition] |
| 82 | + [:pause :kill :partition :clock]]) |
| 83 | + |
| 84 | +(def special-nemeses |
| 85 | + "A map of special nemesis names to collections of faults" |
| 86 | + {:none [] |
| 87 | + :standard [:pause :kill :partition :clock :member] |
| 88 | + :all [:pause :kill :partition :clock :member]}) |
| 89 | + |
| 90 | +(defn parse-nemesis-spec |
| 91 | + "Takes a comma-separated nemesis string and returns a collection of keyword |
| 92 | + faults." |
| 93 | + [spec] |
| 94 | + (->> (str/split spec #",") |
| 95 | + (map keyword) |
| 96 | + (mapcat #(get special-nemeses % [%])))) |
| 97 | + |
72 | 98 | (def cli-opts
|
73 | 99 | "Options for test runners."
|
74 | 100 | [["-v" "--version VERSION"
|
|
81 | 107 | :parse-fn keyword
|
82 | 108 | :missing (str "--workload " (cli/one-of workloads))
|
83 | 109 | :validate [workloads (cli/one-of workloads)]]
|
| 110 | + [nil "--nemesis FAULTS" "A comma-separated list of nemesis faults to enable" |
| 111 | + :parse-fn parse-nemesis-spec |
| 112 | + :validate [(partial every? (into nemeses (keys special-nemeses))) |
| 113 | + (str "Faults must be one of " nemeses " or " |
| 114 | + (cli/one-of special-nemeses))]] |
| 115 | + [nil "--nemesis-interval SECONDS" "How long to wait between nemesis faults" |
| 116 | + :default 3 |
| 117 | + :parse-fn read-string |
| 118 | + :validate [#(and (number? %) (pos? %)) "must be a positive number"]] |
84 | 119 | ["-e" "--engine NAME"
|
85 | 120 | "What Tarantool data engine should we use?"
|
86 | 121 | :default "memtx"]])
|
|
122 | 157 | (defn tarantool-test
|
123 | 158 | [opts]
|
124 | 159 | (let [workload ((get workloads (:workload opts)) opts)
|
125 |
| - nemesis nemesis/noop |
| 160 | + nemesis (nemesis/nemesis-package |
| 161 | + {:db db/db |
| 162 | + :nodes (:nodes opts) |
| 163 | + :faults (:nemesis opts) |
| 164 | + :partition {:targets [:primaries]} |
| 165 | + :pause {:targets [nil :one :primaries :majority :all]} |
| 166 | + :kill {:targets [nil :one :primaries :majority :all]} |
| 167 | + :interval (:nemesis-interval opts)}) |
| 168 | + _ (info (pr-str nemesis)) |
126 | 169 | gen (->> (:generator workload)
|
127 | 170 | (gen/nemesis (:generator nemesis))
|
128 | 171 | (gen/time-limit (:time-limit opts)))
|
|
136 | 179 | (merge tests/noop-test
|
137 | 180 | opts
|
138 | 181 | {:client (:client workload)
|
139 |
| - :nemesis nemesis |
| 182 | + :nemesis (:nemesis nemesis) |
140 | 183 | :name (str "tarantool-" (:version opts))
|
141 | 184 | :os ubuntu/os
|
142 | 185 | :db (db/db (:version opts))
|
143 | 186 | :engine (:engine opts)
|
144 | 187 | :mvcc (:mvcc opts)
|
145 | 188 | :pure-generators true
|
146 | 189 | :generator gen
|
147 |
| - :checker (checker/compose {:perf (checker/perf) |
| 190 | + :checker (checker/compose {:perf (checker/perf {:nemeses (:perf nemesis)}) |
148 | 191 | :clock-skew (checker/clock-plot)
|
149 | 192 | :crash (crash-checker)
|
150 | 193 | :timeline (timeline/html)
|
|
0 commit comments