Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEV: add test case covering partial writes #963

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/redis/connection/ruby.rb
Expand Up @@ -68,6 +68,7 @@ def _read_from_socket(nbytes)
end

def _write_to_socket(data)
data = data.b
total_bytes_written = 0
loop do
case bytes_written = write_nonblock(data, exception: false)
Expand Down Expand Up @@ -95,7 +96,6 @@ def _write_to_socket(data)
def write(data)
return super(data) unless @write_timeout

data = data.b
length = data.bytesize
total_count = 0
loop do
Expand Down
10 changes: 10 additions & 0 deletions test/internals_test.rb
Expand Up @@ -12,6 +12,16 @@ def test_logger
assert log.string =~ /\[Redis\] call_time=\d+\.\d+ ms/
end

def test_large_payload
# see: https://github.com/redis/redis-rb/issues/962
# large payloads will trigger write_nonblock to write a portion
# of the payload in connection/ruby.rb _write_to_socket
large = "\u3042" * 4_000_000
r.setex("foo", 10, large)
result = r.get("foo")
assert_equal result, large
end

def test_logger_with_pipelining
r.pipelined do
r.set "foo", "bar"
Expand Down