Skip to content

Commit 4cba2aa

Browse files
committed
Add primary node discovery
Early versions of tests always first node as a primary in a cluster. With automated leader election leader can be on any node in clustera, so discovery of primary instance has been added. It consists of SQL function `_LEADER()` implemented in Lua, ``` unix/:/var/run/tarantool/jepsen.control> box.execute([[SELECT _LEADER()]]) --- - metadata: - name: COLUMN_1 type: string rows: - ['89.208.84.154'] ... ``` `primary` function that connects to desired node and gets IP address of primary instance using `_LEADER()` function and `primaries` function that gather information about primaries on every node in a cluster. Closes #43 Closes #17
1 parent 330c54f commit 4cba2aa

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/tarantool/db.clj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
[clojure.java.io :as io]
55
[next.jdbc :as j]
66
[next.jdbc.connection :as connection]
7+
[tarantool.client :as cl]
78
[jepsen.os.debian :as debian]
89
[jepsen.control.util :as cu]
910
[jepsen [core :as jepsen]
@@ -203,6 +204,16 @@
203204
(= n 1) true
204205
:else false)))
205206

207+
(defn primaries
208+
"Return a seq of primaries in a cluster."
209+
[test]
210+
(if (= 1 (count (:nodes test)))
211+
(:nodes test)
212+
(->> (pmap cl/primary (:nodes test))
213+
(set)
214+
(into [])
215+
(remove nil?))))
216+
206217
(defn configure!
207218
"Configure instance"
208219
[test node]
@@ -212,6 +223,7 @@
212223
(c/exec :mkdir :-p "/etc/tarantool/instances.enabled")
213224
(c/exec :usermod :-a :-G :tarantool :ubuntu)
214225
(c/exec :echo (-> "tarantool/jepsen.lua" io/resource slurp
226+
(str/replace #"%TARANTOOL_IP_ADDRESS%" node)
215227
(str/replace #"%TARANTOOL_REPLICATION%" (replica-set test))
216228
(str/replace #"%TARANTOOL_IS_READ_ONLY%" (boolean-to-str read-only))
217229
(str/replace #"%TARANTOOL_MVCC%" (boolean-to-str (:mvcc test)))

0 commit comments

Comments
 (0)