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]
(case (:f op)
:read (exec-with-retries 30 (fn []
(assoc op
:type :ok
:value (count (zk-list conn "/")))))
(assoc op
:type :ok
:value (count (zk-list conn "/")))))
:add (try
(do
(zk-multi-create-many-seq-nodes conn "/seq-" (:value op))

View File

@ -32,20 +32,20 @@
(defn unpack-deb
[path]
(do
(c/exec :dpkg :-x path common-prefix)
(c/exec :rm :-f path)
(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 :dpkg :-x path common-prefix)
(c/exec :rm :-f path)
(c/exec :mv (str common-prefix "/usr/bin/clickhouse") common-prefix)
(c/exec :rm :-rf (str common-prefix "/usr") (str common-prefix "/etc"))))
(defn unpack-tgz
[path]
(do
(c/exec :mkdir :-p (str common-prefix "/unpacked"))
(c/exec :tar :-zxvf path :-C (str common-prefix "/unpacked"))
(c/exec :rm :-f path)
(let [subdir (c/exec :ls (str common-prefix "/unpacked"))]
(c/exec :mv (str common-prefix "/unpacked/" subdir "/usr/bin/clickhouse") common-prefix)
(c/exec :rm :-fr (str common-prefix "/unpacked")))))
(c/exec :mkdir :-p (str common-prefix "/unpacked"))
(c/exec :tar :-zxvf path :-C (str common-prefix "/unpacked"))
(c/exec :rm :-f path)
(let [subdir (c/exec :ls (str common-prefix "/unpacked"))]
(c/exec :mv (str common-prefix "/unpacked/" subdir "/usr/bin/clickhouse") common-prefix)
(c/exec :rm :-fr (str common-prefix "/unpacked")))))
(defn chmod-binary
[path]
@ -85,10 +85,10 @@
(defn install-configs
[test node]
(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 "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 (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 "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")))
(defn db
[version reuse-binary]
@ -96,25 +96,24 @@
(setup! [_ test node]
(c/su
(do
(info "Preparing directories")
(prepare-dirs)
(if (or (not (cu/exists? binary-path)) (not reuse-binary))
(info "Preparing directories")
(prepare-dirs)
(if (or (not (cu/exists? binary-path)) (not reuse-binary))
(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 "Installing configs")
(install-configs test node)
(info "Starting server")
(start-clickhouse! node test)
(info "ClickHouse started"))))
(info "Installing configs")
(install-configs test node)
(info "Starting server")
(start-clickhouse! node test)
(info "ClickHouse started"))))
(teardown! [_ test node]
(info node "Tearing down clickhouse")
(kill-clickhouse! node test)
(c/su
(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 data-dir)
(c/exec :rm :-rf logs-dir)
@ -125,5 +124,5 @@
(c/su
(kill-clickhouse! node test)
(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")])))

View File

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

View File

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

View File

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

View File

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

View File

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