Update some valkey-cli related in tcl (#236)

Signed-off-by: hwware <wen.hui.ware@gmail.com>
This commit is contained in:
Wen Hui 2024-04-05 16:46:33 -04:00 committed by GitHub
parent 47444c67de
commit 7f5bcc96f0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 25 additions and 25 deletions

View File

@ -90,7 +90,7 @@ test "Cluster consistency during live resharding" {
--cluster-to $target \ --cluster-to $target \
--cluster-slots 100 \ --cluster-slots 100 \
--cluster-yes \ --cluster-yes \
{*}[rediscli_tls_config "../../../tests"] \ {*}[valkeycli_tls_config "../../../tests"] \
| [info nameofexecutable] \ | [info nameofexecutable] \
../tests/helpers/onlydots.tcl \ ../tests/helpers/onlydots.tcl \
&] 0] &] 0]

View File

@ -40,7 +40,7 @@ test "Resharding all the master #0 slots away from it" {
set output [exec \ set output [exec \
../../../src/valkey-cli --cluster rebalance \ ../../../src/valkey-cli --cluster rebalance \
127.0.0.1:[get_instance_attrib redis 0 port] \ 127.0.0.1:[get_instance_attrib redis 0 port] \
{*}[rediscli_tls_config "../../../tests"] \ {*}[valkeycli_tls_config "../../../tests"] \
--cluster-weight ${master0_id}=0 >@ stdout ] --cluster-weight ${master0_id}=0 >@ stdout ]
} }
@ -61,7 +61,7 @@ test "Resharding back some slot to master #0" {
set output [exec \ set output [exec \
../../../src/valkey-cli --cluster rebalance \ ../../../src/valkey-cli --cluster rebalance \
127.0.0.1:[get_instance_attrib redis 0 port] \ 127.0.0.1:[get_instance_attrib redis 0 port] \
{*}[rediscli_tls_config "../../../tests"] \ {*}[valkeycli_tls_config "../../../tests"] \
--cluster-weight ${master0_id}=.01 \ --cluster-weight ${master0_id}=.01 \
--cluster-use-empty-masters >@ stdout] --cluster-use-empty-masters >@ stdout]
} }

View File

@ -39,7 +39,7 @@ test "Resharding all the master #0 slots away from it" {
set output [exec \ set output [exec \
../../../src/valkey-cli --cluster rebalance \ ../../../src/valkey-cli --cluster rebalance \
127.0.0.1:[get_instance_attrib redis 0 port] \ 127.0.0.1:[get_instance_attrib redis 0 port] \
{*}[rediscli_tls_config "../../../tests"] \ {*}[valkeycli_tls_config "../../../tests"] \
--cluster-weight ${master0_id}=0 >@ stdout ] --cluster-weight ${master0_id}=0 >@ stdout ]
} }

View File

@ -8,7 +8,7 @@ proc config_set_all_nodes {keyword value} {
proc fix_cluster {addr} { proc fix_cluster {addr} {
set code [catch { set code [catch {
exec ../../../src/valkey-cli {*}[rediscli_tls_config "../../../tests"] --cluster fix $addr << yes exec ../../../src/valkey-cli {*}[valkeycli_tls_config "../../../tests"] --cluster fix $addr << yes
} result] } result]
if {$code != 0} { if {$code != 0} {
puts "redis-cli --cluster fix returns non-zero exit code, output below:\n$result" puts "redis-cli --cluster fix returns non-zero exit code, output below:\n$result"
@ -17,7 +17,7 @@ proc fix_cluster {addr} {
# but we can ignore that and rely on the check below. # but we can ignore that and rely on the check below.
assert_cluster_state ok assert_cluster_state ok
wait_for_condition 100 100 { wait_for_condition 100 100 {
[catch {exec ../../../src/valkey-cli {*}[rediscli_tls_config "../../../tests"] --cluster check $addr} result] == 0 [catch {exec ../../../src/valkey-cli {*}[valkeycli_tls_config "../../../tests"] --cluster check $addr} result] == 0
} else { } else {
puts "redis-cli --cluster check returns non-zero exit code, output below:\n$result" puts "redis-cli --cluster check returns non-zero exit code, output below:\n$result"
fail "Cluster could not settle with configuration" fail "Cluster could not settle with configuration"
@ -28,7 +28,7 @@ proc wait_cluster_stable {} {
wait_for_condition 1000 50 { wait_for_condition 1000 50 {
[catch {exec ../../../src/valkey-cli --cluster \ [catch {exec ../../../src/valkey-cli --cluster \
check 127.0.0.1:[get_instance_attrib redis 0 port] \ check 127.0.0.1:[get_instance_attrib redis 0 port] \
{*}[rediscli_tls_config "../../../tests"] \ {*}[valkeycli_tls_config "../../../tests"] \
}] == 0 }] == 0
} else { } else {
fail "Cluster doesn't stabilize" fail "Cluster doesn't stabilize"

View File

@ -12,7 +12,7 @@ start_server {tags {"cli"}} {
set opts "-n $::dbnum" set opts "-n $::dbnum"
} }
set ::env(TERM) dumb set ::env(TERM) dumb
set cmdline [rediscli [srv host] [srv port] $opts] set cmdline [valkeycli [srv host] [srv port] $opts]
if {$infile ne ""} { if {$infile ne ""} {
set cmdline "$cmdline < $infile" set cmdline "$cmdline < $infile"
set mode "r" set mode "r"
@ -92,7 +92,7 @@ start_server {tags {"cli"}} {
} }
proc _run_cli {host port db opts args} { proc _run_cli {host port db opts args} {
set cmd [rediscli $host $port [list -n $db {*}$args]] set cmd [valkeycli $host $port [list -n $db {*}$args]]
foreach {key value} $opts { foreach {key value} $opts {
if {$key eq "pipe"} { if {$key eq "pipe"} {
set cmd "sh -c \"$value | $cmd\"" set cmd "sh -c \"$value | $cmd\""
@ -580,7 +580,7 @@ if {!$::tls} { ;# fake_redis_node doesn't support TLS
} }
test "DUMP RESTORE with -x option" { test "DUMP RESTORE with -x option" {
set cmdline [rediscli [srv host] [srv port]] set cmdline [valkeycli [srv host] [srv port]]
exec {*}$cmdline DEL set new_set exec {*}$cmdline DEL set new_set
exec {*}$cmdline SADD set 1 2 3 4 5 6 exec {*}$cmdline SADD set 1 2 3 4 5 6
@ -594,7 +594,7 @@ if {!$::tls} { ;# fake_redis_node doesn't support TLS
} }
test "DUMP RESTORE with -X option" { test "DUMP RESTORE with -X option" {
set cmdline [rediscli [srv host] [srv port]] set cmdline [valkeycli [srv host] [srv port]]
exec {*}$cmdline DEL zset new_zset exec {*}$cmdline DEL zset new_zset
exec {*}$cmdline ZADD zset 1 a 2 b 3 c exec {*}$cmdline ZADD zset 1 a 2 b 3 c

View File

@ -1,4 +1,4 @@
proc rediscli_tls_config {testsdir} { proc valkeycli_tls_config {testsdir} {
set tlsdir [file join $testsdir tls] set tlsdir [file join $testsdir tls]
set cert [file join $tlsdir client.crt] set cert [file join $tlsdir client.crt]
set key [file join $tlsdir client.key] set key [file join $tlsdir client.key]
@ -11,23 +11,23 @@ proc rediscli_tls_config {testsdir} {
} }
} }
# Returns command line for executing redis-cli # Returns command line for executing valkey-cli
proc rediscli {host port {opts {}}} { proc valkeycli {host port {opts {}}} {
set cmd [list src/valkey-cli -h $host -p $port] set cmd [list src/valkey-cli -h $host -p $port]
lappend cmd {*}[rediscli_tls_config "tests"] lappend cmd {*}[valkeycli_tls_config "tests"]
lappend cmd {*}$opts lappend cmd {*}$opts
return $cmd return $cmd
} }
# Returns command line for executing redis-cli with a unix socket address # Returns command line for executing valkey-cli with a unix socket address
proc rediscli_unixsocket {unixsocket {opts {}}} { proc valkeycli_unixsocket {unixsocket {opts {}}} {
return [list src/valkey-cli -s $unixsocket {*}$opts] return [list src/valkey-cli -s $unixsocket {*}$opts]
} }
# Run redis-cli with specified args on the server of specified level. # Run valkey-cli with specified args on the server of specified level.
# Returns output broken down into individual lines. # Returns output broken down into individual lines.
proc rediscli_exec {level args} { proc valkeycli_exec {level args} {
set cmd [rediscli_unixsocket [srv $level unixsocket] $args] set cmd [valkeycli_unixsocket [srv $level unixsocket] $args]
set fd [open "|$cmd" "r"] set fd [open "|$cmd" "r"]
set ret [lrange [split [read $fd] "\n"] 0 end-1] set ret [lrange [split [read $fd] "\n"] 0 end-1]
close $fd close $fd

View File

@ -121,18 +121,18 @@ start_server {config "minimal.conf" tags {"external:skip"}} {
# Make sure bind parameter is as expected and server handles binding # Make sure bind parameter is as expected and server handles binding
# accordingly. # accordingly.
# (it seems that rediscli_exec behaves differently in RESP3, possibly # (it seems that valkeycli_exec behaves differently in RESP3, possibly
# because CONFIG GET returns a dict instead of a list so redis-cli emits # because CONFIG GET returns a dict instead of a list so valkey-cli emits
# it in a single line) # it in a single line)
if {$::force_resp3} { if {$::force_resp3} {
assert_equal {{bind }} [rediscli_exec 0 config get bind] assert_equal {{bind }} [valkeycli_exec 0 config get bind]
} else { } else {
assert_equal {bind {}} [rediscli_exec 0 config get bind] assert_equal {bind {}} [valkeycli_exec 0 config get bind]
} }
catch {reconnect 0} err catch {reconnect 0} err
assert_match {*connection refused*} $err assert_match {*connection refused*} $err
assert_equal {OK} [rediscli_exec 0 config set bind *] assert_equal {OK} [valkeycli_exec 0 config set bind *]
reconnect 0 reconnect 0
r ping r ping
} {PONG} } {PONG}