2019-07-24 05:58:15 -04:00
|
|
|
set testmodule [file normalize tests/modules/infotest.so]
|
|
|
|
|
|
|
|
# Return value for INFO property
|
|
|
|
proc field {info property} {
|
|
|
|
if {[regexp "\r\n$property:(.*?)\r\n" $info _ value]} {
|
|
|
|
set _ $value
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
start_server {tags {"modules"}} {
|
|
|
|
r module load $testmodule log-key 0
|
|
|
|
|
2019-11-03 08:02:25 -05:00
|
|
|
test {module reading info} {
|
|
|
|
# check string, integer and float fields
|
|
|
|
assert_equal [r info.gets replication role] "master"
|
2019-11-04 00:57:52 -05:00
|
|
|
assert_equal [r info.getc replication role] "master"
|
2019-11-03 08:02:25 -05:00
|
|
|
assert_equal [r info.geti stats expired_keys] 0
|
|
|
|
assert_equal [r info.getd stats expired_stale_perc] 0
|
|
|
|
|
2019-11-04 01:50:29 -05:00
|
|
|
# check signed and unsigned
|
|
|
|
assert_equal [r info.geti infotest infotest_global] -2
|
|
|
|
assert_equal [r info.getu infotest infotest_uglobal] -2
|
|
|
|
|
2019-11-03 08:02:25 -05:00
|
|
|
# the above are always 0, try module info that is non-zero
|
|
|
|
assert_equal [r info.geti infotest_italian infotest_due] 2
|
|
|
|
set tre [r info.getd infotest_italian infotest_tre]
|
|
|
|
assert {$tre > 3.2 && $tre < 3.4 }
|
|
|
|
|
|
|
|
# search using the wrong section
|
2024-03-21 05:56:59 -04:00
|
|
|
catch { [r info.gets badname redict_version] } e
|
2019-11-03 08:02:25 -05:00
|
|
|
assert_match {*not found*} $e
|
|
|
|
|
|
|
|
# check that section filter works
|
|
|
|
assert { [string match "*usec_per_call*" [r info.gets all cmdstat_info.gets] ] }
|
|
|
|
catch { [r info.gets default cmdstat_info.gets] ] } e
|
|
|
|
assert_match {*not found*} $e
|
|
|
|
}
|
|
|
|
|
2019-07-24 05:58:15 -04:00
|
|
|
test {module info all} {
|
|
|
|
set info [r info all]
|
|
|
|
# info all does not contain modules
|
|
|
|
assert { ![string match "*Spanish*" $info] }
|
2019-09-30 13:47:35 -04:00
|
|
|
assert { ![string match "*infotest_*" $info] }
|
2019-07-24 05:58:15 -04:00
|
|
|
assert { [string match "*used_memory*" $info] }
|
2022-09-21 01:10:03 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
test {module info all infotest} {
|
|
|
|
set info [r info all infotest]
|
|
|
|
# info all infotest should contain both ALL and the module information
|
|
|
|
assert { [string match "*Spanish*" $info] }
|
|
|
|
assert { [string match "*infotest_*" $info] }
|
|
|
|
assert { [string match "*used_memory*" $info] }
|
2019-07-24 05:58:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
test {module info everything} {
|
|
|
|
set info [r info everything]
|
|
|
|
# info everything contains all default sections, but not ones for crash report
|
2019-08-18 03:01:57 -04:00
|
|
|
assert { [string match "*infotest_global*" $info] }
|
2019-07-24 05:58:15 -04:00
|
|
|
assert { [string match "*Spanish*" $info] }
|
|
|
|
assert { [string match "*Italian*" $info] }
|
|
|
|
assert { [string match "*used_memory*" $info] }
|
|
|
|
assert { ![string match "*Klingon*" $info] }
|
|
|
|
field $info infotest_dos
|
|
|
|
} {2}
|
|
|
|
|
|
|
|
test {module info modules} {
|
|
|
|
set info [r info modules]
|
|
|
|
# info all does not contain modules
|
|
|
|
assert { [string match "*Spanish*" $info] }
|
2019-08-18 03:01:57 -04:00
|
|
|
assert { [string match "*infotest_global*" $info] }
|
2019-07-24 05:58:15 -04:00
|
|
|
assert { ![string match "*used_memory*" $info] }
|
|
|
|
}
|
|
|
|
|
|
|
|
test {module info one module} {
|
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
|
|
|
set info [r info INFOtest] ;# test case insensitive compare
|
2019-07-24 05:58:15 -04:00
|
|
|
# info all does not contain modules
|
|
|
|
assert { [string match "*Spanish*" $info] }
|
|
|
|
assert { ![string match "*used_memory*" $info] }
|
2019-08-18 03:01:57 -04:00
|
|
|
field $info infotest_global
|
|
|
|
} {-2}
|
2019-07-24 05:58:15 -04:00
|
|
|
|
|
|
|
test {module info one section} {
|
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
|
|
|
set info [r info INFOtest_SpanisH] ;# test case insensitive compare
|
2019-07-24 05:58:15 -04:00
|
|
|
assert { ![string match "*used_memory*" $info] }
|
|
|
|
assert { ![string match "*Italian*" $info] }
|
2019-08-18 03:01:57 -04:00
|
|
|
assert { ![string match "*infotest_global*" $info] }
|
2019-07-24 05:58:15 -04:00
|
|
|
field $info infotest_uno
|
|
|
|
} {one}
|
|
|
|
|
2019-08-18 02:41:45 -04:00
|
|
|
test {module info dict} {
|
|
|
|
set info [r info infotest_keyspace]
|
|
|
|
set keyspace [field $info infotest_db0]
|
|
|
|
set keys [scan [regexp -inline {keys\=([\d]*)} $keyspace] keys=%d]
|
|
|
|
} {3}
|
2019-07-24 05:58:15 -04:00
|
|
|
|
2021-02-15 10:08:53 -05:00
|
|
|
test {module info unsafe fields} {
|
|
|
|
set info [r info infotest_unsafe]
|
|
|
|
assert_match {*infotest_unsafe_field:value=1*} $info
|
|
|
|
}
|
|
|
|
|
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 {module info multiply sections without all, everything, default keywords} {
|
|
|
|
set info [r info replication INFOTEST]
|
|
|
|
assert { [string match "*Spanish*" $info] }
|
|
|
|
assert { ![string match "*used_memory*" $info] }
|
|
|
|
assert { [string match "*repl_offset*" $info] }
|
|
|
|
}
|
|
|
|
|
|
|
|
test {module info multiply sections with all keyword and modules} {
|
|
|
|
set info [r info all modules]
|
|
|
|
assert { [string match "*cluster*" $info] }
|
|
|
|
assert { [string match "*cmdstat_info*" $info] }
|
|
|
|
assert { [string match "*infotest_global*" $info] }
|
|
|
|
}
|
|
|
|
|
|
|
|
test {module info multiply sections with everything keyword} {
|
|
|
|
set info [r info replication everything cpu]
|
|
|
|
assert { [string match "*client_recent*" $info] }
|
|
|
|
assert { [string match "*cmdstat_info*" $info] }
|
|
|
|
assert { [string match "*Italian*" $info] }
|
|
|
|
# check that we didn't get the same info twice
|
|
|
|
assert { ![string match "*used_cpu_user_children*used_cpu_user_children*" $info] }
|
|
|
|
assert { ![string match "*Italian*Italian*" $info] }
|
|
|
|
field $info infotest_dos
|
|
|
|
} {2}
|
|
|
|
|
2022-01-23 03:05:06 -05:00
|
|
|
test "Unload the module - infotest" {
|
|
|
|
assert_equal {OK} [r module unload infotest]
|
|
|
|
}
|
|
|
|
|
2019-08-18 02:41:45 -04:00
|
|
|
# TODO: test crash report.
|
2019-07-24 05:58:15 -04:00
|
|
|
}
|