|
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]]))
|
|
48 | 48 | ;:pages pages/workload
|
49 | 49 | :register register/workload})
|
50 | 50 |
|
| 51 | +(def standard-workloads |
| 52 | + "The workload names we run for test-all by default." |
| 53 | + (keys workloads)) |
| 54 | + |
51 | 55 | (def workload-options
|
52 | 56 | "For each workload, a map of workload options to all the values that option
|
53 | 57 | supports."
|
|
64 | 68 | ;:pages {:serialized-indices [true false]}
|
65 | 69 | :register {}})
|
66 | 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 | + |
67 | 97 | (def cli-opts
|
68 | 98 | "Options for test runners."
|
69 | 99 | [["-v" "--version VERSION"
|
|
76 | 106 | :parse-fn keyword
|
77 | 107 | :missing (str "--workload " (cli/one-of workloads))
|
78 | 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"]] |
79 | 118 | ["-e" "--engine NAME"
|
80 | 119 | "What Tarantool data engine should we use?"
|
81 | 120 | :default "memtx"]])
|
82 | 121 |
|
83 | 122 | (def crash-pattern
|
84 | 123 | "An egrep pattern we use to find crashes in the Tarantool logs."
|
85 |
| - "Segmentation fault|too long WAL write|F>") |
| 124 | + "Segmentation fault|too long WAL write|F>|ER_TUPLE_FOUND") |
86 | 125 |
|
87 | 126 | (defn logged-crashes
|
88 | 127 | "Takes a test, and returns a map of nodes to strings from their Tarantool logs
|
|
115 | 154 | (defn tarantool-test
|
116 | 155 | [opts]
|
117 | 156 | (let [workload ((get workloads (:workload opts)) opts)
|
118 |
| - 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)) |
119 | 166 | gen (->> (:generator workload)
|
120 | 167 | (gen/nemesis (:generator nemesis))
|
121 | 168 | (gen/time-limit (:time-limit opts)))
|
|
129 | 176 | (merge tests/noop-test
|
130 | 177 | opts
|
131 | 178 | {:client (:client workload)
|
132 |
| - :nemesis nemesis |
| 179 | + :nemesis (:nemesis nemesis) |
133 | 180 | :name (str "tarantool-" (:version opts))
|
134 | 181 | :os ubuntu/os
|
135 | 182 | :db (db/db (:version opts))
|
136 | 183 | :engine (:engine opts)
|
137 | 184 | :mvcc (:mvcc opts)
|
138 | 185 | :pure-generators true
|
139 | 186 | :generator gen
|
140 |
| - :checker (checker/compose {:perf (checker/perf) |
| 187 | + :checker (checker/compose {:perf (checker/perf {:nemeses (:perf nemesis)}) |
141 | 188 | :clock-skew (checker/clock-plot)
|
142 | 189 | :crash (crash-checker)
|
143 | 190 | :timeline (timeline/html)
|
144 | 191 | :stats (checker/stats)
|
145 | 192 | :exceptions (checker/unhandled-exceptions)
|
146 | 193 | :workload (:checker workload)})})))
|
147 | 194 |
|
| 195 | +(defn all-tests |
| 196 | + "Takes parsed CLI options and constructs a sequence of test options, by |
| 197 | + combining all workloads and nemeses." |
| 198 | + [opts] |
| 199 | + (let [nemeses (if-let [n (:nemesis opts)] [n] standard-nemeses) |
| 200 | + workloads (if-let [w (:workload opts)] [w] standard-workloads) |
| 201 | + counts (range (:test-count opts))] |
| 202 | + (->> (for [i counts, n nemeses, w workloads] |
| 203 | + (assoc opts :nemesis n :workload w)) |
| 204 | + (map tarantool-test)))) |
| 205 | + |
148 | 206 | (defn -main
|
149 | 207 | "Handles command line arguments."
|
150 | 208 | [& args]
|
151 | 209 | (cli/run! (merge (cli/single-test-cmd {:test-fn tarantool-test
|
152 | 210 | :opt-spec cli-opts})
|
| 211 | + (cli/test-all-cmd {:test-fn all-tests |
| 212 | + :opt-spec cli-opts}) |
153 | 213 | (cli/serve-cmd))
|
154 | 214 | args))
|
0 commit comments