Lipeng Zhu 87a5bfc002
Support connection schemes valkey:// and valkeys:// (#199)
1. Support valkey:// and valkeys:// scheme in valkey-cli and
valkey-benchmark. Retain the original Redis schemes for compatibility.
2. Add unit tests for valid URI, all schemes.

Fixes: https://github.com/valkey-io/valkey/issues/198
Fixes: https://github.com/valkey-io/valkey/issues/200

---------

Signed-off-by: Lipeng Zhu <lipeng.zhu@intel.com>
2024-04-23 03:02:41 +02:00

44 lines
1.3 KiB
Tcl

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