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.
This commit is contained in:
Yossi Gottlieb 2021-08-01 15:07:27 +03:00 committed by GitHub
parent 1483f5aa9b
commit 68b8b45cd5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -31,13 +31,25 @@ start_server {tags {"cli"}} {
}
proc read_cli {fd} {
set buf [read $fd]
while {[string length $buf] == 0} {
# wait some time and try again
set ret [read $fd]
while {[string length $ret] == 0} {
after 10
set buf [read $fd]
set ret [read $fd]
}
set _ $buf
# We may have a short read, try to read some more.
set empty_reads 0
while {$empty_reads < 5} {
set buf [read $fd]
if {[string length $buf] == 0} {
after 10
incr empty_reads
} else {
append ret $buf
set empty_reads 0
}
}
return $ret
}
proc write_cli {fd buf} {