Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cockroachdb: use CONFIGURE ZONE in set-replication-zone! #23

Merged
merged 1 commit into from
Aug 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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