|
2 | 2 | (:require [clojure.tools.logging :refer :all]
|
3 | 3 | [clojure.string :as str]
|
4 | 4 | [clojure.java.io :as io]
|
5 |
| - [next.jdbc :as j] |
6 |
| - [next.jdbc.connection :as connection] |
| 5 | + ;[next.jdbc :as j] |
| 6 | + ;[next.jdbc.connection :as connection] |
| 7 | + [tarantool.client :as cl] |
7 | 8 | [jepsen.os.debian :as debian]
|
8 | 9 | [jepsen.control.util :as cu]
|
9 | 10 | [jepsen [core :as jepsen]
|
|
191 | 192 | [b]
|
192 | 193 | (if (true? b) "true" "false"))
|
193 | 194 |
|
194 |
| -(defn is-primary? |
195 |
| - [test node] |
196 |
| - (let [p (jepsen/primary test)] |
197 |
| - (if (= node p) true false))) |
198 |
| - |
199 | 195 | (defn is-single-mode?
|
200 | 196 | [test]
|
201 | 197 | (let [n (count (:nodes test))]
|
|
206 | 202 | (defn configure!
|
207 | 203 | "Configure instance"
|
208 | 204 | [test node]
|
209 |
| - (let [read-only (not (is-primary? test node))] |
210 |
| - (info "Joining" node "as" (if (true? read-only) "replica" "leader")) |
211 |
| - (c/exec :mkdir :-p "/etc/tarantool/instances.available") |
212 |
| - (c/exec :mkdir :-p "/etc/tarantool/instances.enabled") |
213 |
| - (c/exec :usermod :-a :-G :tarantool :ubuntu) |
214 |
| - (c/exec :echo (-> "tarantool/jepsen.lua" io/resource slurp |
215 |
| - (str/replace #"%TARANTOOL_REPLICATION%" (replica-set test)) |
216 |
| - (str/replace #"%TARANTOOL_IS_READ_ONLY%" (boolean-to-str read-only)) |
217 |
| - (str/replace #"%TARANTOOL_SINGLE_MODE%" (boolean-to-str (is-single-mode? test))) |
218 |
| - (str/replace #"%TARANTOOL_DATA_ENGINE%" (:engine test))) |
219 |
| - :> "/etc/tarantool/instances.enabled/jepsen.lua") |
220 |
| - (c/exec :cp "/etc/tarantool/instances.enabled/jepsen.lua" "/etc/tarantool/instances.available"))) |
221 |
| - |
222 |
| -(defn is-read-only |
223 |
| - [conn] |
224 |
| - (j/execute! conn ["SELECT lua('return box.info().ro') IS NOT NULL"])) |
225 |
| - |
226 |
| -(defn set-read-only-mode |
227 |
| - "Disable and enable read only mode" |
228 |
| - [conn mode] |
229 |
| - (j/execute! conn ["SELECT LUA('box.cfg{read_only=true}; return true')"])) |
| 205 | + (info "Joining" node "as" (if (true? read-only) "replica" "leader")) |
| 206 | + (c/exec :mkdir :-p "/etc/tarantool/instances.available") |
| 207 | + (c/exec :mkdir :-p "/etc/tarantool/instances.enabled") |
| 208 | + (c/exec :usermod :-a :-G :tarantool :ubuntu) |
| 209 | + (c/exec :echo (-> "tarantool/jepsen.lua" io/resource slurp |
| 210 | + (str/replace #"%TARANTOOL_REPLICATION%" (replica-set test)) |
| 211 | + ;(str/replace #"%TARANTOOL_IS_READ_ONLY%" (boolean-to-str read-only)) |
| 212 | + (str/replace #"%TARANTOOL_SINGLE_MODE%" (boolean-to-str (is-single-mode? test))) |
| 213 | + (str/replace #"%TARANTOOL_DATA_ENGINE%" (:engine test))) |
| 214 | + :> "/etc/tarantool/instances.enabled/jepsen.lua") |
| 215 | + (c/exec :cp "/etc/tarantool/instances.enabled/jepsen.lua" "/etc/tarantool/instances.available")) |
230 | 216 |
|
231 | 217 | (defn db
|
232 | 218 | "Tarantool DB for a particular version."
|
|
0 commit comments