start adding nemesis

This commit is contained in:
Antonio Andelic 2022-10-28 07:34:23 +00:00
parent cc65def352
commit 77a7411bd0
5 changed files with 54 additions and 17 deletions

View File

@ -5,6 +5,7 @@
[nemesis :as nemesis] [nemesis :as nemesis]
[control :as c] [control :as c]
[generator :as gen]] [generator :as gen]]
[jepsen.clickhouse.nemesis :as chnem]
[jepsen.clickhouse.constants :refer :all] [jepsen.clickhouse.constants :refer :all]
[jepsen.clickhouse.utils :as chu] [jepsen.clickhouse.utils :as chu]
[jepsen.clickhouse.keeper.utils :refer :all])) [jepsen.clickhouse.keeper.utils :refer :all]))
@ -23,14 +24,6 @@
(fn start [test node] (chu/kill-clickhouse! node test)) (fn start [test node] (chu/kill-clickhouse! node test))
(fn stop [test node] (start-clickhouse! node test)))) (fn stop [test node] (start-clickhouse! node test))))
(defn random-node-hammer-time-nemesis
[]
(nemesis/hammer-time "clickhouse"))
(defn all-nodes-hammer-time-nemesis
[]
(nemesis/hammer-time identity "clickhouse"))
(defn select-last-file (defn select-last-file
[path] [path]
(last (clojure.string/split (last (clojure.string/split
@ -141,9 +134,9 @@
:generator (start-stop-generator 1 10)} :generator (start-stop-generator 1 10)}
"simple-partitioner" {:nemesis (nemesis/partition-random-halves) "simple-partitioner" {:nemesis (nemesis/partition-random-halves)
:generator (start-stop-generator 5 5)} :generator (start-stop-generator 5 5)}
"random-node-hammer-time" {:nemesis (random-node-hammer-time-nemesis) "random-node-hammer-time" {:nemesis (chnem/random-node-hammer-time-nemesis)
:generator (start-stop-generator 5 5)} :generator (start-stop-generator 5 5)}
"all-nodes-hammer-time" {:nemesis (all-nodes-hammer-time-nemesis) "all-nodes-hammer-time" {:nemesis (chnem/all-nodes-hammer-time-nemesis)
:generator (start-stop-generator 1 10)} :generator (start-stop-generator 1 10)}
"logs-corruptor" {:nemesis (logs-corruption-nemesis) "logs-corruptor" {:nemesis (logs-corruption-nemesis)
:generator (corruption-generator)} :generator (corruption-generator)}

View File

@ -0,0 +1,23 @@
(ns jepsen.clickhouse.nemesis
(:require
[clojure.tools.logging :refer :all]
[jepsen
[nemesis :as nemesis]
[generator :as gen]]))
(defn random-node-hammer-time-nemesis
[]
(nemesis/hammer-time "clickhouse"))
(defn all-nodes-hammer-time-nemesis
[]
(nemesis/hammer-time identity "clickhouse"))
(defn start-stop-generator
[time-corrupt time-ok]
(->>
(cycle [(gen/sleep time-ok)
{:type :info, :f :start}
(gen/sleep time-corrupt)
{:type :info, :f :stop}])))

View File

@ -1,6 +1,7 @@
(ns jepsen.clickhouse.server.client (ns jepsen.clickhouse.server.client
(:require [clojure.java.jdbc :as j] (:require [clojure.java.jdbc :as j]
[clojure.tools.logging :refer :all] [clojure.tools.logging :refer :all]
[jepsen.util :as util]
[jepsen.reconnect :as rc])) [jepsen.reconnect :as rc]))
(def operation-timeout "Default operation timeout in ms" 10000) (def operation-timeout "Default operation timeout in ms" 10000)
@ -16,11 +17,15 @@
(defn open-connection (defn open-connection
[node] [node]
(let [spec (db-spec node) (util/timeout 30000
connection (j/get-connection spec) (throw (RuntimeException.
added-connection (j/add-connection spec connection)] (str "Connection to " node " timed out")))
(assert added-connection) (util/retry 0.1
added-connection)) (let [spec (db-spec node)
connection (j/get-connection spec)
added-connection (j/add-connection spec connection)]
(assert added-connection)
added-connection))))
(defn close-connection (defn close-connection
"Close connection" "Close connection"
@ -35,7 +40,7 @@
(rc/open! (rc/open!
(rc/wrapper (rc/wrapper
{:name (name node) {:name (name node)
:open #(open-connection node) :open (partial open-connection node)
:close close-connection :close close-connection
:log? true}))) :log? true})))

View File

@ -12,6 +12,7 @@
[jepsen.clickhouse.server [jepsen.clickhouse.server
[register :as register] [register :as register]
[set :as set]] [set :as set]]
[jepsen.clickhouse.server.nemesis :as custom-nemesis]
[jepsen.control.util :as cu] [jepsen.control.util :as cu]
[jepsen.os.ubuntu :as ubuntu] [jepsen.os.ubuntu :as ubuntu]
[jepsen.checker.timeline :as timeline] [jepsen.checker.timeline :as timeline]
@ -48,13 +49,15 @@
[opts] [opts]
(info "Test opts\n" (with-out-str (pprint opts))) (info "Test opts\n" (with-out-str (pprint opts)))
(let [quorum (boolean (:quorum opts)) (let [quorum (boolean (:quorum opts))
workload ((get workloads (:workload opts)) opts)] workload ((get workloads (:workload opts)) opts)
current-nemesis (get custom-nemesis/custom-nemesises "random-node-hammer-time")]
(merge tests/noop-test (merge tests/noop-test
opts opts
{:name (str "clickhouse-server-" (name (:workload opts))) {:name (str "clickhouse-server-" (name (:workload opts)))
:os ubuntu/os :os ubuntu/os
:db (get-db opts) :db (get-db opts)
:pure-generators true :pure-generators true
:nemesis (:nemesis current-nemesis)
:client (:client workload) :client (:client workload)
:checker (checker/compose :checker (checker/compose
{:perf (checker/perf) {:perf (checker/perf)
@ -62,7 +65,12 @@
:generator (gen/phases :generator (gen/phases
(->> (:generator workload) (->> (:generator workload)
(gen/stagger (/ (:rate opts))) (gen/stagger (/ (:rate opts)))
(gen/nemesis (:generator current-nemesis))
(gen/time-limit (:time-limit opts))) (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)))}))) (gen/clients (:final-generator workload)))})))
(defn clickhouse-server-test (defn clickhouse-server-test

View File

@ -0,0 +1,8 @@
(ns jepsen.clickhouse.server.nemesis
(:require [jepsen.clickhouse.nemesis :as chnem]))
(def custom-nemesises
{"random-node-hammer-time" {:nemesis (chnem/random-node-hammer-time-nemesis)
:generator (chnem/start-stop-generator 5 5)}
"all-nodes-hammer-time" {:nemesis (chnem/all-nodes-hammer-time-nemesis)
:generator (chnem/start-stop-generator 1 10)}})