jepsen: fix nemesis to actually generate many operations
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing

This commit is contained in:
Alex 2023-10-24 16:39:50 +02:00
parent d13bde5e26
commit d7ab2c639e

View file

@ -32,9 +32,12 @@
[test] [test]
(let [layout-show (c/on (jepsen/primary test) (c/exec grg/binary :layout :show)) (let [layout-show (c/on (jepsen/primary test) (c/exec grg/binary :layout :show))
[_ layout-next-version] (re-find #"apply --version (\d+)\n" layout-show)] [_ layout-next-version] (re-find #"apply --version (\d+)\n" layout-show)]
(if layout-next-version
(do
(info "layout show: " layout-show "; next-version: " layout-next-version) (info "layout show: " layout-show "; next-version: " layout-next-version)
(c/on (jepsen/primary test) (c/on (jepsen/primary test)
(c/exec grg/binary :layout :apply :--version layout-next-version)))) (c/exec grg/binary :layout :apply :--version layout-next-version)))
(info "no layout changes to apply"))))
(defn reconfigure-subset (defn reconfigure-subset
"Reconfigure cluster with only a subset of nodes" "Reconfigure cluster with only a subset of nodes"
@ -65,11 +68,17 @@
; ---- nemesis scenari ---- ; ---- nemesis scenari ----
(defn nemesis-op
"A generator for a single nemesis operation"
[op]
(fn [_ _] {:type :info, :f op}))
(defn scenario-c (defn scenario-c
"Clock scramble scenario" "Clock scramble scenario"
[opts] [opts]
{:generator (cycle [(gen/sleep 5) {:generator (->>
{:type :info, :f :clock-scramble}]) (nemesis-op :clock-scramble)
(gen/stagger 5))
:nemesis (nemesis/compose :nemesis (nemesis/compose
{{:clock-scramble :scramble} (nemesis/clock-scrambler 20.0)})}) {{:clock-scramble :scramble} (nemesis/clock-scrambler 20.0)})})
@ -77,10 +86,10 @@
"Clock scramble + partition scenario" "Clock scramble + partition scenario"
[opts] [opts]
{:generator (->> {:generator (->>
(gen/mix [{:type :info, :f :clock-scramble} (gen/mix [(nemesis-op :clock-scramble)
{:type :info, :f :partition-stop} (nemesis-op :partition-stop)
{:type :info, :f :partition-start}]) (nemesis-op :partition-start)])
(gen/stagger 3)) (gen/stagger 5))
:final-generator (gen/once {:type :info, :f :partition-stop}) :final-generator (gen/once {:type :info, :f :partition-stop})
:nemesis (nemesis/compose :nemesis (nemesis/compose
{{:clock-scramble :scramble} (nemesis/clock-scrambler 20.0) {{:clock-scramble :scramble} (nemesis/clock-scrambler 20.0)
@ -91,9 +100,9 @@
"Cluster reconfiguration scenario" "Cluster reconfiguration scenario"
[opts] [opts]
{:generator (->> {:generator (->>
(gen/mix [{:type :info, :f :reconfigure-start} (gen/mix [(nemesis-op :reconfigure-start)
{:type :info, :f :reconfigure-stop}]) (nemesis-op :reconfigure-stop)])
(gen/stagger 3)) (gen/stagger 5))
:nemesis (nemesis/compose :nemesis (nemesis/compose
{{:reconfigure-start :start {{:reconfigure-start :start
:reconfigure-stop :stop} (reconfigure-subset 3)})}) :reconfigure-stop :stop} (reconfigure-subset 3)})})
@ -102,11 +111,11 @@
"Partition + cluster reconfiguration scenario" "Partition + cluster reconfiguration scenario"
[opts] [opts]
{:generator (->> {:generator (->>
(gen/mix [{:type :info, :f :partition-start} (gen/mix [(nemesis-op :partition-start)
{:type :info, :f :partition-stop} (nemesis-op :partition-stop)
{:type :info, :f :reconfigure-start} (nemesis-op :reconfigure-start)
{:type :info, :f :reconfigure-stop}]) (nemesis-op :reconfigure-stop)])
(gen/stagger 3)) (gen/stagger 5))
:final-generator (gen/once {:type :info, :f :partition-stop}) :final-generator (gen/once {:type :info, :f :partition-stop})
:nemesis (nemesis/compose :nemesis (nemesis/compose
{{:partition-start :start {{:partition-start :start
@ -118,12 +127,12 @@
"Clock scramble + partition + cluster reconfiguration scenario" "Clock scramble + partition + cluster reconfiguration scenario"
[opts] [opts]
{:generator (->> {:generator (->>
(gen/mix [{:type :info, :f :clock-scramble} (gen/mix [(nemesis-op :clock-scramble)
{:type :info, :f :partition-start} (nemesis-op :partition-start)
{:type :info, :f :partition-stop} (nemesis-op :partition-stop)
{:type :info, :f :reconfigure-start} (nemesis-op :reconfigure-start)
{:type :info, :f :reconfigure-stop}]) (nemesis-op :reconfigure-stop)])
(gen/stagger 3)) (gen/stagger 5))
:final-generator (gen/once {:type :info, :f :partition-stop}) :final-generator (gen/once {:type :info, :f :partition-stop})
:nemesis (nemesis/compose :nemesis (nemesis/compose
{{:clock-scramble :scramble} (nemesis/clock-scrambler 20.0) {{:clock-scramble :scramble} (nemesis/clock-scrambler 20.0)