Test TOPICWHOTIME + add support for ACK response on unchanged topic
This commit is contained in:
@ -15,6 +15,7 @@
|
||||
(:require [clojure.tools.logging :refer :all]
|
||||
[clojure.java.io :as io]
|
||||
[clojure.string :as str]
|
||||
[clojure.instant :as instant]
|
||||
[jepsen [cli :as cli]
|
||||
[client :as client]
|
||||
[control :as c]
|
||||
@ -157,10 +158,11 @@
|
||||
(let [this (assoc this
|
||||
:socket socket
|
||||
:reader (io/reader socket)
|
||||
:writer (io/writer socket))]
|
||||
:writer (io/writer socket)
|
||||
:nick (str "test-" node "-" (.getLocalPort socket)))]
|
||||
(send-commands this [{:cmd "CAP" :params ["LS" "302"]}
|
||||
{:cmd "CAP" :params ["REQ" "labeled-response batch draft/channel-rename"]}
|
||||
{:cmd "NICK" :params [(str "test-" node "-" (.getLocalPort socket))]}
|
||||
{:cmd "CAP" :params ["REQ" "labeled-response batch draft/channel-rename server-time"]}
|
||||
{:cmd "NICK" :params [(:nick this)]}
|
||||
{:cmd "USER" :params [(str "test-" node) "*" "*" (str "test " node " port " (.getLocalPort socket))]}
|
||||
{:tags {"label" "cap-end"} :cmd "CAP" :params ["END"]}])
|
||||
(read-response this "cap-end") ; block until end of registration
|
||||
@ -196,16 +198,27 @@
|
||||
; RPL_TOPICWHOTIME
|
||||
(assert (= (:cmd topicwhotime-cmd) "333") (str "expected RPL_TOPICWHOTIME: " topicwhotime-cmd))
|
||||
(assert (= (:cmd batch-close) "BATCH") "topic batch close cmd")
|
||||
(let [[nick chan topic] (:params topic-cmd)]
|
||||
(assoc op :type :ok, :value topic))))))
|
||||
(let [[my-nick chan topic] (:params topic-cmd)
|
||||
[my-nick chan who time] (:params topicwhotime-cmd)]
|
||||
(let [[nick userhost] (str/split who #"!" 2)
|
||||
time (Integer/parseInt time)]
|
||||
(assoc op :type :ok, :value {:topic topic
|
||||
:who nick
|
||||
:time time})))))))
|
||||
:write-topic (do
|
||||
(send-command this {:tags {"label" "write-topic"}
|
||||
:cmd "TOPIC"
|
||||
:params ["#chan" (:value op)]})
|
||||
(let [[cmd] (read-response this "write-topic")]
|
||||
(assert (= (:cmd cmd) "TOPIC") (str "unexpected TOPIC reply: " cmd))
|
||||
(let [[chan topic] (:params cmd)]
|
||||
(assoc op :type :ok, :value topic))))))
|
||||
(case (:cmd cmd)
|
||||
; Sable returns ACK when two clients set the same topic value
|
||||
; at the same time
|
||||
"ACK" (assoc op :type :fail, :error :noop)
|
||||
"TOPIC" (let [[chan topic] (:params cmd)
|
||||
time (/ (.getTime (instant/read-instant-timestamp (get (:tags cmd) "time"))) 1000)]
|
||||
(assoc op :type :ok, :value {:topic topic
|
||||
:who (:nick this)
|
||||
:time time })))))))
|
||||
|
||||
(teardown! [this test])
|
||||
|
||||
|
Reference in New Issue
Block a user