Fix style

This commit is contained in:
alesapin 2021-03-26 19:57:23 +03:00
parent f32704101b
commit e101fbab53
7 changed files with 48 additions and 49 deletions

View File

@ -25,9 +25,9 @@
(invoke! [this test op] (invoke! [this test op]
(case (:f op) (case (:f op)
:read (exec-with-retries 30 (fn [] :read (exec-with-retries 30 (fn []
(assoc op (assoc op
:type :ok :type :ok
:value (count (zk-list conn "/"))))) :value (count (zk-list conn "/")))))
:add (try :add (try
(do (do
(zk-multi-create-many-seq-nodes conn "/seq-" (:value op)) (zk-multi-create-many-seq-nodes conn "/seq-" (:value op))

View File

@ -32,20 +32,20 @@
(defn unpack-deb (defn unpack-deb
[path] [path]
(do (do
(c/exec :dpkg :-x path common-prefix) (c/exec :dpkg :-x path common-prefix)
(c/exec :rm :-f path) (c/exec :rm :-f path)
(c/exec :mv (str common-prefix "/usr/bin/clickhouse") common-prefix) (c/exec :mv (str common-prefix "/usr/bin/clickhouse") common-prefix)
(c/exec :rm :-rf (str common-prefix "/usr") (str common-prefix "/etc")))) (c/exec :rm :-rf (str common-prefix "/usr") (str common-prefix "/etc"))))
(defn unpack-tgz (defn unpack-tgz
[path] [path]
(do (do
(c/exec :mkdir :-p (str common-prefix "/unpacked")) (c/exec :mkdir :-p (str common-prefix "/unpacked"))
(c/exec :tar :-zxvf path :-C (str common-prefix "/unpacked")) (c/exec :tar :-zxvf path :-C (str common-prefix "/unpacked"))
(c/exec :rm :-f path) (c/exec :rm :-f path)
(let [subdir (c/exec :ls (str common-prefix "/unpacked"))] (let [subdir (c/exec :ls (str common-prefix "/unpacked"))]
(c/exec :mv (str common-prefix "/unpacked/" subdir "/usr/bin/clickhouse") common-prefix) (c/exec :mv (str common-prefix "/unpacked/" subdir "/usr/bin/clickhouse") common-prefix)
(c/exec :rm :-fr (str common-prefix "/unpacked"))))) (c/exec :rm :-fr (str common-prefix "/unpacked")))))
(defn chmod-binary (defn chmod-binary
[path] [path]
@ -85,10 +85,10 @@
(defn install-configs (defn install-configs
[test node] [test node]
(c/exec :echo (slurp (io/resource "config.xml")) :> (str configs-dir "/config.xml")) (c/exec :echo (slurp (io/resource "config.xml")) :> (str configs-dir "/config.xml"))
(c/exec :echo (slurp (io/resource "users.xml")) :> (str configs-dir "/users.xml")) (c/exec :echo (slurp (io/resource "users.xml")) :> (str configs-dir "/users.xml"))
(c/exec :echo (slurp (io/resource "listen.xml")) :> (str sub-configs-dir "/listen.xml")) (c/exec :echo (slurp (io/resource "listen.xml")) :> (str sub-configs-dir "/listen.xml"))
(c/exec :echo (cluster-config test node (slurp (io/resource "test_keeper_config.xml"))) :> (str sub-configs-dir "/test_keeper_config.xml"))) (c/exec :echo (cluster-config test node (slurp (io/resource "test_keeper_config.xml"))) :> (str sub-configs-dir "/test_keeper_config.xml")))
(defn db (defn db
[version reuse-binary] [version reuse-binary]
@ -96,25 +96,24 @@
(setup! [_ test node] (setup! [_ test node]
(c/su (c/su
(do (do
(info "Preparing directories") (info "Preparing directories")
(prepare-dirs) (prepare-dirs)
(if (or (not (cu/exists? binary-path)) (not reuse-binary)) (if (or (not (cu/exists? binary-path)) (not reuse-binary))
(do (info "Downloading clickhouse") (do (info "Downloading clickhouse")
(install-downloaded-clickhouse (download-clickhouse version))) (install-downloaded-clickhouse (download-clickhouse version)))
(info "Binary already exsist on path" binary-path "skipping download")) (info "Binary already exsist on path" binary-path "skipping download"))
(info "Installing configs") (info "Installing configs")
(install-configs test node) (install-configs test node)
(info "Starting server") (info "Starting server")
(start-clickhouse! node test) (start-clickhouse! node test)
(info "ClickHouse started")))) (info "ClickHouse started"))))
(teardown! [_ test node] (teardown! [_ test node]
(info node "Tearing down clickhouse") (info node "Tearing down clickhouse")
(kill-clickhouse! node test) (kill-clickhouse! node test)
(c/su (c/su
(if (not reuse-binary) (if (not reuse-binary)
(c/exec :rm :-rf binary-path)) (c/exec :rm :-rf binary-path))
(c/exec :rm :-rf pid-file-path) (c/exec :rm :-rf pid-file-path)
(c/exec :rm :-rf data-dir) (c/exec :rm :-rf data-dir)
(c/exec :rm :-rf logs-dir) (c/exec :rm :-rf logs-dir)
@ -125,5 +124,5 @@
(c/su (c/su
(kill-clickhouse! node test) (kill-clickhouse! node test)
(c/cd data-dir (c/cd data-dir
(c/exec :tar :czf "coordination.tar.gz" "coordination"))) (c/exec :tar :czf "coordination.tar.gz" "coordination")))
[stderr-file (str logs-dir "/clickhouse-server.log") (str data-dir "/coordination.tar.gz")]))) [stderr-file (str logs-dir "/clickhouse-server.log") (str data-dir "/coordination.tar.gz")])))

View File

@ -134,10 +134,10 @@
[cli worload-nemeseis-collection] [cli worload-nemeseis-collection]
(take (:test-count cli) (take (:test-count cli)
(shuffle (for [[workload nemesis] worload-nemeseis-collection] (shuffle (for [[workload nemesis] worload-nemeseis-collection]
(assoc cli (assoc cli
:nemesis nemesis :nemesis nemesis
:workload workload :workload workload
:test-count 1))))) :test-count 1)))))
(defn all-tests (defn all-tests
"Turns CLI options into a sequence of tests." "Turns CLI options into a sequence of tests."
[test-fn cli] [test-fn cli]

View File

@ -85,13 +85,13 @@
(defn logs-and-snapshots-corruption-nemesis (defn logs-and-snapshots-corruption-nemesis
[] []
(corruptor-nemesis coordination-data-dir (fn [path] (corruptor-nemesis coordination-data-dir (fn [path]
(do (do
(corrupt-file (select-last-file (str path "/snapshots"))) (corrupt-file (select-last-file (str path "/snapshots")))
(corrupt-file (select-last-file (str path "/logs"))))))) (corrupt-file (select-last-file (str path "/logs")))))))
(defn drop-all-corruption-nemesis (defn drop-all-corruption-nemesis
[] []
(corruptor-nemesis coordination-data-dir (fn [path] (corruptor-nemesis coordination-data-dir (fn [path]
(c/exec :rm :-fr path)))) (c/exec :rm :-fr path))))
(defn partition-bridge-nemesis (defn partition-bridge-nemesis
[] []

View File

@ -41,8 +41,8 @@
:drain :drain
; drain via delete is to long, just list all nodes ; drain via delete is to long, just list all nodes
(exec-with-retries 30 (fn [] (exec-with-retries 30 (fn []
(zk-sync conn) (zk-sync conn)
(assoc op :type :ok :value (into #{} (map #(str %1) (zk-list conn "/")))))))) (assoc op :type :ok :value (into #{} (map #(str %1) (zk-list conn "/"))))))))
(teardown! [_ test]) (teardown! [_ test])

View File

@ -23,10 +23,10 @@
(invoke! [this test op] (invoke! [this test op]
(case (:f op) (case (:f op)
:read (exec-with-retries 30 (fn [] :read (exec-with-retries 30 (fn []
(zk-sync conn) (zk-sync conn)
(assoc op (assoc op
:type :ok :type :ok
:value (read-string (:data (zk-get-str conn k)))))) :value (read-string (:data (zk-get-str conn k))))))
:add (try :add (try
(do (do
(zk-add-to-set conn k (:value op)) (zk-add-to-set conn k (:value op))

View File

@ -113,11 +113,11 @@
first-child (first (sort children))] first-child (first (sort children))]
(if (not (nil? first-child)) (if (not (nil? first-child))
(try (try
(do (.check txn path (:version stat)) (do (.check txn path (:version stat))
(.setData txn path (data/to-bytes "") -1) ; I'm just checking multitransactions (.setData txn path (data/to-bytes "") -1) ; I'm just checking multitransactions
(.delete txn (str path first-child) -1) (.delete txn (str path first-child) -1)
(.commit txn) (.commit txn)
first-child) first-child)
(catch KeeperException$BadVersionException _ nil) (catch KeeperException$BadVersionException _ nil)
; Even if we got connection loss, delete may actually be executed. ; Even if we got connection loss, delete may actually be executed.
; This function is used for queue model, which strictly require ; This function is used for queue model, which strictly require
@ -166,7 +166,7 @@
:--logger.errorlog (str logs-dir "/clickhouse-server.err.log") :--logger.errorlog (str logs-dir "/clickhouse-server.err.log")
:--test_keeper_server.snapshot_storage_path coordination-snapshots-dir :--test_keeper_server.snapshot_storage_path coordination-snapshots-dir
:--test_keeper_server.logs_storage_path coordination-logs-dir) :--test_keeper_server.logs_storage_path coordination-logs-dir)
(wait-clickhouse-alive! node test))) (wait-clickhouse-alive! node test)))
(defn exec-with-retries (defn exec-with-retries
[retries f & args] [retries f & args]