mirror of https://mirror.osredm.com/root/redis.git
fflush stdout after responses partial backport from (#9136)
2. Make redis-cli flush stdout when printing a reply This was needed in order to fix a hung in redis-cli test that uses --replica. Note that printf does flush when there's a newline, but fwrite does not. 3. fix the redis-cli --replica test which used to pass previously because it didn't really care what it read, and because redis-cli used printf to print these other things to stdout. 4. improve redis-cli --replica test to run with both diskless and disk-based. Co-authored-by: Oran Agra <oran@redislabs.com> Co-authored-by: Viktor Söderqvist <viktor@zuiderkwast.se> (cherry picked from commit1eb4baa5b8
) (cherry picked from commit8884971223
)
This commit is contained in:
parent
196d06b9b3
commit
cbcdebe3b5
|
@ -1275,6 +1275,7 @@ static int cliReadReply(int output_raw_strings) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fwrite(out,sdslen(out),1,stdout);
|
fwrite(out,sdslen(out),1,stdout);
|
||||||
|
fflush(stdout);
|
||||||
sdsfree(out);
|
sdsfree(out);
|
||||||
}
|
}
|
||||||
freeReplyObject(reply);
|
freeReplyObject(reply);
|
||||||
|
|
|
@ -247,9 +247,9 @@ start_server {tags {"cli"}} {
|
||||||
test_redis_cli_rdb_dump
|
test_redis_cli_rdb_dump
|
||||||
}
|
}
|
||||||
|
|
||||||
test "Connecting as a replica" {
|
proc test_redis_cli_repl {} {
|
||||||
set fd [open_cli "--replica"]
|
set fd [open_cli "--replica"]
|
||||||
wait_for_condition 500 500 {
|
wait_for_condition 500 100 {
|
||||||
[string match {*slave0:*state=online*} [r info]]
|
[string match {*slave0:*state=online*} [r info]]
|
||||||
} else {
|
} else {
|
||||||
fail "redis-cli --replica did not connect"
|
fail "redis-cli --replica did not connect"
|
||||||
|
@ -258,14 +258,30 @@ start_server {tags {"cli"}} {
|
||||||
for {set i 0} {$i < 100} {incr i} {
|
for {set i 0} {$i < 100} {incr i} {
|
||||||
r set test-key test-value-$i
|
r set test-key test-value-$i
|
||||||
}
|
}
|
||||||
r client kill type slave
|
|
||||||
catch {
|
wait_for_condition 500 100 {
|
||||||
assert_match {*SET*key-a*} [read_cli $fd]
|
[string match {*test-value-99*} [read_cli $fd]]
|
||||||
|
} else {
|
||||||
|
fail "redis-cli --replica didn't read commands"
|
||||||
}
|
}
|
||||||
|
|
||||||
close_cli $fd
|
fconfigure $fd -blocking true
|
||||||
|
r client kill type slave
|
||||||
|
catch { close_cli $fd } err
|
||||||
|
assert_match {*Server closed the connection*} $err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "Connecting as a replica" {
|
||||||
|
# Disk-based master
|
||||||
|
assert_match "OK" [r config set repl-diskless-sync no]
|
||||||
|
test_redis_cli_repl
|
||||||
|
|
||||||
|
# Disk-less master
|
||||||
|
assert_match "OK" [r config set repl-diskless-sync yes]
|
||||||
|
assert_match "OK" [r config set repl-diskless-sync-delay 0]
|
||||||
|
test_redis_cli_repl
|
||||||
|
} {}
|
||||||
|
|
||||||
test "Piping raw protocol" {
|
test "Piping raw protocol" {
|
||||||
set cmds [tmpfile "cli_cmds"]
|
set cmds [tmpfile "cli_cmds"]
|
||||||
set cmds_fd [open $cmds "w"]
|
set cmds_fd [open $cmds "w"]
|
||||||
|
|
Loading…
Reference in New Issue