2023-04-18 10:14:13 +00:00
|
|
|
(ns jepsen.garage
|
2023-04-19 12:14:22 +00:00
|
|
|
(:require
|
|
|
|
[clojure.string :as str]
|
|
|
|
[jepsen
|
|
|
|
[checker :as checker]
|
|
|
|
[cli :as cli]
|
|
|
|
[generator :as gen]
|
|
|
|
[nemesis :as nemesis]
|
|
|
|
[tests :as tests]]
|
|
|
|
[jepsen.os.debian :as debian]
|
|
|
|
[jepsen.garage
|
|
|
|
[grg :as grg]
|
2023-04-19 13:27:26 +00:00
|
|
|
[reg :as reg]
|
|
|
|
[set :as set]]))
|
2023-04-18 14:10:07 +00:00
|
|
|
|
2023-04-19 12:14:22 +00:00
|
|
|
(def workloads
|
|
|
|
"A map of workload names to functions that construct workloads, given opts."
|
2023-04-19 13:27:26 +00:00
|
|
|
{"reg" reg/workload
|
2023-04-19 13:59:30 +00:00
|
|
|
"set1" set/workload1
|
|
|
|
"set2" set/workload2})
|
2023-04-18 14:10:07 +00:00
|
|
|
|
2023-04-19 12:14:22 +00:00
|
|
|
(def cli-opts
|
|
|
|
"Additional command line options."
|
|
|
|
[["-I" "--increasing-timestamps" "Garage version with increasing timestamps on PutObject"
|
|
|
|
:default false]
|
|
|
|
["-r" "--rate HZ" "Approximate number of requests per second, per thread."
|
|
|
|
:default 10
|
|
|
|
:parse-fn read-string
|
|
|
|
:validate [#(and (number? %) (pos? %)) "Must be a positive number"]]
|
|
|
|
[nil "--ops-per-key NUM" "Maximum number of operations on any given key."
|
|
|
|
:default 100
|
|
|
|
:parse-fn parse-long
|
|
|
|
:validate [pos? "Must be a positive integer."]]
|
|
|
|
["-w" "--workload NAME" "Workload of test to run"
|
|
|
|
:default "reg"
|
|
|
|
:validate [workloads (cli/one-of workloads)]]])
|
2023-04-18 10:14:13 +00:00
|
|
|
|
|
|
|
(defn garage-test
|
|
|
|
"Given an options map from the command line runner (e.g. :nodes, :ssh,
|
|
|
|
:concurrency, ...), constructs a test map."
|
|
|
|
[opts]
|
2023-04-19 12:14:22 +00:00
|
|
|
(let [workload ((get workloads (:workload opts)) opts)
|
|
|
|
garage-version (if (:increasing-timestamps opts)
|
|
|
|
"03490d41d58576d7b3bcf977b2726d72a3a66ada"
|
|
|
|
"v0.8.2")]
|
|
|
|
(merge tests/noop-test
|
|
|
|
opts
|
|
|
|
{:pure-generators true
|
|
|
|
:name (str "garage " (name (:workload opts)))
|
|
|
|
:os debian/os
|
|
|
|
:db (grg/db garage-version)
|
|
|
|
:client (:client workload)
|
2023-04-19 13:27:26 +00:00
|
|
|
:generator (gen/phases
|
|
|
|
(->>
|
|
|
|
(:generator workload)
|
|
|
|
(gen/stagger (/ (:rate opts)))
|
|
|
|
(gen/nemesis
|
|
|
|
(cycle [(gen/sleep 5)
|
|
|
|
{:type :info, :f :start}
|
|
|
|
(gen/sleep 5)
|
|
|
|
{:type :info, :f :stop}]))
|
|
|
|
(gen/time-limit (:time-limit opts)))
|
|
|
|
(gen/log "Healing cluster")
|
|
|
|
(gen/nemesis (gen/once {:type :info, :f :stop}))
|
|
|
|
(gen/log "Waiting for recovery")
|
|
|
|
(gen/sleep 10)
|
|
|
|
(gen/clients (:final-generator workload)))
|
2023-04-19 12:14:22 +00:00
|
|
|
:nemesis (nemesis/partition-random-halves)
|
|
|
|
:checker (checker/compose
|
|
|
|
{:perf (checker/perf)
|
|
|
|
:workload (:checker workload)})
|
|
|
|
})))
|
|
|
|
|
2023-04-18 10:14:13 +00:00
|
|
|
|
|
|
|
(defn -main
|
|
|
|
"Handles command line arguments. Can either run a test, or a web server for
|
|
|
|
browsing results."
|
|
|
|
[& args]
|
2023-04-19 12:14:22 +00:00
|
|
|
(cli/run! (merge (cli/single-test-cmd {:test-fn garage-test
|
|
|
|
:opt-spec cli-opts})
|
2023-04-18 11:59:03 +00:00
|
|
|
(cli/serve-cmd))
|
2023-04-18 10:14:13 +00:00
|
|
|
args))
|