WIP client
This commit is contained in:
@ -15,18 +15,28 @@
|
||||
(:require [jepsen.cli :as cli]
|
||||
[jepsen.tests :as tests]
|
||||
[jepsen.os.debian :as debian]
|
||||
[jable.client :as client]
|
||||
[jepsen.generator :as gen]
|
||||
[jable.db :as db]))
|
||||
|
||||
(defn r [_ _] {:type :invoke, :f :read-topic, :value nil})
|
||||
(defn w [_ _] {:type :invoke, :f :write-topic, :value (rand-int 5)})
|
||||
|
||||
(defn sable-test
|
||||
"Given an options map from the command line runner (e.g. :nodes, :ssh,
|
||||
:concurrency, ...), constructs a test map."
|
||||
[opts]
|
||||
(merge tests/noop-test
|
||||
opts
|
||||
{:name "etcd"
|
||||
{:pure-generators true
|
||||
:name "etcd"
|
||||
:os debian/os
|
||||
:db (db/sable (:sable-bin opts) (:nodes opts))
|
||||
:pure-generators true}))
|
||||
:client (client/jable.client.Client. nil nil nil)
|
||||
:generator (->> r
|
||||
(gen/stagger 1)
|
||||
(gen/nemesis nil)
|
||||
(gen/time-limit 15))}))
|
||||
|
||||
(def cli-opts
|
||||
"Additional command line options."
|
||||
|
@ -103,3 +103,32 @@
|
||||
(if trailing
|
||||
(conj params trailing)
|
||||
params))}))
|
||||
|
||||
(defrecord Client [socket reader writer]
|
||||
client/Client
|
||||
(open! [this test node]
|
||||
(let [socket (Socket. node 6667)]
|
||||
(let [this (assoc this
|
||||
:socket socket
|
||||
:reader (io/reader socket)
|
||||
:writer (io/writer socket))]
|
||||
(send-commands this [{:cmd "CAP" :params ["LS" "302"]}
|
||||
{:cmd "CAP" :params ["REQ" "labeled-response batch"]}
|
||||
{:cmd "NICK" :params [(str "test-" node)]}
|
||||
{:cmd "USER" :params ["test" "*" "*" "test"]}
|
||||
{:cmd "CAP" :params ["END"]}
|
||||
{:cmd "JOIN" :params ["#chan"]}
|
||||
{:cmd "MODE" :params ["#chan" "-t"]}])
|
||||
this)))
|
||||
|
||||
(setup! [this test])
|
||||
|
||||
(invoke! [_ test op])
|
||||
|
||||
(teardown! [this test])
|
||||
|
||||
(close! [this test]
|
||||
(send-command this {:cmd "QUIT" :params ["closing client"]})
|
||||
(.close (:writer this))
|
||||
(.close (:reader this))
|
||||
(.close (:socket this))))
|
||||
|
Reference in New Issue
Block a user