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
|
2023-10-18 14:30:45 +00:00
|
|
|
[daemon :as grg]
|
2023-10-20 13:48:37 +00:00
|
|
|
[nemesis :as grgNemesis]
|
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-10-20 10:56:45 +00:00
|
|
|
{"reg1" reg/workload1
|
|
|
|
"reg2" reg/workload2
|
2023-04-19 13:59:30 +00:00
|
|
|
"set1" set/workload1
|
|
|
|
"set2" set/workload2})
|
2023-04-18 14:10:07 +00:00
|
|
|
|
2023-10-20 13:48:37 +00:00
|
|
|
(def scenari
|
|
|
|
"A map of scenari to the associated nemesis"
|
2023-10-24 09:39:45 +00:00
|
|
|
{"c" grgNemesis/scenario-c
|
|
|
|
"cp" grgNemesis/scenario-cp
|
|
|
|
"r" grgNemesis/scenario-r
|
2023-10-24 13:44:05 +00:00
|
|
|
"pr" grgNemesis/scenario-pr
|
2023-10-25 09:41:34 +00:00
|
|
|
"cpr" grgNemesis/scenario-cpr
|
2023-10-25 12:43:24 +00:00
|
|
|
"cdp" grgNemesis/scenario-cdp
|
2023-10-25 09:41:34 +00:00
|
|
|
"dpr" grgNemesis/scenario-dpr})
|
2023-10-20 13:48:37 +00:00
|
|
|
|
2023-10-20 11:36:48 +00:00
|
|
|
(def patches
|
|
|
|
"A map of patch names to Garage builds"
|
|
|
|
{"default" "v0.9.0"
|
2023-10-20 13:00:10 +00:00
|
|
|
"tsfix1" "d146cdd5b66ca1d3ed65ce93ca42c6db22defc09"
|
2023-11-16 11:57:21 +00:00
|
|
|
"tsfix2" "c82d91c6bccf307186332b6c5c6fc0b128b1b2b1"
|
2023-12-14 15:23:48 +00:00
|
|
|
"task3a" "707442f5de416fdbed4681a33b739f0a787b7834"
|
|
|
|
"task3b" "431b28e0cfdc9cac6c649193cf602108a8b02997"
|
|
|
|
"task3c" "0041b013a473e3ae72f50209d8f79db75a72848b"})
|
2023-10-20 11:36:48 +00:00
|
|
|
|
2023-04-19 12:14:22 +00:00
|
|
|
(def cli-opts
|
|
|
|
"Additional command line options."
|
2023-10-20 11:36:48 +00:00
|
|
|
[["-p" "--patch NAME" "Garage patch to use"
|
|
|
|
:default "default"
|
|
|
|
:validate [patches (cli/one-of patches)]]
|
2023-10-20 13:48:37 +00:00
|
|
|
["-s" "--scenario NAME" "Nemesis scenario to run"
|
|
|
|
:default "cp"
|
|
|
|
:validate [scenari (cli/one-of scenari)]]
|
2023-04-19 12:14:22 +00:00
|
|
|
["-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"
|
2023-10-20 13:48:37 +00:00
|
|
|
:default "reg1"
|
2023-04-19 12:14:22 +00:00
|
|
|
: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-10-25 09:41:34 +00:00
|
|
|
(let [garage-version (get patches (:patch opts))
|
|
|
|
db (grg/db garage-version)
|
|
|
|
workload ((get workloads (:workload opts)) opts)
|
|
|
|
scenario ((get scenari (:scenario opts)) (assoc opts :db db))]
|
2023-04-19 12:14:22 +00:00
|
|
|
(merge tests/noop-test
|
|
|
|
opts
|
|
|
|
{:pure-generators true
|
2023-12-14 15:23:48 +00:00
|
|
|
:name (str "garage-" (name (:patch opts)) " " (name (:workload opts)) " " (name (:scenario opts)))
|
2023-04-19 12:14:22 +00:00
|
|
|
:os debian/os
|
2023-10-25 09:41:34 +00:00
|
|
|
:db db
|
2023-04-19 12:14:22 +00:00
|
|
|
:client (:client workload)
|
2023-04-19 13:27:26 +00:00
|
|
|
:generator (gen/phases
|
|
|
|
(->>
|
|
|
|
(:generator workload)
|
|
|
|
(gen/stagger (/ (:rate opts)))
|
2023-10-20 13:48:37 +00:00
|
|
|
(gen/nemesis (:generator scenario))
|
2023-04-19 13:27:26 +00:00
|
|
|
(gen/time-limit (:time-limit opts)))
|
|
|
|
(gen/log "Healing cluster")
|
2023-10-20 13:53:46 +00:00
|
|
|
(gen/nemesis (:final-generator scenario))
|
2023-04-19 13:27:26 +00:00
|
|
|
(gen/log "Waiting for recovery")
|
|
|
|
(gen/sleep 10)
|
2023-12-14 15:23:48 +00:00
|
|
|
(gen/log "Running final generator")
|
|
|
|
(gen/clients (:final-generator workload))
|
|
|
|
(gen/log "Generators all done"))
|
2023-10-20 13:48:37 +00:00
|
|
|
:nemesis (:nemesis scenario)
|
2023-04-19 12:14:22 +00:00
|
|
|
:checker (checker/compose
|
2023-10-25 09:41:34 +00:00
|
|
|
{:perf (checker/perf (:perf scenario))
|
2023-04-19 12:14:22 +00:00
|
|
|
: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))
|