Skip to content

Commit 9433175

Browse files
committed
Try to test write timeouts by filling the buffer
1 parent 9d9f248 commit 9433175

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/internals_test.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,23 @@ def test_connection_timeout
160160
assert (Time.now - start_time) <= opts[:timeout]
161161
end
162162

163+
driver(:ruby) do
164+
def test_write_timeout
165+
server = TCPServer.new("127.0.0.1", 0)
166+
port = server.addr[1]
167+
168+
# Hacky, but we need the buffer size
169+
val = TCPSocket.new("127.0.0.1", port).getsockopt(Socket::SOL_SOCKET, Socket::SO_SNDBUF).unpack("i")[0]
170+
171+
assert_raise(Redis::TimeoutError) do
172+
Timeout.timeout(1) do
173+
redis = Redis.new(:port => port, :timeout => 5, :write_timeout => 0.1)
174+
redis.set("foo", "1" * val*2)
175+
end
176+
end
177+
end
178+
end
179+
163180
def close_on_ping(seq, options = {})
164181
$request = 0
165182

0 commit comments

Comments
 (0)