Unverified Commit 68b8b45c authored by Yossi Gottlieb's avatar Yossi Gottlieb Committed by GitHub
Browse files

Tests: avoid short reads on redis-cli output. (#9301)

In some cases large replies on slow systems may only be partially read
by the test suite, resulting with parsing errors.

This fix is still timing sensitive but should greatly reduce the chances
of this happening.
parent 1483f5aa
...@@ -31,13 +31,25 @@ start_server {tags {"cli"}} { ...@@ -31,13 +31,25 @@ start_server {tags {"cli"}} {
} }
proc read_cli {fd} { proc read_cli {fd} {
set buf [read $fd] set ret [read $fd]
while {[string length $buf] == 0} { while {[string length $ret] == 0} {
# wait some time and try again
after 10 after 10
set ret [read $fd]
}
# We may have a short read, try to read some more.
set empty_reads 0
while {$empty_reads < 5} {
set buf [read $fd] set buf [read $fd]
if {[string length $buf] == 0} {
after 10
incr empty_reads
} else {
append ret $buf
set empty_reads 0
}
} }
set _ $buf return $ret
} }
proc write_cli {fd buf} { proc write_cli {fd buf} {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment