mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-23 08:38:27 -05:00
23325c135f
Summary of changes: 1. Rename `redisCommand->name` to `redisCommand->declared_name`, it is a const char * for native commands and SDS for module commands. 2. Store the [sub]command fullname in `redisCommand->fullname` (sds). 3. List subcommands in `ACL CAT` 4. List subcommands in `COMMAND LIST` 5. `moduleUnregisterCommands` now will also free the module subcommands. 6. RM_GetCurrentCommandName returns full command name Other changes: 1. Add `addReplyErrorArity` and `addReplyErrorExpireTime` 2. Remove `getFullCommandName` function that now is useless. 3. Some cleanups about `fullname` since now it is SDS. 4. Delete `populateSingleCommand` function from server.h that is useless. 5. Added tests to cover this change. 6. Add some module unload tests and fix the leaks 7. Make error messages uniform, make sure they always contain the full command name and that it's quoted. 7. Fixes some typos see the history in #9504, fixes #10124 Co-authored-by: Oran Agra <oran@redislabs.com> Co-authored-by: guybe7 <guy.benoish@redislabs.com>
99 lines
3.4 KiB
Tcl
99 lines
3.4 KiB
Tcl
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
|
|
|
|
test {module reading info} {
|
|
# check string, integer and float fields
|
|
assert_equal [r info.gets replication role] "master"
|
|
assert_equal [r info.getc replication role] "master"
|
|
assert_equal [r info.geti stats expired_keys] 0
|
|
assert_equal [r info.getd stats expired_stale_perc] 0
|
|
|
|
# check signed and unsigned
|
|
assert_equal [r info.geti infotest infotest_global] -2
|
|
assert_equal [r info.getu infotest infotest_uglobal] -2
|
|
|
|
# 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
|
|
catch { [r info.gets badname redis_version] } e
|
|
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
|
|
}
|
|
|
|
test {module info all} {
|
|
set info [r info all]
|
|
# info all does not contain modules
|
|
assert { ![string match "*Spanish*" $info] }
|
|
assert { ![string match "*infotest_*" $info] }
|
|
assert { [string match "*used_memory*" $info] }
|
|
}
|
|
|
|
test {module info everything} {
|
|
set info [r info everything]
|
|
# info everything contains all default sections, but not ones for crash report
|
|
assert { [string match "*infotest_global*" $info] }
|
|
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] }
|
|
assert { [string match "*infotest_global*" $info] }
|
|
assert { ![string match "*used_memory*" $info] }
|
|
}
|
|
|
|
test {module info one module} {
|
|
set info [r info INFOTEST]
|
|
# info all does not contain modules
|
|
assert { [string match "*Spanish*" $info] }
|
|
assert { ![string match "*used_memory*" $info] }
|
|
field $info infotest_global
|
|
} {-2}
|
|
|
|
test {module info one section} {
|
|
set info [r info INFOTEST_SPANISH]
|
|
assert { ![string match "*used_memory*" $info] }
|
|
assert { ![string match "*Italian*" $info] }
|
|
assert { ![string match "*infotest_global*" $info] }
|
|
field $info infotest_uno
|
|
} {one}
|
|
|
|
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}
|
|
|
|
test {module info unsafe fields} {
|
|
set info [r info infotest_unsafe]
|
|
assert_match {*infotest_unsafe_field:value=1*} $info
|
|
}
|
|
|
|
test "Unload the module - infotest" {
|
|
assert_equal {OK} [r module unload infotest]
|
|
}
|
|
|
|
# TODO: test crash report.
|
|
}
|