2024-04-05 16:46:33 -04:00
|
|
|
proc valkeycli_tls_config {testsdir} {
|
2019-09-12 10:56:54 +03:00
|
|
|
set tlsdir [file join $testsdir tls]
|
2020-12-11 18:31:40 +02:00
|
|
|
set cert [file join $tlsdir client.crt]
|
|
|
|
set key [file join $tlsdir client.key]
|
2019-09-12 10:56:54 +03:00
|
|
|
set cacert [file join $tlsdir ca.crt]
|
|
|
|
|
|
|
|
if {$::tls} {
|
|
|
|
return [list --tls --cert $cert --key $key --cacert $cacert]
|
|
|
|
} else {
|
|
|
|
return {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-05 16:46:33 -04:00
|
|
|
# Returns command line for executing valkey-cli
|
|
|
|
proc valkeycli {host port {opts {}}} {
|
2024-03-28 09:58:28 -07:00
|
|
|
set cmd [list src/valkey-cli -h $host -p $port]
|
2024-04-05 16:46:33 -04:00
|
|
|
lappend cmd {*}[valkeycli_tls_config "tests"]
|
2019-09-12 10:56:54 +03:00
|
|
|
lappend cmd {*}$opts
|
|
|
|
return $cmd
|
|
|
|
}
|
2021-06-22 12:50:17 +03:00
|
|
|
|
2024-04-23 09:02:41 +08:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2024-04-05 16:46:33 -04:00
|
|
|
# Returns command line for executing valkey-cli with a unix socket address
|
|
|
|
proc valkeycli_unixsocket {unixsocket {opts {}}} {
|
2024-03-28 09:58:28 -07:00
|
|
|
return [list src/valkey-cli -s $unixsocket {*}$opts]
|
2021-06-22 12:50:17 +03:00
|
|
|
}
|
|
|
|
|
2024-04-05 16:46:33 -04:00
|
|
|
# Run valkey-cli with specified args on the server of specified level.
|
2021-06-22 12:50:17 +03:00
|
|
|
# Returns output broken down into individual lines.
|
2024-04-05 16:46:33 -04:00
|
|
|
proc valkeycli_exec {level args} {
|
|
|
|
set cmd [valkeycli_unixsocket [srv $level unixsocket] $args]
|
2021-06-22 12:50:17 +03:00
|
|
|
set fd [open "|$cmd" "r"]
|
|
|
|
set ret [lrange [split [read $fd] "\n"] 0 end-1]
|
|
|
|
close $fd
|
|
|
|
|
|
|
|
return $ret
|
|
|
|
}
|