Make INFO command variadic (#6891)
This is an enhancement for INFO command, previously INFO only support one argument
for different info section , if user want to get more categories information, either perform
INFO all / default or calling INFO for multiple times.
**Description of the feature**
The goal of adding this feature is to let the user retrieve multiple categories via the INFO
command, and still avoid emitting the same section twice.
A use case for this is like Redis Sentinel, which periodically calling INFO command to refresh
info from monitored Master/Slaves, only Server and Replication part categories are used for
parsing information. If the INFO command can return just enough categories that client side
needs, it can save a lot of time for client side parsing it as well as network bandwidth.
**Implementation**
To share code between redis, sentinel, and other users of INFO (DEBUG and modules),
we have a new `genInfoSectionDict` function that returns a dict and some boolean flags
(e.g. `all`) to the caller (built from user input).
Sentinel is later purging unwanted sections from that, and then it is forwarded to the info `genRedisInfoString`.
**Usage Examples**
INFO Server Replication
INFO CPU Memory
INFO default commandstats
Co-authored-by: Oran Agra <oran@redislabs.com>
2022-02-08 06:14:42 -05:00
|
|
|
start_server {tags {"info and its relative command"}} {
|
2024-09-19 22:18:19 -04:00
|
|
|
test "Extract version and sha1 details from info command and print" {
|
|
|
|
set i [r info]
|
|
|
|
regexp {redis_version:(.*?)\r\n} $i - version
|
|
|
|
regexp {redis_git_sha1:(.*?)\r\n} $i - sha1
|
|
|
|
puts "Testing Valkey version $version ($sha1)"
|
|
|
|
}
|
|
|
|
|
Make INFO command variadic (#6891)
This is an enhancement for INFO command, previously INFO only support one argument
for different info section , if user want to get more categories information, either perform
INFO all / default or calling INFO for multiple times.
**Description of the feature**
The goal of adding this feature is to let the user retrieve multiple categories via the INFO
command, and still avoid emitting the same section twice.
A use case for this is like Redis Sentinel, which periodically calling INFO command to refresh
info from monitored Master/Slaves, only Server and Replication part categories are used for
parsing information. If the INFO command can return just enough categories that client side
needs, it can save a lot of time for client side parsing it as well as network bandwidth.
**Implementation**
To share code between redis, sentinel, and other users of INFO (DEBUG and modules),
we have a new `genInfoSectionDict` function that returns a dict and some boolean flags
(e.g. `all`) to the caller (built from user input).
Sentinel is later purging unwanted sections from that, and then it is forwarded to the info `genRedisInfoString`.
**Usage Examples**
INFO Server Replication
INFO CPU Memory
INFO default commandstats
Co-authored-by: Oran Agra <oran@redislabs.com>
2022-02-08 06:14:42 -05:00
|
|
|
test "info command with at most one sub command" {
|
|
|
|
foreach arg {"" "all" "default" "everything"} {
|
|
|
|
if {$arg == ""} {
|
|
|
|
set info [r 0 info]
|
|
|
|
} else {
|
|
|
|
set info [r 0 info $arg]
|
|
|
|
}
|
|
|
|
|
|
|
|
assert { [string match "*redis_version*" $info] }
|
|
|
|
assert { [string match "*used_cpu_user*" $info] }
|
|
|
|
assert { ![string match "*sentinel_tilt*" $info] }
|
|
|
|
assert { [string match "*used_memory*" $info] }
|
|
|
|
if {$arg == "" || $arg == "default"} {
|
|
|
|
assert { ![string match "*rejected_calls*" $info] }
|
|
|
|
} else {
|
|
|
|
assert { [string match "*rejected_calls*" $info] }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
test "info command with one sub-section" {
|
|
|
|
set info [r info cpu]
|
|
|
|
assert { [string match "*used_cpu_user*" $info] }
|
|
|
|
assert { ![string match "*sentinel_tilt*" $info] }
|
|
|
|
assert { ![string match "*used_memory*" $info] }
|
|
|
|
|
|
|
|
set info [r info sentinel]
|
|
|
|
assert { ![string match "*sentinel_tilt*" $info] }
|
|
|
|
assert { ![string match "*used_memory*" $info] }
|
|
|
|
|
|
|
|
set info [r info commandSTATS] ;# test case insensitive compare
|
|
|
|
assert { ![string match "*used_memory*" $info] }
|
|
|
|
assert { [string match "*rejected_calls*" $info] }
|
|
|
|
}
|
|
|
|
|
|
|
|
test "info command with multiple sub-sections" {
|
|
|
|
set info [r info cpu sentinel]
|
|
|
|
assert { [string match "*used_cpu_user*" $info] }
|
|
|
|
assert { ![string match "*sentinel_tilt*" $info] }
|
|
|
|
assert { ![string match "*master_repl_offset*" $info] }
|
|
|
|
|
|
|
|
set info [r info cpu all]
|
|
|
|
assert { [string match "*used_cpu_user*" $info] }
|
|
|
|
assert { ![string match "*sentinel_tilt*" $info] }
|
|
|
|
assert { [string match "*used_memory*" $info] }
|
|
|
|
assert { [string match "*master_repl_offset*" $info] }
|
|
|
|
assert { [string match "*rejected_calls*" $info] }
|
|
|
|
# check that we didn't get the same info twice
|
|
|
|
assert { ![string match "*used_cpu_user_children*used_cpu_user_children*" $info] }
|
|
|
|
|
|
|
|
set info [r info cpu default]
|
|
|
|
assert { [string match "*used_cpu_user*" $info] }
|
|
|
|
assert { ![string match "*sentinel_tilt*" $info] }
|
|
|
|
assert { [string match "*used_memory*" $info] }
|
|
|
|
assert { [string match "*master_repl_offset*" $info] }
|
|
|
|
assert { ![string match "*rejected_calls*" $info] }
|
|
|
|
# check that we didn't get the same info twice
|
|
|
|
assert { ![string match "*used_cpu_user_children*used_cpu_user_children*" $info] }
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|