Skip to content

Commit

Permalink
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 25 deletions.
1 change: 0 additions & 1 deletion cockroachdb/project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
:dependencies [[org.clojure/clojure "1.8.0"]
[jepsen "0.1.9-SNAPSHOT"]
[org.clojure/java.jdbc "0.6.1"]
[circleci/clj-yaml "0.5.5"]
[org.postgresql/postgresql "9.4.1211"]]
:jvm-opts ["-Xmx12g"
"-XX:+UseConcMarkSweepGC"
Expand Down
2 changes: 1 addition & 1 deletion cockroachdb/src/jepsen/cockroach.clj
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@

(jepsen/synchronize test)
(when (= node (jepsen/primary test))
(auto/set-replication-zone! ".default"
(auto/set-replication-zone! "default"
{:range_min_bytes 1024
:range_max_bytes 1048576})
(info node "Creating database...")
Expand Down
29 changes: 6 additions & 23 deletions cockroachdb/src/jepsen/cockroach/auto.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
(:require [clojure.tools.logging :refer :all]
[clojure.java.io :as io]
[clojure.string :as str]
[clj-yaml.core :as yaml]
[jepsen.util :as util]
[jepsen [core :as jepsen]
[control :as c :refer [|]]]
Expand Down Expand Up @@ -100,29 +99,13 @@
[:-e ~@body]
[:>> errlog (c/lit "2>&1")]))))

(defn replication-zone
"Gets the replication zone on a given node. With no args, fetches the default
zone."
([]
(replication-zone ".default"))
([name]
(yaml/parse-string
(c/cd working-path
(c/exec cockroach :zone :get name (when insecure :--insecure))))))

(defn set-replication-zone!
"Sets the replication zone on the given node. Returns the new replication
zone."
[name zone]
(c/sudo cockroach-user
(-> (c/cd working-path
(c/exec :echo (yaml/generate-string zone) |
cockroach :zone :set
(when insecure :--insecure)
:--file=-
name))
(str/replace #"UPDATE .+\n" "")
(yaml/parse-string))))
"Sets the replication zone on the given node."
[zone config]
(csql! (str
"alter range " zone " configure zone using "
(str/join ", "
(map (fn [[k v]] (str (name k) " = " v)) config)))))

(defn install-bumptime!
"Install time adjusting binary"
Expand Down

0 comments on commit 5369ce1

Please sign in to comment.