Skip to content

Commit eb7023e

Browse files
committed
Add a test for abruptly closed connections
Ref: redis/redis-rb#1106
1 parent 79d4d89 commit eb7023e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/redis_client/connection_test.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,23 @@ def test_reconnect_with_call_once
192192
assert_equal "1", client.call("GET", "counter")
193193
end
194194

195+
def test_killed_connection
196+
client = new_client(reconnect_attempts: 1, id: "background")
197+
198+
thread = Thread.new do
199+
client.blocking_call(false, "BLPOP", "list", 0)
200+
end
201+
thread.join(0.1)
202+
assert_predicate thread, :alive?
203+
204+
second_client = new_client
205+
206+
id = second_client.call("CLIENT", "LIST").lines.grep(/name=background/)[0].match(/^id=(\d+)/)[1]
207+
assert_equal 1, second_client.call("CLIENT", "KILL", "ID", id)
208+
second_client.call("LPUSH", "list", "hello")
209+
assert_equal ["list", "hello"], thread.join.value
210+
end
211+
195212
private
196213

197214
def assert_timeout(error, faster_than = 0.5, &block)

0 commit comments

Comments
 (0)